From 620e60eebce2c1f35c5c9a82f6ca365b316587f5 Mon Sep 17 00:00:00 2001 From: Valaris Date: Sun, 29 Jan 2006 16:10:48 +0000 Subject: AS OF SVN REV. 5901, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5094 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 configure (limited to 'configure') diff --git a/configure b/configure new file mode 100644 index 000000000..ef4f2a9a9 --- /dev/null +++ b/configure @@ -0,0 +1,256 @@ +#!/bin/bash +## NOTE: +## I know this is not a clean way to check for some stuff +## and edit the Makefile, but hey, it does work! + +# Configure script for eAthena +# Copyright (C) 2005 dontBR +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +# Default variables +status_mmx="No" +status_sse="No" +status_sse2="No" +status_sse3="No" +status_pcre="No" +prefix='/opt/eathena/' + +# Functions +function check_sed { + echo -n "Checking for sed... " + if [ -f $(which sed) ]; then + echo "yes" + else + echo "Error: sed not found in $PATH" + exit 1 + fi +} + +function check_gcc { + echo -n "Checking for gcc... " + if [ -f $(which gcc) ]; then + echo "yes" + else + echo "Error: GCC not found in $PATH" + exit 1 + fi +} + +function check_make { + echo -n "Checking for (g)make... " + if [ -f $(which make) ]; then + maker=make + echo "yes" + else if [ -f $(which gmake) ]; then + maker=gmake + echo "yes" + else + echo "Error: (g)make not found in $PATH" + exit 1 + fi + fi +} + +function check_sockets { + echo -n "Checking for sockets... " + echo "#include +#include +#include +int main(){ +}" > test_sockets.c + if $(gcc test_sockets.c -o test_sockets); then + echo "yes" + rm -f test_sockets.c test_sockets + else + echo "Error: Unix sockets not found/working." + exit 1 + rm -f test_sockets.c + fi +} + +function check_mysql_headers { + echo -n "Checking for MySQL headers... " + if [ -d /usr/local/lib/mysql ]; then # Default + echo "yes" + mysql_headers_path='/usr/local/lib/mysql' + else + if [ -d /usr/include/mysql ]; then # Gentoo/Debian/? + echo "yes" + mysql_headers_path='/usr/include/mysql' + else + echo "Error: MySQL headers not found." + mysql_headers_path='Not found.' + fi + fi +} + +function optimize { + case $@ in + mmx ) status_mmx="Yes" ;; + sse ) status_sse="Yes" ;; + sse2 ) status_sse2="Yes" ;; + sse3 ) status_sse3="Yes" ;; + all ) status_mmx="Yes" + status_sse="Yes" + status_sse2="Yes" + status_sse3="Yes" ;; + esac +} + +function make_changes { + if [ "$maker" != "make" ]; then + sed -e 's,MAKE = make,MAKE = '$maker',g' Makefile -i + fi + if [ "$status_mmx" = "Yes" ]; then + sed -e 's,# OPT += -mmmx,OPT += -mmmx,g' Makefile -i + fi + if [ "$status_sse" = "Yes" ]; then + sed -e 's,# OPT += -msse,OPT += -msse,g' Makefile -i + fi + if [ "$status_sse2" = "Yes" ]; then + sed -e 's,# OPT += -msse2,OPT += -msse2,g' Makefile -i + fi + if [ "$status_sse3" = "Yes" ]; then + sed -e 's,# OPT += -msse3,OPT += -msse3,g' Makefile -i + fi + if [ "$status_pcre" = "Yes" ]; then + sed -e 's,# OPT += -DPCRE_SUPPORT,OPT += -DPCRE_SUPPORT,g' Makefile -i + fi + if [ "$mysql_headers_path" != "/usr/local/lib/mysql" ] && [ "$mysql_headers_path" != "Not found." ]; then + sed -e 's,LIBS += -L/usr/local/lib/mysql -lmysqlclient,LIBS += -L'$mysql_headers_path' -lmysqlclient,g' Makefile -i + fi +} + +function opt_check_pcre { + echo -n "Checking for PCRE... " + if [ -f /usr/local/lib/pcre.h ]; then + echo "yes" + status_pcre="Yes" + else + echo "Error: PCRE not found." + status_pcre="No" + fi +} + +function make_report { + echo "Configuration report:" + echo eAthena + + echo + echo Enable PCRE support..... : $status_pcre + echo + echo Enable MMX optimization. : $status_mmx + echo Enable SSE optimization. : $status_sse + echo Enable SSE2 optimization : $status_sse2 + echo Enable SSE3 optimization : $status_sse3 + echo + echo MySQL headers path...... : $mysql_headers_path + echo + echo eAthena will be installed in $prefix + echo Please type \'make txt\' or \'make sql\' now to compile eAthena. +} + +function helptext { + echo "eAthena Configure Script version 0.1" + echo + echo "Options:" + echo + echo " -h Display this help message and exit." + echo " -d Enter debug mode." + echo " -o Turn on optimization flags." + echo " Supported:" + echo " mmx" + echo " sse" + echo " sse2" + echo " sse3" + echo " all" + echo " -e Enable PCRE support." + echo " -p Root directory where eA is going to be installed." + echo " DON'T FORGET THE LAST SLASH!" + echo " For example:" + echo " ./configure -p /usr/local/" + echo " This will create /usr/local/bin/login-server," + echo " /usr/local/etc/eathena/save/account.txt, etc" + echo " Default is /opt/eathena/" + echo + echo "Report bugs (about the configure script) to dontBR at the eAthena Support Board." +} + +function make_installable { + echo -e '' >> Makefile + echo -e 'install: conf/%.conf conf/%.txt' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'bin/)' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'etc/eathena/)' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'var/log/eathena/)' >> Makefile + echo -e ' $(shell mv save '$prefix'etc/eathena/save)' >> Makefile + echo -e ' $(shell mv db '$prefix'etc/eathena/db)' >> Makefile + echo -e ' $(shell mv conf '$prefix'etc/eathena/conf)' >> Makefile + echo -e ' $(shell mv npc '$prefix'etc/eathena/npc)' >> Makefile + echo -e ' $(shell mv log/* '$prefix'var/log/eathena/)' >> Makefile + echo -e ' $(shell cp *-server* '$prefix'bin/)' >> Makefile + echo -e ' $(shell cp ladmin '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/save/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/db/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/conf/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/npc/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'var/log/eathena/ '$prefix'bin/log)' >> Makefile + echo '' >> Makefile + echo -e 'bin-clean:' >> Makefile + echo -e ' $(shell rm '$prefix'bin/login-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/char-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/map-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/ladmin)' >> Makefile + echo '' >> Makefile + echo -e 'uninstall:' >> Makefile + echo -e ' bin-clean' >> Makefile + echo -e ' $(shell rm '$prefix'bin/save)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/db)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/conf)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/npc)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/log)' >> Makefile + echo -e ' $(shell rm -rf '$prefix'etc/eathena)' >> Makefile + echo -e ' $(shell rm -rf '$prefix'var/log/eathena)' >> Makefile +} + + +# Arguments +while getopts ":hdo:ep:" opt; do + case $opt in + h ) helptext ; exit ;; + d ) set -x ;; + o ) optimize ${OPTARG} ;; + e ) opt_check_pcre ;; + p ) prefix=${OPTARG} ; [ -d ${OPTARG} ] || echo "The directory $prefix does not exist. Creating...";; + esac +done + + +# Execution +echo "eAthena configure script" +echo "Note: This is ALPHA software! Do NOT use it on a production server!" +echo +echo "Checking for dependencies.." +check_sed +check_gcc +check_make +check_sockets +check_mysql_headers +make_changes +make_installable +echo +make_report +exit -- cgit v1.2.3-70-g09d2 From 366e7bf28c3f99c330dad67a63c7bf00b6443092 Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 1 Sep 2007 09:40:12 +0000 Subject: eol-style for the startup scripts and batch files git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11104 54d463be-8e91-2dee-dedb-b68131a5f0ec --- athena-start | 148 ++++++++-------- char-server.sh | 32 ++-- charserv-sql.bat | 16 +- charserv.bat | 16 +- configure | 512 +++++++++++++++++++++++++++--------------------------- login-server.sh | 32 ++-- logserv-sql.bat | 16 +- logserv.bat | 16 +- map-server.sh | 32 ++-- mapserv-sql.bat | 16 +- mapserv.bat | 16 +- object_del.bat | 31 ---- runserver-sql.bat | 16 +- runserver.bat | 150 ++++++++-------- start | 70 ++++---- 15 files changed, 544 insertions(+), 575 deletions(-) delete mode 100644 object_del.bat (limited to 'configure') diff --git a/athena-start b/athena-start index e9d3865f1..742145604 100644 --- a/athena-start +++ b/athena-start @@ -1,74 +1,74 @@ -#!/bin/sh -# athena starting script by rowla -# modified by shazeya@syafi.com (NL101541) - -PATH=./:$PATH - -L_SRV=login-server_sql -C_SRV=char-server_sql -M_SRV=map-server_sql - -print_start() { -# more << EOF -echo "Athena Starting..." -echo " (c) 2003 Athena Project" -echo " modified by shazeya@syafi.com" -echo "" -#echo "Debug informations will appear," -#echo "since this is a test release." -#echo "" -echo "checking..." -#EOF -} - -#check_account() { -# if [ ! -f ./save/account.txt ]; then -# echo "0 s1 p1 - S 0" > save/account.txt -# echo "1 s2 p2 - S 0" >>save/account.txt -# echo "2 s3 p3 - S 0" >>save/account.txt -# echo "3 s4 p4 - S 0" >>save/account.txt -# echo "4 s5 p5 - S 0" >>save/account.txt -# fi -#} - -check_files() { - - for i in ${L_SRV} ${C_SRV} ${M_SRV} - do - if [ ! -f ./$i ]; then - echo "$i does not exist, or can't run." - echo "Stop. Check your compile." - exit 1; - fi - done - -# more << EOF -echo "Check complete." -echo "Looks good, a nice Athena!" -#EOF -} - - -case $1 in - 'start') - print_start -# check_account - check_files - - exec ./${L_SRV}& - exec ./${C_SRV}& - exec ./${M_SRV}& - - echo "Now Started Athena." -;; - 'stop') - ps ax | grep -E "${L_SRV}|${C_SRV}|${M_SRV}" | awk '{print $1}' | xargs kill -9 -;; - 'restart') - $0 stop - $0 start -;; - *) - echo "Usage: athena-start { start | stop | restart }" -;; -esac +#!/bin/sh +# athena starting script by rowla +# modified by shazeya@syafi.com (NL101541) + +PATH=./:$PATH + +L_SRV=login-server_sql +C_SRV=char-server_sql +M_SRV=map-server_sql + +print_start() { +# more << EOF +echo "Athena Starting..." +echo " (c) 2003 Athena Project" +echo " modified by shazeya@syafi.com" +echo "" +#echo "Debug informations will appear," +#echo "since this is a test release." +#echo "" +echo "checking..." +#EOF +} + +#check_account() { +# if [ ! -f ./save/account.txt ]; then +# echo "0 s1 p1 - S 0" > save/account.txt +# echo "1 s2 p2 - S 0" >>save/account.txt +# echo "2 s3 p3 - S 0" >>save/account.txt +# echo "3 s4 p4 - S 0" >>save/account.txt +# echo "4 s5 p5 - S 0" >>save/account.txt +# fi +#} + +check_files() { + + for i in ${L_SRV} ${C_SRV} ${M_SRV} + do + if [ ! -f ./$i ]; then + echo "$i does not exist, or can't run." + echo "Stop. Check your compile." + exit 1; + fi + done + +# more << EOF +echo "Check complete." +echo "Looks good, a nice Athena!" +#EOF +} + + +case $1 in + 'start') + print_start +# check_account + check_files + + exec ./${L_SRV}& + exec ./${C_SRV}& + exec ./${M_SRV}& + + echo "Now Started Athena." +;; + 'stop') + ps ax | grep -E "${L_SRV}|${C_SRV}|${M_SRV}" | awk '{print $1}' | xargs kill -9 +;; + 'restart') + $0 stop + $0 start +;; + *) + echo "Usage: athena-start { start | stop | restart }" +;; +esac diff --git a/char-server.sh b/char-server.sh index 39c1882ad..6cddf373c 100644 --- a/char-server.sh +++ b/char-server.sh @@ -1,16 +1,16 @@ -#/bin/sh -#Hi my naem is Kirt and I liek anime - -ulimit -Sc unlimited - -while [ 3 ] ; do -if [ -f .stopserver3 ] ; then -echo server marked down >> servlog.txt -else -echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt -./char-server -fi - -sleep 5 - -done +#/bin/sh +#Hi my naem is Kirt and I liek anime + +ulimit -Sc unlimited + +while [ 3 ] ; do +if [ -f .stopserver3 ] ; then +echo server marked down >> servlog.txt +else +echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt +./char-server +fi + +sleep 5 + +done diff --git a/charserv-sql.bat b/charserv-sql.bat index 894db5dc5..90b58b205 100644 --- a/charserv-sql.bat +++ b/charserv-sql.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -char-server_sql.exe -echo . -echo . -echo Char server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +char-server_sql.exe +echo . +echo . +echo Char server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/charserv.bat b/charserv.bat index 29d03a3a4..cda0f4eb4 100644 --- a/charserv.bat +++ b/charserv.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -char-server.exe -echo . -echo . -echo Char server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +char-server.exe +echo . +echo . +echo Char server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/configure b/configure index ef4f2a9a9..b50031368 100644 --- a/configure +++ b/configure @@ -1,256 +1,256 @@ -#!/bin/bash -## NOTE: -## I know this is not a clean way to check for some stuff -## and edit the Makefile, but hey, it does work! - -# Configure script for eAthena -# Copyright (C) 2005 dontBR -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -# Default variables -status_mmx="No" -status_sse="No" -status_sse2="No" -status_sse3="No" -status_pcre="No" -prefix='/opt/eathena/' - -# Functions -function check_sed { - echo -n "Checking for sed... " - if [ -f $(which sed) ]; then - echo "yes" - else - echo "Error: sed not found in $PATH" - exit 1 - fi -} - -function check_gcc { - echo -n "Checking for gcc... " - if [ -f $(which gcc) ]; then - echo "yes" - else - echo "Error: GCC not found in $PATH" - exit 1 - fi -} - -function check_make { - echo -n "Checking for (g)make... " - if [ -f $(which make) ]; then - maker=make - echo "yes" - else if [ -f $(which gmake) ]; then - maker=gmake - echo "yes" - else - echo "Error: (g)make not found in $PATH" - exit 1 - fi - fi -} - -function check_sockets { - echo -n "Checking for sockets... " - echo "#include -#include -#include -int main(){ -}" > test_sockets.c - if $(gcc test_sockets.c -o test_sockets); then - echo "yes" - rm -f test_sockets.c test_sockets - else - echo "Error: Unix sockets not found/working." - exit 1 - rm -f test_sockets.c - fi -} - -function check_mysql_headers { - echo -n "Checking for MySQL headers... " - if [ -d /usr/local/lib/mysql ]; then # Default - echo "yes" - mysql_headers_path='/usr/local/lib/mysql' - else - if [ -d /usr/include/mysql ]; then # Gentoo/Debian/? - echo "yes" - mysql_headers_path='/usr/include/mysql' - else - echo "Error: MySQL headers not found." - mysql_headers_path='Not found.' - fi - fi -} - -function optimize { - case $@ in - mmx ) status_mmx="Yes" ;; - sse ) status_sse="Yes" ;; - sse2 ) status_sse2="Yes" ;; - sse3 ) status_sse3="Yes" ;; - all ) status_mmx="Yes" - status_sse="Yes" - status_sse2="Yes" - status_sse3="Yes" ;; - esac -} - -function make_changes { - if [ "$maker" != "make" ]; then - sed -e 's,MAKE = make,MAKE = '$maker',g' Makefile -i - fi - if [ "$status_mmx" = "Yes" ]; then - sed -e 's,# OPT += -mmmx,OPT += -mmmx,g' Makefile -i - fi - if [ "$status_sse" = "Yes" ]; then - sed -e 's,# OPT += -msse,OPT += -msse,g' Makefile -i - fi - if [ "$status_sse2" = "Yes" ]; then - sed -e 's,# OPT += -msse2,OPT += -msse2,g' Makefile -i - fi - if [ "$status_sse3" = "Yes" ]; then - sed -e 's,# OPT += -msse3,OPT += -msse3,g' Makefile -i - fi - if [ "$status_pcre" = "Yes" ]; then - sed -e 's,# OPT += -DPCRE_SUPPORT,OPT += -DPCRE_SUPPORT,g' Makefile -i - fi - if [ "$mysql_headers_path" != "/usr/local/lib/mysql" ] && [ "$mysql_headers_path" != "Not found." ]; then - sed -e 's,LIBS += -L/usr/local/lib/mysql -lmysqlclient,LIBS += -L'$mysql_headers_path' -lmysqlclient,g' Makefile -i - fi -} - -function opt_check_pcre { - echo -n "Checking for PCRE... " - if [ -f /usr/local/lib/pcre.h ]; then - echo "yes" - status_pcre="Yes" - else - echo "Error: PCRE not found." - status_pcre="No" - fi -} - -function make_report { - echo "Configuration report:" - echo eAthena - - echo - echo Enable PCRE support..... : $status_pcre - echo - echo Enable MMX optimization. : $status_mmx - echo Enable SSE optimization. : $status_sse - echo Enable SSE2 optimization : $status_sse2 - echo Enable SSE3 optimization : $status_sse3 - echo - echo MySQL headers path...... : $mysql_headers_path - echo - echo eAthena will be installed in $prefix - echo Please type \'make txt\' or \'make sql\' now to compile eAthena. -} - -function helptext { - echo "eAthena Configure Script version 0.1" - echo - echo "Options:" - echo - echo " -h Display this help message and exit." - echo " -d Enter debug mode." - echo " -o Turn on optimization flags." - echo " Supported:" - echo " mmx" - echo " sse" - echo " sse2" - echo " sse3" - echo " all" - echo " -e Enable PCRE support." - echo " -p Root directory where eA is going to be installed." - echo " DON'T FORGET THE LAST SLASH!" - echo " For example:" - echo " ./configure -p /usr/local/" - echo " This will create /usr/local/bin/login-server," - echo " /usr/local/etc/eathena/save/account.txt, etc" - echo " Default is /opt/eathena/" - echo - echo "Report bugs (about the configure script) to dontBR at the eAthena Support Board." -} - -function make_installable { - echo -e '' >> Makefile - echo -e 'install: conf/%.conf conf/%.txt' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'bin/)' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'etc/eathena/)' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'var/log/eathena/)' >> Makefile - echo -e ' $(shell mv save '$prefix'etc/eathena/save)' >> Makefile - echo -e ' $(shell mv db '$prefix'etc/eathena/db)' >> Makefile - echo -e ' $(shell mv conf '$prefix'etc/eathena/conf)' >> Makefile - echo -e ' $(shell mv npc '$prefix'etc/eathena/npc)' >> Makefile - echo -e ' $(shell mv log/* '$prefix'var/log/eathena/)' >> Makefile - echo -e ' $(shell cp *-server* '$prefix'bin/)' >> Makefile - echo -e ' $(shell cp ladmin '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/save/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/db/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/conf/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/npc/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'var/log/eathena/ '$prefix'bin/log)' >> Makefile - echo '' >> Makefile - echo -e 'bin-clean:' >> Makefile - echo -e ' $(shell rm '$prefix'bin/login-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/char-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/map-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/ladmin)' >> Makefile - echo '' >> Makefile - echo -e 'uninstall:' >> Makefile - echo -e ' bin-clean' >> Makefile - echo -e ' $(shell rm '$prefix'bin/save)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/db)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/conf)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/npc)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/log)' >> Makefile - echo -e ' $(shell rm -rf '$prefix'etc/eathena)' >> Makefile - echo -e ' $(shell rm -rf '$prefix'var/log/eathena)' >> Makefile -} - - -# Arguments -while getopts ":hdo:ep:" opt; do - case $opt in - h ) helptext ; exit ;; - d ) set -x ;; - o ) optimize ${OPTARG} ;; - e ) opt_check_pcre ;; - p ) prefix=${OPTARG} ; [ -d ${OPTARG} ] || echo "The directory $prefix does not exist. Creating...";; - esac -done - - -# Execution -echo "eAthena configure script" -echo "Note: This is ALPHA software! Do NOT use it on a production server!" -echo -echo "Checking for dependencies.." -check_sed -check_gcc -check_make -check_sockets -check_mysql_headers -make_changes -make_installable -echo -make_report -exit +#!/bin/bash +## NOTE: +## I know this is not a clean way to check for some stuff +## and edit the Makefile, but hey, it does work! + +# Configure script for eAthena +# Copyright (C) 2005 dontBR +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +# Default variables +status_mmx="No" +status_sse="No" +status_sse2="No" +status_sse3="No" +status_pcre="No" +prefix='/opt/eathena/' + +# Functions +function check_sed { + echo -n "Checking for sed... " + if [ -f $(which sed) ]; then + echo "yes" + else + echo "Error: sed not found in $PATH" + exit 1 + fi +} + +function check_gcc { + echo -n "Checking for gcc... " + if [ -f $(which gcc) ]; then + echo "yes" + else + echo "Error: GCC not found in $PATH" + exit 1 + fi +} + +function check_make { + echo -n "Checking for (g)make... " + if [ -f $(which make) ]; then + maker=make + echo "yes" + else if [ -f $(which gmake) ]; then + maker=gmake + echo "yes" + else + echo "Error: (g)make not found in $PATH" + exit 1 + fi + fi +} + +function check_sockets { + echo -n "Checking for sockets... " + echo "#include +#include +#include +int main(){ +}" > test_sockets.c + if $(gcc test_sockets.c -o test_sockets); then + echo "yes" + rm -f test_sockets.c test_sockets + else + echo "Error: Unix sockets not found/working." + exit 1 + rm -f test_sockets.c + fi +} + +function check_mysql_headers { + echo -n "Checking for MySQL headers... " + if [ -d /usr/local/lib/mysql ]; then # Default + echo "yes" + mysql_headers_path='/usr/local/lib/mysql' + else + if [ -d /usr/include/mysql ]; then # Gentoo/Debian/? + echo "yes" + mysql_headers_path='/usr/include/mysql' + else + echo "Error: MySQL headers not found." + mysql_headers_path='Not found.' + fi + fi +} + +function optimize { + case $@ in + mmx ) status_mmx="Yes" ;; + sse ) status_sse="Yes" ;; + sse2 ) status_sse2="Yes" ;; + sse3 ) status_sse3="Yes" ;; + all ) status_mmx="Yes" + status_sse="Yes" + status_sse2="Yes" + status_sse3="Yes" ;; + esac +} + +function make_changes { + if [ "$maker" != "make" ]; then + sed -e 's,MAKE = make,MAKE = '$maker',g' Makefile -i + fi + if [ "$status_mmx" = "Yes" ]; then + sed -e 's,# OPT += -mmmx,OPT += -mmmx,g' Makefile -i + fi + if [ "$status_sse" = "Yes" ]; then + sed -e 's,# OPT += -msse,OPT += -msse,g' Makefile -i + fi + if [ "$status_sse2" = "Yes" ]; then + sed -e 's,# OPT += -msse2,OPT += -msse2,g' Makefile -i + fi + if [ "$status_sse3" = "Yes" ]; then + sed -e 's,# OPT += -msse3,OPT += -msse3,g' Makefile -i + fi + if [ "$status_pcre" = "Yes" ]; then + sed -e 's,# OPT += -DPCRE_SUPPORT,OPT += -DPCRE_SUPPORT,g' Makefile -i + fi + if [ "$mysql_headers_path" != "/usr/local/lib/mysql" ] && [ "$mysql_headers_path" != "Not found." ]; then + sed -e 's,LIBS += -L/usr/local/lib/mysql -lmysqlclient,LIBS += -L'$mysql_headers_path' -lmysqlclient,g' Makefile -i + fi +} + +function opt_check_pcre { + echo -n "Checking for PCRE... " + if [ -f /usr/local/lib/pcre.h ]; then + echo "yes" + status_pcre="Yes" + else + echo "Error: PCRE not found." + status_pcre="No" + fi +} + +function make_report { + echo "Configuration report:" + echo eAthena + + echo + echo Enable PCRE support..... : $status_pcre + echo + echo Enable MMX optimization. : $status_mmx + echo Enable SSE optimization. : $status_sse + echo Enable SSE2 optimization : $status_sse2 + echo Enable SSE3 optimization : $status_sse3 + echo + echo MySQL headers path...... : $mysql_headers_path + echo + echo eAthena will be installed in $prefix + echo Please type \'make txt\' or \'make sql\' now to compile eAthena. +} + +function helptext { + echo "eAthena Configure Script version 0.1" + echo + echo "Options:" + echo + echo " -h Display this help message and exit." + echo " -d Enter debug mode." + echo " -o Turn on optimization flags." + echo " Supported:" + echo " mmx" + echo " sse" + echo " sse2" + echo " sse3" + echo " all" + echo " -e Enable PCRE support." + echo " -p Root directory where eA is going to be installed." + echo " DON'T FORGET THE LAST SLASH!" + echo " For example:" + echo " ./configure -p /usr/local/" + echo " This will create /usr/local/bin/login-server," + echo " /usr/local/etc/eathena/save/account.txt, etc" + echo " Default is /opt/eathena/" + echo + echo "Report bugs (about the configure script) to dontBR at the eAthena Support Board." +} + +function make_installable { + echo -e '' >> Makefile + echo -e 'install: conf/%.conf conf/%.txt' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'bin/)' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'etc/eathena/)' >> Makefile + echo -e ' $(shell mkdir -p '$prefix'var/log/eathena/)' >> Makefile + echo -e ' $(shell mv save '$prefix'etc/eathena/save)' >> Makefile + echo -e ' $(shell mv db '$prefix'etc/eathena/db)' >> Makefile + echo -e ' $(shell mv conf '$prefix'etc/eathena/conf)' >> Makefile + echo -e ' $(shell mv npc '$prefix'etc/eathena/npc)' >> Makefile + echo -e ' $(shell mv log/* '$prefix'var/log/eathena/)' >> Makefile + echo -e ' $(shell cp *-server* '$prefix'bin/)' >> Makefile + echo -e ' $(shell cp ladmin '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/save/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/db/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/conf/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'etc/eathena/npc/ '$prefix'bin/)' >> Makefile + echo -e ' $(shell ln -s '$prefix'var/log/eathena/ '$prefix'bin/log)' >> Makefile + echo '' >> Makefile + echo -e 'bin-clean:' >> Makefile + echo -e ' $(shell rm '$prefix'bin/login-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/char-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/map-server*)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/ladmin)' >> Makefile + echo '' >> Makefile + echo -e 'uninstall:' >> Makefile + echo -e ' bin-clean' >> Makefile + echo -e ' $(shell rm '$prefix'bin/save)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/db)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/conf)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/npc)' >> Makefile + echo -e ' $(shell rm '$prefix'bin/log)' >> Makefile + echo -e ' $(shell rm -rf '$prefix'etc/eathena)' >> Makefile + echo -e ' $(shell rm -rf '$prefix'var/log/eathena)' >> Makefile +} + + +# Arguments +while getopts ":hdo:ep:" opt; do + case $opt in + h ) helptext ; exit ;; + d ) set -x ;; + o ) optimize ${OPTARG} ;; + e ) opt_check_pcre ;; + p ) prefix=${OPTARG} ; [ -d ${OPTARG} ] || echo "The directory $prefix does not exist. Creating...";; + esac +done + + +# Execution +echo "eAthena configure script" +echo "Note: This is ALPHA software! Do NOT use it on a production server!" +echo +echo "Checking for dependencies.." +check_sed +check_gcc +check_make +check_sockets +check_mysql_headers +make_changes +make_installable +echo +make_report +exit diff --git a/login-server.sh b/login-server.sh index e37645ed5..b658a3e35 100644 --- a/login-server.sh +++ b/login-server.sh @@ -1,16 +1,16 @@ -#/bin/sh -#Hi my naem is Kirt and I liek anime - -ulimit -Sc unlimited - -while [ 2 ] ; do -if [ -f .stopserver2 ] ; then -echo server marked down >> servlog.txt -else -echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt -./login-server -fi - -sleep 5 - -done +#/bin/sh +#Hi my naem is Kirt and I liek anime + +ulimit -Sc unlimited + +while [ 2 ] ; do +if [ -f .stopserver2 ] ; then +echo server marked down >> servlog.txt +else +echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt +./login-server +fi + +sleep 5 + +done diff --git a/logserv-sql.bat b/logserv-sql.bat index 15f57fb45..3280c4095 100644 --- a/logserv-sql.bat +++ b/logserv-sql.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -login-server_sql.exe -echo . -echo . -echo Login server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +login-server_sql.exe +echo . +echo . +echo Login server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/logserv.bat b/logserv.bat index 945c59c36..9ea82e4c0 100644 --- a/logserv.bat +++ b/logserv.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -login-server.exe -echo . -echo . -echo Login server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +login-server.exe +echo . +echo . +echo Login server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/map-server.sh b/map-server.sh index f66e9f1c5..04a635463 100644 --- a/map-server.sh +++ b/map-server.sh @@ -1,16 +1,16 @@ -#/bin/sh -#Hi my naem is Kirt and I liek anime - -ulimit -Sc unlimited - -while [ 1 ] ; do -if [ -f .stopserver ] ; then -echo server marked down >> servlog.txt -else -echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt -./map-server -fi - -sleep 5 - -done +#/bin/sh +#Hi my naem is Kirt and I liek anime + +ulimit -Sc unlimited + +while [ 1 ] ; do +if [ -f .stopserver ] ; then +echo server marked down >> servlog.txt +else +echo restarting server at time at `date +"%m-%d-%H:%M-%S"`>> startlog.txt +./map-server +fi + +sleep 5 + +done diff --git a/mapserv-sql.bat b/mapserv-sql.bat index 78a9179c9..ae65d3be3 100644 --- a/mapserv-sql.bat +++ b/mapserv-sql.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -map-server_sql.exe -echo . -echo . -echo Map server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +map-server_sql.exe +echo . +echo . +echo Map server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/mapserv.bat b/mapserv.bat index 813cbd110..d9eee9f6e 100644 --- a/mapserv.bat +++ b/mapserv.bat @@ -1,9 +1,9 @@ -@echo off -rem Writen by Jbain -:end -map-server.exe -echo . -echo . -echo Map server crashed! restarting in 15 seconds! press ctl+C to cancel restart! -PING -n 15 127.0.0.1 >nul +@echo off +rem Writen by Jbain +:end +map-server.exe +echo . +echo . +echo Map server crashed! restarting in 15 seconds! press ctl+C to cancel restart! +PING -n 15 127.0.0.1 >nul goto end \ No newline at end of file diff --git a/object_del.bat b/object_del.bat deleted file mode 100644 index b2c3c46ef..000000000 --- a/object_del.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -echo Y | del src\char\*.o -echo Y | del src\char\GNUmakefile -echo Y | del src\char_sql\*.o -echo Y | del src\char_sql\GNUmakefile -echo Y | del src\common\obj\*.o -echo Y | rmdir src\common\obj -echo Y | del src\common\GNUmakefile -echo Y | del src\ladmin\GNUmakefile -echo Y | del src\login\*.o -echo Y | del src\login\GNUmakefile -echo Y | del src\login_sql\*.o -echo Y | del src\login_sql\GNUmakefile -echo Y | del src\map\txtobj\*.o -echo Y | rmdir src\map\txtobj -echo Y | del src\map\sqlobj\*.o -echo Y | rmdir src\map\sqlobj -echo Y | del src\map\GNUmakefile -echo Y | del src\txt-converter\char\GNUmakefile -echo Y | del src\txt-converter\char\*.o -echo Y | del src\txt-converter\login\GNUmakefile -echo Y | del src\txt-converter\login\*.o -echo Y | del char-converter.exe -echo Y | del char-server.exe -echo Y | del char-server_sql.exe -echo Y | del ladmin.exe -echo Y | del login-converter.exe -echo Y | del login-server.exe -echo Y | del login-server_sql.exe -echo Y | del map-server.exe -echo Y | del map-server_sql.exe \ No newline at end of file diff --git a/runserver-sql.bat b/runserver-sql.bat index 57d6fa1b8..f424a205a 100644 --- a/runserver-sql.bat +++ b/runserver-sql.bat @@ -1,8 +1,8 @@ -@echo off -rem This is and auto-restart script for the eAthena Ragnarok Online Server Emulator. -rem It will also keep the map server OPEN after it crashes to that errors may be -rem more easily identified -rem Writen by Jbain -start cmd /k logserv-sql.bat -start cmd /k charserv-sql.bat -start cmd /k mapserv-sql.bat +@echo off +rem This is and auto-restart script for the eAthena Ragnarok Online Server Emulator. +rem It will also keep the map server OPEN after it crashes to that errors may be +rem more easily identified +rem Writen by Jbain +start cmd /k logserv-sql.bat +start cmd /k charserv-sql.bat +start cmd /k mapserv-sql.bat diff --git a/runserver.bat b/runserver.bat index 4fc66edc9..553274013 100644 --- a/runserver.bat +++ b/runserver.bat @@ -1,75 +1,75 @@ -@echo off - -rem ----- Configuration ----- - rem Defines the server type (txt or sql). - set SERVER_TYPE=txt - rem Defines how long to wait before restarting (in seconds). - set SLEEP_TIME=15 - rem Defines whether to run all servers in one window (yes or no). - set SINGLE_WINDOW=no -rem ----- ------------- ----- - -:L_Init - set this=%0 - if %SERVER_TYPE% == txt set suffix= - if %SERVER_TYPE% == sql set suffix=_sql - if %SINGLE_WINDOW% == yes set wndswitch=/B - -:L_Main - set command=%1 - if "%command%" == "" goto L_DefaultAction - - if %command% == exec goto L_ExecServerExe - if %command% == start goto L_StartServerExe - if %command% == stop goto L_StopServerExe - if %command% == restart echo "TODO" - goto L_EOF - -:L_DefaultAction -:L_StartServer - call %this% start login-server%suffix%.exe - call %this% start char-server%suffix%.exe - call %this% start map-server%suffix%.exe - goto L_EOF - -:L_StopServer - call %this% stop login-server%suffix%.exe - call %this% stop char-server%suffix%.exe - call %this% stop map-server%suffix%.exe - goto L_EOF - -:L_StartServerExe - set filename=%2 - if "%filename%" == "" goto L_StartServer - if exist %filename% goto L_HaveExe - echo Cannot start '%filename%' because the file is missing! - goto L_EOF - - :L_HaveExe - echo Starting %filename%... - start "%filename%" %wndswitch% %this% exec %filename% - goto L_EOF - -:L_StopServerExe - set filename=%2 - if "%filename%" == "" goto L_StopServer - if exist %windir%\system32\taskkill.exe goto L_HaveTaskKill - echo The 'stop' command is not available on your system. - exit - - :L_HaveTaskKill - rem CAUTION! This will kill all processes called %filename%. - echo Stopping '%filename%'... - taskkill /F /FI "WINDOWTITLE eq %filename% - %this% exec %filename%" - taskkill /F /IM "%filename%" - goto L_EOF - -:L_ExecServerExe - %filename% - echo . - echo . - echo Server exited, restarting in %SLEEP_TIME% seconds! Press CTRL+C to abort! - ping.exe -n %SLEEP_TIME% 127.0.0.1 > nul - goto L_ExecServerExe - -:L_EOF +@echo off + +rem ----- Configuration ----- + rem Defines the server type (txt or sql). + set SERVER_TYPE=txt + rem Defines how long to wait before restarting (in seconds). + set SLEEP_TIME=15 + rem Defines whether to run all servers in one window (yes or no). + set SINGLE_WINDOW=no +rem ----- ------------- ----- + +:L_Init + set this=%0 + if %SERVER_TYPE% == txt set suffix= + if %SERVER_TYPE% == sql set suffix=_sql + if %SINGLE_WINDOW% == yes set wndswitch=/B + +:L_Main + set command=%1 + if "%command%" == "" goto L_DefaultAction + + if %command% == exec goto L_ExecServerExe + if %command% == start goto L_StartServerExe + if %command% == stop goto L_StopServerExe + if %command% == restart echo "TODO" + goto L_EOF + +:L_DefaultAction +:L_StartServer + call %this% start login-server%suffix%.exe + call %this% start char-server%suffix%.exe + call %this% start map-server%suffix%.exe + goto L_EOF + +:L_StopServer + call %this% stop login-server%suffix%.exe + call %this% stop char-server%suffix%.exe + call %this% stop map-server%suffix%.exe + goto L_EOF + +:L_StartServerExe + set filename=%2 + if "%filename%" == "" goto L_StartServer + if exist %filename% goto L_HaveExe + echo Cannot start '%filename%' because the file is missing! + goto L_EOF + + :L_HaveExe + echo Starting %filename%... + start "%filename%" %wndswitch% %this% exec %filename% + goto L_EOF + +:L_StopServerExe + set filename=%2 + if "%filename%" == "" goto L_StopServer + if exist %windir%\system32\taskkill.exe goto L_HaveTaskKill + echo The 'stop' command is not available on your system. + exit + + :L_HaveTaskKill + rem CAUTION! This will kill all processes called %filename%. + echo Stopping '%filename%'... + taskkill /F /FI "WINDOWTITLE eq %filename% - %this% exec %filename%" + taskkill /F /IM "%filename%" + goto L_EOF + +:L_ExecServerExe + %filename% + echo . + echo . + echo Server exited, restarting in %SLEEP_TIME% seconds! Press CTRL+C to abort! + ping.exe -n %SLEEP_TIME% 127.0.0.1 > nul + goto L_ExecServerExe + +:L_EOF diff --git a/start b/start index b92fb56df..bd12a5e88 100644 --- a/start +++ b/start @@ -1,35 +1,35 @@ -#!/bin/bash -# modified by shazeya@syafi.com (NL130240) - -./athena-start start -sleep 30 - -while [ true ]; do - if [ " 0" = "$(ps | grep -e log | wc -l)" ] || -# if [ " 0" = "$(ps | grep -e login | wc -l)" ] || - [ " 0" = "$(ps | grep -e char | wc -l)" ] || - [ " 0" = "$(ps | grep -e map | wc -l)" ]; then - printf "Error:" - date - sleep 10 - printf "Checking:" - date - if [ " 0" = "$(ps | grep -e log | wc -l)" ] || -# if [ " 0" = "$(ps | grep -e login | wc -l)" ] || - [ " 0" = "$(ps | grep -e char | wc -l)" ] || - [ " 0" = "$(ps | grep -e map | wc -l)" ]; then - printf "Error Confirmation:" - date - printf "Restoration:" - date - ./athena-start start - else - printf "Check Miss Sorry:" - date - fi -# else -# printf "Check OK:" -# date - fi - sleep 10 -done +#!/bin/bash +# modified by shazeya@syafi.com (NL130240) + +./athena-start start +sleep 30 + +while [ true ]; do + if [ " 0" = "$(ps | grep -e log | wc -l)" ] || +# if [ " 0" = "$(ps | grep -e login | wc -l)" ] || + [ " 0" = "$(ps | grep -e char | wc -l)" ] || + [ " 0" = "$(ps | grep -e map | wc -l)" ]; then + printf "Error:" + date + sleep 10 + printf "Checking:" + date + if [ " 0" = "$(ps | grep -e log | wc -l)" ] || +# if [ " 0" = "$(ps | grep -e login | wc -l)" ] || + [ " 0" = "$(ps | grep -e char | wc -l)" ] || + [ " 0" = "$(ps | grep -e map | wc -l)" ]; then + printf "Error Confirmation:" + date + printf "Restoration:" + date + ./athena-start start + else + printf "Check Miss Sorry:" + date + fi +# else +# printf "Check OK:" +# date + fi + sleep 10 +done -- cgit v1.2.3-70-g09d2 From 5245e666a09df5f401c1329bf5ee1fc1b09b1d16 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 20 Sep 2007 11:09:36 +0000 Subject: * Merged the tmpsql branch: - Abstraction for the sql code (sql.c/h). - New configure script and makefiles. - Restored txt zeny logging code. (r10814) - Rewrote mapserver's sql code - itemdb, mobdb, mapreg, logs. (r10814) - Fixed a precedence issue (&& and ) in char_sql/char.c. (r10833) - Improved db reading code a bit for consistency. (r11077) - Added separate atcommand for mail deletion. (r11077) - Corrected a few messages that said "new" instead of "unread". (r11077) - Broadcast (*) messages now use "*" as the target's name (not ""). (r11077) - Moved StringBuf code from utils.c/h to strlib.c/h. (r11084 r11117) - Some misc login server cleanups (reformatting etc). (r11136) - Corrected/modified some header entries. (r11141 r11147 11148) - Adjusted VS project files. (r11147) - Adjusted the way the sql charserver does item saving. (r11192) - Corrected usage of reserved keyword 'friend' in mmo.h. (r11192) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11245 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 17 + Makefile | 253 ---- Makefile.in | 181 +++ conf-tmpl/msg_athena.conf | 4 +- configure | 256 ---- configure.in | 295 +++++ eAthena-8.sln | 8 + src/char/Makefile | 31 - src/char/Makefile.in | 46 + src/char/char.c | 8 +- src/char/char.h | 3 +- src/char/int_guild.c | 8 +- src/char/int_guild.h | 3 + src/char/int_homun.c | 8 +- src/char/int_homun.h | 1 - src/char/int_party.c | 8 +- src/char/int_party.h | 4 +- src/char/int_pet.c | 8 +- src/char/int_pet.h | 2 + src/char/int_status.c | 7 +- src/char/int_status.h | 6 +- src/char/int_storage.c | 9 +- src/char/int_storage.h | 4 +- src/char/inter.c | 9 +- src/char/inter.h | 2 + src/char_sql/Makefile | 28 - src/char_sql/Makefile.in | 56 + src/char_sql/char.c | 2213 +++++++++++++++-------------------- src/char_sql/char.h | 28 +- src/char_sql/int_guild.c | 868 +++++++------- src/char_sql/int_guild.h | 25 +- src/char_sql/int_homun.c | 217 ++-- src/char_sql/int_homun.h | 2 + src/char_sql/int_party.c | 318 +++-- src/char_sql/int_party.h | 2 + src/char_sql/int_pet.c | 140 ++- src/char_sql/int_pet.h | 2 + src/char_sql/int_storage.c | 358 +++--- src/char_sql/int_storage.h | 3 + src/char_sql/inter.c | 321 ++--- src/char_sql/inter.h | 22 +- src/char_sql/itemdb.c | 219 ---- src/char_sql/itemdb.h | 44 - src/common/Makefile | 56 - src/common/Makefile.in | 95 ++ src/common/db.c | 1 - src/common/ers.c | 3 +- src/common/ers.h | 2 + src/common/md5calc.c | 2 +- src/common/mmo.h | 7 +- src/common/plugins.c | 4 +- src/common/showmsg.c | 21 +- src/common/socket.c | 13 +- src/common/socket.h | 4 +- src/common/sql.c | 851 ++++++++++++++ src/common/sql.h | 343 ++++++ src/common/strlib.c | 134 ++- src/common/strlib.h | 22 + src/common/utils.c | 154 +-- src/common/utils.h | 28 +- src/ladmin/Makefile | 18 - src/ladmin/Makefile.in | 31 + src/login/Makefile | 25 - src/login/Makefile.in | 35 + src/login/login.c | 300 +++-- src/login_sql/Makefile | 22 - src/login_sql/Makefile.in | 46 + src/login_sql/login.c | 1335 +++++++++++---------- src/map/Makefile | 103 -- src/map/Makefile.in | 148 +++ src/map/atcommand.c | 41 +- src/map/battle.c | 1 + src/map/charcommand.c | 1 + src/map/clif.c | 1 + src/map/guild.c | 6 +- src/map/intif.c | 2 +- src/map/itemdb.c | 496 +++----- src/map/log.c | 392 ++++--- src/map/log.h | 8 - src/map/mail.c | 464 ++++---- src/map/mail.h | 4 +- src/map/map.c | 138 +-- src/map/map.h | 53 +- src/map/mob.c | 112 +- src/map/npc.c | 1 + src/map/party.c | 1 + src/map/pc.c | 3 +- src/map/pet.c | 1 + src/map/script.c | 372 +++--- src/map/skill.c | 1 + src/map/status.c | 1 + src/plugins/Makefile | 42 - src/plugins/Makefile.in | 67 ++ src/tool/Makefile | 14 - src/tool/Makefile.in | 28 + src/txt-converter/Makefile | 24 - src/txt-converter/Makefile.in | 68 ++ src/txt-converter/char-converter.c | 1 + src/txt-converter/login-converter.c | 39 +- vcproj-6/char-server_sql.dsp | 16 +- vcproj-6/login-server_sql.dsp | 8 + vcproj-6/map-server_sql.dsp | 8 + vcproj-7.1/char-server_sql.vcproj | 12 +- vcproj-7.1/login-server_sql.vcproj | 6 + vcproj-7.1/map-server_sql.vcproj | 6 + vcproj-8/char-server_sql.vcproj | 18 +- vcproj-8/char-server_txt.vcproj | 4 + vcproj-8/login-server_sql.vcproj | 10 +- vcproj-8/map-server_sql.vcproj | 8 + vcproj-8/txt-converter-char.vcproj | 116 +- vcproj-8/txt-converter-login.vcproj | 20 +- 111 files changed, 6561 insertions(+), 5903 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.in delete mode 100644 configure create mode 100644 configure.in delete mode 100644 src/char/Makefile create mode 100644 src/char/Makefile.in delete mode 100644 src/char_sql/Makefile create mode 100644 src/char_sql/Makefile.in delete mode 100644 src/char_sql/itemdb.c delete mode 100644 src/char_sql/itemdb.h delete mode 100644 src/common/Makefile create mode 100644 src/common/Makefile.in create mode 100644 src/common/sql.c create mode 100644 src/common/sql.h delete mode 100644 src/ladmin/Makefile create mode 100644 src/ladmin/Makefile.in delete mode 100644 src/login/Makefile create mode 100644 src/login/Makefile.in delete mode 100644 src/login_sql/Makefile create mode 100644 src/login_sql/Makefile.in delete mode 100644 src/map/Makefile create mode 100644 src/map/Makefile.in delete mode 100644 src/plugins/Makefile create mode 100644 src/plugins/Makefile.in delete mode 100644 src/tool/Makefile create mode 100644 src/tool/Makefile.in delete mode 100644 src/txt-converter/Makefile create mode 100644 src/txt-converter/Makefile.in (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ada21ce57..5a1178a99 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,23 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/09/20 + * Merged the tmpsql branch: [FlavioJS] + - Abstraction for the sql code (sql.c/h). + - New configure script and makefiles. + - Restored txt zeny logging code. (r10814) + - Rewrote mapserver's sql code - itemdb, mobdb, mapreg, logs. (r10814) + - Fixed a precedence issue (&& and ) in char_sql/char.c. (r10833) + - Improved db reading code a bit for consistency. (r11077) + - Added separate atcommand for mail deletion. (r11077) + - Corrected a few messages that said "new" instead of "unread". (r11077) + - Broadcast (*) messages now use "*" as the target's name (not ""). (r11077) + - Moved StringBuf code from utils.c/h to strlib.c/h. (r11084 r11117) + - Some misc login server cleanups (reformatting etc). (r11136) + - Corrected/modified some header entries. (r11141 r11147 11148) + - Adjusted VS project files. (r11147) + - Adjusted the way the sql charserver does item saving. (r11192) + - Corrected usage of reserved keyword 'friend' in mmo.h. (r11192) 2007/09/17 * Several skills with a splash area (except ground based ones) will now hit Ice-walls when casted by mobs. diff --git a/Makefile b/Makefile deleted file mode 100644 index 020ea5133..000000000 --- a/Makefile +++ /dev/null @@ -1,253 +0,0 @@ - -CACHED = $(shell ls | grep Makefile.cache) -ifeq ($(findstring Makefile.cache,$(CACHED)), Makefile.cache) -MKDEF = $(shell cat Makefile.cache) -else - -CC = gcc -pipe -# CC = g++ --pipe - -MAKE = make -# MAKE = gmake - -# Detecting gcc version -GCC_VERSION = $(shell $(CC) -v 2>&1 | grep version | cut -d' ' -f3 | cut -d'.' -f1) - -OPT = -g -OPT += -O2 -# OPT += -O3 -# OPT += -mmmx -# OPT += -msse -# OPT += -msse2 -# OPT += -msse3 -# OPT += -rdynamic -OPT += -ffast-math -# OPT += -fbounds-checking -# OPT += -fstack-protector -# OPT += -fomit-frame-pointer -OPT += -Wall -Wno-sign-compare -ifeq ($(GCC_VERSION), 4) - OPT += -Wno-unused-parameter -Wno-pointer-sign -endif -# Server Packet Protocol version (also defined in src/common/mmo.h) -# OPT += -DPACKETVER=8 -# Makes map-wide script variables be saved to SQL instead of TXT files. -# OPT += -DMAPREGSQL -# Enable the perl regular expression support for scripts -# OPT += -DPCRE_SUPPORT -# OPT += -DGCOLLECT -# OPT += -DMEMWATCH -# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK -# OPT += -DBCHECK - -# LIBS += -lgc -# LIBS += -ldmalloc -# LIBS += -L/usr/local/lib -lpcre - -PLATFORM = $(shell uname) -ARCH = $(shell uname -m) - -ifeq ($(findstring Linux,$(PLATFORM)), Linux) - LIBS += -ldl -endif - -ifeq ($(findstring SunOS,$(PLATFORM)), SunOS) - LIBS += -lsocket -lnsl -ldl - MAKE = gmake -endif - -ifeq ($(findstring FreeBSD,$(PLATFORM)), FreeBSD) - MAKE = gmake - OS_TYPE = -D__FREEBSD__ -endif - -ifeq ($(findstring NetBSD,$(PLATFORM)), NetBSD) - MAKE = gmake - OS_TYPE = -D__NETBSD__ -endif - -ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) - OPT += -DFD_SETSIZE=4096 - OS_TYPE = -DCYGWIN -endif - -ifeq ($(findstring mingw,$(shell gcc --version)), mingw) - IS_MINGW = 1 - OS_TYPE = -DMINGW - OPT += -DFD_SETSIZE=4096 -# CFLAGS += -I../zlib -# LIBS += -L../../lib - LIBS += -lws2_32 -endif - - -ifeq ($(findstring x86_64,$(ARCH)), x86_64) - OPT += -m32 -endif - -CFLAGS = $(OPT) -I../common $(OS_TYPE) - -ifdef SQLFLAG - ifdef IS_MINGW - CFLAGS += -I../mysql - LIBS += -lmysql - else - MYSQLFLAG_CONFIG = $(shell which mysql_config) - ifeq ($(findstring /,$(MYSQLFLAG_CONFIG)), /) - MYSQLFLAG_VERSION = $(shell $(MYSQLFLAG_CONFIG) --version | sed s:\\..*::) - ifeq ($(findstring 5,$(MYSQLFLAG_VERSION)), 5) - MYSQLFLAG_CONFIG_ARGUMENT = --include - else - MYSQLFLAG_CONFIG_ARGUMENT = --cflags - endif - CFLAGS += $(shell $(MYSQLFLAG_CONFIG) $(MYSQLFLAG_CONFIG_ARGUMENT)) - LIBS += $(shell $(MYSQLFLAG_CONFIG) --libs) - else - CFLAGS += -I/usr/local/include/mysql - LIBS += -L/usr/local/lib/mysql -lmysqlclient - endif - endif -endif - -ifneq ($(findstring -lz,$(LIBS)), -lz) - LIBS += -lz -endif -ifneq ($(findstring -lm,$(LIBS)), -lm) - LIBS += -lm -endif - -MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(LIBS)" - -endif - -.PHONY: txt sql common login login_sql char char_sql map map_sql ladmin converters \ - addons plugins tools clean depend - -txt : Makefile.cache conf common login char map ladmin - -ifdef SQLFLAG -sql: Makefile.cache conf common login_sql char_sql map_sql -else -sql: - $(MAKE) SQLFLAG=1 $@ -endif - -conf: - cp -r conf-tmpl conf - cp -r save-tmpl save - rm -rf conf/.svn conf/*/.svn save/.svn - -common: src/common/GNUmakefile - $(MAKE) -C src/$@ $(MKDEF) - -login: src/login/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -char: src/char/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -map: src/map/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -login_sql: src/login_sql/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) sql - -char_sql: src/char_sql/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) sql - -map_sql: src/map/GNUmakefile common - $(MAKE) -C src/map $(MKDEF) sql - -ladmin: src/ladmin/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) - -plugins addons: src/plugins/GNUmakefile common - $(MAKE) -C src/plugins $(MKDEF) - -tools: - $(MAKE) -C src/tool $(MKDEF) - -ifdef SQLFLAG -converters: src/txt-converter/GNUmakefile common - $(MAKE) -C src/txt-converter $(MKDEF) -else -converters: - $(MAKE) SQLFLAG=1 $@ -endif - -clean: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ - src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ - src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile - rm -f Makefile.cache - $(MAKE) -C src/common $@ - $(MAKE) -C src/login $@ - $(MAKE) -C src/login_sql $@ - $(MAKE) -C src/char $@ - $(MAKE) -C src/char_sql $@ - $(MAKE) -C src/map $@ - $(MAKE) -C src/ladmin $@ - $(MAKE) -C src/plugins $@ - $(MAKE) -C src/txt-converter $@ - -depend: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ - src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ - src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile - cd src/common; makedepend -fGNUmakefile -pobj/ -Y. *.c; cd ../..; - cd src/login; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/login_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/char; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/char_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/map; makedepend -DTXT_ONLY -fGNUmakefile -ptxtobj/ -Y. -Y../common *.c; cd ../..; - cd src/map; makedepend -fGNUmakefile -a -psqlobj/ -Y. -Y../common *.c; cd ../..; - cd src/ladmin; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/txt-converter; makedepend -DTXT_SQL_CONVERT -fGNUmakefile -Y. -Y../common *.c; cd ../..; - $(MAKE) -C src/plugins $@ - -Makefile.cache: - printf "$(subst ",\",$(MKDEF))" > Makefile.cache - -src/%/GNUmakefile: src/%/Makefile - sed -e 's/$$>/$$^/' $< > $@ - -src/common/GNUmakefile: src/common/Makefile -src/login/GNUmakefile: src/login/Makefile -src/login_sql/GNUmakefile: src/login_sql/Makefile -src/char/GNUmakefile: src/char/Makefile -src/char_sql/GNUmakefile: src/char_sql/Makefile -src/map/GNUmakefile: src/map/Makefile -src/plugins/GNUmakefile: src/plugins/Makefile -src/ladmin/GNUmakefile: src/ladmin/Makefile -src/txt-converter/GNUmakefile: src/txt-converter/Makefile - -install: conf/%.conf conf/%.txt - $(shell mkdir -p /opt/eathena/bin/) - $(shell mkdir -p /opt/eathena/etc/eathena/) - $(shell mkdir -p /opt/eathena/var/log/eathena/) - $(shell mv save /opt/eathena/etc/eathena/save) - $(shell mv db /opt/eathena/etc/eathena/db) - $(shell mv conf /opt/eathena/etc/eathena/conf) - $(shell mv npc /opt/eathena/etc/eathena/npc) - $(shell mv log/* /opt/eathena/var/log/eathena/) - $(shell cp *-server* /opt/eathena/bin/) - $(shell cp ladmin /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log) - -bin-clean: - $(shell rm /opt/eathena/bin/login-server*) - $(shell rm /opt/eathena/bin/char-server*) - $(shell rm /opt/eathena/bin/map-server*) - $(shell rm /opt/eathena/bin/ladmin) - -uninstall: - bin-clean - $(shell rm /opt/eathena/bin/save) - $(shell rm /opt/eathena/bin/db) - $(shell rm /opt/eathena/bin/conf) - $(shell rm /opt/eathena/bin/npc) - $(shell rm /opt/eathena/bin/log) - $(shell rm -rf /opt/eathena/etc/eathena) - $(shell rm -rf /opt/eathena/var/log/eathena) diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 000000000..a1075c85a --- /dev/null +++ b/Makefile.in @@ -0,0 +1,181 @@ +@SET_MAKE@ + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql ladmin tools converters plugins conf + SQL_DEPENDS=common_sql login_sql char_sql map_sql conf + COMMON_SQL_DEPENDS= + LOGIN_SQL_DEPENDS=common_sql + CHAR_SQL_DEPENDS=common_sql + MAP_SQL_DEPENDS=common_sql + CONVERTERS_DEPENDS=common_sql +else + ALL_DEPENDS=common login char map ladmin tools plugins conf + SQL_DEPENDS=needs_mysql + COMMON_SQL_DEPENDS=needs_mysql + LOGIN_SQL_DEPENDS=needs_mysql + CHAR_SQL_DEPENDS=needs_mysql + MAP_SQL_DEPENDS=needs_mysql + CONVERTERS_DEPENDS=needs_mysql +endif + +##################################################################### +.PHONY: txt sql common common_sql login login_sql char char_sql map map_sql \ + ladmin tools converters plugins addons conf clean help depend + +all: $(ALL_DEPENDS) + +txt: common login char map conf + +sql: $(SQL_DEPENDS) + +common: + @$(MAKE) -C src/common txt + +common_sql: $(COMMON_SQL_DEPENDS) + @$(MAKE) -C src/common sql + +login: common + @$(MAKE) -C src/login + +login_sql: $(LOGIN_SQL_DEPENDS) + @$(MAKE) -C src/login_sql + +char: common + @$(MAKE) -C src/char + +char_sql: $(CHAR_SQL_DEPENDS) + @$(MAKE) -C src/char_sql + +map: common + @$(MAKE) -C src/map txt + +map_sql: $(MAP_SQL_DEPENDS) + @$(MAKE) -C src/map sql + +ladmin: common + @$(MAKE) -C src/ladmin + +tools: + @$(MAKE) -C src/tool + +converters: $(CONVERTERS_DEPENDS) + @$(MAKE) -C src/txt-converter + +plugins addons: common + @$(MAKE) -C src/plugins + +conf: +# conf: +# 1) create conf and conf/import folders +# 2) add missing import files +# 3) copy the rest of the files and folders +# 4) remove remaining .svn folders + @echo "building conf folder..." + @if test ! -d conf ; then mkdir conf ; fi + @if test ! -d conf/import ; then mkdir conf/import ; fi + @for f in $$(ls conf-tmpl/import) ; do if test ! -e conf/import/$$f ; then cp conf-tmpl/import/$$f conf/import ; fi ; done + @for f in $$(ls conf-tmpl) ; do if test "$$f" != "import" ; then cp -rf conf-tmpl/$$f conf ; fi ; done + @rm -rf conf/*/.svn +# save: +# 1) create save folder +# 2) add missing files + @echo "building save folder..." + @if test ! -d save ; then mkdir save ; fi + @for f in $$(ls save-tmpl) ; do if test ! -e save/$$f ; then cp save-tmpl/$$f save ; fi ; done + +clean: + @$(MAKE) -C src/common $@ + @$(MAKE) -C src/login $@ + @$(MAKE) -C src/login_sql $@ + @$(MAKE) -C src/char $@ + @$(MAKE) -C src/char_sql $@ + @$(MAKE) -C src/map $@ + @$(MAKE) -C src/ladmin $@ + @$(MAKE) -C src/plugins $@ + @$(MAKE) -C src/tool $@ + @$(MAKE) -C src/txt-converter $@ + +help: + @echo "most common targets are 'all' 'txt' 'sql' 'clean' 'help'" + @echo "possible targets are:" + @echo "'common' - builds object files used in TXT servers" + @echo "'common_sql' - builds object files used in SQL servers" + @echo "'login' - builds login server (TXT version)" + @echo "'login_sql' - builds login server (SQL version)" + @echo "'char' - builds char server (TXT version)" + @echo "'char_sql' - builds char server (SQL version)" + @echo "'map' - builds map server (TXT version)" + @echo "'map_sql' - builds map server (SQL version)" + @echo "'ladmin' - builds remote administration tool" + @echo "'tools' - builds all the tools in src/tools" + @echo "'converters' - builds the login/char converters" + @echo "'plugins' - builds all the plugins in src/plugins" + @echo "'addons'" + @echo "'conf' - builds conf and save folders from the templates" + @echo "'all' - builds all above targets" + @echo "'txt' - builds txt servers (targets 'common' 'login' 'char' 'map' and" + @echo " 'conf')" + @echo "'sql' - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'" + @echo " 'map_sql' and 'conf')" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +##################################################################### +# TODO + +# Server Packet Protocol version (also defined in src/common/mmo.h) +# CFLAGS += -DPACKETVER=8 + +# Makes map-wide script variables be saved to SQL instead of TXT files. +# CFLAGS += -DMAPREGSQL + +# OPT += -DGCOLLECT +# LIBS += -lgc + +# OPT += -DMEMWATCH + +# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK +# LIBS += -ldmalloc + +# OPT += -DBCHECK + + +install: conf/%.conf conf/%.txt + $(shell mkdir -p /opt/eathena/bin/) + $(shell mkdir -p /opt/eathena/etc/eathena/) + $(shell mkdir -p /opt/eathena/var/log/eathena/) + $(shell mv save /opt/eathena/etc/eathena/save) + $(shell mv db /opt/eathena/etc/eathena/db) + $(shell mv conf /opt/eathena/etc/eathena/conf) + $(shell mv npc /opt/eathena/etc/eathena/npc) + $(shell mv log/* /opt/eathena/var/log/eathena/) + $(shell cp *-server* /opt/eathena/bin/) + $(shell cp ladmin /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log) + +bin-clean: + $(shell rm /opt/eathena/bin/login-server*) + $(shell rm /opt/eathena/bin/char-server*) + $(shell rm /opt/eathena/bin/map-server*) + $(shell rm /opt/eathena/bin/ladmin) + +uninstall: + bin-clean + $(shell rm /opt/eathena/bin/save) + $(shell rm /opt/eathena/bin/db) + $(shell rm /opt/eathena/bin/conf) + $(shell rm /opt/eathena/bin/npc) + $(shell rm /opt/eathena/bin/log) + $(shell rm -rf /opt/eathena/etc/eathena) + $(shell rm -rf /opt/eathena/var/log/eathena) diff --git a/conf-tmpl/msg_athena.conf b/conf-tmpl/msg_athena.conf index 88967c26a..851350300 100644 --- a/conf-tmpl/msg_athena.conf +++ b/conf-tmpl/msg_athena.conf @@ -436,9 +436,9 @@ 511: %d - From : %s (New - Priority) 512: %d - From : %s (New) 513: %d - From : %s -514: You have %d new messages. +514: You have %d unread messages. 515: You have %d unread priority messages. -516: You have no new messages. +516: You have no unread messages. 517: Message not found. 518: Reading message from %s. 519: Cannot delete unread priority mail. diff --git a/configure b/configure deleted file mode 100644 index b50031368..000000000 --- a/configure +++ /dev/null @@ -1,256 +0,0 @@ -#!/bin/bash -## NOTE: -## I know this is not a clean way to check for some stuff -## and edit the Makefile, but hey, it does work! - -# Configure script for eAthena -# Copyright (C) 2005 dontBR -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -# Default variables -status_mmx="No" -status_sse="No" -status_sse2="No" -status_sse3="No" -status_pcre="No" -prefix='/opt/eathena/' - -# Functions -function check_sed { - echo -n "Checking for sed... " - if [ -f $(which sed) ]; then - echo "yes" - else - echo "Error: sed not found in $PATH" - exit 1 - fi -} - -function check_gcc { - echo -n "Checking for gcc... " - if [ -f $(which gcc) ]; then - echo "yes" - else - echo "Error: GCC not found in $PATH" - exit 1 - fi -} - -function check_make { - echo -n "Checking for (g)make... " - if [ -f $(which make) ]; then - maker=make - echo "yes" - else if [ -f $(which gmake) ]; then - maker=gmake - echo "yes" - else - echo "Error: (g)make not found in $PATH" - exit 1 - fi - fi -} - -function check_sockets { - echo -n "Checking for sockets... " - echo "#include -#include -#include -int main(){ -}" > test_sockets.c - if $(gcc test_sockets.c -o test_sockets); then - echo "yes" - rm -f test_sockets.c test_sockets - else - echo "Error: Unix sockets not found/working." - exit 1 - rm -f test_sockets.c - fi -} - -function check_mysql_headers { - echo -n "Checking for MySQL headers... " - if [ -d /usr/local/lib/mysql ]; then # Default - echo "yes" - mysql_headers_path='/usr/local/lib/mysql' - else - if [ -d /usr/include/mysql ]; then # Gentoo/Debian/? - echo "yes" - mysql_headers_path='/usr/include/mysql' - else - echo "Error: MySQL headers not found." - mysql_headers_path='Not found.' - fi - fi -} - -function optimize { - case $@ in - mmx ) status_mmx="Yes" ;; - sse ) status_sse="Yes" ;; - sse2 ) status_sse2="Yes" ;; - sse3 ) status_sse3="Yes" ;; - all ) status_mmx="Yes" - status_sse="Yes" - status_sse2="Yes" - status_sse3="Yes" ;; - esac -} - -function make_changes { - if [ "$maker" != "make" ]; then - sed -e 's,MAKE = make,MAKE = '$maker',g' Makefile -i - fi - if [ "$status_mmx" = "Yes" ]; then - sed -e 's,# OPT += -mmmx,OPT += -mmmx,g' Makefile -i - fi - if [ "$status_sse" = "Yes" ]; then - sed -e 's,# OPT += -msse,OPT += -msse,g' Makefile -i - fi - if [ "$status_sse2" = "Yes" ]; then - sed -e 's,# OPT += -msse2,OPT += -msse2,g' Makefile -i - fi - if [ "$status_sse3" = "Yes" ]; then - sed -e 's,# OPT += -msse3,OPT += -msse3,g' Makefile -i - fi - if [ "$status_pcre" = "Yes" ]; then - sed -e 's,# OPT += -DPCRE_SUPPORT,OPT += -DPCRE_SUPPORT,g' Makefile -i - fi - if [ "$mysql_headers_path" != "/usr/local/lib/mysql" ] && [ "$mysql_headers_path" != "Not found." ]; then - sed -e 's,LIBS += -L/usr/local/lib/mysql -lmysqlclient,LIBS += -L'$mysql_headers_path' -lmysqlclient,g' Makefile -i - fi -} - -function opt_check_pcre { - echo -n "Checking for PCRE... " - if [ -f /usr/local/lib/pcre.h ]; then - echo "yes" - status_pcre="Yes" - else - echo "Error: PCRE not found." - status_pcre="No" - fi -} - -function make_report { - echo "Configuration report:" - echo eAthena - - echo - echo Enable PCRE support..... : $status_pcre - echo - echo Enable MMX optimization. : $status_mmx - echo Enable SSE optimization. : $status_sse - echo Enable SSE2 optimization : $status_sse2 - echo Enable SSE3 optimization : $status_sse3 - echo - echo MySQL headers path...... : $mysql_headers_path - echo - echo eAthena will be installed in $prefix - echo Please type \'make txt\' or \'make sql\' now to compile eAthena. -} - -function helptext { - echo "eAthena Configure Script version 0.1" - echo - echo "Options:" - echo - echo " -h Display this help message and exit." - echo " -d Enter debug mode." - echo " -o Turn on optimization flags." - echo " Supported:" - echo " mmx" - echo " sse" - echo " sse2" - echo " sse3" - echo " all" - echo " -e Enable PCRE support." - echo " -p Root directory where eA is going to be installed." - echo " DON'T FORGET THE LAST SLASH!" - echo " For example:" - echo " ./configure -p /usr/local/" - echo " This will create /usr/local/bin/login-server," - echo " /usr/local/etc/eathena/save/account.txt, etc" - echo " Default is /opt/eathena/" - echo - echo "Report bugs (about the configure script) to dontBR at the eAthena Support Board." -} - -function make_installable { - echo -e '' >> Makefile - echo -e 'install: conf/%.conf conf/%.txt' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'bin/)' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'etc/eathena/)' >> Makefile - echo -e ' $(shell mkdir -p '$prefix'var/log/eathena/)' >> Makefile - echo -e ' $(shell mv save '$prefix'etc/eathena/save)' >> Makefile - echo -e ' $(shell mv db '$prefix'etc/eathena/db)' >> Makefile - echo -e ' $(shell mv conf '$prefix'etc/eathena/conf)' >> Makefile - echo -e ' $(shell mv npc '$prefix'etc/eathena/npc)' >> Makefile - echo -e ' $(shell mv log/* '$prefix'var/log/eathena/)' >> Makefile - echo -e ' $(shell cp *-server* '$prefix'bin/)' >> Makefile - echo -e ' $(shell cp ladmin '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/save/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/db/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/conf/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'etc/eathena/npc/ '$prefix'bin/)' >> Makefile - echo -e ' $(shell ln -s '$prefix'var/log/eathena/ '$prefix'bin/log)' >> Makefile - echo '' >> Makefile - echo -e 'bin-clean:' >> Makefile - echo -e ' $(shell rm '$prefix'bin/login-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/char-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/map-server*)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/ladmin)' >> Makefile - echo '' >> Makefile - echo -e 'uninstall:' >> Makefile - echo -e ' bin-clean' >> Makefile - echo -e ' $(shell rm '$prefix'bin/save)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/db)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/conf)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/npc)' >> Makefile - echo -e ' $(shell rm '$prefix'bin/log)' >> Makefile - echo -e ' $(shell rm -rf '$prefix'etc/eathena)' >> Makefile - echo -e ' $(shell rm -rf '$prefix'var/log/eathena)' >> Makefile -} - - -# Arguments -while getopts ":hdo:ep:" opt; do - case $opt in - h ) helptext ; exit ;; - d ) set -x ;; - o ) optimize ${OPTARG} ;; - e ) opt_check_pcre ;; - p ) prefix=${OPTARG} ; [ -d ${OPTARG} ] || echo "The directory $prefix does not exist. Creating...";; - esac -done - - -# Execution -echo "eAthena configure script" -echo "Note: This is ALPHA software! Do NOT use it on a production server!" -echo -echo "Checking for dependencies.." -check_sed -check_gcc -check_make -check_sockets -check_mysql_headers -make_changes -make_installable -echo -make_report -exit diff --git a/configure.in b/configure.in new file mode 100644 index 000000000..080df746b --- /dev/null +++ b/configure.in @@ -0,0 +1,295 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_INIT(eAthena) +AC_REVISION($Revision$) +AC_PREREQ([2.61]) +AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) +AC_CONFIG_FILES([Makefile src/common/Makefile]) +AC_CONFIG_FILES([src/char/Makefile src/login/Makefile src/ladmin/Makefile]) +AC_CONFIG_FILES([src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile]) +AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) + + +# +# Enable/disable MySql and optionally specify the path (optional library) +# +AC_ARG_WITH( + [mysql], + AC_HELP_STRING( + [--with-mysql=@<:@ARG@:>@], + [use MySQL client library @<:@default=yes@:>@, optionally specify path to the mysql_config executable] + ), + [ + if test "$withval" = "no" ; then + want_mysql="no" + elif test "$withval" = "yes" ; then + want_mysql="yes" + else + want_mysql="yes" + MYSQL_CONFIG_HOME="$withval" + fi + ], + [want_mysql="yes"] +) + + +# +# Enable/disable PCRE and optionally specify the path (optional library) +# +AC_ARG_WITH( + [pcre], + AC_HELP_STRING( + [--with-pcre=@<:@ARG@:>@], + [use PCRE library @<:@default=yes@:>@, optionally specify the root directory path of pcre installation] + ), + [ + if test "$withval" = "no" ; then + want_pcre="no" + elif test "$withval" = "yes" ; then + want_pcre="yes" + else + want_pcre="yes" + PCRE_HOME="$withval" + fi + ], + [want_pcre="yes"] +) + + +# +# Specify the path of the zlib library (required library) +# +AC_ARG_WITH( + [zlib], + AC_HELP_STRING( + [--with-zlib=DIR], + [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)] + ), + [ + test -n "$withval" && ZLIB_HOME="$withval" + ], + [ + ZLIB_HOME=/usr/local + test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr + ] +) + + + +############################################################################### +# Checks for programs and types. + +AC_PROG_MAKE_SET +AC_PROG_CC +AC_PROG_CPP +AC_LANG([C]) + + +CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare" +CPPFLAGS="$CPPFLAGS -I../common" + + +AC_C_BIGENDIAN( + [AC_MSG_ERROR([[bigendian is not supported... stopping]])], + , + [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])] +) + + +AC_MSG_CHECKING([whether pointers can be stored in ints (old code)]) +pointers_fit_in_ints="no" +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])], + [pointers_fit_in_ints="yes"], + [] +) +if test "$pointers_fit_in_ints" = "no" ; then + CFLAGS="$CFLAGS -m32" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])], + [pointers_fit_in_ints="yes (with -m32)"], + [] + ) +fi +AC_MSG_RESULT($pointers_fit_in_ints) +if test "$pointers_fit_in_ints" = "no" ; then + AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping]) +fi + + +AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-unused-parameter" +AC_COMPILE_IFELSE( + [int foo;], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ] +) + + +AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CPPFLAGS -Wno-pointer-sign" +AC_COMPILE_IFELSE( + [int foo;], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ] +) + + +############################################################################### +# Checks for libraries and header files. + + + +dnl +dnl Check MySQL library (optional) +dnl + +MYSQL_VERSION="" +MYSQL_CFLAGS="" +MYSQL_LIBS="" + +if test "$want_mysql" = "no" ; then + AC_MSG_NOTICE([ignoring MySQL (optional)]) +else + if test -z "$MYSQL_CONFIG_HOME" -o test; then + AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no]) + fi + + AC_MSG_CHECKING([MySQL library (optional)]) + if test "$MYSQL_CONFIG_HOME" != "no" ; then + HAVE_MYSQL="yes" + MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`" + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + AC_MSG_RESULT([yes ($MYSQL_VERSION)]) + else + AC_MSG_RESULT([no]) + AC_MSG_NOTICE([disabling MySQL (optional)]) + fi +fi + +AC_SUBST([HAVE_MYSQL]) +AC_SUBST([MYSQL_VERSION]) +AC_SUBST([MYSQL_CFLAGS]) +AC_SUBST([MYSQL_LIBS]) + + + +dnl +dnl Check PCRE libraries (optional) +dnl + +##TODO PCRE version +PCRE_LIBS="" +PCRE_CFLAGS="" + +if test "$want_pcre" = "no" ; then + AC_MSG_NOTICE([ignoring PCRE (optional)]) +else + if test -z "$PCRE_HOME" ; then + AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], []) + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-lpcre" + fi + else + PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" + PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" + AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], []) + CPPFLAGS="$PCRE_OLD_CPPFLAGS" + LDFLAGS="$PCRE_OLD_LDFLAGS" + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-L$PCRE_HOME/lib -lpcre" + test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" + fi + fi + AC_MSG_CHECKING([PCRE library (optional)]) + if test "$HAVE_PCRE" = "yes" ; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_NOTICE([disabling PCRE (optional)]) + fi +fi + +AC_SUBST([HAVE_PCRE]) +AC_SUBST([PCRE_LIBS]) +AC_SUBST([PCRE_CFLAGS]) + + + +dnl +dnl zlib library (required) +dnl + +if test -n "${ZLIB_HOME}" ; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" +fi +AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])]) +AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])]) + + + +dnl +dnl math library (required) +dnl + +AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])]) + + + +dnl +dnl Host specific stuff +dnl + +AC_MSG_CHECKING([host OS]) +host_os="`uname`" +AC_MSG_RESULT([$host_os]) +fd_setsize="" +DLLEXT=".so" +case $host_os in +Solaris* ) + LIBS="$LIBS -lsocket -lnsl -ldl" + ;; +Linux* ) + LIBS="$LIBS -ldl" + ;; +FreeBSD*) + CPPFLAGS="$CPPFLAGS -D__FREEBSD__" + ;; +NetBSD*) + CPPFLAGS="$CPPFLAGS -D__NETBSD__" + ;; +CYGWIN*) + CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN" + fd_setsize="done" + DLLEXT=".dll" + ;; +esac +AC_SUBST([DLLEXT]) + +AC_MSG_CHECKING([for MinGW]) +if test -n "`$CC --version | grep -i mingw`" ; then + AC_MSG_RESULT([yes]) + CPPFLAGS="$CPPFLAGS -DMINGW" + if test -z "$fd_setsize" ; then + CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" + fi + LIBS="$LIBS -lws2_32" +else + AC_MSG_RESULT([no]) +fi + + + +############################################################################### +AC_OUTPUT diff --git a/eAthena-8.sln b/eAthena-8.sln index 4411e95ea..c6f05d3d6 100644 --- a/eAthena-8.sln +++ b/eAthena-8.sln @@ -117,15 +117,23 @@ Global {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-EAE9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/char/Makefile b/src/char/Makefile deleted file mode 100644 index 17b66b810..000000000 --- a/src/char/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -all txt: char-server - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/grfio.h ../common/mapindex.h - -%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -char-server: char.o inter.o int_party.o int_guild.o int_status.o int_storage.o int_pet.o int_homun.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> $(LIB_S) - -clean: - rm -f *.o ../../char-server GNUmakefile - -# DO NOT DELETE - -char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) -int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) -int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) -int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) -int_status.o: int_status.c int_status.h char.h $(COMMON_H) -int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) -int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) diff --git a/src/char/Makefile.in b/src/char/Makefile.in new file mode 100644 index 000000000..78d2cb2c8 --- /dev/null +++ b/src/char/Makefile.in @@ -0,0 +1,46 @@ +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h \ + ../common/strlib.h ../common/grfio.h \ + ../common/mapindex.h ../common/ers.h + +CHAR_OBJ = char.o inter.o int_party.o int_guild.o int_storage.o int_status.o int_pet.o int_homun.o + +##################################################################### +.PHONY : all char-server clean help + +all: char-server + +char-server: $(CHAR_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ + +clean: + rm -f *.o ../../char-server@EXEEXT@ + +help: + @echo "possible targets are 'char-server' 'all' 'clean' 'help'" + @echo "'char-server' - char server (TXT version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +%.o: %.c + @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# DO NOT DELETE + +char.o: char.c char.h inter.h int_pet.h $(COMMON_H) +inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) +int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) +int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) +int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) +int_status.o: int_status.c int_status.h char.h $(COMMON_H) +int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) +int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) diff --git a/src/char/char.c b/src/char/char.c index ba21cd68e..9ef31871d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -11,17 +11,19 @@ #include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/timer.h" +#include "../common/lock.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/showmsg.h" +#include "../common/utils.h" #include "../common/version.h" - #include "inter.h" #include "int_guild.h" #include "int_homun.h" #include "int_pet.h" #include "int_party.h" #include "int_storage.h" -#ifdef ENABLE_SC_SAVING #include "int_status.h" -#endif #include "char.h" #include diff --git a/src/char/char.h b/src/char/char.h index ded9a9b2e..72077ac09 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,6 @@ #define _CHAR_H_ #include "../common/mmo.h" -#include "../common/mapindex.h" #define START_CHAR_NUM 150000 #define MAX_MAP_SERVERS 30 @@ -21,7 +20,7 @@ struct character_data { struct mmo_charstatus* search_character(int aid, int cid); struct mmo_charstatus* search_character_byname(char* character_name); int search_character_index(char* character_name); -char * search_character_name(int index); +char* search_character_name(int index); int search_character_online(int aid, int cid); int mapif_sendall(unsigned char *buf, unsigned int len); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index c4ae0a493..52514692c 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/malloc.h" @@ -17,6 +13,10 @@ #include "int_storage.h" #include "int_guild.h" +#include +#include +#include + char guild_txt[1024] = "save/guild.txt"; char castle_txt[1024] = "save/castle.txt"; diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 6b0e9f7b5..06293eb0f 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -4,6 +4,9 @@ #ifndef _INT_GUILD_H_ #define _INT_GUILD_H_ +struct guild; +struct guild_castle; + int inter_guild_init(void); void inter_guild_final(void); int inter_guild_save(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 684601449..35f8f9c50 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/mmo.h" #include "../common/malloc.h" #include "../common/socket.h" @@ -15,6 +11,10 @@ #include "inter.h" #include "int_homun.h" +#include +#include +#include + char homun_txt[1024]="save/homun.txt"; static struct dbt *homun_db; diff --git a/src/char/int_homun.h b/src/char/int_homun.h index d56ab97a9..1858ed4ba 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -8,7 +8,6 @@ int inter_homun_init(void); void inter_homun_final(void); int inter_homun_save(void); int inter_homun_delete(int homun_id); - int inter_homun_parse_frommap(int fd); extern char homun_txt[1024]; diff --git a/src/char/int_party.c b/src/char/int_party.c index b47a8b59c..96181cd1b 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/malloc.h" @@ -16,6 +12,10 @@ #include "inter.h" #include "int_party.h" +#include +#include +#include + char party_txt[1024] = "save/party.txt"; #ifndef TXT_SQL_CONVERT struct party_data { diff --git a/src/char/int_party.h b/src/char/int_party.h index 453699617..ad724e475 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -4,12 +4,12 @@ #ifndef _INT_PARTY_H_ #define _INT_PARTY_H_ +struct party; + int inter_party_init(void); void inter_party_final(void); int inter_party_save(void); - int inter_party_parse_frommap(int fd); - int inter_party_leave(int party_id,int account_id, int char_id); extern char party_txt[1024]; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index b15e8e259..e7ff2aff2 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/mmo.h" #include "../common/malloc.h" #include "../common/socket.h" @@ -15,6 +11,10 @@ #include "inter.h" #include "int_pet.h" +#include +#include +#include + char pet_txt[1024]="save/pet.txt"; #ifndef TXT_SQL_CONVERT diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 43f354798..9234af109 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -4,6 +4,8 @@ #ifndef _INT_PET_H_ #define _INT_PET_H_ +struct s_pet; + int inter_pet_init(void); void inter_pet_final(void); int inter_pet_save(void); diff --git a/src/char/int_status.c b/src/char/int_status.c index ea255d507..cc25b1485 100644 --- a/src/char/int_status.c +++ b/src/char/int_status.c @@ -1,13 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include - -#include "int_status.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/lock.h" #include "../common/malloc.h" #include "../common/showmsg.h" +#include "int_status.h" + +#include static struct dbt * scdata_db = NULL; //Contains all the status change data in-memory. [Skotlex] char scdata_txt[1024]="save/scdata.txt"; //By [Skotlex] diff --git a/src/char/int_status.h b/src/char/int_status.h index 3ddf08299..3202cd88e 100644 --- a/src/char/int_status.h +++ b/src/char/int_status.h @@ -4,7 +4,7 @@ #ifndef _INT_STATUS_H_ #define _INT_STATUS_H_ -#include "char.h" +struct status_change_data; struct scdata { int account_id, char_id; @@ -14,12 +14,10 @@ struct scdata { extern char scdata_txt[1024]; -#ifdef ENABLE_SC_SAVING -struct scdata *status_search_scdata(int aid, int cid); +struct scdata* status_search_scdata(int aid, int cid); void status_delete_scdata(int aid, int cid); void inter_status_save(void); void status_init(void); void status_final(void); -#endif #endif /* _INT_STATUS_H_ */ diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 3698dc78f..4d933d257 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -1,22 +1,23 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/mmo.h" #include "../common/malloc.h" #include "../common/socket.h" #include "../common/db.h" #include "../common/lock.h" #include "../common/showmsg.h" +#include "../common/utils.h" #include "char.h" #include "inter.h" #include "int_storage.h" #include "int_pet.h" #include "int_guild.h" +#include +#include +#include + // ƒtƒ@ƒCƒ‹–¼‚̃fƒtƒHƒ‹ƒg // inter_config_read()‚ÅÄݒ肳‚ê‚é char storage_txt[1024]="save/storage.txt"; diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 976d77034..dbc487c4c 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -4,13 +4,15 @@ #ifndef _INT_STORAGE_H_ #define _INT_STORAGE_H_ +struct storage; +struct guild_storage; + int inter_storage_init(void); void inter_storage_final(void); int inter_storage_save(void); int inter_guild_storage_save(void); int inter_storage_delete(int account_id); int inter_guild_storage_delete(int guild_id); - int inter_storage_parse_frommap(int fd); extern char storage_txt[1024]; diff --git a/src/char/inter.c b/src/char/inter.c index cadb05f92..721017188 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/db.h" #include "../common/mmo.h" #include "../common/socket.h" @@ -12,7 +8,6 @@ #include "../common/malloc.h" #include "../common/lock.h" #include "../common/showmsg.h" - #include "char.h" #include "inter.h" #include "int_party.h" @@ -22,6 +17,10 @@ #include "int_pet.h" #include "int_homun.h" +#include +#include +#include + #define WISDATA_TTL (60*1000) // Existence time of Wisp/page data (60 seconds) // that is the waiting time of answers of all map-servers #define WISDELLIST_MAX 256 // Number of elements of Wisp/page data deletion list diff --git a/src/char/inter.h b/src/char/inter.h index 5a6a0edde..c9843965e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -4,6 +4,8 @@ #ifndef _INTER_H_ #define _INTER_H_ +struct accreg; + int inter_init_txt(const char *file); void inter_final(void); int inter_save(void); diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile deleted file mode 100644 index 21fd1f339..000000000 --- a/src/char_sql/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -all sql: char-server_sql - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/grfio.h ../common/mapindex.h - -char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o int_homun.o itemdb.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../char-server_sql GNUmakefile - -# DO NOT DELETE - -char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h -int_party.o: int_party.c int_party.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/timer.h ../common/db.h ../common/showmsg.h -int_guild.o: int_guild.c int_guild.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/db.h ../common/showmsg.h -int_storage.o: int_storage.c int_storage.h char.h itemdb.h ../common/showmsg.h -int_pet.o: int_pet.c int_pet.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h -int_homun.o: int_homun.c int_homun.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h -itemdb.o: itemdb.c itemdb.h ../common/db.h ../common/mmo.h ../common/showmsg.h diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in new file mode 100644 index 000000000..b47869208 --- /dev/null +++ b/src/char_sql/Makefile.in @@ -0,0 +1,56 @@ +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj_sql/sql.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h \ + ../common/strlib.h ../common/grfio.h \ + ../common/mapindex.h ../common/ers.h ../common/sql.h + +CHAR_OBJ = char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o int_homun.o + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) $(COMMON_OBJ) +else + CHAR_SERVER_SQL_DEPENDS=needs_mysql +endif + +##################################################################### +.PHONY : all char-server_sql clean help + +all: char-server_sql + +char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) + @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ + +clean: + rm -f *.o ../../char-server_sql@EXEEXT@ + +help: + @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" + @echo "'char-server_sql' - char server (SQL version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +%.o: %.c + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# DO NOT DELETE + +char.o: char.c char.h $(COMMON_H) +inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h $(COMMON_H) +int_party.o: int_party.c int_party.h inter.h $(COMMON_H) +int_guild.o: int_guild.c int_guild.h inter.h $(COMMON_H) +int_storage.o: int_storage.c int_storage.h char.h $(COMMON_H) +int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) +int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 458f784e8..e2baa3b9e 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -2,17 +2,21 @@ // For more information, see LICENCE in the main folder #include "../common/cbasetypes.h" +#include "../common/strlib.h" +#include "../common/core.h" +#include "../common/timer.h" #include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/mapindex.h" #include "../common/showmsg.h" -#include "../common/strlib.h" +#include "../common/socket.h" +#include "../common/version.h" #include "../common/utils.h" - #include "inter.h" #include "int_guild.h" #include "int_homun.h" -#include "itemdb.h" +#include "int_party.h" #include "char.h" #include @@ -25,7 +29,6 @@ #endif #include #include -#include #include #include #include @@ -121,7 +124,7 @@ static int max_account_id = DEFAULT_MAX_ACCOUNT_ID, max_char_id = DEFAULT_MAX_CH static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex] // Advanced subnet check [LuzZza] -struct _subnet { +struct s_subnet { uint32 subnet; uint32 mask; uint32 char_ip; @@ -146,7 +149,6 @@ struct { } auth_fifo[AUTH_FIFO_SIZE]; int auth_fifo_pos = 0; -struct mmo_charstatus char_dat; int char_num, char_max; int max_connect_user = 0; int gm_allow_level = 99; @@ -214,11 +216,8 @@ void set_char_online(int map_id, int char_id, int account_id) struct online_char_data* character; if ( char_id != 99 ) { - sprintf(tmp_sql, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'",char_db,char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); if (max_account_id < account_id || max_char_id < char_id) { //Notify map-server of the new max IDs [Skotlex] @@ -270,20 +269,19 @@ void set_char_offline(int char_id, int account_id) struct online_char_data* character; if ( char_id == 99 ) - sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id); - else { + { + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) ) + Sql_ShowDebug(sql_handle); + } + else + { cp = idb_get(char_db_,char_id); inter_guild_CharOffline(char_id, cp?cp->guild_id:-1); if (cp) idb_remove(char_db_,char_id); - sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id); - - if (mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); } if ((character = idb_get(online_char_db, account_id)) != NULL) @@ -358,21 +356,12 @@ void set_all_offline(int id) void set_all_offline_sql(void) { //Set all players to 'OFFLINE' - sprintf(tmp_sql, "UPDATE `%s` SET `online` = '0'", char_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql, "UPDATE `%s` SET `online` = '0'", guild_member_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql, "UPDATE `%s` SET `connect_member` = '0'", guild_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) ) + Sql_ShowDebug(sql_handle); } //---------------------------------------------------------------------- @@ -398,26 +387,31 @@ void read_gm_account(void) aFree(gm_account); GM_num = 0; - sprintf(tmp_sql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'",login_db_account_id,login_db_level,login_db,login_db_level,lowest_gm_level); - if (mysql_query(&lmysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - lsql_res = mysql_store_result(&lmysql_handle); - if (lsql_res) { - gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * (size_t)mysql_num_rows(lsql_res), 1); - while ((lsql_row = mysql_fetch_row(lsql_res))) { - gm_account[GM_num].account_id = atoi(lsql_row[0]); - gm_account[GM_num].level = atoi(lsql_row[1]); - GM_num++; + if( SQL_ERROR == Sql_Query(lsql_handle, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'", login_db_account_id, login_db_level, login_db, login_db_level, lowest_gm_level) ) + Sql_ShowDebug(sql_handle); + + if( Sql_NumRows(lsql_handle) > 0 ) + { + char* data; + + CREATE(gm_account, struct gm_account, (size_t)Sql_NumRows(lsql_handle)); + while( SQL_SUCCESS == Sql_NextRow(lsql_handle) ) + { + // account_id + Sql_GetData(lsql_handle, 0, &data, NULL); + gm_account[GM_num].account_id = atoi(data); + // account_id + Sql_GetData(lsql_handle, 1, &data, NULL); + gm_account[GM_num].level = atoi(data); + ++GM_num; } } + Sql_FreeResult(lsql_handle); - mysql_free_result(lsql_res); mapif_send_gmaccounts(); } #endif //TXT_SQL_CONVERT -int compare_item(struct item *a, struct item *b) +int compare_item(const struct item* a, const struct item* b) { if(a->id == b->id && @@ -444,15 +438,15 @@ static void* create_charstatus(DBKey key, va_list args) return cp; } #endif //TXT_SQL_CONVERT -int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ - int i=0,j; + +int mmo_char_tosql(int char_id, struct mmo_charstatus* p) +{ + int i = 0; int count = 0; int diff = 0; - char *tmp_ptr; //Building a single query should be more efficient than running - //multiple queries for each thing about to be saved, right? [Skotlex] char save_status[128]; //For displaying save information. [Skotlex] struct mmo_charstatus *cp; - struct itemtmp mapitem[MAX_GUILD_STORAGE]; + StringBuf buf; if (char_id!=p->char_id) return 0; @@ -462,68 +456,35 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ cp = aCalloc(1, sizeof(struct mmo_charstatus)); #endif + StringBuf_Init(&buf); memset(save_status, 0, sizeof(save_status)); - diff = 0; + //map inventory data - for(i=0;iinventory[i], &cp->inventory[i])) - diff = 1; - if(p->inventory[i].nameid>0){ - mapitem[count].flag=0; - mapitem[count].id = p->inventory[i].id; - mapitem[count].nameid=p->inventory[i].nameid; - mapitem[count].amount = p->inventory[i].amount; - mapitem[count].equip = p->inventory[i].equip; - mapitem[count].identify = p->inventory[i].identify; - mapitem[count].refine = p->inventory[i].refine; - mapitem[count].attribute = p->inventory[i].attribute; - for (j=0; jinventory[i].card[j]; - count++; - } + if( memcmp(p->inventory, cp->inventory, sizeof(p->inventory)) ) + { + memitemdata_to_sql(p->inventory, MAX_INVENTORY, p->char_id, TABLE_INVENTORY); + strcat(save_status, " inventory"); } - //printf("- Save item data to MySQL!\n"); - if (diff) - if (!memitemdata_to_sql(mapitem, count, p->char_id,TABLE_INVENTORY)) - strcat(save_status, " inventory"); - - count = 0; - diff = 0; //map cart data - for(i=0;icart[i], &cp->cart[i])) - diff = 1; - if(p->cart[i].nameid>0){ - mapitem[count].flag=0; - mapitem[count].id = p->cart[i].id; - mapitem[count].nameid=p->cart[i].nameid; - mapitem[count].amount = p->cart[i].amount; - mapitem[count].equip = p->cart[i].equip; - mapitem[count].identify = p->cart[i].identify; - mapitem[count].refine = p->cart[i].refine; - mapitem[count].attribute = p->cart[i].attribute; - for (j=0; jcart[i].card[j]; - count++; - } + if( memcmp(p->cart, cp->cart, sizeof(p->cart)) ) + { + memitemdata_to_sql(p->cart, MAX_CART, p->char_id, TABLE_CART); + strcat(save_status, " cart"); } - if (diff) - if (!memitemdata_to_sql(mapitem, count, p->char_id,TABLE_CART)) - strcat(save_status, " cart"); #ifdef TXT_SQL_CONVERT { //Insert the barebones to then update the rest. - char t_name[NAME_LENGTH*2]; - jstrescapecpy(t_name, p->name); - sprintf(tmp_sql, "REPLACE INTO `%s` (`char_id`, `account_id`, `char_num`, `name`) VALUES ('%d', '%d', '%d', '%s')", - char_db, p->char_id, p->account_id, p->char_num, t_name); - if(mysql_query(&mysql_handle, tmp_sql)) + char esc_name[NAME_LENGTH*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`, `char_num`, `name`) VALUES ('%d', '%d', '%s')", + char_db, p->account_id, p->char_num, esc_name) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else - strcat(save_status, " creation"); + Sql_ShowDebug(sql_handle); + } + + strcat(save_status, " creation"); } #endif @@ -544,11 +505,11 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) ) { //Save status - sprintf(tmp_sql ,"UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," "`base_exp`='%u', `job_exp`='%u', `zeny`='%d'," "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d'," - "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d'," //[orn] add homun_id (homunculus id) + "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d'," "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d'" " WHERE `account_id`='%d' AND `char_id` = '%d'", @@ -556,19 +517,15 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ p->base_exp, p->job_exp, p->zeny, p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, - p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, //[orn] add homun_id (homunculus id) + p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, - p->account_id, p->char_id - ); - - if(mysql_query(&mysql_handle, tmp_sql)) + p->account_id, p->char_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else - strcat(save_status, " status"); + Sql_ShowDebug(sql_handle); + } + strcat(save_status, " status"); } //Values that will seldom change (to speed up saving) @@ -581,7 +538,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ (p->fame != cp->fame) ) { - sprintf(tmp_sql ,"UPDATE `%s` SET `class`='%d'," + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d'," "`hair`='%d',`hair_color`='%d',`clothes_color`='%d'," "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d'," "`karma`='%d',`manner`='%d', `fame`='%d'" @@ -590,108 +547,81 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ p->hair, p->hair_color, p->clothes_color, p->partner_id, p->father, p->mother, p->child, p->karma, p->manner, p->fame, - p->account_id, p->char_id - ); - if(mysql_query(&mysql_handle, tmp_sql)) + p->account_id, p->char_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else - strcat(save_status, " status2"); - } - - - diff = 0; + Sql_ShowDebug(sql_handle); + } - for(i=0;imemo_point[i].map == cp->memo_point[i].map && p->memo_point[i].x == cp->memo_point[i].x && p->memo_point[i].y == cp->memo_point[i].y) - continue; - diff = 1; - break; + strcat(save_status, " status2"); } - if (diff) - { //Save memo + //memo points + if( memcmp(p->memo_point, cp->memo_point, sizeof(p->memo_point)) ) + { + char esc_mapname[NAME_LENGTH*2+1]; + //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",memo_db, p->char_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) ) + Sql_ShowDebug(sql_handle); //insert here. - tmp_ptr = tmp_sql; - tmp_ptr += sprintf(tmp_ptr, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db); - count = 0; - for(i=0;imemo_point[i].map){ - tmp_ptr += sprintf(tmp_ptr,"('%d', '%s', '%d', '%d'),", - char_id, mapindex_id2name(p->memo_point[i].map), p->memo_point[i].x, p->memo_point[i].y); - count++; + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db); + for( i = 0, count = 0; i < MAX_MEMOPOINTS; ++i ) + { + if( p->memo_point[i].map ) + { + if( count ) + StringBuf_AppendStr(&buf, ","); + Sql_EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map)); + StringBuf_Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y); + ++count; } } - if (count) - { //Dangerous? Only if none of the above sprintf worked. [Skotlex] - tmp_ptr[-1] = '\0'; //Remove the trailing comma. - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else - strcat(save_status, " memo"); - } else //Memo Points cleared (how is this possible?). - strcat(save_status, " memo"); + if( count ) + { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + } + + strcat(save_status, " memo"); } - diff = 0; - for(i=0;iskill[i].lv != 0) && (p->skill[i].id == 0)) p->skill[i].id = i; // Fix skill tree - if((p->skill[i].id != cp->skill[i].id) || (p->skill[i].lv != cp->skill[i].lv) || - (p->skill[i].flag != cp->skill[i].flag)) - { - diff = 1; - break; - } - } - if (diff) - { //Save skills - + //skills + if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) + { //`skill` (`char_id`, `id`, `lv`) - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",skill_db, p->char_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - tmp_ptr = tmp_sql; - tmp_ptr += sprintf(tmp_ptr,"INSERT INTO `%s`(`char_id`,`id`,`lv`) VALUES ", skill_db); - count = 0; + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`) VALUES ", skill_db); //insert here. - for(i=0;iskill[i].id && p->skill[i].flag!=1) { - tmp_ptr += sprintf(tmp_ptr,"('%d','%d','%d'),", - char_id, p->skill[i].id, (p->skill[i].flag==0)?p->skill[i].lv:p->skill[i].flag-2); - count++; + if( count ) + StringBuf_AppendStr(&buf, ","); + StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->skill[i].id, (p->skill[i].flag == 0 ? p->skill[i].lv : p->skill[i].flag - 2)); + ++count; } } - - if (count) + if( count ) { - tmp_ptr[-1] = '\0'; //Remove trailing comma. - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else - strcat(save_status, " skills"); - } else //Skills removed (reset?) - strcat(save_status, " skills"); + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + } + + strcat(save_status, " skills"); } + diff = 0; for(i = 0; i < MAX_FRIENDS; i++){ if(p->friends[i].char_id != cp->friends[i].char_id || @@ -702,58 +632,54 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } if(diff == 1) - { //Save friends - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - tmp_ptr = tmp_sql; - tmp_ptr += sprintf(tmp_ptr, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db); - count = 0; - for(i = 0; i < MAX_FRIENDS; i++){ - if(p->friends[i].char_id > 0) + { //Save friends + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db); + for( i = 0, count = 0; i < MAX_FRIENDS; ++i ) + { + if( p->friends[i].char_id > 0 ) { - tmp_ptr += sprintf(tmp_ptr, "('%d','%d','%d'),", char_id, p->friends[i].account_id, p->friends[i].char_id); + if( count ) + StringBuf_AppendStr(&buf, ","); + StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->friends[i].account_id, p->friends[i].char_id); count++; } } - if (count) + if( count ) { - tmp_ptr[-1] = '\0'; //Remove the last comma. [Skotlex] - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + else strcat(save_status, " friends"); - } else //Friend list cleared. + } + else //Friend list cleared. strcat(save_status, " friends"); - } #ifdef HOTKEY_SAVING // hotkeys - tmp_ptr = tmp_sql; - tmp_ptr += sprintf(tmp_ptr, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db); + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db); diff = 0; for(i = 0; i < ARRAYLENGTH(p->hotkeys); i++){ if(memcmp(&p->hotkeys[i], &cp->hotkeys[i], sizeof(struct hotkey))) { - tmp_ptr += sprintf(tmp_ptr, "('%d','%d','%d','%d','%d'),", char_id, i, p->hotkeys[i].type, p->hotkeys[i].id , p->hotkeys[i].lv); + if( diff ) + StringBuf_AppendStr(&buf, ",");// not the first hotkey + StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv); diff = 1; } } if(diff) { - tmp_ptr[-1] = 0; - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + else strcat(save_status, " hotkeys"); - } } #endif + StringBuf_Destroy(&buf); if (save_status[0]!='\0' && save_log) ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status); #ifndef TXT_SQL_CONVERT @@ -764,129 +690,138 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ return 0; } -// [Ilpalazzo-sama] -int memitemdata_to_sql(struct itemtmp mapitem[], int count, int char_id, int tableswitch) +/// Saves an array of 'item' entries into the specified table. +int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch) { - int i,j, flag, id; - char* tablename; - char selectoption[16]; - char* str_p = tmp_sql; + StringBuf buf; + SqlStmt* stmt; + int i; + int j; + const char* tablename; + const char* selectoption; + struct item item; // temp storage variable + bool* flag; // bit array for inventory matching + bool found; switch (tableswitch) { - case TABLE_INVENTORY: tablename = inventory_db; sprintf(selectoption,"char_id"); break; - case TABLE_CART: tablename = cart_db; sprintf(selectoption,"char_id"); break; - case TABLE_STORAGE: tablename = storage_db; sprintf(selectoption,"account_id"); break; - case TABLE_GUILD_STORAGE: tablename = guild_storage_db; sprintf(selectoption,"guild_id"); break; + case TABLE_INVENTORY: tablename = inventory_db; selectoption = "char_id"; break; + case TABLE_CART: tablename = cart_db; selectoption = "char_id"; break; + case TABLE_STORAGE: tablename = storage_db; selectoption = "account_id"; break; + case TABLE_GUILD_STORAGE: tablename = guild_storage_db; selectoption = "guild_id"; break; default: ShowError("Invalid table name!\n"); return 1; } - //=======================================mysql database data > memory=============================================== - - str_p += sprintf(str_p, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`"); - for (j=0; j SQL =============================== -#ifndef TXT_SQL_CONVERT - if(!itemdb_isequip(mapitem[i].nameid)) - { //Quick update of stackable items. Update Qty and Equip should be enough, but in case we are also updating identify - sprintf(tmp_sql,"UPDATE `%s` SET `equip`='%d', `identify`='%d', `amount`='%d' WHERE `id`='%d' LIMIT 1", - tablename, mapitem[i].equip, mapitem[i].identify,mapitem[i].amount, id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } else -#endif //TXT_SQL_CONVERT - { //Equipment or Misc item, just update all fields. - str_p = tmp_sql; - str_p += sprintf(str_p,"UPDATE `%s` SET `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d'", - tablename, mapitem[i].equip, mapitem[i].identify, mapitem[i].refine, mapitem[i].attribute); - - for(j=0; jchar_id = char_id; - p->account_id = atoi(sql_row[1]); - p->char_num = atoi(sql_row[2]); - strncpy(p->name, sql_row[3], NAME_LENGTH-1); - p->class_ = atoi(sql_row[4]); - p->base_level = atoi(sql_row[5]); - p->job_level = atoi(sql_row[6]); - p->base_exp = (unsigned int)cap_value(atof(sql_row[7]), 0, UINT_MAX); - p->job_exp = (unsigned int)cap_value(atof(sql_row[8]), 0, UINT_MAX); - p->zeny = atoi(sql_row[9]); - p->str = atoi(sql_row[10]); - p->agi = atoi(sql_row[11]); - p->vit = atoi(sql_row[12]); - p->int_ = atoi(sql_row[13]); - p->dex = atoi(sql_row[14]); - p->luk = atoi(sql_row[15]); - p->max_hp = atoi(sql_row[16]); - p->hp = atoi(sql_row[17]); - p->max_sp = atoi(sql_row[18]); - p->sp = atoi(sql_row[19]); - p->status_point = (unsigned short)cap_value(atoi(sql_row[20]), 0, USHRT_MAX); - p->skill_point = (unsigned short)cap_value(atoi(sql_row[21]), 0, USHRT_MAX); - p->option = atoi(sql_row[22]); - p->karma = atoi(sql_row[23]); - p->manner = atoi(sql_row[24]); - p->party_id = atoi(sql_row[25]); - p->guild_id = atoi(sql_row[26]); - p->pet_id = atoi(sql_row[27]); - p->hom_id = atoi(sql_row[28]); - p->hair = atoi(sql_row[29]); - p->hair_color = atoi(sql_row[30]); - p->clothes_color = atoi(sql_row[31]); - p->weapon = atoi(sql_row[32]); - p->shield = atoi(sql_row[33]); - p->head_top = atoi(sql_row[34]); - p->head_mid = atoi(sql_row[35]); - p->head_bottom = atoi(sql_row[36]); - p->last_point.map = mapindex_name2id(sql_row[37]); p->last_point.x = atoi(sql_row[38]); p->last_point.y = atoi(sql_row[39]); - p->save_point.map = mapindex_name2id(sql_row[40]); p->save_point.x = atoi(sql_row[41]); p->save_point.y = atoi(sql_row[42]); - p->partner_id = atoi(sql_row[43]); - p->father = atoi(sql_row[44]); - p->mother = atoi(sql_row[45]); - p->child = atoi(sql_row[46]); - p->fame = atoi(sql_row[47]); - + //TODO: prepared statement goes here >_> [ultramage] + Sql_GetData(sql_handle, 1, &data, NULL); p->account_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->char_num = atoi(data); + Sql_GetData(sql_handle, 3, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 4, &data, NULL); p->class_ = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); p->base_level = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); p->job_level = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); p->base_exp = (unsigned int)cap_value(strtoul(data,NULL,10), 0, UINT_MAX); + Sql_GetData(sql_handle, 8, &data, NULL); p->job_exp = (unsigned int)cap_value(strtoul(data,NULL,10), 0, UINT_MAX); + Sql_GetData(sql_handle, 9, &data, NULL); p->zeny = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); p->str = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); p->agi = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); p->vit = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); p->int_ = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); p->dex = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); p->luk = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); p->max_hp = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); p->hp = atoi(data); + Sql_GetData(sql_handle, 18, &data, NULL); p->max_sp = atoi(data); + Sql_GetData(sql_handle, 19, &data, NULL); p->sp = atoi(data); + Sql_GetData(sql_handle, 20, &data, NULL); p->status_point = (unsigned short)cap_value(atoi(data), 0, USHRT_MAX); + Sql_GetData(sql_handle, 21, &data, NULL); p->skill_point = (unsigned short)cap_value(atoi(data), 0, USHRT_MAX); + Sql_GetData(sql_handle, 22, &data, NULL); p->option = atoi(data); + Sql_GetData(sql_handle, 23, &data, NULL); p->karma = atoi(data); + Sql_GetData(sql_handle, 24, &data, NULL); p->manner = atoi(data); + Sql_GetData(sql_handle, 25, &data, NULL); p->party_id = atoi(data); + Sql_GetData(sql_handle, 26, &data, NULL); p->guild_id = atoi(data); + Sql_GetData(sql_handle, 27, &data, NULL); p->pet_id = atoi(data); + Sql_GetData(sql_handle, 28, &data, NULL); p->hom_id = atoi(data); + Sql_GetData(sql_handle, 29, &data, NULL); p->hair = atoi(data); + Sql_GetData(sql_handle, 30, &data, NULL); p->hair_color = atoi(data); + Sql_GetData(sql_handle, 31, &data, NULL); p->clothes_color = atoi(data); + Sql_GetData(sql_handle, 32, &data, NULL); p->weapon = atoi(data); + Sql_GetData(sql_handle, 33, &data, NULL); p->shield = atoi(data); + Sql_GetData(sql_handle, 34, &data, NULL); p->head_top = atoi(data); + Sql_GetData(sql_handle, 35, &data, NULL); p->head_mid = atoi(data); + Sql_GetData(sql_handle, 36, &data, NULL); p->head_bottom = atoi(data); + Sql_GetData(sql_handle, 37, &data, NULL); p->last_point.map = mapindex_name2id(data); + Sql_GetData(sql_handle, 38, &data, NULL); p->last_point.x = atoi(data); + Sql_GetData(sql_handle, 39, &data, NULL); p->last_point.y = atoi(data); + Sql_GetData(sql_handle, 40, &data, NULL); p->save_point.map = mapindex_name2id(data); + Sql_GetData(sql_handle, 41, &data, NULL); p->save_point.x = atoi(data); + Sql_GetData(sql_handle, 42, &data, NULL); p->save_point.y = atoi(data); + Sql_GetData(sql_handle, 43, &data, NULL); p->partner_id = atoi(data); + Sql_GetData(sql_handle, 44, &data, NULL); p->father = atoi(data); + Sql_GetData(sql_handle, 45, &data, NULL); p->mother = atoi(data); + Sql_GetData(sql_handle, 46, &data, NULL); p->child = atoi(data); + Sql_GetData(sql_handle, 47, &data, NULL); p->fame = atoi(data); + //free mysql result. - mysql_free_result(sql_res); + Sql_FreeResult(sql_handle); strcat (t_msg, " status"); if (!load_everything) // For quick selection of data when displaying the char menu @@ -986,149 +919,120 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything //read memo data //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) - sprintf(tmp_sql, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`='%d' ORDER by `memo_id`",memo_db, char_id); // TBR - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`='%d' ORDER by `memo_id`", memo_db, char_id) ) + Sql_ShowDebug(sql_handle); - if (sql_res) { - for(i=0;(sql_row = mysql_fetch_row(sql_res));i++){ - p->memo_point[i].map = mapindex_name2id(sql_row[0]); - p->memo_point[i].x=atoi(sql_row[1]); - p->memo_point[i].y=atoi(sql_row[2]); - } - mysql_free_result(sql_res); - strcat (t_msg, " memo"); + for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + Sql_GetData(sql_handle, 0, &data, NULL); p->memo_point[i].map = mapindex_name2id(data); + Sql_GetData(sql_handle, 1, &data, NULL); p->memo_point[i].x = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->memo_point[i].y = atoi(data); } + strcat(t_msg, " memo"); //read inventory //`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) - str_p += sprintf(str_p, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`"); - - for (j=0; jinventory[i].id = atoi(sql_row[0]); - p->inventory[i].nameid = atoi(sql_row[1]); - p->inventory[i].amount = atoi(sql_row[2]); - p->inventory[i].equip = atoi(sql_row[3]); - p->inventory[i].identify = atoi(sql_row[4]); - p->inventory[i].refine = atoi(sql_row[5]); - p->inventory[i].attribute = atoi(sql_row[6]); - for (j=0; jinventory[i].card[j] = atoi(sql_row[7+j]); + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id); + + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_INVENTORY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + Sql_GetData(sql_handle, 0, &data, NULL); p->inventory[i].id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); p->inventory[i].nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->inventory[i].amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); p->inventory[i].equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); p->inventory[i].identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); p->inventory[i].refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); p->inventory[i].attribute = atoi(data); + for( j = 0; j < MAX_SLOTS; ++j ) + { + Sql_GetData(sql_handle, 7 + j, &data, NULL); p->inventory[i].card[j] = atoi(data); } - mysql_free_result(sql_res); - strcat (t_msg, " inventory"); } + strcat(t_msg, " inventory"); //read cart //`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) - str_p = tmp_sql; - str_p += sprintf(str_p, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`"); - for (j = 0; j < MAX_SLOTS; j++) str_p += sprintf(str_p, ", `card%d`", j); - str_p += sprintf(str_p, " FROM `%s` WHERE `char_id`='%d'", cart_db, char_id); - - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - for(i=0;(sql_row = mysql_fetch_row(sql_res));i++){ - p->cart[i].id = atoi(sql_row[0]); - p->cart[i].nameid = atoi(sql_row[1]); - p->cart[i].amount = atoi(sql_row[2]); - p->cart[i].equip = atoi(sql_row[3]); - p->cart[i].identify = atoi(sql_row[4]); - p->cart[i].refine = atoi(sql_row[5]); - p->cart[i].attribute = atoi(sql_row[6]); - for(j=0; jcart[i].card[j] = atoi(sql_row[7+j]); + StringBuf_Clear(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", cart_db, char_id); + + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_CART && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + Sql_GetData(sql_handle, 0, &data, NULL); p->cart[i].id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); p->cart[i].nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->cart[i].amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); p->cart[i].equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); p->cart[i].identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); p->cart[i].refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); p->cart[i].attribute = atoi(data); + for( j = 0; j < MAX_SLOTS; ++j ) + { + Sql_GetData(sql_handle, 7 + j, &data, NULL); p->cart[i].card[j] = atoi(data); } - mysql_free_result(sql_res); - strcat (t_msg, " cart"); } + strcat(t_msg, " cart"); //read skill //`skill` (`char_id`, `id`, `lv`) - sprintf(tmp_sql, "SELECT `id`, `lv` FROM `%s` WHERE `char_id`='%d'",skill_db, char_id); // TBR - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - for(i=0;(sql_row = mysql_fetch_row(sql_res));i++){ - n = atoi(sql_row[0]); - p->skill[n].id = n; //memory!? shit!. - p->skill[n].lv = atoi(sql_row[1]); - } - mysql_free_result(sql_res); - strcat (t_msg, " skills"); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`, `lv` FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_SKILL && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + int n; + Sql_GetData(sql_handle, 0, &data, NULL); + n = atoi(data); + p->skill[n].id = n; //FIXME: why not use a boolean? + Sql_GetData(sql_handle, 1, &data, NULL); + p->skill[n].lv = atoi(data); } + strcat(t_msg, " skills"); //Friend list //Shamelessly stolen from its_sparky (ie: thanks) and then assimilated by [Skotlex] - sprintf(tmp_sql, "SELECT f.friend_account, f.friend_id, c.name FROM `%s` f LEFT JOIN `%s` c ON f.friend_account=c.account_id AND f.friend_id=c.char_id WHERE f.char_id='%d'", friend_db, char_db, char_id); - - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - sql_res = mysql_store_result(&mysql_handle); - if(sql_res) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT c.name, f.friend_account, f.friend_id FROM `%s` f LEFT JOIN `%s` c ON f.friend_account=c.account_id AND f.friend_id=c.char_id WHERE f.char_id='%d'", friend_db, char_db, char_id) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) { - for(i = 0; (sql_row = mysql_fetch_row(sql_res)) && ifriends[i].account_id = atoi(sql_row[0]); - p->friends[i].char_id = atoi(sql_row[1]); - strncpy(p->friends[i].name, sql_row[2], NAME_LENGTH-1); //The -1 is to avoid losing the ending \0 [Skotlex] - } - } - } - mysql_free_result(sql_res); - strcat (t_msg, " friends"); + // name + Sql_GetData(sql_handle, 0, &data, &len); + if( *data == '\0' ) + continue; + memcpy(p->friends[i].name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 1, &data, NULL); p->friends[i].account_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->friends[i].char_id = atoi(data); } + strcat(t_msg, " friends"); #ifdef HOTKEY_SAVING //Hotkeys - sprintf(tmp_sql, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n", mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__, __LINE__, tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - - if (sql_res) { - while ((sql_row = mysql_fetch_row(sql_res))) { - n = atoi(sql_row[0]); - if( n < 0 || n >= HOTKEY_SAVING) - continue; - p->hotkeys[n].type = atoi(sql_row[1]); - p->hotkeys[n].id = atoi(sql_row[2]); - p->hotkeys[n].lv = atoi(sql_row[3]); - } - mysql_free_result(sql_res); - strcat (t_msg, " hotkeys"); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) ) + Sql_ShowDebug(sql_handle); + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int n; + Sql_GetData(sql_handle, 0, &data, NULL); n = atoi(data); + if( n < 0 || n >= HOTKEY_SAVING ) + continue; + Sql_GetData(sql_handle, 1, &data, NULL); p->hotkeys[n].type = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); p->hotkeys[n].id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); p->hotkeys[n].lv = atoi(data); } + strcat(t_msg, " hotkeys"); #endif if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly! + Sql_FreeResult(sql_handle); + StringBuf_Destroy(&buf); cp = idb_ensure(char_db_, char_id, create_charstatus); memcpy(cp, p, sizeof(struct mmo_charstatus)); @@ -1140,8 +1044,7 @@ int mmo_char_sql_init(void) { ShowInfo("Begin Initializing.......\n"); char_db_= db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA, sizeof(int)); - // memory initialize - memset(&char_dat, 0, sizeof(struct mmo_charstatus)); + if(char_per_account == 0){ ShowStatus("Chars per Account: 'Unlimited'.......\n"); }else{ @@ -1168,18 +1071,13 @@ int make_new_char_sql(int fd, unsigned char *dat) { struct char_session_data *sd; char name[NAME_LENGTH]; - char t_name[NAME_LENGTH*2]; + char esc_name[NAME_LENGTH*2+1]; unsigned int i; // Used in for loop and comparing with strlen, safe to be unsigned. [Lance] - int char_id, temp; + int char_id; - strncpy(name, dat, NAME_LENGTH); - name[NAME_LENGTH-1] = '\0'; //Always terminate string. + safestrncpy(name, dat, NAME_LENGTH); normalize_name(name,TRIM_CHARS); //Normalize character name. [Skotlex] - jstrescapecpy(t_name, name); - - // disabled until fixed >.> - // Note: escape characters should be added to jstrescape()! - //mysql_real_escape_string(&mysql_handle, t_name, t_name_temp, sizeof(t_name_temp)); + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); if (!session_isValid(fd) || !(sd = (struct char_session_data*)session[fd]->session_data)) return -2; @@ -1194,22 +1092,14 @@ int make_new_char_sql(int fd, unsigned char *dat) //check for charcount (maxchars) :) if(char_per_account != 0){ - sprintf(tmp_sql, "SELECT `account_id` FROM `%s` WHERE `account_id` = '%d'", char_db, sd->account_id); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if(sql_res){ - //ok - temp = (int)mysql_num_rows(sql_res); - if(temp >= char_per_account){ - //hehe .. limit exceeded :P - ShowInfo("Create char failed (%d): charlimit exceeded.\n", sd->account_id); - mysql_free_result(sql_res); - return -2; - } - mysql_free_result(sql_res); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` = '%d'", char_db, sd->account_id) ) + Sql_ShowDebug(sql_handle); + if( Sql_NumRows(sql_handle) >= char_per_account ) + { + //hehe .. limit exceeded :P + ShowInfo("Create char failed (%d): charlimit exceeded.\n", sd->account_id); + Sql_FreeResult(sql_handle); + return -2; } } @@ -1231,14 +1121,10 @@ int make_new_char_sql(int fd, unsigned char *dat) (dat[31] >= 9)) { // hair color (dat[31] can not be negativ) if (log_char) { // char.log to charlog - sprintf(tmp_sql,"INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - charlog_db,"make new char error", sd->account_id, dat[30], t_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]); - //query - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + charlog_db,"make new char error", sd->account_id, dat[30], esc_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]) ) + Sql_ShowDebug(sql_handle); } ShowWarning("Create char failed (%d): stats error (bot cheat?!)\n", sd->account_id); return -2; @@ -1249,31 +1135,23 @@ int make_new_char_sql(int fd, unsigned char *dat) if (dat[i] < 1 || dat[i] > 9) { if (log_char) { // char.log to charlog - sprintf(tmp_sql,"INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - charlog_db,"make new char error", sd->account_id, dat[30], t_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]); - //query - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + charlog_db, "make new char error", sd->account_id, dat[30], esc_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]) ) + Sql_ShowDebug(sql_handle); } ShowWarning("Create char failed (%d): stats error (bot cheat?!)\n", sd->account_id); - return -2; + return -2; } } // now we know that every stat has proper value but we have to check if str/int agi/luk vit/dex pairs are correct if( ((dat[24]+dat[27]) > 10) || ((dat[25]+dat[29]) > 10) || ((dat[26]+dat[28]) > 10) ) { if (log_char) { // char.log to charlog - sprintf(tmp_sql,"INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" - "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - charlog_db,"make new char error", sd->account_id, dat[30], t_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]); - //query - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + charlog_db, "make new char error", sd->account_id, dat[30], esc_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]) ) + Sql_ShowDebug(sql_handle); } ShowWarning("Create char failed (%d): stats error (bot cheat?!)\n", sd->account_id); return -2; @@ -1281,93 +1159,58 @@ int make_new_char_sql(int fd, unsigned char *dat) if (log_char) { // char.log to charlog - sprintf(tmp_sql,"INSERT INTO `%s`(`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - charlog_db,"make new char", sd->account_id, dat[30], t_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]); - //query - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + charlog_db, "make new char", sd->account_id, dat[30], esc_name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]) ) + Sql_ShowDebug(sql_handle); } //printf("make new char %d-%d %s %d, %d, %d, %d, %d, %d - %d, %d\n", // fd, dat[30], dat, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[33], dat[31]); //Check Name (already in use?) - sprintf(tmp_sql, "SELECT 1 FROM `%s` WHERE `name` = '%s'",char_db, t_name); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) + { + Sql_ShowDebug(sql_handle); return -2; } - sql_res = mysql_store_result(&mysql_handle); - if(sql_res){ - temp = (int)mysql_num_rows(sql_res); - mysql_free_result(sql_res); - if (temp > 0) { - ShowInfo("Create char failed: charname already in use\n"); - return -1; - } + if( Sql_NumRows(sql_handle) > 0 ) + { + ShowInfo("Create char failed: charname already in use\n"); + return -1; } // check char slot. - sprintf(tmp_sql, "SELECT `account_id`, `char_num` FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d'",char_db, sd->account_id, dat[30]); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - - if(sql_res){ - temp = (int)mysql_num_rows(sql_res); - mysql_free_result(sql_res); - if (temp > 0) { - ShowWarning("Create char failed (%d, slot: %d), slot already in use\n", sd->account_id, dat[30]); - return -2; - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_num` FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d'", char_db, sd->account_id, dat[30]) ) + Sql_ShowDebug(sql_handle); + if( Sql_NumRows(sql_handle) > 0 ) + { + ShowWarning("Create char failed (%d, slot: %d), slot already in use\n", sd->account_id, dat[30]); + return -2; } //New Querys [Sirius] //Insert the char to the 'chardb' ^^ - sprintf(tmp_sql, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`," - "`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES (" - "'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')", - char_db, sd->account_id , dat[30] , t_name, start_zeny, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], - (40 * (100 + dat[26])/100) , (40 * (100 + dat[26])/100 ), (11 * (100 + dat[27])/100), (11 * (100 + dat[27])/100), dat[33], dat[31], - mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`," + "`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES (" + "'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')", + char_db, sd->account_id , dat[30] , esc_name, start_zeny, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], + (40 * (100 + dat[26])/100) , (40 * (100 + dat[26])/100 ), (11 * (100 + dat[27])/100), (11 * (100 + dat[27])/100), dat[33], dat[31], + mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) ) + { + Sql_ShowDebug(sql_handle); return -2; //No, stop the procedure! } //Now we need the charid from sql! - if(mysql_field_count(&mysql_handle) == 0 && - mysql_insert_id(&mysql_handle) > 0) - char_id = (int)mysql_insert_id(&mysql_handle); - else { - //delete the char ..(no trash in DB!) but how is this possible? - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d' AND `name` = '%s'", char_db, sd->account_id, dat[30], t_name); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - return -2; //XD end of the (World? :P) .. charcreate (denied) - } + char_id = (int)Sql_LastInsertId(sql_handle); //Give the char the default items //`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) if (start_weapon > 0) { //add Start Weapon (Knife?) - sprintf(tmp_sql,"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `equip`, `identify`) VALUES ('%d', '%d', '%d', '%d', '%d')", inventory_db, char_id, start_weapon,1,0x02,1); - if (mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `equip`, `identify`) VALUES ('%d', '%d', '%d', '%d', '%d')", inventory_db, char_id, start_weapon, 1, 0x02, 1) ) + Sql_ShowDebug(sql_handle); } if (start_armor > 0) { //Add default armor (cotton shirt?) - sprintf(tmp_sql,"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `equip`, `identify`) VALUES ('%d', '%d', '%d', '%d', '%d')", inventory_db, char_id, start_armor,1,0x10,1); - if (mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `equip`, `identify`) VALUES ('%d', '%d', '%d', '%d', '%d')", inventory_db, char_id, start_armor, 1, 0x10, 1) ) + Sql_ShowDebug(sql_handle); } ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, dat[30], name); @@ -1382,58 +1225,50 @@ int make_new_char_sql(int fd, unsigned char *dat) */ int delete_char_sql(int char_id, int partner_id) { - char char_name[NAME_LENGTH], t_name[NAME_LENGTH*2]; //Name needs be escaped. - int account_id, party_id, guild_id, hom_id, char_base_level; - - sprintf(tmp_sql, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id` FROM `%s` WHERE `char_id`='%d'",char_db, char_id); + char name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped. + int account_id; + int party_id; + int guild_id; + int hom_id; + int base_level; + char* data; + size_t len; - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - sql_res = mysql_store_result(&mysql_handle); - - if(sql_res) - sql_row = mysql_fetch_row(sql_res); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); - if (sql_res == NULL || sql_row == NULL) + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) { ShowError("delete_char_sql: Unable to fetch character data, deletion aborted.\n"); - if (sql_res) - mysql_free_result(sql_res); + Sql_FreeResult(sql_handle); return -1; } - strncpy(char_name, sql_row[0], NAME_LENGTH); - char_name[NAME_LENGTH-1] = '\0'; - jstrescapecpy(t_name, char_name); //Escape string for sql use... [Skotlex] - account_id = atoi(sql_row[1]); - party_id = atoi(sql_row[2]); - guild_id = atoi(sql_row[3]); - char_base_level = atoi(sql_row[4]); - hom_id = atoi(sql_row[5]); - mysql_free_result(sql_res); //Let's free this as soon as possible to avoid problems later on. + + Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 1, &data, NULL); account_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); party_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data); + + Sql_EscapeStringLen(sql_handle, esc_name, data, min(len, NAME_LENGTH)); + Sql_FreeResult(sql_handle); //check for config char del condition [Lupus] - if( ( char_del_level > 0 && char_base_level >= char_del_level ) - || ( char_del_level < 0 && char_base_level <= -char_del_level ) + if( ( char_del_level > 0 && base_level >= char_del_level ) + || ( char_del_level < 0 && base_level <= -char_del_level ) ) { - ShowInfo("Char deletion aborted: %s, BaseLevel: %i\n",char_name,char_base_level); + ShowInfo("Char deletion aborted: %s, BaseLevel: %i\n", name, base_level); return -1; } /* Divorce [Wizputer] */ if (partner_id) { - sprintf(tmp_sql,"UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d'",char_db,partner_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql,"DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND `char_id`='%d'",inventory_db,WEDDING_RING_M,WEDDING_RING_F,partner_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d'", char_db, partner_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND `char_id`='%d'", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id) ) + Sql_ShowDebug(sql_handle); } //Make the character leave the party [Skotlex] @@ -1442,36 +1277,41 @@ int delete_char_sql(int char_id, int partner_id) /* delete char's pet */ //Delete the hatched pet if you have one... - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d' AND `incuvate` = '0'",pet_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incuvate` = '0'", pet_db, char_id) ) + Sql_ShowDebug(sql_handle); // Komurka's suggested way to clear pets, modified by [Skotlex] (because I always personalize what I do :X) //Removing pets that are in the char's inventory.... { //NOTE: The syntax for multi-table deletes is a bit changed between 4.0 and 4.1 regarding aliases, so we have to consider the version... [Skotlex] //Since we only care about the major and minor version, a double conversion is good enough. (4.1.20 -> 4.10000) - double mysql_version = atof(mysql_get_server_info(&mysql_handle)); - - sprintf(tmp_sql, - "delete FROM `%s` USING `%s` as c LEFT JOIN `%s` as i ON c.char_id = i.char_id, `%s` as p WHERE c.char_id = '%d' AND i.card0 = -256 AND p.pet_id = (i.card1|(i.card2<<2))", - (mysql_version<4.1?pet_db:"p"), char_db, inventory_db, pet_db, char_id); - - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - //Removing pets that are in the char's cart.... - sprintf(tmp_sql, - "delete FROM `%s` USING `%s` as c LEFT JOIN `%s` as i ON c.char_id = i.char_id, `%s` as p WHERE c.char_id = '%d' AND i.card0 = -256 AND p.pet_id = (i.card1|(i.card2<<2))", - (mysql_version<4.1?pet_db:"p"), char_db, cart_db, pet_db, char_id); - - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + //double mysql_version = atof(mysql_get_server_info(&mysql_handle)); + // + //sprintf(tmp_sql, + //"delete FROM `%s` USING `%s` as c LEFT JOIN `%s` as i ON c.char_id = i.char_id, `%s` as p WHERE c.char_id = '%d' AND i.card0 = -256 AND p.pet_id = (i.card1|(i.card2<<2))", + // (mysql_version<4.1?pet_db:"p"), char_db, inventory_db, pet_db, char_id); + // + //if(mysql_query(&mysql_handle, tmp_sql)) { + // ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); + // ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + //} + + ////Removing pets that are in the char's cart.... + //sprintf(tmp_sql, + //"delete FROM `%s` USING `%s` as c LEFT JOIN `%s` as i ON c.char_id = i.char_id, `%s` as p WHERE c.char_id = '%d' AND i.card0 = -256 AND p.pet_id = (i.card1|(i.card2<<2))", + // (mysql_version<4.1?pet_db:"p"), char_db, cart_db, pet_db, char_id); + // + //if(mysql_query(&mysql_handle, tmp_sql)) { + // ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); + // ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + //} + + //## TODO double-check the functionality of this query + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE pet_id IN " + "(SELECT card1|card2<<2 FROM `%s` WHERE char_id = '%d' AND card0 = -256" + " UNION" + " SELECT card1|card2<<2 FROM `%s` WHERE char_id = '%d' AND card0 = -256)", + pet_db, inventory_db, char_id, cart_db, char_id) ) + Sql_ShowDebug(sql_handle); } /* remove homunculus */ @@ -1479,126 +1319,68 @@ int delete_char_sql(int char_id, int partner_id) inter_delete_homunculus(hom_id); /* delete char's friends list */ - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d'",friend_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) ) + Sql_ShowDebug(sql_handle); /* delete char from other's friend list */ //NOTE: Won't this cause problems for people who are already online? [Skotlex] - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `friend_id` = '%d'",friend_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) ) + Sql_ShowDebug(sql_handle); #ifdef HOTKEY_SAVING /* delete hotkeys */ - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) ) + Sql_ShowDebug(sql_handle); #endif /* delete inventory */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",inventory_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) ) + Sql_ShowDebug(sql_handle); /* delete cart inventory */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",cart_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) ) + Sql_ShowDebug(sql_handle); /* delete memo areas */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",memo_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) ) + Sql_ShowDebug(sql_handle); /* delete character registry */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'",reg_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); /* delete skills */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",skill_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) ) + Sql_ShowDebug(sql_handle); #ifdef ENABLE_SC_SAVING /* status changes */ - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", - scdata_db, account_id, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); #endif if (log_char) { - sprintf(tmp_sql,"INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')", - charlog_db, account_id, 0, char_id, t_name); - //query - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')", + charlog_db, account_id, 0, char_id, esc_name) ) + Sql_ShowDebug(sql_handle); } /* delete character */ - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",char_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); /* No need as we used inter_guild_leave [Skotlex] // Also delete info from guildtables. - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",guild_member_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) ) + Sql_ShowDebug(sql_handle); */ - sprintf(tmp_sql, "SELECT `guild_id` FROM `%s` WHERE `master` = '%s'", guild_db, t_name); - - if (mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } else { - sql_res = mysql_store_result(&mysql_handle); - - if (sql_res == NULL) { - if (mysql_errno(&mysql_handle) != 0) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - return -1; - } else { - int rows = (int)mysql_num_rows(sql_res); - mysql_free_result(sql_res); - if (rows > 0) { - mapif_parse_BreakGuild(0,guild_id); - } - else if (guild_id) //Leave your guild. - inter_guild_leave(guild_id, account_id, char_id); - } - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `master` = '%s'", guild_db, esc_name) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + mapif_parse_BreakGuild(0,guild_id); + else if( guild_id ) + inter_guild_leave(guild_id, account_id, char_id);// Leave your guild. return 0; } @@ -1674,28 +1456,21 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p) int mmo_char_send006b(int fd, struct char_session_data* sd) { int i, j, found_num = 0; + char* data; set_char_online(-1, 99, sd->account_id); //search char. - sprintf(tmp_sql, "SELECT `char_id` FROM `%s` WHERE `account_id` = '%d' AND `char_num` < '%d'",char_db, sd->account_id, MAX_CHARS); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - found_num = (int)mysql_num_rows(sql_res); -// ShowInfo("number of chars: %d\n", found_num); - i = 0; - while((sql_row = mysql_fetch_row(sql_res))) { - sd->found_char[i] = atoi(sql_row[0]); - i++; - } - mysql_free_result(sql_res); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id` = '%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + sd->found_char[i] = atoi(data); } - - for(i = found_num; i < MAX_CHARS; i++) + found_num = i; + for( ; i < MAX_CHARS; ++i ) sd->found_char[i] = -1; if (save_log) @@ -1708,6 +1483,7 @@ int mmo_char_send006b(int fd, struct char_session_data* sd) memset(WFIFOP(fd,4), 0, 20); // unknown bytes for(i = 0; i < found_num; i++) { + struct mmo_charstatus char_dat; mmo_char_fromsql(sd->found_char[i], &char_dat, false); j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat); } @@ -1925,71 +1701,65 @@ int parse_fromlogin(int fd) { int acc, sex; unsigned char buf[16]; - MYSQL_RES* sql_res2; acc = RFIFOL(fd,2); sex = RFIFOB(fd,6); - if (acc > 0) { - sprintf(tmp_sql, "SELECT `char_id`,`class`,`skill_point`,`guild_id` FROM `%s` WHERE `account_id` = '%d'",char_db, acc); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( acc > 0 ) + { + int char_id[MAX_CHARS]; + int class_[MAX_CHARS]; + int guild_id[MAX_CHARS]; + int num; + int i; + char* data; + + // get characters + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + char_id[i] = atoi(data); + // class + Sql_GetData(sql_handle, 1, &data, NULL); + class_[i] = atoi(data); + // guild_id + Sql_GetData(sql_handle, 2, &data, NULL); + guild_id[i] = atoi(data); } - sql_res2 = mysql_store_result(&mysql_handle); - - while(sql_res2 && (sql_row = mysql_fetch_row(sql_res2))) { - int char_id, guild_id, jobclass, skill_point, class_; - char_id = atoi(sql_row[0]); - jobclass = atoi(sql_row[1]); - skill_point = atoi(sql_row[2]); - guild_id = atoi(sql_row[3]); - class_ = jobclass; - if (jobclass == JOB_BARD || jobclass == JOB_DANCER || - jobclass == JOB_CLOWN || jobclass == JOB_GYPSY || - jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) { + num = i; + for( i = 0; i < num; ++i ) + { + if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER || + class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY || + class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ) + { // job modification - if (jobclass == JOB_BARD || jobclass == JOB_DANCER) { - class_ = (sex) ? JOB_BARD : JOB_DANCER; - } else if (jobclass == JOB_CLOWN || jobclass == JOB_GYPSY) { - class_ = (sex) ? JOB_CLOWN : JOB_GYPSY; - } else if (jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) { - class_ = (sex) ? JOB_BABY_BARD : JOB_BABY_DANCER; - } + if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ) + class_[i] = (sex ? JOB_BARD : JOB_DANCER); + else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ) + class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY); + else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ) + class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER); // remove specifical skills of classes 19,20 4020,4021 and 4042,4043 - sprintf(tmp_sql, "SELECT `lv` FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - while(( sql_row = mysql_fetch_row(sql_res))) { - skill_point += atoi(sql_row[0]); - } - mysql_free_result(sql_res); - } - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `skill_point` = `skill_point` +" + " (SELECT SUM(lv) FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330' AND `lv` > '0')" + " WHERE `char_id` = '%d'", + char_db, skill_db, char_id[i], char_id[i]) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'", skill_db, char_id[i]) ) + Sql_ShowDebug(sql_handle); } // to avoid any problem with equipment and invalid sex, equipment is unequiped. - sprintf(tmp_sql, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'",inventory_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield`='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class_, skill_point, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - if (guild_id) //If there is a guild, update the guild_member data [Skotlex] - inter_guild_sex_changed(guild_id, acc, char_id, sex); - } - if (sql_res2) - mysql_free_result(sql_res2); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'", inventory_db, char_id[i]) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', `head_bottom`='0' WHERE `char_id`='%d'", char_db, class_[i], char_id[i]) ) + Sql_ShowDebug(sql_handle); + + if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex] + inter_guild_sex_changed(guild_id[i], acc, char_id[i], sex); + } + Sql_FreeResult(sql_handle); } // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { @@ -2220,74 +1990,59 @@ int save_accreg2(unsigned char* buf, int len) void char_read_fame_list(void) { int i; - struct fame_list fame_item; + char* data; + size_t len; // Empty ranking lists memset(smith_fame_list, 0, sizeof(smith_fame_list)); memset(chemist_fame_list, 0, sizeof(chemist_fame_list)); memset(taekwon_fame_list, 0, sizeof(taekwon_fame_list)); // Build Blacksmith ranking list - sprintf(tmp_sql, "SELECT `char_id`,`fame`, `name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, fame_list_size_smith); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - i = 0; - while((sql_row = mysql_fetch_row(sql_res))) { - fame_item.id = atoi(sql_row[0]); - fame_item.fame = atoi(sql_row[1]); - strncpy(fame_item.name, sql_row[2], NAME_LENGTH); - memcpy(&smith_fame_list[i], &fame_item, sizeof(struct fame_list)); - - if (++i == fame_list_size_smith) - break; - } - mysql_free_result(sql_res); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, fame_list_size_smith) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + smith_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + smith_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH)); } // Build Alchemist ranking list - sprintf(tmp_sql, "SELECT `char_id`,`fame`, `name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, fame_list_size_chemist); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - i = 0; - while((sql_row = mysql_fetch_row(sql_res))) { - fame_item.id = atoi(sql_row[0]); - fame_item.fame = atoi(sql_row[1]); - strncpy(fame_item.name, sql_row[2], NAME_LENGTH); - - memcpy(&chemist_fame_list[i], &fame_item, sizeof(struct fame_list)); - - if (++i == fame_list_size_chemist) - break; - } - mysql_free_result(sql_res); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, fame_list_size_chemist) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + chemist_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + chemist_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH)); } // Build Taekwon ranking list - sprintf(tmp_sql, "SELECT `char_id`,`fame`, `name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - i = 0; - while((sql_row = mysql_fetch_row(sql_res))) { - fame_item.id = atoi(sql_row[0]); - fame_item.fame = atoi(sql_row[1]); - strncpy(fame_item.name, sql_row[2], NAME_LENGTH); - - memcpy(&taekwon_fame_list[i], &fame_item, sizeof(struct fame_list)); - - if (++i == fame_list_size_taekwon) - break; - } - mysql_free_result(sql_res); - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + taekwon_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + taekwon_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH)); + } + Sql_FreeResult(sql_handle); } // Send map-servers the fame ranking lists @@ -2340,22 +2095,23 @@ void char_update_fame_list(int type, int index, int fame) //Returns 1 on found, 0 on not found (buffer is filled with Unknown char name) int char_loadName(int char_id, char* name) { - sprintf(tmp_sql, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - sql_res = mysql_store_result(&mysql_handle); - sql_row = sql_res?mysql_fetch_row(sql_res):NULL; + char* data; + size_t len; - if (sql_row) - memcpy(name, sql_row[0], NAME_LENGTH); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + Sql_GetData(sql_handle, 0, &data, &len); + memset(name, 0, NAME_LENGTH); + memcpy(name, data, min(len, NAME_LENGTH)); + return 1; + } else + { memcpy(name, unknown_char_name, NAME_LENGTH); - if (sql_res) mysql_free_result(sql_res); - - return (sql_row) ? 1 : 0; + } + return 0; } int search_mapserver(unsigned short map, uint32 ip, uint16 port); @@ -2393,11 +2149,8 @@ int parse_frommap(int fd) mapif_sendallwos(fd, buf, WBUFW(buf,2)); } memset(&server[id], 0, sizeof(struct mmo_map_server)); - sprintf(tmp_sql, "DELETE FROM `ragsrvinfo` WHERE `index`='%d'", server_fd[id]); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo` WHERE `index`='%d'", server_fd[id]) ) + Sql_ShowDebug(sql_handle); server_fd[id] = -1; online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server. } @@ -2495,35 +2248,34 @@ int parse_frommap(int fd) int aid, cid; aid = RFIFOL(fd,2); cid = RFIFOL(fd,6); - sprintf(tmp_sql, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", - scdata_db, aid, cid); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", + scdata_db, aid, cid) ) + { + Sql_ShowDebug(sql_handle); break; } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - struct status_change_data data; - int count = 0; + if( Sql_NumRows(sql_handle) > 0 ) + { + struct status_change_data scdata; + int count; + char* data; + WFIFOHEAD(fd,14+50*sizeof(struct status_change_data)); WFIFOW(fd,0) = 0x2b1d; WFIFOL(fd,4) = aid; WFIFOL(fd,8) = cid; - while((sql_row = mysql_fetch_row(sql_res)) && count < 50) + for( count = 0; count < 50 && SQL_SUCCESS == Sql_NextRow(sql_handle); ++count ) { - data.type = atoi(sql_row[0]); - data.tick = atoi(sql_row[1]); - data.val1 = atoi(sql_row[2]); - data.val2 = atoi(sql_row[3]); - data.val3 = atoi(sql_row[4]); - data.val4 = atoi(sql_row[5]); - memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &data, sizeof(struct status_change_data)); - count++; + Sql_GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); scdata.tick = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data); + memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data)); } if (count >= 50) ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid); - mysql_free_result(sql_res); if (count > 0) { WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data); @@ -2531,13 +2283,11 @@ int parse_frommap(int fd) WFIFOSET(fd,WFIFOW(fd,2)); //Clear the data once loaded. - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) ) + Sql_ShowDebug(sql_handle); } } + Sql_FreeResult(sql_handle); #endif RFIFOSKIP(fd, 10); } @@ -2598,6 +2348,7 @@ int parse_frommap(int fd) (character = idb_get(online_char_db, aid)) != NULL && character->char_id == cid)) { + struct mmo_charstatus char_dat; memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); mmo_char_tosql(cid, &char_dat); } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off. @@ -2648,6 +2399,7 @@ int parse_frommap(int fd) int map_id, map_fd = -1; struct online_char_data* data; struct mmo_charstatus* char_data; + struct mmo_charstatus char_dat; map_id = search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port. if (map_id >= 0) @@ -2677,7 +2429,8 @@ int parse_frommap(int fd) WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now? memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus)); WFIFOSET(map_fd, WFIFOW(map_fd,2)); - data = idb_ensure(online_char_db, RFIFOL(fd, 2), create_online_char_data); + + data = idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); data->char_id = char_data->char_id; data->server = map_id; //Update server where char is. @@ -2739,110 +2492,117 @@ int parse_frommap(int fd) if (RFIFOREST(fd) < 44) return 0; { - char character_name[NAME_LENGTH], t_name[NAME_LENGTH*2]; + char character_name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1];// escaped character name int acc = RFIFOL(fd,2); // account_id of who ask (-1 if nobody) + memcpy(character_name, RFIFOP(fd,6), NAME_LENGTH); character_name[NAME_LENGTH-1] = '\0'; - jstrescapecpy(t_name, character_name); //Escape string for sql use... [Skotlex] + Sql_EscapeStringLen(sql_handle, esc_name, character_name, strnlen(character_name, NAME_LENGTH)); // prepare answer WFIFOHEAD(fd,34); WFIFOW(fd,0) = 0x2b0f; // answer WFIFOL(fd,2) = acc; // who want do operation WFIFOW(fd,30) = RFIFOW(fd, 30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban - sprintf(tmp_sql, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'",char_db, t_name); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) + Sql_ShowDebug(sql_handle); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( Sql_NumRows(sql_handle) > 0 ) + { + char* data; + size_t len; - sql_res = mysql_store_result(&mysql_handle); - - if (sql_res) { - if (mysql_num_rows(sql_res)) { - sql_row = mysql_fetch_row(sql_res); - memcpy(WFIFOP(fd,6), sql_row[1], NAME_LENGTH); // put correct name if found - WFIFOW(fd,32) = 0; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - switch(RFIFOW(fd, 30)) { - case 1: // block - if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) { - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,10); - WFIFOW(login_fd,0) = 0x2724; - WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value - WFIFOL(login_fd,6) = 5; // status of the account - WFIFOSET(login_fd,10); - } else - WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + // name + Sql_GetData(sql_handle, 1, &data, &len); + if( len >= NAME_LENGTH ) + memcpy(WFIFOP(fd,6), data, NAME_LENGTH); + else + { + memcpy(WFIFOP(fd,6), data, len); + memset(WFIFOP(fd,6+len), 0, NAME_LENGTH - len); + } + // account_id + Sql_GetData(sql_handle, 0, &data, NULL); + WFIFOW(fd,32) = 0; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + switch(RFIFOW(fd, 30)) { + case 1: // block + if (acc == -1 || isGM(acc) >= isGM(atoi(data))) { + if (login_fd > 0) { // don't send request if no login-server + WFIFOHEAD(login_fd,10); + WFIFOW(login_fd,0) = 0x2724; + WFIFOL(login_fd,2) = atoi(data); // account value + WFIFOL(login_fd,6) = 5; // status of the account + WFIFOSET(login_fd,10); } else - WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - break; - case 2: // ban - if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) { - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,18); - WFIFOW(login_fd, 0) = 0x2725; - WFIFOL(login_fd, 2) = atoi(sql_row[0]); // account value - WFIFOW(login_fd, 6) = RFIFOW(fd,32); // year - WFIFOW(login_fd, 8) = RFIFOW(fd,34); // month - WFIFOW(login_fd,10) = RFIFOW(fd,36); // day - WFIFOW(login_fd,12) = RFIFOW(fd,38); // hour - WFIFOW(login_fd,14) = RFIFOW(fd,40); // minute - WFIFOW(login_fd,16) = RFIFOW(fd,42); // second - WFIFOSET(login_fd,18); - } else - WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } else + WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + break; + case 2: // ban + if (acc == -1 || isGM(acc) >= isGM(atoi(data))) { + if (login_fd > 0) { // don't send request if no login-server + WFIFOHEAD(login_fd,18); + WFIFOW(login_fd, 0) = 0x2725; + WFIFOL(login_fd, 2) = atoi(data); // account value + WFIFOW(login_fd, 6) = RFIFOW(fd,32); // year + WFIFOW(login_fd, 8) = RFIFOW(fd,34); // month + WFIFOW(login_fd,10) = RFIFOW(fd,36); // day + WFIFOW(login_fd,12) = RFIFOW(fd,38); // hour + WFIFOW(login_fd,14) = RFIFOW(fd,40); // minute + WFIFOW(login_fd,16) = RFIFOW(fd,42); // second + WFIFOSET(login_fd,18); } else - WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - break; - case 3: // unblock - if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) { - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,10); - WFIFOW(login_fd,0) = 0x2724; - WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value - WFIFOL(login_fd,6) = 0; // status of the account - WFIFOSET(login_fd,10); - } else - WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } else + WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + break; + case 3: // unblock + if (acc == -1 || isGM(acc) >= isGM(atoi(data))) { + if (login_fd > 0) { // don't send request if no login-server + WFIFOHEAD(login_fd,10); + WFIFOW(login_fd,0) = 0x2724; + WFIFOL(login_fd,2) = atoi(data); // account value + WFIFOL(login_fd,6) = 0; // status of the account + WFIFOSET(login_fd,10); } else - WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - break; - case 4: // unban - if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) { - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x272a; - WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value - WFIFOSET(login_fd,6); - } else - WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } else + WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + break; + case 4: // unban + if (acc == -1 || isGM(acc) >= isGM(atoi(data))) { + if (login_fd > 0) { // don't send request if no login-server + WFIFOHEAD(login_fd,6); + WFIFOW(login_fd,0) = 0x272a; + WFIFOL(login_fd,2) = atoi(data); // account value + WFIFOSET(login_fd,6); } else - WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - break; - case 5: // changesex - if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) { - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x2727; - WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value - WFIFOSET(login_fd,6); - } else - WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } else + WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + break; + case 5: // changesex + if (acc == -1 || isGM(acc) >= isGM(atoi(data))) { + if (login_fd > 0) { // don't send request if no login-server + WFIFOHEAD(login_fd,6); + WFIFOW(login_fd,0) = 0x2727; + WFIFOL(login_fd,2) = atoi(data); // account value + WFIFOSET(login_fd,6); } else - WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - break; - } - } else { - // character name not found - memcpy(WFIFOP(fd,6), character_name, NAME_LENGTH); - WFIFOW(fd,32) = 1; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - } - // send answer if a player ask, not if the server ask - if (acc != -1) { - WFIFOSET(fd, 34); + WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } else + WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + break; } - mysql_free_result(sql_res); + } else { + // character name not found + memcpy(WFIFOP(fd,6), character_name, NAME_LENGTH); + WFIFOW(fd,32) = 1; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline + } + Sql_FreeResult(sql_handle); + // send answer if a player ask, not if the server ask + if (acc != -1) { + WFIFOSET(fd, 34); } RFIFOSKIP(fd, 44); @@ -2908,18 +2668,18 @@ int parse_frommap(int fd) if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,8)) return 0; { - char motd[256], t_name[2*sizeof(char)*sizeof(server_name)+1], t_motd[512]; //Required for jstrescapecpy [Skotlex] + char motd[256]; + char esc_motd[sizeof(motd)*2+1]; + char esc_server_name[sizeof(server_name)*2+1]; + strncpy(motd, RFIFOP(fd,10), 255); //First copy it to make sure the motd fits. - motd[255]='\0'; - jstrescapecpy(t_motd,motd); - jstrescapecpy(t_name,server_name); - - sprintf(tmp_sql, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d',`motd`='%s'", - fd, t_name, RFIFOW(fd,2), RFIFOW(fd,4), RFIFOW(fd,6), t_motd); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + motd[255] = '\0'; + Sql_EscapeString(sql_handle, esc_motd, motd); + Sql_EscapeString(sql_handle, esc_server_name, server_name); + + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d',`motd`='%s'", + fd, esc_server_name, RFIFOW(fd,2), RFIFOW(fd,4), RFIFOW(fd,6), esc_motd) ) + Sql_ShowDebug(sql_handle); RFIFOSKIP(fd,RFIFOW(fd,8)); } break; @@ -2956,29 +2716,31 @@ int parse_frommap(int fd) return 0; { #ifdef ENABLE_SC_SAVING - int count, aid, cid, i; - struct status_change_data data; - char *p = tmp_sql; + int count, aid, cid; aid = RFIFOL(fd, 4); cid = RFIFOL(fd, 8); count = RFIFOW(fd, 12); - - p+= sprintf(p, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db); - - for (i = 0; i < count; i++) - { - memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); - p += sprintf (p, " ('%d','%d','%hu','%d','%d','%d','%d','%d'),", aid, cid, - data.type, data.tick, data.val1, data.val2, data.val3, data.val4); - } - if (count > 0) + + if( count > 0 ) { - *--p = '\0'; //Remove final comma. - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + struct status_change_data data; + StringBuf buf; + int i; + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db); + for( i = 0; i < count; ++i ) + { + memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); + if( count > 0 ) + StringBuf_AppendStr(&buf, ", "); + StringBuf_Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid, + data.type, data.tick, data.val1, data.val2, data.val3, data.val4); } + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + StringBuf_Destroy(&buf); } #endif RFIFOSKIP(fd, RFIFOW(fd, 2)); @@ -3156,36 +2918,35 @@ int parse_char(int fd) case 0x66: // char select FIFOSD_CHECK(3); - sprintf(tmp_sql, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'",char_db, sd->account_id, RFIFOB(fd, 2)); - RFIFOSKIP(fd, 3); + do // TODO: poor code structure + { + struct mmo_charstatus char_dat; + char* data; + int char_id; - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - sql_row = sql_res?mysql_fetch_row(sql_res):NULL; - - if (sql_row) + if ( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, RFIFOB(fd,2)) + || SQL_SUCCESS != Sql_NextRow(sql_handle) + || SQL_SUCCESS != Sql_GetData(sql_handle, 0, &data, NULL) ) { - int char_id = atoi(sql_row[0]); - mysql_free_result(sql_res); //Free'd as soon as possible - mmo_char_fromsql(char_id, &char_dat, true); - char_dat.sex = sd->sex; - } else { - mysql_free_result(sql_res); + //Not found?? May be forged packet. + Sql_ShowDebug(sql_handle); + Sql_FreeResult(sql_handle); + //TODO: perhaps add some reply? (otherwise it hangs the client) break; } + char_id = atoi(data); + Sql_FreeResult(sql_handle); + mmo_char_fromsql(char_id, &char_dat, true); + char_dat.sex = sd->sex; + if (log_char) { - char escaped_name[NAME_LENGTH*2]; - sprintf(tmp_sql,"INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')", - charlog_db, sd->account_id, RFIFOB(fd, 2), jstrescapecpy(escaped_name, char_dat.name)); - //query - if(mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + char esc_name[NAME_LENGTH*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')", + charlog_db, sd->account_id, RFIFOB(fd, 2), esc_name) ) + Sql_ShowDebug(sql_handle); } ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, RFIFOB(fd, 2), char_dat.name); @@ -3249,6 +3010,22 @@ int parse_char(int fd) WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] WFIFOSET(fd,28); + } + { + //Send player to map + uint32 subnet_map_ip; + char map_name[MAP_NAME_LENGTH_EXT]; + snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(char_dat.last_point.map)); + WFIFOHEAD(fd,28); + WFIFOW(fd,0) = 0x71; + WFIFOL(fd,2) = char_dat.char_id; + memcpy(WFIFOP(fd,6), map_name, MAP_NAME_LENGTH_EXT); + + // Advanced subnet check [LuzZza] + subnet_map_ip = lan_subnetcheck(ipl); + WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); + WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] + WFIFOSET(fd,28); } if (auth_fifo_pos >= AUTH_FIFO_SIZE) auth_fifo_pos = 0; @@ -3273,7 +3050,8 @@ int parse_char(int fd) WFIFOB(fd,2) = 1; // 01 = Server closed WFIFOSET(fd,3); break; - } + } + //Send auth ok to map server WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus)); WFIFOW(map_fd,0) = 0x2afd; @@ -3284,9 +3062,11 @@ int parse_char(int fd) WFIFOL(map_fd,12) = (unsigned long)auth_fifo[auth_fifo_pos].connect_until_time; memcpy(WFIFOP(map_fd,20), &char_dat, sizeof(struct mmo_charstatus)); WFIFOSET(map_fd, WFIFOW(map_fd,2)); - + set_char_online(i, auth_fifo[auth_fifo_pos].char_id, auth_fifo[auth_fifo_pos].account_id); auth_fifo_pos++; + } while(0); + RFIFOSKIP(fd,3); break; case 0x67: // make new @@ -3313,14 +3093,13 @@ int parse_char(int fd) } { //Send to player. int len; + struct mmo_charstatus char_dat; WFIFOHEAD(fd,110); WFIFOW(fd,0) = 0x6d; mmo_char_fromsql(i, &char_dat, false); //Only the short data is needed. len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat); WFIFOSET(fd,len); - RFIFOSKIP(fd,37); - } //to do for(ch = 0; ch < MAX_CHARS; ch++) { if (sd->found_char[ch] == -1) { @@ -3328,6 +3107,9 @@ int parse_char(int fd) break; } } + + RFIFOSKIP(fd,37); + } break; case 0x68: // delete char @@ -3336,8 +3118,10 @@ int parse_char(int fd) if (cmd == 0x1fb) FIFOSD_CHECK(56); { int cid = RFIFOL(fd,2); + int char_pid=0; - ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); + WFIFOHEAD(fd,46); + ShowInfo(CL_RED" Request Char Deletion:"CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); memcpy(email, RFIFOP(fd,6), 40); RFIFOSKIP(fd,RFIFOREST(fd)); // hack to make the other deletion packet work @@ -3371,41 +3155,32 @@ int parse_char(int fd) } /* Grab the partner id */ - sprintf(tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id`='%d'",char_db, cid); - - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - sql_res = mysql_store_result(&mysql_handle); - - if(sql_res) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id`='%d'", char_db, cid) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) { - int char_pid=0; - sql_row = mysql_fetch_row(sql_res); - if (sql_row) - char_pid = atoi(sql_row[0]); - mysql_free_result(sql_res); - - /* Delete character and partner (if any) */ - if(delete_char_sql(cid, char_pid)<0){ - //can't delete the char - //either SQL error or can't delete by some CONFIG conditions - //del fail - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - break; - } - if (char_pid != 0) - { /* If there is partner, tell map server to do divorce */ - WBUFW(buf,0) = 0x2b12; - WBUFL(buf,2) = cid; - WBUFL(buf,6) = char_pid; - mapif_sendall(buf,10); - } + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + char_pid = atoi(data); + } + + /* Delete character and partner (if any) */ + if(delete_char_sql(cid, char_pid)<0){ + //can't delete the char + //either SQL error or can't delete by some CONFIG conditions + //del fail + WFIFOW(fd, 0) = 0x70; + WFIFOB(fd, 2) = 0; + WFIFOSET(fd, 3); + break; + } + if (char_pid != 0) + { /* If there is partner, tell map server to do divorce */ + WBUFW(buf,0) = 0x2b12; + WBUFL(buf,2) = cid; + WBUFL(buf,6) = char_pid; + mapif_sendall(buf,10); } /* Char successfully deleted.*/ WFIFOHEAD(fd,2); @@ -3824,15 +3599,6 @@ void sql_config_read(const char* cfgName) #ifndef TXT_SQL_CONVERT else if(!strcmpi(w1,"db_path")) strcpy(db_path,w2); - //Map server option to use SQL item/mob-db or not - else if(!strcmpi(w1,"use_sql_db")==0){ - db_use_sqldbs = config_switch(w2); - ShowStatus("Using SQL dbs: %s\n",w2); - } - else if(!strcmpi(w1,"item_db_db")) - strcpy(item_db_db,w2); - else if(!strcmpi(w1,"item_db2_db")) - strcpy(item_db2_db,w2); #endif //support the import command, just like any other config else if(!strcmpi(w1,"import")) @@ -4005,7 +3771,6 @@ int char_config_read(const char* cfgName) void do_final(void) { ShowInfo("Doing final stage...\n"); - do_final_itemdb(); //check SQL save progress. //wait until save char complete @@ -4017,13 +3782,9 @@ void do_final(void) flush_fifos(); mapindex_final(); - - sprintf(tmp_sql,"DELETE FROM `ragsrvinfo"); - if (mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo") ) + Sql_ShowDebug(sql_handle); if(gm_account) { aFree(gm_account); @@ -4037,9 +3798,9 @@ void do_final(void) char_db_->destroy(char_db_, NULL); online_char_db->destroy(online_char_db, NULL); - mysql_close(&mysql_handle); - if(char_gm_read) - mysql_close(&lmysql_handle); + Sql_Free(sql_handle); + if( lsql_handle ) + Sql_Free(lsql_handle); ShowInfo("ok! all done...\n"); } @@ -4102,9 +3863,6 @@ int do_init(int argc, char **argv) inter_init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server ÃʱâÈ­ ShowInfo("Finished reading the inter-server configuration.\n"); - //Read ItemDB - do_init_itemdb(); - ShowInfo("Initializing char server.\n"); online_char_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int)); mmo_char_sql_init(); @@ -4158,121 +3916,86 @@ int do_init(int argc, char **argv) //Cleaning the tables for NULL entrys @ startup [Sirius] //Chardb clean ShowInfo("Cleaning the '%s' table...\n", char_db); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `account_id` = '0'", char_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) ) + Sql_ShowDebug(sql_handle); + //guilddb clean - ShowInfo("Cleaning the '%s' table...\n", guild_db); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - + ShowInfo("Cleaning the '%s' table...\n", guild_db); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) ) + Sql_ShowDebug(sql_handle); + //guildmemberdb clean ShowInfo("Cleaning the '%s' table...\n", guild_member_db); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db); - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - ShowInfo("End of char server initilization function.\n"); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) ) + Sql_ShowDebug(sql_handle); - ShowInfo("open port %d.....\n",char_port); - char_fd = make_listen_bind(bind_ip, char_port); + ShowInfo("End of char server initilization function.\n"); ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); return 0; } int char_child(int parent_id, int child_id) { - int tmp_id = 0; - sprintf (tmp_sql, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id); - if (mysql_query (&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + if( child_id == atoi(data) ) + { + Sql_FreeResult(sql_handle); + return 1; + } } - sql_res = mysql_store_result (&mysql_handle); - sql_row = sql_res?mysql_fetch_row (sql_res):NULL; - if (sql_row) - tmp_id = atoi (sql_row[0]); - else - ShowError("CHAR: child Failed!\n"); - if (sql_res) mysql_free_result (sql_res); - if ( tmp_id == child_id ) - return 1; - else - return 0; + Sql_FreeResult(sql_handle); + return 0; } int char_married(int pl1, int pl2) { - int tmp_id = 0; - sprintf (tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1); - if (mysql_query (&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + if( pl2 == atoi(data) ) + { + Sql_FreeResult(sql_handle); + return 1; + } } - sql_res = mysql_store_result (&mysql_handle); - sql_row = sql_res?mysql_fetch_row (sql_res):NULL; - if (sql_row) - tmp_id = atoi (sql_row[0]); - else - ShowError("CHAR: married Failed!\n"); - if (sql_res) mysql_free_result (sql_res); - if ( tmp_id == pl2 ) - return 1; - else - return 0; + Sql_FreeResult(sql_handle); + return 0; } int char_family(int pl1, int pl2, int pl3) { - int charid, partnerid, childid; - sprintf (tmp_sql, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, pl1, pl2, pl3); - if (mysql_query (&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - sql_res = mysql_store_result (&mysql_handle); - if (!sql_res) return 0; - - while((sql_row = mysql_fetch_row(sql_res))) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, pl1, pl2, pl3) ) + Sql_ShowDebug(sql_handle); + else while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) { - charid = atoi(sql_row[0]); - partnerid = atoi(sql_row[1]); - childid = atoi(sql_row[2]); - if (charid == pl1) { - if ((pl2 == partnerid && pl3 == childid) || - (pl3 == partnerid && pl2 == childid) - ) { - mysql_free_result (sql_res); - return childid; - } - } - if(charid == pl2) { - if ((pl1 == partnerid && pl3 == childid) || - (pl3 == partnerid && pl1 == childid) - ) { - mysql_free_result (sql_res); - return childid; - } - } - if(charid == pl3) { - if ((pl1 == partnerid && pl2 == childid) || - (pl2 == partnerid && pl1 == childid) - ) { - mysql_free_result (sql_res); - return childid; - } + int charid; + int partnerid; + int childid; + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); charid = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); childid = atoi(data); + + if( (pl1 == charid && ((pl2 == partnerid && pl3 == childid ) || (pl2 == childid && pl3 == partnerid))) || + (pl1 == partnerid && ((pl2 == charid && pl3 == childid ) || (pl2 == childid && pl3 == charid ))) || + (pl1 == childid && ((pl2 == charid && pl3 == partnerid) || (pl2 == partnerid && pl3 == charid ))) ) + { + Sql_FreeResult(sql_handle); + return childid; } } - mysql_free_result (sql_res); + Sql_FreeResult(sql_handle); return 0; } diff --git a/src/char_sql/char.h b/src/char_sql/char.h index 5af183033..c99d1e16a 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -4,37 +4,13 @@ #ifndef _CHAR_SQL_H_ #define _CHAR_SQL_H_ -#include "../common/core.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/mmo.h" -#include "../common/version.h" -#include "../common/db.h" -#include "../common/mapindex.h" - -#include "inter.h" -#include "int_pet.h" -#include "int_guild.h" -#include "int_party.h" -#include "int_storage.h" -#include "itemdb.h" +struct mmo_charstatus; #define START_CHAR_NUM 150000 #define MAX_MAP_SERVERS 30 #define DEFAULT_AUTOSAVE_INTERVAL 300*1000 -struct itemtmp { - int flag;//checked = 1 else 0 - int id; - short nameid; - short amount; - unsigned short equip; - char identify; - char refine; - char attribute; - short card[4]; -}; enum { TABLE_INVENTORY, TABLE_CART, @@ -42,7 +18,7 @@ enum { TABLE_GUILD_STORAGE, }; -int memitemdata_to_sql(struct itemtmp mapitem[], int count, int char_id,int tableswitch); +int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch); int mapif_sendall(unsigned char *buf,unsigned int len); int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index b72c85ab2..f33f58097 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -1,10 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/mmo.h" #include "../common/cbasetypes.h" #include "../common/strlib.h" @@ -12,9 +8,14 @@ #include "../common/db.h" #include "../common/malloc.h" #include "../common/socket.h" +#include "../common/timer.h" +#include "char.h" #include "inter.h" #include "int_guild.h" -#include "char.h" + +#include +#include +#include #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 @@ -87,18 +88,10 @@ static int guild_save_timer(int tid, unsigned int tick, int id, int data) { int inter_guild_removemember_tosql(int account_id, int char_id) { - sprintf(tmp_sql,"DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql,"UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); return 0; } #endif //TXT_SQL_CONVERT @@ -120,19 +113,11 @@ int inter_guild_tosql(struct guild *g,int flag) // temporary storage for str convertion. They must be twice the size of the // original string to ensure no overflows will occur. [Skotlex] - char t_name[NAME_LENGTH*2], - t_master[NAME_LENGTH*2], - t_mes1[120], - t_mes2[240], - t_member[NAME_LENGTH*2], - t_position[NAME_LENGTH*2], - t_alliance[NAME_LENGTH*2], - t_ename[NAME_LENGTH*2], - t_emes[80], - t_info[240]; - char emblem_data[4096]; + char t_info[256]; + char esc_name[NAME_LENGTH*2+1]; + char esc_master[NAME_LENGTH*2+1]; char new_guild = 0; - int i=0, sql_index; + int i=0; if (g->guild_id<=0 && g->guild_id != -1) return 0; @@ -140,9 +125,9 @@ int inter_guild_tosql(struct guild *g,int flag) ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag); #endif - jstrescapecpy(t_name, g->name); - - t_info[0]='\0'; + Sql_EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH)); + Sql_EscapeStringLen(sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH)); + *t_info = '\0'; #ifndef TXT_SQL_CONVERT // Insert a new guild the guild @@ -151,27 +136,19 @@ int inter_guild_tosql(struct guild *g,int flag) strcat(t_info, " guild_create"); // Create a new guild - sprintf(tmp_sql,"INSERT INTO `%s` " + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " "(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " "VALUES ('%s', '%s', '%d', '%d', '%d', '%d')", - guild_db,t_name,jstrescapecpy(t_master,g->master),g->guild_lv,g->max_member,g->average_lv,g->member[0].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(sql_handle); if (g->guild_id == -1) return 0; //Failed to create guild! - } + } else - { - //New guild, catch id - if(mysql_field_count(&mysql_handle) == 0 && mysql_insert_id(&mysql_handle) != 0) - { - g->guild_id = (int)mysql_insert_id(&mysql_handle); - new_guild = 1; - } - else - return 0; //Failed to get ID?? + { + g->guild_id = (int)Sql_LastInsertId(sql_handle); + new_guild = 1; } } #else @@ -180,21 +157,15 @@ int inter_guild_tosql(struct guild *g,int flag) { strcat(t_info, " guild_create"); // Since the PK is guild id + master id, a replace will not be enough if we are overwriting data, we need to wipe the previous guild. - sprintf(tmp_sql,"DELETE FROM `%s` where `guild_id` = '%d'", guild_db,g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` where `guild_id` = '%d'", guild_db, g->guild_id) ) + Sql_ShowDebug(sql_handle); // Create a new guild - sprintf(tmp_sql,"REPLACE INTO `%s` " + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " "(`guild_id`,`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " "VALUES ('%d', '%s', '%s', '%d', '%d', '%d', '%d')", - guild_db,g->guild_id,t_name,jstrescapecpy(t_master,g->master),g->guild_lv,g->max_member,g->average_lv,g->member[0].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + guild_db, g->guild_id, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(sql_handle); return 0; //Failed to create guild. } } @@ -202,51 +173,79 @@ int inter_guild_tosql(struct guild *g,int flag) // If we need an update on an existing guild or more update on the new guild if (((flag & GS_BASIC_MASK) && !new_guild) || ((flag & (GS_BASIC_MASK & ~GS_BASIC)) && new_guild)) { - sql_index = sprintf(tmp_sql,"UPDATE `%s` SET ", guild_db); + StringBuf buf; + bool add_comma = false; + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "UPDATE `%s` SET ", guild_db); if (flag & GS_EMBLEM) { - char * pData = emblem_data; + char emblem_data[sizeof(g->emblem_data)*2+1]; + char* pData = emblem_data; + strcat(t_info, " emblem"); // Convert emblem_data to hex + //TODO: why not use binary directly? [ultramage] for(i=0; iemblem_len; i++){ *pData++ = dataToHex[(g->emblem_data[i] >> 4) & 0x0F]; *pData++ = dataToHex[g->emblem_data[i] & 0x0F]; } *pData = 0; - sql_index += sprintf(tmp_sql + sql_index,"`emblem_len`=%d,`emblem_id`=%d,`emblem_data`='%s',",g->emblem_len,g->emblem_id,emblem_data); + StringBuf_Printf(&buf, "`emblem_len`=%d, `emblem_id`=%d, `emblem_data`='%s'", g->emblem_len, g->emblem_id, emblem_data); + add_comma = true; } if (flag & GS_BASIC) { strcat(t_info, " basic"); - sql_index += sprintf(tmp_sql + sql_index,"`name`='%s', `master`='%s', `char_id`=%d,",t_name,jstrescapecpy(t_master,g->master),g->member[0].char_id); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`name`='%s', `master`='%s', `char_id`=%d", esc_name, esc_master, g->member[0].char_id); } if (flag & GS_CONNECT) { strcat(t_info, " connect"); - sql_index += sprintf(tmp_sql + sql_index,"`connect_member`=%d,`average_lv`=%d,",g->connect_member, g->average_lv); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`connect_member`=%d, `average_lv`=%d", g->connect_member, g->average_lv); } if (flag & GS_MES) { + char esc_mes1[sizeof(g->mes1)*2+1]; + char esc_mes2[sizeof(g->mes2)*2+1]; + strcat(t_info, " mes"); - sql_index += sprintf(tmp_sql + sql_index,"`mes1`='%s',`mes2`='%s',",jstrescapecpy(t_mes1,g->mes1),jstrescapecpy(t_mes2,g->mes2)); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + Sql_EscapeStringLen(sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1))); + Sql_EscapeStringLen(sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2))); + StringBuf_Printf(&buf, "`mes1`='%s', `mes2`='%s'", esc_mes1, esc_mes2); } if (flag & GS_LEVEL) { strcat(t_info, " level"); - sql_index += sprintf(tmp_sql + sql_index,"`guild_lv`=%d,`skill_point`=%d,`exp`=%u,`next_exp`=%u,`max_member`=%d,",g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); - } - sprintf(tmp_sql + sql_index -1," WHERE `guild_id`=%d", g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%u, `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); } + StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "%s", StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + StringBuf_Destroy(&buf); } if (flag&GS_MEMBER) { struct guild_member *m; + strcat(t_info, " members"); // Update only needed players for(i=0;imax_member;i++){ @@ -257,26 +256,18 @@ int inter_guild_tosql(struct guild *g,int flag) #endif if(m->account_id) { //Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO - sprintf(tmp_sql,"REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) " + Sql_EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) " "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%u','%d','%d','%d','%s')", - guild_member_db, g->guild_id, m->account_id,m->char_id, - m->hair,m->hair_color,m->gender, - m->class_,m->lv,m->exp,m->exp_payper,m->online,m->position, - jstrescapecpy(t_member,m->name)); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + guild_member_db, g->guild_id, m->account_id, m->char_id, + m->hair, m->hair_color, m->gender, + m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) ) + Sql_ShowDebug(sql_handle); if (m->modified & GS_MEMBER_NEW) { - sprintf(tmp_sql,"UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'", - char_db, g->guild_id, m->char_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'", + char_db, g->guild_id, m->char_id) ) + Sql_ShowDebug(sql_handle); } m->modified = GS_MEMBER_UNMODIFIED; } @@ -292,13 +283,10 @@ int inter_guild_tosql(struct guild *g,int flag) if (!p->modified) continue; #endif - sprintf(tmp_sql,"REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d', '%s','%d','%d')", - guild_position_db, g->guild_id, i, jstrescapecpy(t_position,p->name),p->mode,p->exp_mode); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')", + guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) ) + Sql_ShowDebug(sql_handle); p->modified = GS_POSITION_UNMODIFIED; } } @@ -309,12 +297,10 @@ int inter_guild_tosql(struct guild *g,int flag) // NOTE: no need to do it on both sides since both guilds in memory had // their info changed, not to mention this would also mess up oppositions! // [Skotlex] -// sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'",guild_alliance_db, g->guild_id,g->guild_id); - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_alliance_db, g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + //if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) ) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(sql_handle); } else { @@ -324,15 +310,11 @@ int inter_guild_tosql(struct guild *g,int flag) struct guild_alliance *a=&g->alliance[i]; if(a->guild_id>0) { - sprintf(tmp_sql,"REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) " + Sql_EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) " "VALUES ('%d','%d','%d','%s')", - guild_alliance_db, g->guild_id,a->opposition,a->guild_id,jstrescapecpy(t_alliance,a->name)); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) ) + Sql_ShowDebug(sql_handle); } } } @@ -344,15 +326,17 @@ int inter_guild_tosql(struct guild *g,int flag) for(i=0;iexpulsion[i]; if(e->account_id>0){ - sprintf(tmp_sql,"REPLACE INTO `%s` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) " + char esc_mes[sizeof(e->mes)*2+1]; + char esc_acc[sizeof(e->acc)*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH)); + Sql_EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes))); + Sql_EscapeStringLen(sql_handle, esc_acc, e->acc, strnlen(e->acc, sizeof(e->acc))); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) " "VALUES ('%d','%s','%s','%s','%d','%d','%d','%d')", guild_expulsion_db, g->guild_id, - jstrescapecpy(t_ename,e->name),jstrescapecpy(t_emes,e->mes),e->acc,e->account_id,e->rsv1,e->rsv2,e->rsv3 ); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + esc_name, esc_mes, esc_acc, e->account_id, e->rsv1, e->rsv2 ,e->rsv3) ) + Sql_ShowDebug(sql_handle); } } } @@ -362,13 +346,9 @@ int inter_guild_tosql(struct guild *g,int flag) //printf("- Insert guild %d to guild_skill\n",g->guild_id); for(i=0;iskill[i].id>0 && g->skill[i].lv>0){ - sprintf(tmp_sql,"REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')", - guild_skill_db, g->guild_id,g->skill[i].id,g->skill[i].lv); - //printf("%s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')", + guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) ) + Sql_ShowDebug(sql_handle); } } } @@ -377,213 +357,199 @@ int inter_guild_tosql(struct guild *g,int flag) ShowInfo("Saved guild (%d - %s):%s\n",g->guild_id,g->name,t_info); return 1; } + #ifndef TXT_SQL_CONVERT // Read guild from sql struct guild * inter_guild_fromsql(int guild_id) { - int i; - char * pstr, * pEmblemData; struct guild *g; + char* data; + size_t len; + char* p; + int i; - if (guild_id<=0) return NULL; - - g = idb_get(guild_db_,guild_id); - if (g) return g; + if( guild_id <= 0 ) + return NULL; - g = (struct guild*)aCalloc(sizeof(struct guild), 1); + g = idb_get(guild_db_, guild_id); + if( g ) + return g; #ifdef NOISY ShowInfo("Guild load request (%d)...\n", guild_id); #endif - - sprintf(tmp_sql,"SELECT `name`,`master`,`guild_lv`,`connect_member`,`max_member`,`average_lv`,`exp`,`next_exp`,`skill_point`,`mes1`,`mes2`,`emblem_len`,`emblem_id`,`emblem_data` " - "FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - aFree(g); - return NULL; - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res==NULL || mysql_num_rows(sql_res)<1) { - //Guild does not exists. - if (sql_res) mysql_free_result(sql_res); - aFree(g); - return NULL; - } - - sql_row = mysql_fetch_row(sql_res); - if (sql_row==NULL) { - mysql_free_result(sql_res); - aFree(g); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`master`,`guild_lv`,`connect_member`,`max_member`,`average_lv`,`exp`,`next_exp`,`skill_point`,`mes1`,`mes2`,`emblem_len`,`emblem_id`,`emblem_data` " + "FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); return NULL; } - g->guild_id=guild_id; - strncpy(g->name,sql_row[0],NAME_LENGTH-1); - strncpy(g->master,sql_row[1],NAME_LENGTH-1); - g->guild_lv=atoi(sql_row[2]); - g->connect_member=atoi(sql_row[3]); - g->max_member = atoi(sql_row[4]); - if (g->max_member > MAX_GUILD) + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + return NULL;// Guild does not exists. + + CREATE(g, struct guild, 1); + + g->guild_id = guild_id; + Sql_GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data); + if( g->max_member > MAX_GUILD ) { // Fix reduction of MAX_GUILD [PoW] ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD); g->max_member = MAX_GUILD; } - g->average_lv=atoi(sql_row[5]); - g->exp=(unsigned int)atof(sql_row[6]); - g->next_exp=(unsigned int)atof(sql_row[7]); - g->skill_point=atoi(sql_row[8]); - //There shouldn't be a need to copy the very last char, as it's the \0 [Skotlex] - strncpy(g->mes1,sql_row[9],59); - strncpy(g->mes2,sql_row[10],119); - g->emblem_len=atoi(sql_row[11]); - g->emblem_id=atoi(sql_row[12]); - //FIXME: check for sql_row[13]==NULL, just in case - for(i=0,pstr=sql_row[13],pEmblemData=g->emblem_data; i < g->emblem_len; i++,pstr+=2){ - int c1=pstr[0],c2=pstr[1],x1=0,x2=0; - if(c1>='0' && c1<='9') - x1=c1-'0'; - else if(c1>='a' && c1<='f') - x1=c1-'a'+10; - else if(c1>='A' && c1<='F') - x1=c1-'A'+10; - if(c2>='0' && c2<='9') - x2=c2-'0'; - else if(c2>='a' && c2<='f') - x2=c2-'a'+10; - else if(c2>='A' && c2<='F') - x2=c2-'A'+10; - *pEmblemData++=(x1<<4)|x2; + Sql_GetData(sql_handle, 5, &data, NULL); g->average_lv = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); g->exp = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data); + Sql_GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1))); + Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2))); + Sql_GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data); + Sql_GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data); + Sql_GetData(sql_handle, 13, &data, &len); + // convert emblem data from hexadecimal to binary + //TODO: why not store it in the db as binary directly? [ultramage] + for( i = 0, p = g->emblem_data; i < g->emblem_len; ++i, ++p ) + { + if( *data >= '0' && *data <= '9' ) + *p = *data - '0'; + else if( *data >= 'a' && *data <= 'f' ) + *p = *data - 'a' + 10; + else if( *data >= 'A' && *data <= 'F' ) + *p = *data - 'A' + 10; + *p <<= 4; + ++data; + + if( *data >= '0' && *data <= '9' ) + *p |= *data - '0'; + else if( *data >= 'a' && *data <= 'f' ) + *p |= *data - 'a' + 10; + else if( *data >= 'A' && *data <= 'F' ) + *p |= *data - 'A' + 10; + ++data; } - mysql_free_result(sql_res); //printf("- Read guild_member %d from sql \n",guild_id); - sprintf(tmp_sql,"SELECT `guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`rsv1`,`rsv2`,`name` " - "FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`rsv1`,`rsv2`,`name` " + "FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); aFree(g); return NULL; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - for(i=0;((sql_row = mysql_fetch_row(sql_res))&&imax_member);i++){ - struct guild_member *m = &g->member[i]; - m->account_id=atoi(sql_row[1]); - m->char_id=atoi(sql_row[2]); - m->hair=atoi(sql_row[3]); - m->hair_color=atoi(sql_row[4]); - m->gender=atoi(sql_row[5]); - m->class_=atoi(sql_row[6]); - m->lv=atoi(sql_row[7]); - m->exp=strtoul(sql_row[8],NULL,10); - m->exp_payper=atoi(sql_row[9]); - m->online=atoi(sql_row[10]); - m->position = atoi(sql_row[11]); - if (m->position >= MAX_GUILDPOSITION) // Fix reduction of MAX_GUILDPOSITION [PoW] - m->position = MAX_GUILDPOSITION - 1; - - strncpy(m->name,sql_row[14],NAME_LENGTH-1); - m->modified = GS_MEMBER_UNMODIFIED; - } - mysql_free_result(sql_res); + for( i = 0; i < g->max_member && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_member* m = &g->member[i]; + + Sql_GetData(sql_handle, 1, &data, NULL); m->account_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); m->char_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); m->hair = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); m->hair_color = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); m->gender = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); m->lv = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); m->exp = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 9, &data, NULL); m->exp_payper = (unsigned int)atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); m->online = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); m->position = atoi(data); + if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW] + m->position = MAX_GUILDPOSITION - 1; + //## TODO what about the rsv fields? + // rsv1 (12) + // rsv2 (13) + // name + Sql_GetData(sql_handle, 14, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); + m->modified = GS_MEMBER_UNMODIFIED; } //printf("- Read guild_position %d from sql \n",guild_id); - sprintf(tmp_sql,"SELECT `guild_id`,`position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'",guild_position_db, guild_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id`,`position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); aFree(g); return NULL; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - for(i=0;((sql_row = mysql_fetch_row(sql_res))&&iposition[position]; - strncpy(p->name,sql_row[2],NAME_LENGTH-1); - p->mode=atoi(sql_row[3]); - p->exp_mode=atoi(sql_row[4]); - p->modified = GS_POSITION_UNMODIFIED; - } - mysql_free_result(sql_res); + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int position; + struct guild_position* p; + + Sql_GetData(sql_handle, 1, &data, NULL); position = atoi(data); + if( position < 0 || position >= MAX_GUILDPOSITION ) + continue;// invalid position + p = &g->position[position]; + Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 3, &data, NULL); p->mode = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); p->exp_mode = atoi(data); + p->modified = GS_POSITION_UNMODIFIED; } //printf("- Read guild_alliance %d from sql \n",guild_id); - sprintf(tmp_sql,"SELECT `guild_id`,`opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'",guild_alliance_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id`,`opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); aFree(g); return NULL; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - for(i=0;((sql_row = mysql_fetch_row(sql_res))&&ialliance[i]; - a->opposition=atoi(sql_row[1]); - a->guild_id=atoi(sql_row[2]); - strncpy(a->name,sql_row[3],NAME_LENGTH-1); - } - mysql_free_result(sql_res); + for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_alliance* a = &g->alliance[i]; + + Sql_GetData(sql_handle, 1, &data, NULL); a->opposition = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); a->guild_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH)); } //printf("- Read guild_expulsion %d from sql \n",guild_id); - sprintf(tmp_sql,"SELECT `guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3` FROM `%s` WHERE `guild_id`='%d'",guild_expulsion_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); aFree(g); return NULL; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - for(i=0;((sql_row = mysql_fetch_row(sql_res))&&iexpulsion[i]; - - strncpy(e->name,sql_row[1],NAME_LENGTH-1); - //No need to copy char 40, the null terminator. [Skotlex] - strncpy(e->mes,sql_row[2],39); - strncpy(e->acc,sql_row[3],39); - e->account_id=atoi(sql_row[4]); - e->rsv1=atoi(sql_row[5]); - e->rsv2=atoi(sql_row[6]); - e->rsv3=atoi(sql_row[7]); - } - mysql_free_result(sql_res); + for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_expulsion *e = &g->expulsion[i]; + + Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes))); + Sql_GetData(sql_handle, 3, &data, &len); memcpy(e->acc, data, min(len, sizeof(e->acc))); + Sql_GetData(sql_handle, 4, &data, NULL); e->account_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); e->rsv1 = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); e->rsv2 = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); e->rsv3 = atoi(data); } //printf("- Read guild_skill %d from sql \n",guild_id); - sprintf(tmp_sql,"SELECT `guild_id`,`id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`",guild_skill_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id`,`id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); aFree(g); return NULL; } - + for(i = 0; i < MAX_GUILDSKILL; i++) { //Skill IDs must always be initialized. [Skotlex] g->skill[i].id = i + GD_SKILLBASE; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - while ((sql_row = mysql_fetch_row(sql_res))){ - int id = atoi(sql_row[1])-GD_SKILLBASE; - if (id >= 0 && id < MAX_GUILDSKILL) - //I know this seems ridiculous, but the skills HAVE to be placed on their 'correct' array slot or things break x.x [Skotlex] - g->skill[id].lv=atoi(sql_row[2]); - } - mysql_free_result(sql_res); - } + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int id; + // id + Sql_GetData(sql_handle, 1, &data, NULL); + id = atoi(data) - GD_SKILLBASE; + if( id < 0 && id >= MAX_GUILDSKILL ) + continue;// invalid guild skill + // lv + Sql_GetData(sql_handle, 2, &data, NULL); + g->skill[id].lv = atoi(data); + } + Sql_FreeResult(sql_handle); idb_put(guild_db_, guild_id, g); //Add to cache g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long. @@ -604,8 +570,7 @@ ShowDebug("Save guild_castle (%d)\n", gc->castle_id); #endif // sql_query("DELETE FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, gc->castle_id); - - sprintf(tmp_sql,"REPLACE INTO `%s` " + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)" @@ -613,12 +578,8 @@ ShowDebug("Save guild_castle (%d)\n", gc->castle_id); guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible, - gc->guardian[0].hp, gc->guardian[1].hp, gc->guardian[2].hp, gc->guardian[3].hp, gc->guardian[4].hp, gc->guardian[5].hp, gc->guardian[6].hp, gc->guardian[7].hp); - - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + gc->guardian[0].hp, gc->guardian[1].hp, gc->guardian[2].hp, gc->guardian[3].hp, gc->guardian[4].hp, gc->guardian[5].hp, gc->guardian[6].hp, gc->guardian[7].hp) ) + Sql_ShowDebug(sql_handle); #ifndef TXT_SQL_CONVERT memcpy(&castles[gc->castle_id],gc,sizeof(struct guild_castle)); @@ -631,6 +592,8 @@ ShowDebug("Save guild_castle (%d)\n", gc->castle_id); int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) { static int castles_init=0; + char* data; + if (gc==NULL) return 0; if (castle_id==-1) return 0; @@ -649,58 +612,54 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) } memset(gc,0,sizeof(struct guild_castle)); - sprintf(tmp_sql,"SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, " + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, " "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`" - " FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, castle_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + " FROM `%s` WHERE `castle_id`='%d'", guild_castle_db, castle_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } // ARU: This needs to be set even if there are no SQL results gc->castle_id=castle_id; - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { - sql_row = mysql_fetch_row(sql_res); - if (sql_row==NULL){ - mysql_free_result(sql_res); - return 1; //Assume empty castle. - } - gc->guild_id = atoi (sql_row[1]); - gc->economy = atoi (sql_row[2]); - gc->defense = atoi (sql_row[3]); - gc->triggerE = atoi (sql_row[4]); - gc->triggerD = atoi (sql_row[5]); - gc->nextTime = atoi (sql_row[6]); - gc->payTime = atoi (sql_row[7]); - gc->createTime = atoi (sql_row[8]); - gc->visibleC = atoi (sql_row[9]); - gc->guardian[0].visible = atoi (sql_row[10]); - gc->guardian[1].visible = atoi (sql_row[11]); - gc->guardian[2].visible = atoi (sql_row[12]); - gc->guardian[3].visible = atoi (sql_row[13]); - gc->guardian[4].visible = atoi (sql_row[14]); - gc->guardian[5].visible = atoi (sql_row[15]); - gc->guardian[6].visible = atoi (sql_row[16]); - gc->guardian[7].visible = atoi (sql_row[17]); - gc->guardian[0].hp = atoi (sql_row[18]); - gc->guardian[1].hp = atoi (sql_row[19]); - gc->guardian[2].hp = atoi (sql_row[20]); - gc->guardian[3].hp = atoi (sql_row[21]); - gc->guardian[4].hp = atoi (sql_row[22]); - gc->guardian[5].hp = atoi (sql_row[23]); - gc->guardian[6].hp = atoi (sql_row[24]); - gc->guardian[7].hp = atoi (sql_row[25]); - - if (save_log) - ShowInfo("Loaded Castle %d (guild %d)\n",castle_id,gc->guild_id); - - } - mysql_free_result(sql_res) ; //resource free - + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_FreeResult(sql_handle); + return 1; //Assume empty castle. + } + + Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); + Sql_GetData(sql_handle, 18, &data, NULL); gc->guardian[0].hp = atoi(data); + Sql_GetData(sql_handle, 19, &data, NULL); gc->guardian[1].hp = atoi(data); + Sql_GetData(sql_handle, 20, &data, NULL); gc->guardian[2].hp = atoi(data); + Sql_GetData(sql_handle, 21, &data, NULL); gc->guardian[3].hp = atoi(data); + Sql_GetData(sql_handle, 22, &data, NULL); gc->guardian[4].hp = atoi(data); + Sql_GetData(sql_handle, 23, &data, NULL); gc->guardian[5].hp = atoi(data); + Sql_GetData(sql_handle, 24, &data, NULL); gc->guardian[6].hp = atoi(data); + Sql_GetData(sql_handle, 25, &data, NULL); gc->guardian[7].hp = atoi(data); + + Sql_FreeResult(sql_handle); memcpy(&castles[castle_id],gc,sizeof(struct guild_castle)); + if( save_log ) + ShowInfo("Loaded Castle %d (guild %d)\n", castle_id, gc->guild_id); + return 1; } @@ -740,20 +699,24 @@ int inter_guild_CharOnline(int char_id, int guild_id) { if (guild_id == -1) { //Get guild_id from the database - sprintf (tmp_sql , "SELECT guild_id FROM `%s` WHERE char_id='%d'",char_db,char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if(sql_res == NULL) - return 0; //Eh? No guild? - - sql_row = mysql_fetch_row(sql_res); - guild_id = sql_row?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); + } + else + { + guild_id = 0; + } + Sql_FreeResult(sql_handle); } if (guild_id == 0) return 0; //No guild... @@ -785,20 +748,24 @@ int inter_guild_CharOffline(int char_id, int guild_id) { if (guild_id == -1) { //Get guild_id from the database - sprintf (tmp_sql , "SELECT guild_id FROM `%s` WHERE char_id='%d'",char_db,char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if(sql_res == NULL) - return 0; //Eh? No guild? - - sql_row = mysql_fetch_row(sql_res); - guild_id = sql_row?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); + } + else + { + guild_id = 0; + } + Sql_FreeResult(sql_handle); } if (guild_id == 0) return 0; //No guild... @@ -860,23 +827,28 @@ void inter_guild_sql_final(void) int search_guildname(char *str) { int guild_id; - char t_name[NAME_LENGTH*2]; + char esc_name[NAME_LENGTH*2+1]; - jstrescapecpy(t_name, str); + Sql_EscapeStringLen(sql_handle, esc_name, str, strnlen(str, NAME_LENGTH)); //Lookup guilds with the same name - sprintf (tmp_sql , "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, t_name); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) ) + { + Sql_ShowDebug(sql_handle); return -1; } - sql_res = mysql_store_result(&mysql_handle) ; - if(sql_res) - sql_row = mysql_fetch_row(sql_res); - - guild_id = (sql_row&&sql_res&&sql_row[0])?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); + } + else + { + guild_id = 0; + } + Sql_FreeResult(sql_handle); return guild_id; } @@ -1228,56 +1200,58 @@ int mapif_guild_castle_datasave(int castle_id,int index,int value) // castle_id = atoi(sql_row[0]); - gc->guild_id = atoi(sql_row[1]); - gc->economy = atoi(sql_row[2]); - gc->defense = atoi(sql_row[3]); - gc->triggerE = atoi(sql_row[4]); - gc->triggerD = atoi(sql_row[5]); - gc->nextTime = atoi(sql_row[6]); - gc->payTime = atoi(sql_row[7]); - gc->createTime = atoi(sql_row[8]); - gc->visibleC = atoi(sql_row[9]); - gc->guardian[0].visible = atoi(sql_row[10]); - gc->guardian[1].visible = atoi(sql_row[11]); - gc->guardian[2].visible = atoi(sql_row[12]); - gc->guardian[3].visible = atoi(sql_row[13]); - gc->guardian[4].visible = atoi(sql_row[14]); - gc->guardian[5].visible = atoi(sql_row[15]); - gc->guardian[6].visible = atoi(sql_row[16]); - gc->guardian[7].visible = atoi(sql_row[17]); - gc->guardian[0].visible = atoi(sql_row[18]); - gc->guardian[1].visible = atoi(sql_row[19]); - gc->guardian[2].visible = atoi(sql_row[20]); - gc->guardian[3].visible = atoi(sql_row[21]); - gc->guardian[4].visible = atoi(sql_row[22]); - gc->guardian[5].visible = atoi(sql_row[23]); - gc->guardian[6].visible = atoi(sql_row[24]); - gc->guardian[7].visible = atoi(sql_row[25]); - memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle)); - len += sizeof(struct guild_castle); - } - mysql_free_result(sql_res); - } - WFIFOW(fd,2) = len; - WFIFOSET(fd,len); - - aFree(gc); +int mapif_guild_castle_alldataload(int fd) +{ + struct guild_castle s_gc; + struct guild_castle* gc = &s_gc; + int i; + int off; + char* data; + WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle)); + WFIFOW(fd, 0) = 0x3842; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, " + "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," + "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7` FROM `%s` ORDER BY `castle_id`", guild_castle_db) ) + Sql_ShowDebug(sql_handle); + for( i = 0, off = 4; i < MAX_GUILDCASTLE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + memset(gc, 0, sizeof(struct guild_castle)); + + Sql_GetData(sql_handle, 0, &data, NULL); gc->castle_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); + Sql_GetData(sql_handle, 18, &data, NULL); gc->guardian[0].hp = atoi(data); + Sql_GetData(sql_handle, 19, &data, NULL); gc->guardian[1].hp = atoi(data); + Sql_GetData(sql_handle, 20, &data, NULL); gc->guardian[2].hp = atoi(data); + Sql_GetData(sql_handle, 21, &data, NULL); gc->guardian[3].hp = atoi(data); + Sql_GetData(sql_handle, 22, &data, NULL); gc->guardian[4].hp = atoi(data); + Sql_GetData(sql_handle, 23, &data, NULL); gc->guardian[5].hp = atoi(data); + Sql_GetData(sql_handle, 24, &data, NULL); gc->guardian[6].hp = atoi(data); + Sql_GetData(sql_handle, 25, &data, NULL); gc->guardian[7].hp = atoi(data); + + memcpy(WFIFOP(fd, off), gc, sizeof(struct guild_castle)); + off += sizeof(struct guild_castle); + } + Sql_FreeResult(sql_handle); + WFIFOW(fd, 2) = off; + WFIFOSET(fd, off); + return 0; } @@ -1462,11 +1436,8 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl g->save_flag |= GS_EXPULSION; }else{ // Unknown guild, just update the player - sprintf(tmp_sql, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'",char_db, account_id,char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); /* mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); */ } @@ -1542,66 +1513,39 @@ int mapif_parse_BreakGuild(int fd,int guild_id) // Delete guild from sql //printf("- Delete guild %d from guild\n",guild_id); - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) ) + Sql_ShowDebug(sql_handle); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) ) + Sql_ShowDebug(sql_handle); //printf("- Update guild %d of char\n",guild_id); - sprintf(tmp_sql, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'",char_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) ) + Sql_ShowDebug(sql_handle); mapif_guild_broken(guild_id,0); - + if(log_inter) inter_log("guild %s (id=%d) broken\n",g->name,guild_id); - + //Remove the guild from memory. [Skotlex] idb_remove(guild_db_, guild_id); return 0; diff --git a/src/char_sql/int_guild.h b/src/char_sql/int_guild.h index f8b3e98c5..ade191e9f 100644 --- a/src/char_sql/int_guild.h +++ b/src/char_sql/int_guild.h @@ -4,17 +4,6 @@ #ifndef _INT_GUILD_SQL_H_ #define _INT_GUILD_SQL_H_ -int inter_guild_parse_frommap(int fd); -int inter_guild_sql_init(void); -void inter_guild_sql_final(void); -int inter_guild_mapif_init(int fd); -int inter_guild_leave(int guild_id,int account_id,int char_id); -int mapif_parse_BreakGuild(int fd,int guild_id); -int inter_guild_broken(int guild_id); -int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender); -int inter_guild_CharOnline(int char_id, int guild_id); -int inter_guild_CharOffline(int char_id, int guild_id); - #define GS_BASIC 0x0001 #define GS_MEMBER 0x0002 #define GS_POSITION 0x0004 @@ -29,6 +18,20 @@ int inter_guild_CharOffline(int char_id, int guild_id); #define GS_BASIC_MASK (GS_BASIC | GS_EMBLEM | GS_CONNECT | GS_LEVEL | GS_MES) #define GS_REMOVE 0x8000 +struct guild; +struct guild_castle; + +int inter_guild_parse_frommap(int fd); +int inter_guild_sql_init(void); +void inter_guild_sql_final(void); +int inter_guild_mapif_init(int fd); +int inter_guild_leave(int guild_id,int account_id,int char_id); +int mapif_parse_BreakGuild(int fd,int guild_id); +int inter_guild_broken(int guild_id); +int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender); +int inter_guild_CharOnline(int char_id, int guild_id); +int inter_guild_CharOffline(int char_id, int guild_id); + //For the TXT->SQL converter. int inter_guild_tosql(struct guild *g,int flag); int inter_guildcastle_tosql(struct guild_castle *gc); diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c index 42f4ef225..5c0c81f05 100644 --- a/src/char_sql/int_homun.c +++ b/src/char_sql/int_homun.c @@ -1,14 +1,19 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - -#include "char.h" +#include "../common/mmo.h" #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include +#include +#include struct s_homunculus *homun_pt; @@ -68,154 +73,150 @@ int mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, un // Save/Update Homunculus Skills int mapif_save_homunculus_skills(struct s_homunculus *hd) { + SqlStmt* stmt; int i; - for(i=0; ihom_id) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < MAX_HOMUNSKILL; ++i ) { - if(hd->hskill[i].id != 0 && hd->hskill[i].lv != 0 ) + if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 ) { - sprintf(tmp_sql,"REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, %d, %d)", - hd->hom_id, hd->hskill[i].id, hd->hskill[i].lv); - - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0); + SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0); + if( SQL_ERROR == SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return 0; } } } + SqlStmt_Free(stmt); return 1; } int mapif_save_homunculus(int fd, int account_id, struct s_homunculus *hd) { - int flag =1; - char t_name[NAME_LENGTH*2]; - jstrescapecpy(t_name, hd->name); + int flag = 1; + char esc_name[NAME_LENGTH*2+1]; - if(hd->hom_id==0) // new homunculus - { - sprintf(tmp_sql, "INSERT INTO `homunculus` " + Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH)); + + if( hd->hom_id == 0 ) + {// new homunculus + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` " "(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) " "VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - hd->char_id, hd->class_,t_name,hd->level,hd->exp,hd->intimacy,hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, - hd->hp,hd->max_hp,hd->sp,hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize); - + hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, + hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) ) + { + Sql_ShowDebug(sql_handle); + flag = 0; + } + else + { + hd->hom_id = (int)Sql_LastInsertId(sql_handle); + } } else { - sprintf(tmp_sql, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'", - hd->char_id, hd->class_,t_name,hd->level,hd->exp,hd->intimacy,hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, - hd->hp,hd->max_hp,hd->sp,hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id); - } - - if(mysql_query(&mysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - flag = 0; + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'", + hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, + hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) ) + { + Sql_ShowDebug(sql_handle); + flag = 0; + } + else + { + flag = mapif_save_homunculus_skills(hd); + mapif_saved_homunculus(fd, account_id, flag); + } } - if(hd->hom_id==0 && flag!=0) - hd->hom_id = (int)mysql_insert_id(&mysql_handle); // new homunculus - else - { - flag = mapif_save_homunculus_skills(hd); - mapif_saved_homunculus(fd, account_id, flag); - } return flag; } // Load an homunculus -int mapif_load_homunculus(int fd){ +int mapif_load_homunculus(int fd) +{ int i; - RFIFOHEAD(fd); - memset(homun_pt, 0, sizeof(struct s_homunculus)); + char* data; + size_t len; - sprintf(tmp_sql,"SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", RFIFOL(fd,6)); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + memset(homun_pt, 0, sizeof(struct s_homunculus)); + RFIFOHEAD(fd); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", RFIFOL(fd,6)) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { - sql_row = mysql_fetch_row(sql_res); - - homun_pt->hom_id = RFIFOL(fd,6) ; //RFIFOL(fd,2); - homun_pt->class_ = atoi(sql_row[2]); - strncpy(homun_pt->name, sql_row[3], NAME_LENGTH); - homun_pt->char_id = atoi(sql_row[1]); - homun_pt->level = atoi(sql_row[4]); - homun_pt->exp = atoi(sql_row[5]); - homun_pt->intimacy = atoi(sql_row[6]); - homun_pt->hunger = atoi(sql_row[7]); - homun_pt->str = atoi(sql_row[8]); - homun_pt->agi = atoi(sql_row[9]); - homun_pt->vit = atoi(sql_row[10]); - homun_pt->int_ = atoi(sql_row[11]); - homun_pt->dex = atoi(sql_row[12]); - homun_pt->luk = atoi(sql_row[13]); - homun_pt->hp = atoi(sql_row[14]); - homun_pt->max_hp = atoi(sql_row[15]); - homun_pt->sp = atoi(sql_row[16]); - homun_pt->max_sp = atoi(sql_row[17]); - homun_pt->skillpts = atoi(sql_row[18]); - homun_pt->rename_flag = atoi(sql_row[19]); - homun_pt->vaporize = atoi(sql_row[20]); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + homun_pt->hom_id = RFIFOL(fd,6); + Sql_GetData(sql_handle, 1, &data, NULL); homun_pt->char_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); homun_pt->class_ = atoi(data); + Sql_GetData(sql_handle, 3, &data, &len); memcpy(homun_pt->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 4, &data, NULL); homun_pt->level = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); homun_pt->exp = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); homun_pt->intimacy = (unsigned int)strtoul(data, NULL, 10); + homun_pt->intimacy = cap_value(homun_pt->intimacy, 0, 100000); + Sql_GetData(sql_handle, 7, &data, NULL); homun_pt->hunger = atoi(data); + homun_pt->hunger = cap_value(homun_pt->hunger, 0, 100); + Sql_GetData(sql_handle, 8, &data, NULL); homun_pt->str = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); homun_pt->agi = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); homun_pt->vit = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); homun_pt->int_ = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); homun_pt->dex = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); homun_pt->luk = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); homun_pt->hp = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); homun_pt->max_hp = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); homun_pt->sp = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); homun_pt->max_sp = atoi(data); + Sql_GetData(sql_handle, 18, &data, NULL); homun_pt->skillpts = atoi(data); + Sql_GetData(sql_handle, 19, &data, NULL); homun_pt->rename_flag = atoi(data); + Sql_GetData(sql_handle, 20, &data, NULL); homun_pt->vaporize = atoi(data); + + Sql_FreeResult(sql_handle); } - if(homun_pt->hunger < 0) - homun_pt->hunger = 0; - else if(homun_pt->hunger > 100) - homun_pt->hunger = 100; - if(homun_pt->intimacy > 100000) - homun_pt->intimacy = 100000; - - mysql_free_result(sql_res); // Load Homunculus Skill - memset(homun_pt->hskill, 0, sizeof(homun_pt->hskill)); - - sprintf(tmp_sql,"SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d",homun_pt->hom_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d", homun_pt->hom_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle); - if(sql_res){ - while((sql_row = mysql_fetch_row(sql_res))){ - i = (atoi(sql_row[0])-HM_SKILLBASE-1); - homun_pt->hskill[i].id = atoi(sql_row[0]); - homun_pt->hskill[i].lv = atoi(sql_row[1]); - } - } - - mysql_free_result(sql_res); - - if (save_log) + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + // id + Sql_GetData(sql_handle, 0, &data, NULL); + i = atoi(data); + if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL ) + continue;// invalid guild skill + homun_pt->hskill[i].id = (unsigned short)i; + // lv + Sql_GetData(sql_handle, 1, &data, NULL); + homun_pt->hskill[i].lv = (unsigned short)atoi(data); + } + Sql_FreeResult(sql_handle); + + if( save_log ) ShowInfo("Homunculus loaded (%d - %s).\n", homun_pt->hom_id, homun_pt->name); return mapif_info_homunculus(fd, RFIFOL(fd,2), homun_pt); } int inter_delete_homunculus(int hom_id) { - sprintf(tmp_sql, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", hom_id); - if(mysql_query(&mysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - - sprintf(tmp_sql, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", hom_id); - if(mysql_query(&mysql_handle, tmp_sql)) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", hom_id) || + SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", hom_id) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(sql_handle); return 0; } return 1; diff --git a/src/char_sql/int_homun.h b/src/char_sql/int_homun.h index fa49c659f..d990b2219 100644 --- a/src/char_sql/int_homun.h +++ b/src/char_sql/int_homun.h @@ -4,6 +4,8 @@ #ifndef _INT_HOMUN_SQL_H_ #define _INT_HOMUN_SQL_H_ +struct s_homunculus; + int inter_homunculus_sql_init(void); void inter_homunculus_sql_final(void); int mapif_save_homunculus(struct s_homunculus *hd); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index c1c09e9a4..f6d783b3b 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -1,18 +1,22 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - #include "../common/cbasetypes.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/socket.h" #include "../common/showmsg.h" - +#include "../common/mapindex.h" +#include "../common/sql.h" #include "char.h" +#include "inter.h" +#include "int_party.h" + +#include +#include +#include #ifndef TXT_SQL_CONVERT struct party_data { @@ -103,108 +107,88 @@ static void int_party_calc_state(struct party_data *p) int inter_party_tosql(struct party *p, int flag, int index) { // 'party' ('party_id','name','exp','item','leader_id','leader_char') - char t_name[NAME_LENGTH*2]; //Required for jstrescapecpy [Skotlex] + char esc_name[NAME_LENGTH*2+1];// escaped party name int party_id; - if (p == NULL || p->party_id == 0) + + if( p == NULL || p->party_id == 0 ) return 0; party_id = p->party_id; #ifdef NOISY ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name); #endif - jstrescapecpy(t_name, p->name); + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); #ifndef TXT_SQL_CONVERT - if (flag&PS_BREAK) { //Break the party + if( flag & PS_BREAK ) + {// Break the party // we'll skip name-checking and just reset everyone with the same party id [celest] - sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) + Sql_ShowDebug(sql_handle); //Remove from memory idb_remove(party_db_, party_id); return 1; } #endif //TXT_SQL_CONVERT - if(flag&PS_CREATE) { //Create party + if( flag & PS_CREATE ) + {// Create party #ifndef TXT_SQL_CONVERT - sprintf(tmp_sql, "INSERT INTO `%s` " + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " "(`name`, `exp`, `item`, `leader_id`, `leader_char`) " "VALUES ('%s', '%d', '%d', '%d', '%d')", - party_db, t_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - if(mysql_field_count(&mysql_handle) == 0 && - mysql_insert_id(&mysql_handle) != 0) - party_id = p->party_id = (int)mysql_insert_id(&mysql_handle); - else //Failed to retrieve ID?? - return 0; + party_id = p->party_id = (int)Sql_LastInsertId(sql_handle); #else //During conversion, you want to specify the id, and allow overwriting //(in case someone is re-running the process. - sprintf(tmp_sql, "REPLACE INTO `%s` " + + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " "(`party_id`, `name`, `exp`, `item`, `leader_id`, `leader_char`) " "VALUES ('%d', '%s', '%d', '%d', '%d', '%d')", - party_db, p->party_id, t_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + party_db, p->party_id, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } #endif } #ifndef TXT_SQL_CONVERT - if (flag&PS_BASIC) { - //Update party info. - sprintf(tmp_sql, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'", - party_db, t_name, p->exp, p->item, party_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( flag & PS_BASIC ) + {// Update party info. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'", + party_db, esc_name, p->exp, p->item, party_id) ) + Sql_ShowDebug(sql_handle); } - if (flag&PS_LEADER) { - //Update leader - sprintf(tmp_sql, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'", - party_db, p->member[index].account_id, p->member[index].char_id, party_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( flag & PS_LEADER ) + {// Update leader + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'", + party_db, p->member[index].account_id, p->member[index].char_id, party_id) ) + Sql_ShowDebug(sql_handle); } - if (flag&PS_ADDMEMBER) { - //Add one party member. - sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'", - char_db, party_id, p->member[index].account_id, p->member[index].char_id); - if (mysql_query (&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( flag & PS_ADDMEMBER ) + {// Add one party member. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'", + char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) + Sql_ShowDebug(sql_handle); } - if (flag&PS_DELMEMBER) { - //Remove one party member. - sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'", - char_db, party_id, p->member[index].account_id, p->member[index].char_id); - if (mysql_query (&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( flag & PS_DELMEMBER ) + {// Remove one party member. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'", + char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) + Sql_ShowDebug(sql_handle); } #endif //TXT_SQL_CONVERT - if (save_log) + if( save_log ) ShowInfo("Party Saved (%d - %s)\n", party_id, p->name); return 1; } @@ -212,74 +196,69 @@ int inter_party_tosql(struct party *p, int flag, int index) // Read party from mysql struct party_data *inter_party_fromsql(int party_id) { - int leader_id = 0, leader_char = 0; - struct party_data *p; + int leader_id = 0; + int leader_char = 0; + struct party_data* p; + struct party_member* m; + char* data; + size_t len; + int i; + #ifdef NOISY ShowInfo("Load party request ("CL_BOLD"%d"CL_RESET")\n", party_id); #endif - if (party_id <=0) + if( party_id <= 0 ) return NULL; //Load from memory - if ((p = idb_get(party_db_, party_id)) != NULL) + p = idb_get(party_db_, party_id); + if( p != NULL ) return p; - + p = party_pt; memset(p, 0, sizeof(struct party_data)); - sprintf(tmp_sql, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", - party_db, party_id); // TBR - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) + { + Sql_ShowDebug(sql_handle); return NULL; } - sql_res = mysql_store_result(&mysql_handle) ; - if (!sql_res) + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) return NULL; - sql_row = mysql_fetch_row(sql_res); - if (!sql_row) { - mysql_free_result(sql_res); - return NULL; - } + p->party.party_id = party_id; - strncpy(p->party.name, sql_row[1], NAME_LENGTH); - p->party.exp = atoi(sql_row[2])?1:0; - p->party.item = atoi(sql_row[3]); - leader_id = atoi(sql_row[4]); - leader_char = atoi(sql_row[5]); - mysql_free_result(sql_res); + Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0); + Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data); + Sql_FreeResult(sql_handle); // Load members - sprintf(tmp_sql,"SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", - char_db, party_id); // TBR - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) ) + { + Sql_ShowDebug(sql_handle); return NULL; } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - int i; - for (i = 0; iparty.member[i]; - m->account_id = atoi(sql_row[0]); - m->char_id = atoi(sql_row[1]); - m->leader = (m->account_id == leader_id && m->char_id == leader_char)?1:0; - memcpy(m->name, sql_row[2], NAME_LENGTH); - m->lv = atoi(sql_row[3]); - m->map = mapindex_name2id(sql_row[4]); - m->online = atoi(sql_row[5])?1:0; - m->class_ = atoi(sql_row[6]); - } - mysql_free_result(sql_res); - } - - if (save_log) - ShowInfo("Party loaded (%d - %s).\n",party_id, p->party.name); + for( i = 0; i < MAX_PARTY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + m = &p->party.member[i]; + Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data); + Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0); + Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data); + m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0); + } + Sql_FreeResult(sql_handle); + + if( save_log ) + ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name); //Add party to memory. - p = aCalloc(1, sizeof(struct party_data)); + CREATE(p, struct party_data, 1); memcpy(p, party_pt, sizeof(struct party_data)); //init state int_party_calc_state(p); @@ -299,13 +278,9 @@ int inter_party_sql_init(void) /* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex] ShowStatus("cleaning party table...\n"); - sprintf (tmp_sql, - "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL", - party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL", + party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) ) + Sql_ShowDebug(sql_handle); */ return 0; } @@ -318,27 +293,23 @@ void inter_party_sql_final(void) } // Search for the party according to its name -struct party_data* search_partyname(char *str) +struct party_data* search_partyname(char* str) { - char t_name[NAME_LENGTH*2]; - int party_id; - - sprintf(tmp_sql,"SELECT `party_id` FROM `%s` WHERE `name`='%s'",party_db, jstrescapecpy(t_name,str)); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res==NULL || mysql_num_rows(sql_res)<=0) + char esc_name[NAME_LENGTH*2+1]; + char* data; + struct party_data* p = NULL; + + Sql_EscapeStringLen(sql_handle, esc_name, str, strnlen(str, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) { - if (sql_res) mysql_free_result(sql_res); - return NULL; + Sql_GetData(sql_handle, 0, &data, NULL); + p = inter_party_fromsql(atoi(data)); } - sql_row = mysql_fetch_row(sql_res); - party_id = sql_row?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + Sql_FreeResult(sql_handle); - return inter_party_fromsql(party_id); + return p; } // Returns whether this party can keep having exp share or not. @@ -627,12 +598,10 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) int i,j=-1; p = inter_party_fromsql(party_id); - if (!p) { //Party does not exists? - sprintf(tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( p == NULL ) + {// Party does not exists? + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) + Sql_ShowDebug(sql_handle); return 0; } @@ -809,26 +778,27 @@ int inter_party_leave(int party_id,int account_id, int char_id) return mapif_parse_PartyLeave(-1,party_id,account_id, char_id); } -int inter_party_CharOnline(int char_id, int party_id) { - struct party_data *p; - int i; - - if (party_id == -1) { - //Get party_id from the database - sprintf (tmp_sql , "SELECT party_id FROM `%s` WHERE char_id='%d'",char_db,char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); +int inter_party_CharOnline(int char_id, int party_id) +{ + struct party_data* p; + int i; + + if( party_id == -1 ) + {// Get party_id from the database + char* data; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if(sql_res == NULL) + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) return 0; //Eh? No party? - - sql_row = mysql_fetch_row(sql_res); - party_id = sql_row?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + + Sql_GetData(sql_handle, 0, &data, NULL); + party_id = atoi(data); + Sql_FreeResult(sql_handle); } if (party_id == 0) return 0; //No party... @@ -859,22 +829,22 @@ int inter_party_CharOffline(int char_id, int party_id) { struct party_data *p=NULL; int i; - if (party_id == -1) { - //Get guild_id from the database - sprintf (tmp_sql , "SELECT party_id FROM `%s` WHERE char_id='%d'",char_db,char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( party_id == -1 ) + {// Get guild_id from the database + char* data; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if(sql_res == NULL) + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) return 0; //Eh? No party? - - sql_row = mysql_fetch_row(sql_res); - party_id = sql_row?atoi(sql_row[0]):0; - mysql_free_result(sql_res); + + Sql_GetData(sql_handle, 0, &data, NULL); + party_id = atoi(data); + Sql_FreeResult(sql_handle); } if (party_id == 0) return 0; //No party... diff --git a/src/char_sql/int_party.h b/src/char_sql/int_party.h index c244ab59e..d7965c33b 100644 --- a/src/char_sql/int_party.h +++ b/src/char_sql/int_party.h @@ -18,6 +18,8 @@ //Specify that this party must be deleted. #define PS_BREAK 0x20 +struct party; + int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 6352412ce..3ce7c4559 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -1,53 +1,52 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - -#include "char.h" +#include "../common/mmo.h" #include "../common/malloc.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include +#include +#include struct s_pet *pet_pt; //--------------------------------------------------------- -int inter_pet_tosql(int pet_id, struct s_pet *p) { +int inter_pet_tosql(int pet_id, struct s_pet* p) +{ //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - char t_name[NAME_LENGTH*2]; - - jstrescapecpy(t_name, p->name); - - if(p->hungry < 0) - p->hungry = 0; - else if(p->hungry > 100) - p->hungry = 100; - if(p->intimate < 0) - p->intimate = 0; - else if(p->intimate > 1000) - p->intimate = 1000; - if (pet_id == -1) //New pet. - sprintf(tmp_sql,"INSERT INTO `%s` " + char esc_name[NAME_LENGTH*2+1];// escaped pet name + + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + p->hungry = cap_value(p->hungry, 0, 100); + p->intimate = cap_value(p->intimate, 0, 1000); + + if( pet_id == -1 ) + {// New pet. + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " "(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) " "VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - pet_db, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, - p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate); - - else //Update pet. - sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - pet_db, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, - p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } else if (pet_id == -1) { //New pet inserted. - if(mysql_field_count(&mysql_handle) == 0 && - mysql_insert_id(&mysql_handle) != 0) { - p->pet_id = pet_id = (int)mysql_insert_id(&mysql_handle); - } else { - ShowError("inter_pet_tosql: Failed to retrieve new pet_id for '%s'. Pet creation aborted.\n", p->name); + pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, + p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + p->pet_id = (int)Sql_LastInsertId(sql_handle); + } + else + {// Update pet. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", + pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, + p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } } @@ -57,7 +56,10 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { return 1; } #ifndef TXT_SQL_CONVERT -int inter_pet_fromsql(int pet_id, struct s_pet *p){ +int inter_pet_fromsql(int pet_id, struct s_pet* p) +{ + char* data; + size_t len; #ifdef NOISY ShowInfo("Loading pet (%d)...\n",pet_id); @@ -66,42 +68,35 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){ //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - sprintf(tmp_sql,"SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'",pet_db, pet_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) + { + Sql_ShowDebug(sql_handle); return 0; } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { - sql_row = mysql_fetch_row(sql_res); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { p->pet_id = pet_id; - p->class_ = atoi(sql_row[1]); - strncpy(p->name, sql_row[2], NAME_LENGTH); - p->account_id = atoi(sql_row[3]); - p->char_id = atoi(sql_row[4]); - p->level = atoi(sql_row[5]); - p->egg_id = atoi(sql_row[6]); - p->equip = atoi(sql_row[7]); - p->intimate = atoi(sql_row[8]); - p->hungry = atoi(sql_row[9]); - p->rename_flag = atoi(sql_row[10]); - p->incuvate = atoi(sql_row[11]); + Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); p->incuvate = atoi(data); + + Sql_FreeResult(sql_handle); + + p->hungry = cap_value(p->hungry, 0, 100); + p->intimate = cap_value(p->intimate, 0, 1000); + + if( save_log ) + ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name); } - if(p->hungry < 0) - p->hungry = 0; - else if(p->hungry > 100) - p->hungry = 100; - if(p->intimate < 0) - p->intimate = 0; - else if(p->intimate > 1000) - p->intimate = 1000; - - mysql_free_result(sql_res); - - if (save_log) - ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name); return 0; } //---------------------------------------------- @@ -119,11 +114,8 @@ void inter_pet_sql_final(void){ int inter_pet_delete(int pet_id){ ShowInfo("delete pet request: %d...\n",pet_id); - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `pet_id`='%d'",pet_db, pet_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) + Sql_ShowDebug(sql_handle); return 0; } //------------------------------------------------------ diff --git a/src/char_sql/int_pet.h b/src/char_sql/int_pet.h index 5c1955857..733468c77 100644 --- a/src/char_sql/int_pet.h +++ b/src/char_sql/int_pet.h @@ -4,6 +4,8 @@ #ifndef _INT_PET_SQL_H_ #define _INT_PET_SQL_H_ +struct s_pet; + int inter_pet_init(void); void inter_pet_sql_final(void); int inter_pet_save(void); diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index a52e5b530..b13f37200 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -1,17 +1,19 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -// original code from athena -// SQL conversion by Jioh L. Jung +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" // StringBuf +#include "../common/sql.h" +#include "char.h" +#include "inter.h" #include #include #include -#include "char.h" -#include "itemdb.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" #define STORAGE_MEMINC 16 @@ -19,166 +21,130 @@ // reset by inter_config_read() struct storage *storage_pt=NULL; struct guild_storage *guild_storage_pt=NULL; - #endif //TXT_SQL_CONVERT -// storage data -> DB conversion -int storage_tosql(int account_id,struct storage *p){ - int i,j; -// int eqcount=1; -// int noteqcount=1; - int count=0; - struct itemtmp mapitem[MAX_STORAGE]; - for(i=0;istorage_[i].nameid>0){ - mapitem[count].flag=0; - mapitem[count].id = p->storage_[i].id; - mapitem[count].nameid=p->storage_[i].nameid; - mapitem[count].amount = p->storage_[i].amount; - mapitem[count].equip = p->storage_[i].equip; - mapitem[count].identify = p->storage_[i].identify; - mapitem[count].refine = p->storage_[i].refine; - mapitem[count].attribute = p->storage_[i].attribute; - for(j=0; jstorage_[i].card[j]; - count++; - } - } - memitemdata_to_sql(mapitem, count, account_id,TABLE_STORAGE); - - //printf ("storage dump to DB - id: %d (total: %d)\n", account_id, j); +/// Save guild_storage data to sql +int storage_tosql(int account_id,struct storage* p) +{ + memitemdata_to_sql(p->storage_, MAX_STORAGE, account_id, TABLE_STORAGE); + //ShowInfo ("storage save to DB - account: %d\n", account_id); return 0; } -#ifndef TXT_SQL_CONVERT -// DB -> storage data conversion -int storage_fromsql(int account_id, struct storage *p){ - int i=0,j; - char * str_p = tmp_sql; +#ifndef TXT_SQL_CONVERT +/// Load guild_storage data to mem +int storage_fromsql(int account_id, struct storage* p) +{ + StringBuf buf; + struct item* item; + char* data; + int i; + int j; - memset(p,0,sizeof(struct storage)); //clean up memory + memset(p, 0, sizeof(struct storage)); //clean up memory p->storage_amount = 0; p->account_id = account_id; // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} - str_p += sprintf(str_p,"SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); - - for (j=0; jstorage_[i].id= atoi(sql_row[0]); - p->storage_[i].nameid= atoi(sql_row[1]); - p->storage_[i].amount= atoi(sql_row[2]); - p->storage_[i].equip= atoi(sql_row[3]); - p->storage_[i].identify= atoi(sql_row[4]); - p->storage_[i].refine= atoi(sql_row[5]); - p->storage_[i].attribute= atoi(sql_row[6]); - for (j=0; jstorage_[i].card[j]= atoi(sql_row[7+j]); - i++; + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Destroy(&buf); + + for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + item = &p->storage_[i]; + Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); + for( j = 0; j < MAX_SLOTS; ++j ) + { + Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data); } - p->storage_amount = i; - mysql_free_result(sql_res); } + p->storage_amount = i; + Sql_FreeResult(sql_handle); - ShowInfo ("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount); + ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount); return 1; } #endif //TXT_SQL_CONVERT -// Save guild_storage data to sql -int guild_storage_tosql(int guild_id, struct guild_storage *p){ - int i,j; -// int eqcount=1; -// int noteqcount=1; - int count=0; - struct itemtmp mapitem[MAX_GUILD_STORAGE]; - for(i=0;istorage_[i].nameid>0){ - mapitem[count].flag=0; - mapitem[count].id = p->storage_[i].id; - mapitem[count].nameid=p->storage_[i].nameid; - mapitem[count].amount = p->storage_[i].amount; - mapitem[count].equip = p->storage_[i].equip; - mapitem[count].identify = p->storage_[i].identify; - mapitem[count].refine = p->storage_[i].refine; - mapitem[count].attribute = p->storage_[i].attribute; - for (j=0; jstorage_[i].card[j]; - count++; - } - } - memitemdata_to_sql(mapitem, count, guild_id,TABLE_GUILD_STORAGE); - - ShowInfo ("guild storage save to DB - id: %d (total: %d)\n", guild_id,i); +/// Save guild_storage data to sql +int guild_storage_tosql(int guild_id, struct guild_storage* p) +{ + memitemdata_to_sql(p->storage_, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE); + ShowInfo ("guild storage save to DB - guild: %d\n", guild_id); return 0; } + #ifndef TXT_SQL_CONVERT -// Load guild_storage data to mem -int guild_storage_fromsql(int guild_id, struct guild_storage *p){ - int i=0,j; - struct guild_storage *gs=guild_storage_pt; - char * str_p = tmp_sql; - p=gs; - - memset(p,0,sizeof(struct guild_storage)); //clean up memory +/// Load guild_storage data to mem +int guild_storage_fromsql(int guild_id, struct guild_storage* p) +{ + StringBuf buf; + struct item* item; + char* data; + int i; + int j; + + memset(p, 0, sizeof(struct guild_storage)); //clean up memory p->storage_amount = 0; p->guild_id = guild_id; // storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} - str_p += sprintf(str_p,"SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); - - for (j=0; jstorage_[i].id= atoi(sql_row[0]); - p->storage_[i].nameid= atoi(sql_row[1]); - p->storage_[i].amount= atoi(sql_row[2]); - p->storage_[i].equip= atoi(sql_row[3]); - p->storage_[i].identify= atoi(sql_row[4]); - p->storage_[i].refine= atoi(sql_row[5]); - p->storage_[i].attribute= atoi(sql_row[6]); - for (j=0; jstorage_[i].card[j] = atoi(sql_row[7+j]); - i++; + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Destroy(&buf); + + for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + item = &p->storage_[i]; + Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); + for( j = 0; j < MAX_SLOTS; ++j ) + { + Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data); } - p->storage_amount = i; - mysql_free_result(sql_res); } - ShowInfo ("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount); + p->storage_amount = i; + Sql_FreeResult(sql_handle); + + ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount); return 0; } //--------------------------------------------------------- // storage data initialize -int inter_storage_sql_init(void){ +int inter_storage_sql_init(void) +{ //memory alloc ShowDebug("interserver storage memory initialize....(%d byte)\n",sizeof(struct storage)); storage_pt = (struct storage*)aCalloc(sizeof(struct storage), 1); guild_storage_pt = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1); -// memset(storage_pt,0,sizeof(struct storage)); //Calloc sets stuff to 0 already. [Skotlex] -// memset(guild_storage_pt,0,sizeof(struct guild_storage)); return 1; } @@ -192,20 +158,14 @@ void inter_storage_sql_final(void) // q?f[^? int inter_storage_delete(int account_id) { - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `account_id`='%d'",storage_db, account_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) ) + Sql_ShowDebug(sql_handle); return 0; } int inter_guild_storage_delete(int guild_id) { - sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_storage_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) ) + Sql_ShowDebug(sql_handle); return 0; } @@ -213,7 +173,8 @@ int inter_guild_storage_delete(int guild_id) // packet from map server // recive packet about storage data -int mapif_load_storage(int fd,int account_id){ +int mapif_load_storage(int fd,int account_id) +{ //load from DB WFIFOHEAD(fd, sizeof(struct storage)+8); storage_fromsql(account_id, storage_pt); @@ -225,7 +186,8 @@ int mapif_load_storage(int fd,int account_id){ return 0; } // send ack to map server which is "storage data save ok." -int mapif_save_storage_ack(int fd,int account_id){ +int mapif_save_storage_ack(int fd,int account_id) +{ WFIFOHEAD(fd, 7); WFIFOW(fd,0)=0x3811; WFIFOL(fd,2)=account_id; @@ -236,40 +198,29 @@ int mapif_save_storage_ack(int fd,int account_id){ int mapif_load_guild_storage(int fd,int account_id,int guild_id) { - int guild_exist=1; - WFIFOHEAD(fd, sizeof(struct guild_storage)+12); - WFIFOW(fd,0)=0x3818; - -#if 0 // innodb guilds should render this check unnecessary [Aru] - // Check if guild exists, I may write a function for this later, coz I use it several times. - //printf("- Check if guild %d exists\n",g->guild_id); - sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { - sql_row = mysql_fetch_row(sql_res); - guild_exist = atoi (sql_row[0]); - //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); - } - mysql_free_result(sql_res) ; //resource free -#endif - if(guild_exist==1) { - guild_storage_fromsql(guild_id,guild_storage_pt); - WFIFOW(fd,2)=sizeof(struct guild_storage)+12; - WFIFOL(fd,4)=account_id; - WFIFOL(fd,8)=guild_id; - memcpy(WFIFOP(fd,12),guild_storage_pt,sizeof(struct guild_storage)); - } - else { - WFIFOW(fd,2)=12; - WFIFOL(fd,4)=account_id; - WFIFOL(fd,8)=0; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + {// guild exists + guild_storage_fromsql(guild_id, guild_storage_pt); + + WFIFOHEAD(fd, sizeof(struct guild_storage)+12); + WFIFOW(fd,0) = 0x3818; + WFIFOW(fd,2) = sizeof(struct guild_storage)+12; + WFIFOL(fd,4) = account_id; + WFIFOL(fd,8) = guild_id; + memcpy(WFIFOP(fd,12), guild_storage_pt, sizeof(struct guild_storage)); + WFIFOSET(fd, WFIFOW(fd,2)); + return 0; } - WFIFOSET(fd,WFIFOW(fd,2)); - + // guild does not exist + Sql_FreeResult(sql_handle); + WFIFOHEAD(fd, 12); + WFIFOW(fd,0) = 0x3818; + WFIFOW(fd,2) = 12; + WFIFOL(fd,4) = account_id; + WFIFOL(fd,8) = 0; + WFIFOSET(fd, 12); return 0; } int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) @@ -287,13 +238,15 @@ int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) // packet from map server // recive request about storage data -int mapif_parse_LoadStorage(int fd){ +int mapif_parse_LoadStorage(int fd) +{ RFIFOHEAD(fd); mapif_load_storage(fd,RFIFOL(fd,2)); return 0; } // storage data recive and save -int mapif_parse_SaveStorage(int fd){ +int mapif_parse_SaveStorage(int fd) +{ int account_id; int len; RFIFOHEAD(fd); @@ -318,45 +271,38 @@ int mapif_parse_LoadGuildStorage(int fd) int mapif_parse_SaveGuildStorage(int fd) { - int guild_exist=1; int guild_id; int len; + RFIFOHEAD(fd); - guild_id=RFIFOL(fd,8); - len=RFIFOW(fd,2); - if(sizeof(struct guild_storage)!=len-12){ - ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12); + guild_id = RFIFOL(fd,8); + len = RFIFOW(fd,2); + + if( sizeof(struct guild_storage) != len - 12 ) + { + ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); } - else { -#if 0 // Again, innodb key checks make the check pointless - // Check if guild exists, I may write a function for this later, coz I use it several times. - //printf("- Check if guild %d exists\n",g->guild_id); - sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { - sql_row = mysql_fetch_row(sql_res); - guild_exist = atoi (sql_row[0]); - //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); + else + { + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + {// guild exists + Sql_FreeResult(sql_handle); + memcpy(guild_storage_pt, RFIFOP(fd,12), sizeof(struct guild_storage)); + guild_storage_tosql(guild_id, guild_storage_pt); + mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); + return 0; } - mysql_free_result(sql_res) ; //resource free -#endif - if(guild_exist==1) { - memcpy(guild_storage_pt,RFIFOP(fd,12),sizeof(struct guild_storage)); - guild_storage_tosql(guild_id,guild_storage_pt); - mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0); - } - else - mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1); + Sql_FreeResult(sql_handle); } + mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1); return 0; } -int inter_storage_parse_frommap(int fd){ +int inter_storage_parse_frommap(int fd) +{ RFIFOHEAD(fd); switch(RFIFOW(fd,0)){ case 0x3010: mapif_parse_LoadStorage(fd); break; diff --git a/src/char_sql/int_storage.h b/src/char_sql/int_storage.h index dd71ef9ed..7075e36ad 100644 --- a/src/char_sql/int_storage.h +++ b/src/char_sql/int_storage.h @@ -4,6 +4,9 @@ #ifndef _INT_STORAGE_SQL_H_ #define _INT_STORAGE_SQL_H_ +struct storage; +struct guild_storage; + int inter_storage_sql_init(void); void inter_storage_sql_final(void); int inter_storage_delete(int account_id); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index fbff7b7fb..201605bd6 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -1,34 +1,31 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include - -#include "char.h" +#include "../common/mmo.h" +#include "../common/db.h" #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "char.h" #include "inter.h" #include "int_party.h" #include "int_guild.h" #include "int_storage.h" #include "int_pet.h" -#include "int_homun.h" //albator +#include "int_homun.h" + +#include +#include +#include #define WISDATA_TTL (60*1000) // Wisƒf[ƒ^‚̶‘¶ŽžŠÔ(60•b) #define WISDELLIST_MAX 256 // Wisƒf[ƒ^íœƒŠƒXƒg‚Ì—v‘f” -MYSQL mysql_handle; -MYSQL_RES* sql_res ; -MYSQL_ROW sql_row ; -int sql_fields, sql_cnt; -char tmp_sql[65535]; - -MYSQL lmysql_handle; -MYSQL_RES* lsql_res ; -MYSQL_ROW lsql_row ; +Sql* sql_handle = NULL; +Sql* lsql_handle = NULL; int char_server_port = 3306; char char_server_ip[32] = "127.0.0.1"; @@ -89,50 +86,59 @@ int inter_sql_test (void); #endif //TXT_SQL_CONVERT //-------------------------------------------------------- // Save registry to sql -int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type){ +int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type) +{ + struct global_reg* r; + SqlStmt* stmt; + int i; - int j; - char temp_str[64]; //Needs be twice the source to ensure it fits [Skotlex] - char temp_str2[512]; - if (account_id<=0) return 0; - reg->account_id=account_id; + if( account_id <= 0 ) + return 0; + reg->account_id = account_id; reg->char_id = char_id; - switch (type) { - case 3: //Char Reg - //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'",reg_db, char_id); - break; - case 2: //Account Reg - //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'",reg_db, account_id); - break; - case 1: //Account2 Reg - ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); - return 0; - default: - ShowError("inter_accreg_tosql: Invalid type %d\n", type); - return 0; - - } - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) + switch( type ) + { + case 3: //Char Reg + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); + account_id = 0; + break; + case 2: //Account Reg + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + char_id = 0; + break; + case 1: //Account2 Reg + ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); + return 0; + default: + ShowError("inter_accreg_tosql: Invalid type %d\n", type); + return 0; } - if (reg->reg_num<=0) return 0; - - for(j=0;jreg_num;j++){ - if(reg->reg[j].str != NULL){ - sprintf(tmp_sql,"INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d','%s','%s')", - reg_db, type, type!=3?reg->account_id:0, type==3?reg->char_id:0, - jstrescapecpy(temp_str,reg->reg[j].str), jstrescapecpy(temp_str2,reg->reg[j].value)); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( reg->reg_num <= 0 ) + return 0; + + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d',?,?)", reg_db, type, account_id, char_id) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < reg->reg_num; ++i ) + { + r = ®->reg[i]; + if( r->str[0] != '\0' && r->value != '\0' ) + { + // str + SqlStmt_BindParam(stmt, 0, SQLDT_STRING, r->str, strnlen(r->str, sizeof(r->str))); + // value + SqlStmt_BindParam(stmt, 1, SQLDT_STRING, r->value, strnlen(r->value, sizeof(r->value))); + + if( SQL_ERROR == SqlStmt_Execute(stmt) ) + SqlStmt_ShowDebug(stmt); } } + SqlStmt_Free(stmt); return 1; } #ifndef TXT_SQL_CONVERT @@ -140,38 +146,48 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type // Load account_reg from sql (type=2) int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type) { - int j=0; - if (reg==NULL) return 0; + struct global_reg* r; + char* data; + size_t len; + int i; + + if( reg == NULL) + return 0; + memset(reg, 0, sizeof(struct accreg)); - reg->account_id=account_id; - reg->char_id=char_id; + reg->account_id = account_id; + reg->char_id = char_id; //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) - switch (type) { + switch( type ) + { case 3: //char reg - sprintf (tmp_sql, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'",reg_db, reg->char_id); - break; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); + break; case 2: //account reg - sprintf (tmp_sql, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'",reg_db, reg->account_id); - break; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + break; case 1: //account2 reg ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); return 0; + default: + ShowError("inter_accreg_fromsql: Invalid type %d\n", type); + return 0; } - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - - if (sql_res) { - for(j=0;(sql_row = mysql_fetch_row(sql_res));j++){ - strcpy(reg->reg[j].str, sql_row[0]); - strcpy(reg->reg[j].value, sql_row[1]); - } - mysql_free_result(sql_res); + for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + r = ®->reg[i]; + // str + Sql_GetData(sql_handle, 0, &data, &len); + memcpy(r->str, data, min(len, sizeof(r->str))); + // value + Sql_GetData(sql_handle, 1, &data, &len); + memcpy(r->value, data, min(len, sizeof(r->value))); } - reg->reg_num=j; + reg->reg_num = i; + Sql_FreeResult(sql_handle); return 1; } @@ -277,18 +293,17 @@ static int inter_config_read(const char* cfgName) int inter_log(char* fmt, ...) { char str[255]; - char temp_str[510]; //Needs be twice as long as str[] //Skotlex + char esc_str[sizeof(str)*2+1];// escaped str va_list ap; + va_start(ap,fmt); + vsnprintf(str, sizeof(str), fmt, ap); + va_end(ap); - vsprintf(str,fmt,ap); - sprintf(tmp_sql,"INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')",interlog_db, jstrescapecpy(temp_str,str)); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + Sql_EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str))); + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) ) + Sql_ShowDebug(sql_handle); - va_end(ap); return 0; } @@ -298,30 +313,23 @@ int inter_log(char* fmt, ...) int inter_sql_ping(int tid, unsigned int tick, int id, int data) { ShowInfo("Pinging SQL server to keep connection alive...\n"); - mysql_ping(&mysql_handle); - if(char_gm_read) - mysql_ping(&lmysql_handle); + Sql_Ping(sql_handle); + if( char_gm_read ) + Sql_Ping(lsql_handle); return 0; } int sql_ping_init(void) { - int connection_timeout, connection_ping_interval; + uint32 connection_timeout, connection_ping_interval; // set a default value first connection_timeout = 28800; // 8 hours // ask the mysql server for the timeout value - if (!mysql_query(&mysql_handle, "SHOW VARIABLES LIKE 'wait_timeout'") - && (sql_res = mysql_store_result(&mysql_handle)) != NULL) { - sql_row = mysql_fetch_row(sql_res); - if (sql_row) - connection_timeout = atoi(sql_row[1]); - if (connection_timeout < 60) - connection_timeout = 60; - mysql_free_result(sql_res); - } + if( SQL_SUCCESS == Sql_GetTimeout(sql_handle, &connection_timeout) && connection_timeout < 60 ) + connection_timeout = 60; // establish keepalive connection_ping_interval = connection_timeout - 30; // 30-second reserve @@ -342,13 +350,13 @@ int inter_init_sql(const char *file) inter_config_read(file); //DB connection initialized - mysql_init(&mysql_handle); + sql_handle = Sql_Malloc(); ShowInfo("Connect Character DB server.... (Character Server)\n"); - if(!mysql_real_connect(&mysql_handle, char_server_ip, char_server_id, char_server_pw, - char_server_db ,char_server_port, (char *)NULL, 0)) { - //pointer check - ShowFatalError("%s\n",mysql_error(&mysql_handle)); - exit(1); + if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(sql_handle); + exit(1); } #ifndef TXT_SQL_CONVERT else if (inter_sql_test()) { @@ -356,30 +364,27 @@ int inter_init_sql(const char *file) } if(char_gm_read) { - mysql_init(&lmysql_handle); + lsql_handle = Sql_Malloc(); ShowInfo("Connect Character DB server.... (login server)\n"); - if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw, - login_server_db ,login_server_port, (char *)NULL, 0)) { - //pointer check - ShowFatalError("%s\n",mysql_error(&lmysql_handle)); - exit(1); - }else { + if( SQL_ERROR == Sql_Connect(lsql_handle, login_server_id, login_server_pw, login_server_ip, (uint16)login_server_port, login_server_db) ) + { + Sql_ShowDebug(lsql_handle); + Sql_Free(lsql_handle); + Sql_Free(sql_handle); + exit(1); + } + else + { ShowStatus ("Connect Success! (Login Server)\n"); } } #endif //TXT_SQL_CONVERT - if(strlen(default_codepage) > 0 ) { - sprintf( tmp_sql, "SET NAMES %s", default_codepage ); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( *default_codepage ) { + if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) + Sql_ShowDebug(sql_handle); #ifndef TXT_SQL_CONVERT - if(char_gm_read) - if (mysql_query(&lmysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( char_gm_read && SQL_ERROR == Sql_SetEncoding(lsql_handle, default_codepage) ) + Sql_ShowDebug(lsql_handle); #endif //TXT_SQL_CONVERT } @@ -405,32 +410,30 @@ int inter_sql_test (void) "fame", // version 1491 }; char buf[1024] = ""; + char* p; + size_t len; int i; - sprintf(tmp_sql, "EXPLAIN `%s`",char_db); - if (mysql_query(&mysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); - // store DB fields - if (sql_res) { - while((sql_row = mysql_fetch_row(sql_res))) { - strcat (buf, sql_row[0]); - strcat (buf, " "); - } - } + if( SQL_ERROR == Sql_GetColumnNames(sql_handle, char_db, buf, sizeof(buf), '\n') ) + Sql_ShowDebug(sql_handle); // check DB strings - for (i = 0; i < (int)(sizeof(fields) / sizeof(fields[0])); i++) { - if(!strstr(buf, fields[i])) { + for( i = 0; i < ARRAYLENGTH(fields); ++i ) + { + len = strlen(fields[i]); + p = strstr(buf, fields[i]); + while( p != NULL && p[len] != '\n' ) + p = strstr(p, fields[i]); + if( p == NULL ) + { ShowSQL ("Field `%s` not be found in `%s`. Consider updating your database!\n", fields[i], char_db); + if( lsql_handle ) + Sql_Free(lsql_handle); + Sql_Free(sql_handle); exit(1); } } - mysql_free_result(sql_res); - return 1; } @@ -636,7 +639,11 @@ int mapif_parse_WisRequest(int fd) { struct WisData* wd; static int wisid = 0; - char name[NAME_LENGTH], t_name[NAME_LENGTH*2]; //Needs space to allocate names with escaped chars [Skotlex] + char name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1];// escaped name + char* data; + size_t len; + if ( fd <= 0 ) {return 0;} // check if we have a valid fd @@ -649,35 +656,37 @@ int mapif_parse_WisRequest(int fd) } memcpy(name, RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] name[NAME_LENGTH-1]= '\0'; - - sprintf (tmp_sql, "SELECT `name` FROM `%s` WHERE `name`='%s'", - char_db, jstrescapecpy(t_name, name)); - if(mysql_query(&mysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - sql_res = mysql_store_result(&mysql_handle); + + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) ) + Sql_ShowDebug(sql_handle); // search if character exists before to ask all map-servers - if (!(sql_row = mysql_fetch_row(sql_res))) { + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target mapif_send(fd, buf, 27); - // Character exists. So, ask all map-servers - } else { + } + else + {// Character exists. So, ask all map-servers // to be sure of the correct name, rewrite it + Sql_GetData(sql_handle, 0, &data, &len); memset(name, 0, NAME_LENGTH); - strncpy(name, sql_row[0], NAME_LENGTH); + memcpy(name, data, min(len, NAME_LENGTH)); // if source is destination, don't ask other servers. - if (strcmp((char*)RFIFOP(fd,4),name) == 0) { - unsigned char buf[27]; + if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 ) + { + uint8 buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target mapif_send(fd, buf, 27); - } else { + } + else + { CREATE(wd, struct WisData, 1); @@ -695,12 +704,8 @@ int mapif_parse_WisRequest(int fd) mapif_wis_message(wd); } } - - //Freeing ... O.o - if(sql_res){ - mysql_free_result(sql_res); - } - + + Sql_FreeResult(sql_handle); return 0; } diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index 98b0fc49d..c79290c80 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -4,9 +4,8 @@ #ifndef _INTER_SQL_H_ #define _INTER_SQL_H_ -#ifndef _CBASETYPES_H_ -#include "../common/cbasetypes.h" -#endif +struct accreg; +#include "../common/sql.h" int inter_init_sql(const char *file); void inter_final(void); @@ -25,21 +24,8 @@ int inter_log(char *fmt,...); extern unsigned int party_share_level; extern char inter_log_filename[1024]; -#ifdef WIN32 -#include -#endif -//add include for DBMS(mysql) -#include - -extern MYSQL mysql_handle; -extern char tmp_sql[65535]; -extern MYSQL_RES* sql_res ; -extern MYSQL_ROW sql_row ; -extern int sql_cnt; - -extern MYSQL lmysql_handle; -extern MYSQL_RES* lsql_res ; -extern MYSQL_ROW lsql_row ; +extern Sql* sql_handle; +extern Sql* lsql_handle; extern int char_server_port; extern char char_server_ip[32]; diff --git a/src/char_sql/itemdb.c b/src/char_sql/itemdb.c deleted file mode 100644 index b03d76bfe..000000000 --- a/src/char_sql/itemdb.c +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include -#include -#include - -#include "itemdb.h" -#include "db.h" -#include "inter.h" -#include "char.h" -#include "utils.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" - -#define MAX_RANDITEM 2000 - -// ** ITEMDB_OVERRIDE_NAME_VERBOSE ** -// ’è‹`‚·‚邯Aitemdb.txt‚Ægrf‚Å–¼‘O‚ªˆÙ‚È‚éê‡A•\ަ‚µ‚Ü‚·. -//#define ITEMDB_OVERRIDE_NAME_VERBOSE 1 - -char item_db_db[256]="item_db"; // added to specify item_db sql table [Valaris] -char item_db2_db[256]="item_db2"; - -static struct dbt* item_db; - -static void* create_item(DBKey key, va_list args) { - struct item_data *id; - int nameid = key.i; - CREATE(id, struct item_data, 1); - id->nameid = nameid; - id->type = IT_ETC; - return id; -} -/*========================================== - * DB‚ÌŒŸõ - *------------------------------------------*/ -struct item_data* itemdb_search(int nameid) -{ - return idb_ensure(item_db,nameid,create_item); -} - -/*========================================== - * - *------------------------------------------*/ -int itemdb_isequip(int nameid) -{ - int type=itemdb_type(nameid); - if(type==IT_HEALING || type==IT_USABLE || type==IT_ETC || type==IT_CARD || type==IT_AMMO) - return 0; - return 1; -} -/*========================================== - * - *------------------------------------------*/ -int itemdb_isequip2(struct item_data *data) -{ - if(data) { - int type=data->type; - if(type==IT_HEALING || type==IT_USABLE || type==IT_ETC || type==IT_CARD || type==IT_AMMO) - return 0; - else - return 1; - } - return 0; -} - - - -/*========================================== - * ƒAƒCƒeƒ€ƒf[ƒ^ƒx[ƒX‚̓ǂݞ‚Ý - *------------------------------------------*/ -static int itemdb_readdb(void) -{ - FILE *fp; - char line[1024]; - int ln=0,lines=0; - int nameid,j; - char *str[32],*p,*np; - struct item_data *id; - int i=0; - char *filename[]={ "item_db.txt","item_db2.txt" }; - - for(i=0;i<2;i++){ - sprintf(line, "%s/%s", db_path, filename[i]); - fp=fopen(line,"r"); - if(fp==NULL){ - if(i>0) - continue; - ShowFatalError("can't read %s\n",line); - exit(1); - } - - lines=0; - while(fgets(line, sizeof(line), fp)) - { - lines++; - if(line[0]=='/' && line[1]=='/') - continue; - memset(str,0,sizeof(str)); - for(j=0,np=p=line;j<4 && p;j++){ - str[j]=p; - p=strchr(p,','); - if(p){ *p++=0; np=p; } - } - if(str[0]==NULL) - continue; - - nameid=atoi(str[0]); - if(nameid<=0) - continue; - if (j < 4) - { //Crash-fix on broken item lines. [Skotlex] - ShowWarning("Reading %s: Insufficient fields for item with id %d, skipping.\n", filename[i], nameid); - continue; - } - ln++; - - //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View - id=itemdb_search(nameid); - strncpy(id->name, str[1], ITEM_NAME_LENGTH-1); - strncpy(id->jname, str[2], ITEM_NAME_LENGTH-1); - id->type=atoi(str[3]); - if (id->type == IT_DELAYCONSUME) - id->type = IT_USABLE; - } - fclose(fp); - if (ln > 0) { - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]); - } - ln=0; // reset to 0 - } - return 0; -} - -static int itemdb_read_sqldb(void) // sql item_db read, shortened version of map-server item_db read [Valaris] -{ - unsigned short nameid; - struct item_data *id; - char *item_db_name[] = { item_db_db, item_db2_db }; - long unsigned int ln = 0; - int i; - - // ---------- - - for (i = 0; i < 2; i++) { - sprintf(tmp_sql, "SELECT * FROM `%s`", item_db_name[i]); - - // Execute the query; if the query execution succeeded... - if (mysql_query(&mysql_handle, tmp_sql) == 0) { - sql_res = mysql_store_result(&mysql_handle); - - // If the storage of the query result succeeded... - if (sql_res) { - // Parse each row in the query result into sql_row - while ((sql_row = mysql_fetch_row(sql_res))) - { /*Table structure is: - 00 id - 01 name_english - 02 name_japanese - 03 type - ... - */ - nameid = atoi(sql_row[0]); - - // If the identifier is not within the valid range, process the next row - if (nameid == 0) - continue; - - ln++; - - // ---------- - id=itemdb_search(nameid); - - strncpy(id->name, sql_row[1], ITEM_NAME_LENGTH-1); - strncpy(id->jname, sql_row[2], ITEM_NAME_LENGTH-1); - - id->type = atoi(sql_row[3]); - if (id->type == IT_DELAYCONSUME) - id->type = IT_USABLE; - } - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, item_db_name[i]); - ln = 0; - } else { - ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - - // Free the query result - mysql_free_result(sql_res); - } else { - ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } - - return 0; -} - -/*========================================== - * - *------------------------------------------*/ -void do_final_itemdb(void) -{ - if(item_db){ - item_db->destroy(item_db,NULL); - item_db=NULL; - } -} -int do_init_itemdb(void) -{ - item_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int)); - - if (db_use_sqldbs) // it db_use_sqldbs in inter config are yes, will read from item_db for char server display [Valaris] - itemdb_read_sqldb(); - else - itemdb_readdb(); - return 0; -} diff --git a/src/char_sql/itemdb.h b/src/char_sql/itemdb.h deleted file mode 100644 index 4fbd59f96..000000000 --- a/src/char_sql/itemdb.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _ITEMDB_H_ -#define _ITEMDB_H_ - -#include "mmo.h" - -//FIXME: Maybe it would be better to move this enum to mmo.h, -//instead of having it twice on the map server and here? [Skotlex] -enum { - IT_HEALING = 0, - IT_UNKNOWN, //1 - IT_USABLE, //2 - IT_ETC, //3 - IT_WEAPON, //4 - IT_ARMOR, //5 - IT_CARD, //6 - IT_PETEGG, //7 - IT_PETARMOR,//8 - IT_UNKNOWN2,//9 - IT_AMMO, //10 - IT_DELAYCONSUME,//11 - IT_MAX -} item_types; - -struct item_data { - int nameid; - char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; - int type; -}; - -extern char item_db_db[256]; -extern char item_db2_db[256]; -struct item_data* itemdb_search(int nameid); -#define itemdb_type(n) itemdb_search(n)->type - -int itemdb_isequip(int); -int itemdb_isequip2(struct item_data *); - -void do_final_itemdb(void); -int do_init_itemdb(void); - -#endif /* _ITEMDB_H_ */ diff --git a/src/common/Makefile b/src/common/Makefile deleted file mode 100644 index 258423776..000000000 --- a/src/common/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -txt sql all: obj common - -obj: - mkdir obj - -common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ - obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ - obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ - obj/mapindex.o obj/ers.o obj/md5calc.o - - -obj/%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -obj/mini%.o: %.c - $(COMPILE.c) -DMINICORE $(OUTPUT_OPTION) $< - - -clean: - rm -rf *.o obj GNUmakefile - rm -rf svnversion.h -HAVESVN = $(shell which svnversion) - -ifeq ($(findstring /,$(HAVESVN)), /) -svnversion.h: - @printf "#define SVNVERSION " > svnversion.h - @svnversion . >> svnversion.h - @printf "\n" >> svnversion.h -else -svnversion.h: - @printf "\n" > svnversion.h -endif - -obj/minicore.o: core.c core.h -obj/minisocket.o: socket.c socket.h -obj/minimalloc.o: malloc.c malloc.h - -# DO NOT DELETE - -obj/core.o: core.c core.h showmsg.h svnversion.h -obj/socket.o: socket.c socket.h mmo.h showmsg.h plugins.h -obj/timer.o: timer.c timer.h showmsg.h -obj/ers.o: ers.c ers.h cbasetypes.h -obj/db.o: db.c db.h showmsg.h ers.h -obj/lock.o: lock.c lock.h showmsg.h -obj/grfio.o: grfio.c grfio.h -obj/nullpo.o: nullpo.c nullpo.h showmsg.h -obj/malloc.o: malloc.c malloc.h showmsg.h -obj/plugins.o: plugins.c plugins.h plugin.h -obj/showmsg.o: showmsg.c showmsg.h -obj/strlib.o: strlib.c strlib.h utils.h -obj/mapindex.o: mapindex.c mapindex.h -obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h -obj/md5calc.o: md5calc.c md5calc.h -mmo.h: cbasetypes.h - @touch mmo.h diff --git a/src/common/Makefile.in b/src/common/Makefile.in new file mode 100644 index 000000000..c22cc721c --- /dev/null +++ b/src/common/Makefile.in @@ -0,0 +1,95 @@ +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + ALL_DEPENDS=txt sql + SQL_DEPENDS=txt obj_sql common_sql +else + ALL_TARGET=txt + SQL_DEPENDS=needs_mysql +endif + +##################################################################### +.PHONY : all txt sql clean help + +all: $(ALL_DEPENDS) + +txt: obj common + +sql: $(SQL_DEPENDS) + +clean: + rm -rf *.o obj obj_sql + +help: + @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" + @echo "'txt' - builds object files used in txt servers" + @echo "'sql' - builds object files used in sql servers" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +obj: + -mkdir obj + +obj_sql: + -mkdir obj_sql + +common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ + obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ + obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ + obj/mapindex.o obj/ers.o obj/md5calc.o + +common_sql: obj_sql/sql.o + + +obj/%.o: %.c + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +obj/mini%.o: %.c + @CC@ @CFLAGS@ -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +obj_sql/%.o: %.c + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + + +HAVESVN = $(shell which svnversion) + +ifeq ($(findstring /,$(HAVESVN)), /) +svnversion.h: + @printf "#define SVNVERSION " > svnversion.h + @svnversion . >> svnversion.h + @printf "\n" >> svnversion.h +else +svnversion.h: + @printf "\n" > svnversion.h +endif + +obj/minicore.o: core.c core.h +obj/minisocket.o: socket.c socket.h +obj/minimalloc.o: malloc.c malloc.h + +# DO NOT DELETE + +obj/core.o: core.c core.h showmsg.h svnversion.h +obj/db.o: db.c db.h showmsg.h ers.h +obj/ers.o: ers.c ers.h cbasetypes.h +obj/grfio.o: grfio.c grfio.h +obj/lock.o: lock.c lock.h showmsg.h +obj/malloc.o: malloc.c malloc.h showmsg.h +obj/mapindex.o: mapindex.c mapindex.h +obj/md5calc.o: md5calc.c md5calc.h +obj/nullpo.o: nullpo.c nullpo.h showmsg.h +obj/plugins.o: plugins.c plugins.h plugin.h +obj/showmsg.o: showmsg.c showmsg.h +obj/socket.o: socket.c socket.h mmo.h showmsg.h plugins.h +obj/strlib.o: strlib.c strlib.h utils.h +obj/timer.o: timer.c timer.h showmsg.h +obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h +obj_sql/sql.o: sql.c sql.h cbasetypes.h malloc.h showmsg.h utils.h +mmo.h: cbasetypes.h + @touch mmo.h diff --git a/src/common/db.c b/src/common/db.c index 80918d7f6..476c5a0c9 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -70,7 +70,6 @@ #include "db.h" #include "../common/mmo.h" -#include "../common/utils.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/ers.h" diff --git a/src/common/ers.c b/src/common/ers.c index 53c1edc3a..ecdda4609 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -40,9 +40,10 @@ \*****************************************************************************/ #include -#include "ers.h" +#include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree #include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL +#include "ers.h" #ifndef DISABLE_ERS /*****************************************************************************\ diff --git a/src/common/ers.h b/src/common/ers.h index 51b12d8a2..a9ba50073 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -40,7 +40,9 @@ #ifndef _ERS_H_ #define _ERS_H_ +#ifndef _CBASETYPES_H_ #include "../common/cbasetypes.h" +#endif /*****************************************************************************\ * (1) All public parts of the Entry Reusage System. * diff --git a/src/common/md5calc.c b/src/common/md5calc.c index b70236d6b..701a9db6c 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -173,7 +173,7 @@ void MD5_String2binary(const char * string, char * output) //Step 1.Append Padding Bits (extension of a mark bit) //1-1 - string_byte_len = strlen(string); //The byte chief of a character sequence is acquired. + string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired. pstring = (unsigned char *)string; //The position of the present character sequence is set. //1-2 Repeat calculation until length becomes less than 64 bytes. diff --git a/src/common/mmo.h b/src/common/mmo.h index 0fcfff137..619c75295 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -4,9 +4,8 @@ #ifndef _MMO_H_ #define _MMO_H_ -#include #include "cbasetypes.h" -#include "utils.h" // _WIN32 +#include #define FIFOSIZE_SERVERLINK 256*1024 @@ -179,7 +178,7 @@ struct s_homunculus { //[orn] int luk ; }; -struct friend { +struct s_friend { int account_id; int char_id; char name[NAME_LENGTH]; @@ -229,7 +228,7 @@ struct mmo_charstatus { struct item inventory[MAX_INVENTORY],cart[MAX_CART]; struct skill skill[MAX_SKILL]; - struct friend friends[MAX_FRIENDS]; //New friend system [Skotlex] + struct s_friend friends[MAX_FRIENDS]; //New friend system [Skotlex] #ifdef HOTKEY_SAVING struct hotkey hotkeys[HOTKEY_SAVING]; #endif diff --git a/src/common/plugins.c b/src/common/plugins.c index a2d4de73e..58ab60b74 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -1,15 +1,15 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "plugins.h" #include "../common/mmo.h" #include "../common/core.h" #include "../common/timer.h" -#include "../common/utils.h" +#include "../common/utils.h" // findfile() #include "../common/socket.h" #include "../common/malloc.h" #include "../common/version.h" #include "../common/showmsg.h" +#include "plugins.h" #include #include diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 615b52914..6fb8a2e6c 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,7 +2,7 @@ // For more information, see LICENCE in the main folder #include "../common/cbasetypes.h" -#include "../common/utils.h" +#include "../common/strlib.h" // StringBuf #include "showmsg.h" #include @@ -59,7 +59,7 @@ int msg_silent = 0; //Specifies how silent the console is. #define NEWBUF(buf) \ struct { \ char s_[SBUF_SIZE]; \ - struct StringBuf *d_; \ + StringBuf *d_; \ char *v_; \ int l_; \ } buf ={"",NULL,NULL,0}; \ @@ -198,7 +198,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) */ ///////////////////////////////////////////////////////////////// - unsigned long written; + DWORD written; char *p, *q; NEWBUF(tempbuf); // temporary buffer @@ -218,8 +218,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) p = BUFVAL(tempbuf); while ((q = strchr(p, 0x1b)) != NULL) { // find the escape character - if( 0==WriteConsole(handle, p, q-p, &written, 0) ) // write up to the escape - WriteFile(handle, p, q-p, &written, 0); + if( 0==WriteConsole(handle, p, (DWORD)(q-p), &written, 0) ) // write up to the escape + WriteFile(handle, p, (DWORD)(q-p), &written, 0); if( q[1]!='[' ) { // write the escape char (whatever purpose it has) @@ -240,7 +240,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // skip escape and bracket q=q+2; - while(1) + for(;;) { if( ISDIGIT(*q) ) { // add number to number array, only accept 2digits, shift out the rest @@ -501,8 +501,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } } if (*p) // write the rest of the buffer - if( 0==WriteConsole(handle, p, strlen(p), &written, 0) ) - WriteFile(handle,p, strlen(p), &written, 0); + if( 0==WriteConsole(handle, p, (DWORD)strlen(p), &written, 0) ) + WriteFile(handle, p, (DWORD)strlen(p), &written, 0); FREEBUF(tempbuf); return 0; } @@ -689,7 +689,10 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) ShowError("Empty string passed to _vShowMessage().\n"); return 1; } - if ((flag == MSG_DEBUG && !SHOW_DEBUG_MSG) || + if ( +#if !defined(SHOW_DEBUG_MSG) + (flag == MSG_DEBUG) || +#endif (flag == MSG_INFORMATION && msg_silent&1) || (flag == MSG_STATUS && msg_silent&2) || (flag == MSG_NOTICE && msg_silent&4) || diff --git a/src/common/socket.c b/src/common/socket.c index 221a0289b..c70c0cbaa 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -111,8 +111,9 @@ void set_defaultparse(ParseFunc defaultparse) void set_nonblocking(int fd, unsigned long yes) { // TCP_NODELAY BOOL Disables the Nagle algorithm for send coalescing. - if(MODE_NODELAY) - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, sizeof yes); +#if defined(MODE_NODELAY) && MODE_NODELAY == 1 + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, sizeof yes); +#endif // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. // The argp parameter is zero if nonblocking is to be disabled. @@ -169,7 +170,7 @@ int recv_to_fifo(int fd) if( !session_isActive(fd) ) return -1; - len = recv(fd, (char *) session[fd]->rdata + session[fd]->rdata_size, RFIFOSPACE(fd), 0); + len = recv(fd, (char *) session[fd]->rdata + session[fd]->rdata_size, (int)RFIFOSPACE(fd), 0); if (len == SOCKET_ERROR) { if (s_errno == S_ECONNABORTED) { @@ -203,7 +204,7 @@ int send_from_fifo(int fd) if (session[fd]->wdata_size == 0) return 0; - len = send(fd, (const char *) session[fd]->wdata, session[fd]->wdata_size, 0); + len = send(fd, (const char *) session[fd]->wdata, (int)session[fd]->wdata_size, 0); if (len == SOCKET_ERROR) { if (s_errno == S_ECONNABORTED) { @@ -457,7 +458,7 @@ int realloc_writefifo(int fd, size_t addition) return 0; } -int RFIFOSKIP(int fd, int len) +int RFIFOSKIP(int fd, size_t len) { struct socket_data *s; @@ -477,7 +478,7 @@ int RFIFOSKIP(int fd, int len) return 0; } -int WFIFOSET(int fd, int len) +int WFIFOSET(int fd, size_t len) { size_t newreserve; struct socket_data* s = session[fd]; diff --git a/src/common/socket.h b/src/common/socket.h index 469ff678d..4015fed97 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -104,8 +104,8 @@ int make_listen_bind(uint32 ip, uint16 port); int make_connection(uint32 ip, uint16 port); int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size); int realloc_writefifo(int fd, size_t addition); -int WFIFOSET(int fd, int len); -int RFIFOSKIP(int fd, int len); +int WFIFOSET(int fd, size_t len); +int RFIFOSKIP(int fd, size_t len); int do_sendrecv(int next); int do_parsepacket(void); diff --git a/src/common/sql.c b/src/common/sql.c new file mode 100644 index 000000000..cc6e81009 --- /dev/null +++ b/src/common/sql.c @@ -0,0 +1,851 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "sql.h" + +#ifdef WIN32 +#include +#endif +#include +#include // strlen/strnlen/memcpy/memset +#include // strtoul + + + +/// Sql handle +struct Sql +{ + StringBuf buf; + MYSQL handle; + MYSQL_RES* result; + MYSQL_ROW row; + unsigned long* lengths; +}; + + + +// Column length receiver. +// Takes care of the possible size missmatch between uint32 and unsigned long. +struct s_column_length +{ + uint32* out_length; + unsigned long length; +}; +typedef struct s_column_length s_column_length; + + + +/// Sql statement +struct SqlStmt +{ + StringBuf buf; + MYSQL_STMT* stmt; + MYSQL_BIND* params; + MYSQL_BIND* columns; + s_column_length* column_lengths; + size_t max_params; + size_t max_columns; + bool bind_params; + bool bind_columns; +}; + + + +/////////////////////////////////////////////////////////////////////////////// +// Sql Handle +/////////////////////////////////////////////////////////////////////////////// + + + +/// Allocates and initializes a new Sql handle. +Sql* Sql_Malloc(void) +{ + Sql* self; + CREATE(self, Sql, 1); + mysql_init(&self->handle); + StringBuf_Init(&self->buf); + return self; +} + + + +/// Establishes a connection. +int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db) +{ + if( self == NULL ) + return SQL_ERROR; + + StringBuf_Clear(&self->buf); + if( !mysql_real_connect(&self->handle, host, user, passwd, db, (unsigned int)port, NULL/*unix_socket*/, 0/*clientflag*/) ) + { + ShowSQL("%s\n", mysql_error(&self->handle)); + return SQL_ERROR; + } + return SQL_SUCCESS; +} + + + +/// Retrieves the timeout of the connection. +int Sql_GetTimeout(Sql* self, uint32* out_timeout) +{ + if( self && out_timeout && SQL_SUCCESS == Sql_Query(self, "SHOW VARIABLES LIKE 'wait_timeout'") ) + { + char* data; + size_t len; + if( SQL_SUCCESS == Sql_NextRow(self) && + SQL_SUCCESS == Sql_GetData(self, 1, &data, &len) ) + { + *out_timeout = (uint32)strtoul(data, NULL, 10); + Sql_FreeResult(self); + return SQL_SUCCESS; + } + Sql_FreeResult(self); + } + return SQL_ERROR; +} + + + +/// Retrieves the name of the columns of a table into out_buf, with the separator after each name. +int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep) +{ + char* data; + size_t len; + size_t off = 0; + + if( self == NULL || SQL_ERROR == Sql_Query(self, "EXPLAIN `%s`", table) ) + return SQL_ERROR; + + out_buf[off] = '\0'; + while( SQL_SUCCESS == Sql_NextRow(self) && SQL_SUCCESS == Sql_GetData(self, 0, &data, &len) ) + { + len = strnlen(data, len); + if( off + len + 2 > buf_len ) + { + ShowDebug("Sql_GetColumns: output buffer is too small\n"); + *out_buf = '\0'; + return SQL_ERROR; + } + memcpy(out_buf+off, data, len); + off += len; + out_buf[off++] = sep; + } + out_buf[off] = '\0'; + Sql_FreeResult(self); + return SQL_SUCCESS; +} + + + +/// Changes the encoding of the connection. +int Sql_SetEncoding(Sql* self, const char* encoding) +{ + return Sql_Query(self, "SET NAMES %s", encoding); +} + + + +/// Pings the connection. +int Sql_Ping(Sql* self) +{ + if( self && mysql_ping(&self->handle) == 0 ) + return SQL_SUCCESS; + return SQL_ERROR; +} + + + +/// Escapes a string. +size_t Sql_EscapeString(Sql* self, char *out_to, const char *from) +{ + if( self ) + return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)strlen(from)); + else + return (size_t)mysql_escape_string(out_to, from, (unsigned long)strlen(from)); +} + + + +/// Escapes a string. +size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t from_len) +{ + if( self ) + return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)from_len); + else + return (size_t)mysql_escape_string(out_to, from, (unsigned long)from_len); +} + + + +/// Executes a query. +int Sql_Query(Sql* self, const char* query, ...) +{ + int res; + va_list args; + + va_start(args, query); + res = Sql_QueryV(self, query, args); + va_end(args); + + return res; +} + + + +/// Executes a query. +int Sql_QueryV(Sql* self, const char* query, va_list args) +{ + if( self == NULL ) + return SQL_ERROR; + + Sql_FreeResult(self); + StringBuf_Clear(&self->buf); + StringBuf_Vprintf(&self->buf, query, args); + if( mysql_real_query(&self->handle, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) + { + ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + return SQL_ERROR; + } + self->result = mysql_store_result(&self->handle); + if( mysql_errno(&self->handle) != 0 ) + { + ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + return SQL_ERROR; + } + return SQL_SUCCESS; +} + + + +/// Executes a query. +int Sql_QueryStr(Sql* self, const char* query) +{ + if( self == NULL ) + return SQL_ERROR; + + Sql_FreeResult(self); + StringBuf_Clear(&self->buf); + StringBuf_AppendStr(&self->buf, query); + if( mysql_real_query(&self->handle, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) + { + ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + return SQL_ERROR; + } + self->result = mysql_store_result(&self->handle); + if( mysql_errno(&self->handle) != 0 ) + { + ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + return SQL_ERROR; + } + return SQL_SUCCESS; +} + + + +/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query. +uint64 Sql_LastInsertId(Sql* self) +{ + if( self ) + return (uint64)mysql_insert_id(&self->handle); + else + return 0; +} + + + +/// Returns the number of columns in each row of the result. +uint32 Sql_NumColumns(Sql* self) +{ + if( self && self->result ) + return (uint32)mysql_num_fields(self->result); + return 0; +} + + + +/// Returns the number of rows in the result. +uint64 Sql_NumRows(Sql* self) +{ + if( self && self->result ) + return (uint64)mysql_num_rows(self->result); + return 0; +} + + + +/// Fetches the next row. +int Sql_NextRow(Sql* self) +{ + if( self && self->result ) + { + self->row = mysql_fetch_row(self->result); + if( self->row ) + { + self->lengths = mysql_fetch_lengths(self->result); + return SQL_SUCCESS; + } + self->lengths = NULL; + if( mysql_errno(&self->handle) == 0 ) + return SQL_NO_DATA; + } + return SQL_ERROR; +} + + + +/// Gets the data of a column. +int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len) +{ + if( self && self->row ) + { + if( col < Sql_NumColumns(self) ) + { + if( out_buf ) *out_buf = self->row[col]; + if( out_len ) *out_len = (size_t)self->lengths[col]; + } + else + {// out of range - ignore + if( out_buf ) *out_buf = NULL; + if( out_len ) *out_len = 0; + } + return SQL_SUCCESS; + } + return SQL_ERROR; +} + + + +/// Frees the result of the query. +void Sql_FreeResult(Sql* self) +{ + if( self && self->result ) + { + mysql_free_result(self->result); + self->result = NULL; + self->row = NULL; + self->lengths = NULL; + } +} + + + +/// Shows debug information (last query). +void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line) +{ + if( self == NULL ) + ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line); + else if( StringBuf_Length(&self->buf) > 0 ) + ShowDebug("at %s:%lu - %s\n", debug_file, debug_line, StringBuf_Value(&self->buf)); + else + ShowDebug("at %s:%lu\n", debug_file, debug_line); +} + + + +/// Frees a Sql handle returned by Sql_Malloc. +void Sql_Free(Sql* self) +{ + if( self ) + { + Sql_FreeResult(self); + StringBuf_Destroy(&self->buf); + aFree(self); + } +} + + + +/////////////////////////////////////////////////////////////////////////////// +// Prepared Statements +/////////////////////////////////////////////////////////////////////////////// + + + +/// Returns the mysql integer type for the target size. +/// +/// @private +static enum enum_field_types Sql_P_SizeToMysqlIntType(int sz) +{ + switch( sz ) + { + case 1: return MYSQL_TYPE_TINY; + case 2: return MYSQL_TYPE_SHORT; + case 4: return MYSQL_TYPE_LONG; + case 8: return MYSQL_TYPE_LONGLONG; + default: + ShowDebug("SizeToMysqlIntType: unsupported size (%d)\n", sz); + return MYSQL_TYPE_NULL; + } +} + + + +/// Binds a parameter/result. +/// +/// @private +static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, unsigned long* out_length, int8* out_is_null) +{ + memset(bind, 0, sizeof(MYSQL_BIND)); + switch( buffer_type ) + { + case SQLDT_NULL: bind->buffer_type = MYSQL_TYPE_NULL; + break; + // fixed size + case SQLDT_UINT8: bind->is_unsigned = 1; + case SQLDT_INT8: bind->buffer_type = MYSQL_TYPE_TINY; + break; + case SQLDT_UINT16: bind->is_unsigned = 1; + case SQLDT_INT16: bind->buffer_type = MYSQL_TYPE_SHORT; + break; + case SQLDT_UINT32: bind->is_unsigned = 1; + case SQLDT_INT32: bind->buffer_type = MYSQL_TYPE_LONG; + break; + case SQLDT_UINT64: bind->is_unsigned = 1; + case SQLDT_INT64: bind->buffer_type = MYSQL_TYPE_LONGLONG; + break; + // platform dependent size + case SQLDT_UCHAR: bind->is_unsigned = 1; + case SQLDT_CHAR: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(char)); + break; + case SQLDT_USHORT: bind->is_unsigned = 1; + case SQLDT_SHORT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(short)); + break; + case SQLDT_UINT: bind->is_unsigned = 1; + case SQLDT_INT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(int)); + break; + case SQLDT_ULONG: bind->is_unsigned = 1; + case SQLDT_LONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(long)); + break; + case SQLDT_ULONGLONG: bind->is_unsigned = 1; + case SQLDT_LONGLONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(long long)); + break; + // floating point + case SQLDT_FLOAT: bind->buffer_type = MYSQL_TYPE_FLOAT; + break; + case SQLDT_DOUBLE: bind->buffer_type = MYSQL_TYPE_DOUBLE; + break; + // other + case SQLDT_STRING: + case SQLDT_ENUM: bind->buffer_type = MYSQL_TYPE_STRING; + break; + case SQLDT_BLOB: bind->buffer_type = MYSQL_TYPE_BLOB; + break; + default: + ShowDebug("Sql_P_BindSqlDataType: unsupported buffer type (%d)\n", buffer_type); + return SQL_ERROR; + } + bind->buffer = buffer; + bind->buffer_length = (unsigned long)buffer_len; + bind->length = out_length; + bind->is_null = (my_bool*)out_is_null; + return SQL_SUCCESS; +} + + + +/// Prints debug information about a field (type and length). +/// +/// @private +static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) +{ + const char* sign = (is_unsigned ? "UNSIGNED " : ""); + const char* type_string; + switch( type ) + { + default: + ShowDebug("%stype=%s%u, length=%d\n", prefix, sign, type, length); + return; +#define SHOW_DEBUG_OF(x) case x: type_string = #x; break + SHOW_DEBUG_OF(MYSQL_TYPE_TINY); + SHOW_DEBUG_OF(MYSQL_TYPE_SHORT); + SHOW_DEBUG_OF(MYSQL_TYPE_LONG); + SHOW_DEBUG_OF(MYSQL_TYPE_INT24); + SHOW_DEBUG_OF(MYSQL_TYPE_LONGLONG); + SHOW_DEBUG_OF(MYSQL_TYPE_DECIMAL); + SHOW_DEBUG_OF(MYSQL_TYPE_FLOAT); + SHOW_DEBUG_OF(MYSQL_TYPE_DOUBLE); + SHOW_DEBUG_OF(MYSQL_TYPE_TIMESTAMP); + SHOW_DEBUG_OF(MYSQL_TYPE_DATE); + SHOW_DEBUG_OF(MYSQL_TYPE_TIME); + SHOW_DEBUG_OF(MYSQL_TYPE_DATETIME); + SHOW_DEBUG_OF(MYSQL_TYPE_YEAR); + SHOW_DEBUG_OF(MYSQL_TYPE_STRING); + SHOW_DEBUG_OF(MYSQL_TYPE_VAR_STRING); + SHOW_DEBUG_OF(MYSQL_TYPE_BLOB); + SHOW_DEBUG_OF(MYSQL_TYPE_SET); + SHOW_DEBUG_OF(MYSQL_TYPE_ENUM); + SHOW_DEBUG_OF(MYSQL_TYPE_NULL); +#undef SHOW_DEBUG_TYPE_OF + } + ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix); +} + + + +/// Allocates and initializes a new SqlStmt handle. +SqlStmt* SqlStmt_Malloc(Sql* sql) +{ + SqlStmt* self; + MYSQL_STMT* stmt; + + if( sql == NULL ) + return NULL; + + stmt = mysql_stmt_init(&sql->handle); + if( stmt == NULL ) + { + ShowSQL("DB error - %s\n", mysql_error(&sql->handle)); + return NULL; + } + CREATE(self, SqlStmt, 1); + StringBuf_Init(&self->buf); + self->stmt = stmt; + self->params = NULL; + self->columns = NULL; + self->column_lengths = NULL; + self->max_params = 0; + self->max_columns = 0; + self->bind_params = false; + self->bind_columns = false; + + return self; +} + + + +/// Prepares the statement. +int SqlStmt_Prepare(SqlStmt* self, const char* query, ...) +{ + int res; + va_list args; + + va_start(args, query); + res = SqlStmt_PrepareV(self, query, args); + va_end(args); + + return res; +} + + + +/// Prepares the statement. +int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args) +{ + if( self == NULL ) + return SQL_ERROR; + + SqlStmt_FreeResult(self); + StringBuf_Clear(&self->buf); + StringBuf_Vprintf(&self->buf, query, args); + if( mysql_stmt_prepare(self->stmt, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) + { + ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + return SQL_ERROR; + } + self->bind_params = false; + + return SQL_SUCCESS; +} + + + +/// Prepares the statement. +int SqlStmt_PrepareStr(SqlStmt* self, const char* query) +{ + if( self == NULL ) + return SQL_ERROR; + + SqlStmt_FreeResult(self); + StringBuf_Clear(&self->buf); + StringBuf_AppendStr(&self->buf, query); + if( mysql_stmt_prepare(self->stmt, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) + { + ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + return SQL_ERROR; + } + self->bind_params = false; + + return SQL_SUCCESS; +} + + + +/// Returns the number of parameters in the prepared statement. +size_t SqlStmt_NumParams(SqlStmt* self) +{ + if( self ) + return (size_t)mysql_stmt_param_count(self->stmt); + else + return 0; +} + + + +/// Binds a parameter to a buffer. +int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len) +{ + if( self == NULL ) + return SQL_ERROR; + + if( !self->bind_params ) + {// initialize the bindings + size_t i; + size_t count; + + count = SqlStmt_NumParams(self); + if( self->max_params < count ) + { + self->max_params = count; + RECREATE(self->params, MYSQL_BIND, count); + } + memset(self->params, 0, count*sizeof(MYSQL_BIND)); + for( i = 0; i < count; ++i ) + self->params[i].buffer_type = MYSQL_TYPE_NULL; + self->bind_params = true; + } + if( idx < self->max_params ) + return Sql_P_BindSqlDataType(self->params+idx, buffer_type, buffer, buffer_len, NULL, NULL); + else + return SQL_SUCCESS;// out of range - ignore +} + + + +/// Executes the prepared statement. +int SqlStmt_Execute(SqlStmt* self) +{ + if( self == NULL ) + return SQL_ERROR; + + SqlStmt_FreeResult(self); + if( (self->bind_params && mysql_stmt_bind_param(self->stmt, self->params)) || + mysql_stmt_execute(self->stmt) ) + { + ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + return SQL_ERROR; + } + self->bind_columns = false; + if( mysql_stmt_store_result(self->stmt) )// store all the data + { + ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + return SQL_ERROR; + } + + return SQL_SUCCESS; +} + + + +/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. +uint64 SqlStmt_LastInsertId(SqlStmt* self) +{ + if( self ) + return (uint64)mysql_stmt_insert_id(self->stmt); + else + return 0; +} + + + +/// Returns the number of columns in each row of the result. +size_t SqlStmt_NumColumns(SqlStmt* self) +{ + if( self ) + return (size_t)mysql_stmt_field_count(self->stmt); + else + return 0; +} + + + +/// Binds the result of a column to a buffer. +int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null) +{ + if( self == NULL ) + return SQL_ERROR; + + if( buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM ) + { + if( buffer_len < 1 ) + { + ShowDebug("SqlStmt_BindColumn: buffer_len(%d) is too small, no room for the nul-terminator\n", buffer_len); + return SQL_ERROR; + } + --buffer_len;// nul-terminator + } + if( !self->bind_columns ) + {// initialize the bindings + size_t i; + size_t cols; + + cols = SqlStmt_NumColumns(self); + if( self->max_columns < cols ) + { + self->max_columns = cols; + RECREATE(self->columns, MYSQL_BIND, cols); + RECREATE(self->column_lengths, s_column_length, cols); + } + memset(self->columns, 0, cols*sizeof(MYSQL_BIND)); + memset(self->column_lengths, 0, cols*sizeof(s_column_length)); + for( i = 0; i < cols; ++i ) + self->columns[i].buffer_type = MYSQL_TYPE_NULL; + self->bind_columns = true; + } + if( idx < self->max_columns ) + { + self->column_lengths[idx].out_length = out_length; + return Sql_P_BindSqlDataType(self->columns+idx, buffer_type, buffer, buffer_len, &self->column_lengths[idx].length, out_is_null); + } + else + { + return SQL_SUCCESS;// out of range - ignore + } +} + + + +/// Returns the number of rows in the result. +uint64 SqlStmt_NumRows(SqlStmt* self) +{ + if( self ) + return (uint64)mysql_stmt_num_rows(self->stmt); + else + return 0; +} + + + +/// Fetches the next row. +int SqlStmt_NextRow(SqlStmt* self) +{ + int err; + size_t i; + size_t cols; + MYSQL_BIND* column; + unsigned long length; + + if( self == NULL ) + return SQL_ERROR; + + // bind columns + if( self->bind_columns && mysql_stmt_bind_result(self->stmt, self->columns) ) + err = 1;// error binding columns + else + err = mysql_stmt_fetch(self->stmt);// fetch row + + // check for errors + if( err == MYSQL_NO_DATA ) + return SQL_NO_DATA; + if( err == MYSQL_DATA_TRUNCATED ) + { + my_bool truncated; + + if( !self->bind_columns ) + { + ShowSQL("DB error - data truncated (unknown source, columns are not bound)\n"); + return SQL_ERROR; + } + + // find truncated column + cols = SqlStmt_NumColumns(self); + for( i = 0; i < cols; ++i ) + { + column = &self->columns[i]; + column->error = &truncated; + mysql_stmt_fetch_column(self->stmt, column, (unsigned int)i, 0); + column->error = NULL; + if( truncated ) + {// report truncated column + MYSQL_RES* meta; + MYSQL_FIELD* field; + + meta = mysql_stmt_result_metadata(self->stmt); + field = mysql_fetch_field_direct(meta, (unsigned int)i); + ShowSQL("DB error - data of field '%s' was truncated.\n", field->name); + ShowDebug("column - %lu\n", (unsigned long)i); + Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, ""); + if( column->buffer_type == MYSQL_TYPE_STRING ) + Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)"); + else + Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, ""); + mysql_free_result(meta); + return SQL_ERROR; + } + } + ShowSQL("DB error - data truncated (unknown source)\n"); + return SQL_ERROR; + } + if( err ) + { + ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + return SQL_ERROR; + } + + // propagate column lengths and clear unused parts of string/enum/blob buffers + cols = SqlStmt_NumColumns(self); + for( i = 0; i < cols; ++i ) + { + length = self->column_lengths[i].length; + if( self->column_lengths[i].out_length ) + *self->column_lengths[i].out_length = (uint32)length; + column = &self->columns[i]; + if( column->buffer_type == MYSQL_TYPE_STRING ) + {// clear unused part of the string/enum buffer (and nul-terminate) + memset((char*)column->buffer + length, 0, column->buffer_length - length + 1); + } + else if( column->buffer_type == MYSQL_TYPE_BLOB && length < column->buffer_length ) + {// clear unused part of the blob buffer + memset((char*)column->buffer + length, 0, column->buffer_length - length); + } + } + + return SQL_SUCCESS; +} + + + +/// Frees the result of the statement execution. +void SqlStmt_FreeResult(SqlStmt* self) +{ + if( self ) + mysql_stmt_free_result(self->stmt); +} + + + +/// Shows debug information (with statement). +void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line) +{ + if( self == NULL ) + ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line); + if( StringBuf_Length(&self->buf) > 0 ) + ShowDebug("at %s:%lu - %s\n", debug_file, debug_line, StringBuf_Value(&self->buf)); + else + ShowDebug("at %s:%lu\n", debug_file, debug_line); +} + + + +/// Frees a SqlStmt returned by SqlStmt_Malloc. +void SqlStmt_Free(SqlStmt* self) +{ + if( self ) + { + SqlStmt_FreeResult(self); + StringBuf_Destroy(&self->buf); + mysql_stmt_close(self->stmt); + if( self->params ) + aFree(self->params); + if( self->columns ) + { + aFree(self->columns); + aFree(self->column_lengths); + } + aFree(self); + } +} diff --git a/src/common/sql.h b/src/common/sql.h new file mode 100644 index 000000000..ef76b2ec5 --- /dev/null +++ b/src/common/sql.h @@ -0,0 +1,343 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _COMMON_SQL_H_ +#define _COMMON_SQL_H_ + +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif +#include // va_list + + + +// Return codes +#define SQL_ERROR -1 +#define SQL_SUCCESS 0 +#define SQL_NO_DATA 100 + + + +/// Data type identifier. +/// String, enum and blob data types need the buffer length specified. +enum SqlDataType +{ + SQLDT_NULL, + // fixed size + SQLDT_INT8, + SQLDT_INT16, + SQLDT_INT32, + SQLDT_INT64, + SQLDT_UINT8, + SQLDT_UINT16, + SQLDT_UINT32, + SQLDT_UINT64, + // platform dependent size + SQLDT_CHAR, + SQLDT_SHORT, + SQLDT_INT, + SQLDT_LONG, + SQLDT_LONGLONG, + SQLDT_UCHAR, + SQLDT_USHORT, + SQLDT_UINT, + SQLDT_ULONG, + SQLDT_ULONGLONG, + // floating point + SQLDT_FLOAT, + SQLDT_DOUBLE, + // other + SQLDT_STRING, + SQLDT_ENUM, + // Note: An ENUM is a string with restricted values. When an invalid value + // is inserted, it is saved as an empty string (numerical value 0). + SQLDT_BLOB, + SQLDT_LASTID +}; + +struct Sql;// Sql handle (private access) +struct SqlStmt;// Sql statement (private access) + +typedef enum SqlDataType SqlDataType; +typedef struct Sql Sql; +typedef struct SqlStmt SqlStmt; + + +/// Allocates and initializes a new Sql handle. +struct Sql* Sql_Malloc(void); + + + +/// Establishes a connection. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db); + + + + +/// Retrieves the timeout of the connection. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_GetTimeout(Sql* self, uint32* out_timeout); + + + + +/// Retrieves the name of the columns of a table into out_buf, with the separator after each name. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep); + + + + +/// Changes the encoding of the connection. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_SetEncoding(Sql* self, const char* encoding); + + + +/// Pings the connection. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_Ping(Sql* self); + + + +/// Escapes a string. +/// The output buffer must be at least strlen(from)*2+1 in size. +/// +/// @return The size of the escaped string +size_t Sql_EscapeString(Sql* self, char* out_to, const char* from); + + + +/// Escapes a string. +/// The output buffer must be at least from_len*2+1 in size. +/// +/// @return The size of the escaped string +size_t Sql_EscapeStringLen(Sql* self, char* out_to, const char* from, size_t from_len); + + + +/// Executes a query. +/// Any previous result is freed. +/// The query is constructed as if it was sprintf. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_Query(Sql* self, const char* query, ...); + + + +/// Executes a query. +/// Any previous result is freed. +/// The query is constructed as if it was svprintf. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_QueryV(Sql* self, const char* query, va_list args); + + + +/// Executes a query. +/// Any previous result is freed. +/// The query is used directly. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_QueryStr(Sql* self, const char* query); + + + +/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query. +/// +/// @return Value of the auto-increment column +uint64 Sql_LastInsertId(Sql* self); + + + +/// Returns the number of columns in each row of the result. +/// +/// @return Number of columns +uint32 Sql_NumColumns(Sql* self); + + + +/// Returns the number of rows in the result. +/// +/// @return Number of rows +uint64 Sql_NumRows(Sql* self); + + + +/// Fetches the next row. +/// The data of the previous row is no longer valid. +/// +/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA +int Sql_NextRow(Sql* self); + + + +/// Gets the data of a column. +/// The data remains valid until the next row is fetched or the result is freed. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len); + + + +/// Frees the result of the query. +void Sql_FreeResult(Sql* self); + + + +#if defined(SQL_REMOVE_SHOWDEBUG) +#define Sql_ShowDebug(self) (void)0 +#else +#define Sql_ShowDebug(self) Sql_ShowDebug_(self, __FILE__, __LINE__) +#endif +/// Shows debug information (last query). +void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line); + + + +/// Frees a Sql handle returned by Sql_Malloc. +void Sql_Free(Sql* self); + + + +/////////////////////////////////////////////////////////////////////////////// +// Prepared Statements +/////////////////////////////////////////////////////////////////////////////// +// Parameters are placed in the statement by embedding question mark ('?') +// characters into the query at the appropriate positions. +// The markers are legal only in places where they represent data. +// The markers cannot be inside quotes. Quotes will be added automatically +// when they are required. +// +// example queries with parameters: +// 1) SELECT col FROM table WHERE id=? +// 2) INSERT INTO table(col1,col2) VALUES(?,?) + + + +/// Allocates and initializes a new SqlStmt handle. +/// It uses the connection of the parent Sql handle. +/// Queries in Sql and SqlStmt are independent and don't affect each other. +/// +/// @return SqlStmt handle or NULL if an error occured +struct SqlStmt* SqlStmt_Malloc(Sql* sql); + + + +/// Prepares the statement. +/// Any previous result is freed and all parameter bindings are removed. +/// The query is constructed as if it was sprintf. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_Prepare(SqlStmt* self, const char* query, ...); + + + +/// Prepares the statement. +/// Any previous result is freed and all parameter bindings are removed. +/// The query is constructed as if it was svprintf. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args); + + + +/// Prepares the statement. +/// Any previous result is freed and all parameter bindings are removed. +/// The query is used directly. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_PrepareStr(SqlStmt* self, const char* query); + + + +/// Returns the number of parameters in the prepared statement. +/// +/// @return Number or paramenters +size_t SqlStmt_NumParams(SqlStmt* self); + + + +/// Binds a parameter to a buffer. +/// The buffer data will be used when the statement is executed. +/// All parameters should have bindings. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_BindParam(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len); + + + +/// Executes the prepared statement. +/// Any previous result is freed and all column bindings are removed. +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_Execute(SqlStmt* self); + + + +/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. +/// +/// @return Value of the auto-increment column +uint64 SqlStmt_LastInsertId(SqlStmt* self); + + + +/// Returns the number of columns in each row of the result. +/// +/// @return Number of columns +size_t SqlStmt_NumColumns(SqlStmt* self); + + + +/// Binds the result of a column to a buffer. +/// The buffer will be filled with data when the next row is fetched. +/// For string/enum buffer types there has to be enough space for the data +/// and the nul-terminator (an extra byte). +/// +/// @return SQL_SUCCESS or SQL_ERROR +int SqlStmt_BindColumn(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null); + + + +/// Returns the number of rows in the result. +/// +/// @return Number of rows +uint64 SqlStmt_NumRows(SqlStmt* self); + + + +/// Fetches the next row. +/// All column bindings will be filled with data. +/// +/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA +int SqlStmt_NextRow(SqlStmt* self); + + + +/// Frees the result of the statement execution. +void SqlStmt_FreeResult(SqlStmt* self); + + + +#if defined(SQL_REMOVE_SHOWDEBUG) +#define SqlStmt_ShowDebug(self) (void)0 +#else +#define SqlStmt_ShowDebug(self) SqlStmt_ShowDebug_(self, __FILE__, __LINE__) +#endif +/// Shows debug information (with statement). +void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line); + + + +/// Frees a SqlStmt returned by SqlStmt_Malloc. +void SqlStmt_Free(SqlStmt* self); + + + +#endif /* _COMMON_SQL_H_ */ diff --git a/src/common/strlib.c b/src/common/strlib.c index a683dc100..4f204a768 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -3,7 +3,6 @@ #include "../common/cbasetypes.h" #include "../common/malloc.h" -#include "../common/utils.h" #include "strlib.h" #include @@ -258,7 +257,7 @@ int e_mail_check(char* email) { char ch; char* last_arobas; - int len = strlen(email); + size_t len = strlen(email); // athena limits if (len < 3 || len > 39) @@ -310,3 +309,134 @@ char* safestrncpy(char* dst, const char* src, size_t n) ret[n - 1] = '\0'; return ret; } + + +///////////////////////////////////////////////////////////////////// +// StringBuf - dynamic string +// +// @author MouseJstr (original) + +/// Allocates a StringBuf +StringBuf* StringBuf_Malloc() +{ + StringBuf* self; + CREATE(self, StringBuf, 1); + StringBuf_Init(self); + return self; +} + +/// Initializes a previously allocated StringBuf +void StringBuf_Init(StringBuf* self) +{ + self->max_ = 1024; + self->ptr_ = self->buf_ = (char*)aMallocA(self->max_ + 1); +} + +/// Appends the result of printf to the StringBuf +int StringBuf_Printf(StringBuf* self, const char* fmt, ...) +{ + int len; + va_list ap; + + va_start(ap, fmt); + len = StringBuf_Vprintf(self, fmt, ap); + va_end(ap); + + return len; +} + +/// Appends the result of vprintf to the StringBuf +int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) +{ + int n, size, off; + + for(;;) + { + /* Try to print in the allocated space. */ + size = self->max_ - (self->ptr_ - self->buf_); + n = vsnprintf(self->ptr_, size, fmt, ap); + /* If that worked, return the length. */ + if( n > -1 && n < size ) + { + self->ptr_ += n; + return (int)(self->ptr_ - self->buf_); + } + /* Else try again with more space. */ + self->max_ *= 2; // twice the old size + off = (int)(self->ptr_ - self->buf_); + self->buf_ = (char*)aRealloc(self->buf_, self->max_ + 1); + self->ptr_ = self->buf_ + off; + } +} + +/// Appends the contents of another StringBuf to the StringBuf +int StringBuf_Append(StringBuf* self, const StringBuf* sbuf) +{ + int available = self->max_ - (self->ptr_ - self->buf_); + int needed = (int)(sbuf->ptr_ - sbuf->buf_); + + if( needed >= available ) + { + int off = (int)(self->ptr_ - self->buf_); + self->max_ += needed; + self->buf_ = (char*)aRealloc(self->buf_, self->max_ + 1); + self->ptr_ = self->buf_ + off; + } + + memcpy(self->ptr_, sbuf->buf_, needed); + self->ptr_ += needed; + return (int)(self->ptr_ - self->buf_); +} + +// Appends str to the StringBuf +int StringBuf_AppendStr(StringBuf* self, const char* str) +{ + int available = self->max_ - (self->ptr_ - self->buf_); + int needed = (int)strlen(str); + + if( needed >= available ) + {// not enough space, expand the buffer (minimum expansion = 1024) + int off = (int)(self->ptr_ - self->buf_); + self->max_ += max(needed, 1024); + self->buf_ = (char*)aRealloc(self->buf_, self->max_ + 1); + self->ptr_ = self->buf_ + off; + } + + memcpy(self->ptr_, str, needed); + self->ptr_ += needed; + return (int)(self->ptr_ - self->buf_); +} + +// Returns the length of the data in the Stringbuf +int StringBuf_Length(StringBuf* self) +{ + return (int)(self->ptr_ - self->buf_); +} + +/// Returns the data in the StringBuf +char* StringBuf_Value(StringBuf* self) +{ + *self->ptr_ = '\0'; + return self->buf_; +} + +/// Clears the contents of the StringBuf +void StringBuf_Clear(StringBuf* self) +{ + self->ptr_ = self->buf_; +} + +/// Destroys the StringBuf +void StringBuf_Destroy(StringBuf* self) +{ + aFree(self->buf_); + self->ptr_ = self->buf_ = 0; + self->max_ = 0; +} + +// Frees a StringBuf returned by StringBuf_Malloc +void StringBuf_Free(StringBuf* self) +{ + StringBuf_Destroy(self); + aFree(self); +} diff --git a/src/common/strlib.h b/src/common/strlib.h index 42fb75ab2..ee473f466 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -7,6 +7,7 @@ #ifndef _CBASETYPES_H_ #include "../common/cbasetypes.h" #endif +#include char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); @@ -33,4 +34,25 @@ int config_switch(const char* str); /// always nul-terminates the string char* safestrncpy(char* dst, const char* src, size_t n); +/// StringBuf - dynamic string +struct StringBuf +{ + char *buf_; + char *ptr_; + unsigned int max_; +}; +typedef struct StringBuf StringBuf; + +StringBuf* StringBuf_Malloc(void); +void StringBuf_Init(StringBuf* self); +int StringBuf_Printf(StringBuf* self, const char* fmt, ...); +int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list args); +int StringBuf_Append(StringBuf* self, const StringBuf *sbuf); +int StringBuf_AppendStr(StringBuf* self, const char* str); +int StringBuf_Length(StringBuf* self); +char* StringBuf_Value(StringBuf* self); +void StringBuf_Clear(StringBuf* self); +void StringBuf_Destroy(StringBuf* self); +void StringBuf_Free(StringBuf* self); + #endif /* _STRLIB_H_ */ diff --git a/src/common/utils.c b/src/common/utils.c index 15d1d2e68..354bd3814 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -55,118 +55,6 @@ void dump(FILE* fp, const unsigned char* buffer, int length) fprintf(fp, "\n"); } -// Allocate a StringBuf [MouseJstr] -struct StringBuf * StringBuf_Malloc() -{ - struct StringBuf * ret = (struct StringBuf *) aMallocA(sizeof(struct StringBuf)); - StringBuf_Init(ret); - return ret; -} - -// Initialize a previously allocated StringBuf [MouseJstr] -void StringBuf_Init(struct StringBuf * sbuf) { - sbuf->max_ = 1024; - sbuf->ptr_ = sbuf->buf_ = (char *) aMallocA(sbuf->max_ + 1); -} - -// vprintf into a StringBuf, moving the pointer [MouseJstr] -int StringBuf_Vprintf(struct StringBuf *sbuf,const char *fmt,va_list ap) -{ - int n, size, off; - - while (1) { - /* Try to print in the allocated space. */ - size = sbuf->max_ - (sbuf->ptr_ - sbuf->buf_); - n = vsnprintf (sbuf->ptr_, size, fmt, ap); - /* If that worked, return the length. */ - if (n > -1 && n < size) { - sbuf->ptr_ += n; - return (int)(sbuf->ptr_ - sbuf->buf_); - } - /* Else try again with more space. */ - sbuf->max_ *= 2; // twice the old size - off = (int)(sbuf->ptr_ - sbuf->buf_); - sbuf->buf_ = (char *) aRealloc(sbuf->buf_, sbuf->max_ + 1); - sbuf->ptr_ = sbuf->buf_ + off; - } -} - -// printf into a StringBuf, moving the pointer [MouseJstr] -int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...) -{ - int len; - va_list ap; - - va_start(ap,fmt); - len = StringBuf_Vprintf(sbuf,fmt,ap); - va_end(ap); - - return len; -} - -// Append buf2 onto the end of buf1 [MouseJstr] -int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2) -{ - int buf1_avail = buf1->max_ - (buf1->ptr_ - buf1->buf_); - int size2 = (int)(buf2->ptr_ - buf2->buf_); - - if (size2 >= buf1_avail) { - int off = (int)(buf1->ptr_ - buf1->buf_); - buf1->max_ += size2; - buf1->buf_ = (char *) aRealloc(buf1->buf_, buf1->max_ + 1); - buf1->ptr_ = buf1->buf_ + off; - } - - memcpy(buf1->ptr_, buf2->buf_, size2); - buf1->ptr_ += size2; - return (int)(buf1->ptr_ - buf1->buf_); -} - -// Appends str onto the end of buf -int StringBuf_AppendStr(struct StringBuf* sbuf, const char* str) -{ - int available = sbuf->max_ - (sbuf->ptr_ - sbuf->buf_); - int size = (int)strlen(str); - - if( size >= available ) - {// not enough space, expand the buffer (minimum expansion = 1024) - int off = (int)(sbuf->ptr_ - sbuf->buf_); - sbuf->max_ += max(size, 1024); - sbuf->buf_ = (char *) aRealloc(sbuf->buf_, sbuf->max_ + 1); - sbuf->ptr_ = sbuf->buf_ + off; - } - - memcpy(sbuf->ptr_, str, size); - sbuf->ptr_ += size; - return (int)(sbuf->ptr_ - sbuf->buf_); -} - -// Returns the length of the data in a Stringbuf -int StringBuf_Length(struct StringBuf *sbuf) -{ - return (int)(sbuf->ptr_ - sbuf->buf_); -} - -// Destroy a StringBuf [MouseJstr] -void StringBuf_Destroy(struct StringBuf *sbuf) -{ - aFree(sbuf->buf_); - sbuf->ptr_ = sbuf->buf_ = 0; -} - -// Free a StringBuf returned by StringBuf_Malloc [MouseJstr] -void StringBuf_Free(struct StringBuf *sbuf) -{ - StringBuf_Destroy(sbuf); - aFree(sbuf); -} - -// Return the built string from the StringBuf [MouseJstr] -char * StringBuf_Value(struct StringBuf *sbuf) -{ - *sbuf->ptr_ = '\0'; - return sbuf->buf_; -} #ifdef WIN32 @@ -293,35 +181,43 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) } #endif -uint8 GetByte(uint32 val, size_t num) +uint8 GetByte(uint32 val, int idx) { - switch( num ) + switch( idx ) { - case 0: return (uint8)((val & 0x000000FF) ); - case 1: return (uint8)((val & 0x0000FF00) >> 0x08); - case 2: return (uint8)((val & 0x00FF0000) >> 0x10); - case 3: return (uint8)((val & 0xFF000000) >> 0x18); - default: return 0; //better throw something here + case 0: return (uint8)( (val & 0x000000FF) ); + case 1: return (uint8)( (val & 0x0000FF00) >> 0x08 ); + case 2: return (uint8)( (val & 0x00FF0000) >> 0x10 ); + case 3: return (uint8)( (val & 0xFF000000) >> 0x18 ); + default: +#if defined(DEBUG) + ShowDebug("GetByte: invalid index (idx=%d)\n", idx); +#endif + return 0; } } -uint16 GetWord(uint32 val, size_t num) + +uint16 GetWord(uint32 val, int idx) { - switch( num ) + switch( idx ) { - case 0: return (uint16)((val & 0x0000FFFF) ); - case 1: return (uint16)((val & 0xFFFF0000) >> 0x10); - default: return 0; //better throw something here + case 0: return (uint16)( (val & 0x0000FFFF) ); + case 1: return (uint16)( (val & 0xFFFF0000) >> 0x10 ); + default: +#if defined(DEBUG) + ShowDebug("GetWord: invalid index (idx=%d)\n", idx); +#endif + return 0; } } uint16 MakeWord(uint8 byte0, uint8 byte1) { - return - ((uint16)(byte0 ))| - ((uint16)(byte1 << 0x08)); + return byte0 | (byte1 << 0x08); } + uint32 MakeDWord(uint16 word0, uint16 word1) { return - ((uint32)(word0 ))| - ((uint32)(word1 << 0x10)); + ( (uint32)(word0 ) )| + ( (uint32)(word1 << 0x10) ); } diff --git a/src/common/utils.h b/src/common/utils.h index 898a63ab4..21e8e090c 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -4,29 +4,15 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -#include -#include +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + +#include // FILE* // generate a hex dump of the first 'length' bytes of 'buffer' void dump(FILE* fp, const unsigned char* buffer, int length); -struct StringBuf { - char *buf_; - char *ptr_; - unsigned int max_; -}; - -struct StringBuf * StringBuf_Malloc(void); -void StringBuf_Init(struct StringBuf *); -int StringBuf_Vprintf(struct StringBuf *,const char *,va_list); -int StringBuf_Printf(struct StringBuf *,const char *,...); -int StringBuf_Append(struct StringBuf *,const struct StringBuf *); -int StringBuf_AppendStr(struct StringBuf* sbuf, const char* str); -int StringBuf_Length(struct StringBuf* sbuf); -char * StringBuf_Value(struct StringBuf *); -void StringBuf_Destroy(struct StringBuf *); -void StringBuf_Free(struct StringBuf *); - void findfile(const char *p, const char *pat, void (func)(const char*)); //Caps values to min/max @@ -36,8 +22,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*)); // byte word dword access [Shinomori] ////////////////////////////////////////////////////////////////////////// -extern uint8 GetByte(uint32 val, size_t num); -extern uint16 GetWord(uint32 val, size_t num); +extern uint8 GetByte(uint32 val, int idx); +extern uint16 GetWord(uint32 val, int idx); extern uint16 MakeWord(uint8 byte0, uint8 byte1); extern uint32 MakeDWord(uint16 word0, uint16 word1); diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile deleted file mode 100644 index c5818404b..000000000 --- a/src/ladmin/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -all txt sql: ladmin - -COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/utils.o ../common/obj/md5calc.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ - ../common/utils.h ../common/md5calc.h - -ladmin: ladmin.o $(COMMON_OBJ) - $(CC) -o ../../$@ ladmin.o $(COMMON_OBJ) $(LIB_S) - -clean: - rm -f *.o ../../ladmin GNUmakefile - -# DO NOT DELETE - -ladmin.o: ladmin.c ladmin.h $(COMMON_H) diff --git a/src/ladmin/Makefile.in b/src/ladmin/Makefile.in new file mode 100644 index 000000000..f1f7bff23 --- /dev/null +++ b/src/ladmin/Makefile.in @@ -0,0 +1,31 @@ +COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ + ../common/obj/utils.o ../common/obj/md5calc.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ + ../common/utils.h ../common/md5calc.h + +##################################################################### +.PHONY : all ladmin clean help + +all: ladmin + +ladmin: ladmin.o $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../ladmin@EXEEXT@ ladmin.o $(COMMON_OBJ) @LIBS@ + +clean: + rm -f *.o ../../ladmin@EXEEXT@ + +help: + @echo "possible targets are 'ladmin' 'all' 'clean' 'help'" + @echo "'ladmin' - remote administration tool" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +# DO NOT DELETE + +ladmin.o: ladmin.c ladmin.h $(COMMON_H) + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/login/Makefile b/src/login/Makefile deleted file mode 100644 index 11d2e165f..000000000 --- a/src/login/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -all txt: login-server - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/md5calc.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/grfio.h ../common/mapindex.h \ - ../common/md5calc.h - -%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -login-server: login.o $(COMMON_OBJ) - $(CC) -o ../../$@ login.o $(COMMON_OBJ) $(LIB_S) - -clean: - rm -f *.o ../../login-server GNUmakefile - -# DO NOT DELETE - -login.o: login.c login.h $(COMMON_H) diff --git a/src/login/Makefile.in b/src/login/Makefile.in new file mode 100644 index 000000000..c0fdcc8e3 --- /dev/null +++ b/src/login/Makefile.in @@ -0,0 +1,35 @@ +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/grfio.o ../common/obj/mapindex.o \ + ../common/obj/ers.o ../common/obj/md5calc.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/grfio.h ../common/mapindex.h \ + ../common/ers.h ../common/md5calc.h + +##################################################################### +.PHONY : all login-server clean help + +all: login-server + +login-server: login.o $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ login.o $(COMMON_OBJ) @LIBS@ + +clean: + rm -f *.o ../../login-server@EXEEXT@ + +help: + @echo "possible targets are 'login-server' 'all' 'clean' 'help'" + @echo "'login-server' - login server (TXT version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +# DO NOT DELETE + +login.o: login.c login.h $(COMMON_H) + @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/login/login.c b/src/login/login.c index 970bf3aab..bacab0894 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,6 +2,7 @@ // For more information, see LICENCE in the main folder #include "../common/cbasetypes.h" +#include "../common/mmo.h" #include "../common/core.h" #include "../common/socket.h" #include "../common/db.h" @@ -9,7 +10,6 @@ #include "../common/lock.h" #include "../common/malloc.h" #include "../common/strlib.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/version.h" #include "../common/md5calc.h" @@ -17,10 +17,8 @@ #include #include -#include // for stat/lstat/fstat -#include -#include #include +#include // for stat/lstat/fstat uint32 account_id_count = START_ACCOUNT_NUM; bool new_account_flag = true; @@ -1092,20 +1090,18 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) account_id_count++; auth_dat[i].account_id = account_id_count++; - strncpy(auth_dat[i].userid, account->userid, NAME_LENGTH); auth_dat[i].userid[23] = '\0'; - if (use_md5_passwds) { + safestrncpy(auth_dat[i].userid, account->userid, NAME_LENGTH); + if( use_md5_passwds ) MD5_String(account->passwd, auth_dat[i].pass); - } else { - strncpy(auth_dat[i].pass, account->passwd, NAME_LENGTH); auth_dat[i].pass[23] = '\0'; - } - memcpy(auth_dat[i].lastlogin, "-", 2); + else + safestrncpy(auth_dat[i].pass, account->passwd, NAME_LENGTH); + safestrncpy(auth_dat[i].lastlogin, "-", sizeof(auth_dat[i].lastlogin)); auth_dat[i].sex = (sex == 'M' || sex == 'm'); auth_dat[i].logincount = 0; auth_dat[i].state = 0; - strncpy(auth_dat[i].email, e_mail_check(email) ? email : "a@a.com", 40); - strncpy(auth_dat[i].error_message, "-", 20); + safestrncpy(auth_dat[i].email, e_mail_check(email) ? email : "a@a.com", sizeof(auth_dat[i].email)); + safestrncpy(auth_dat[i].error_message, "-", sizeof(auth_dat[i].error_message)); auth_dat[i].ban_until_time = 0; - if (start_limited_time < 0) auth_dat[i].connect_until_time = 0; // unlimited else { // limited time @@ -1128,9 +1124,9 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) return (account_id_count - 1); } -//--------------------------------------- +//----------------------------------------------------- // Check/authentication of a connection -//--------------------------------------- +//----------------------------------------------------- int mmo_auth(struct mmo_account* account, int fd) { unsigned int i; @@ -1138,14 +1134,14 @@ int mmo_auth(struct mmo_account* account, int fd) char tmpstr[256]; int len; int newaccount = 0; - char user_password[256]; + char user_password[32+1]; // reserve for md5-ed pw char ip[16]; uint8* sin_addr = (uint8*)&session[fd]->client_addr; sprintf(ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]); // DNS Blacklist check - if(use_dnsbl) + if( use_dnsbl ) { char r_ip[16]; char ip_dnsbl[256]; @@ -1154,31 +1150,34 @@ int mmo_auth(struct mmo_account* account, int fd) sprintf(r_ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); - for (dnsbl_serv = strtok(dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",")) + for( dnsbl_serv = strtok(dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) { - if (!matched) { - sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); - if(host2ip(ip_dnsbl)) - matched = true; - } + sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); + if( host2ip(ip_dnsbl) ) + matched = true; } - if (matched) { + if( matched ) + { ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); return 3; } } + //Client Version check + if( check_client_version && account->version != 0 && + account->version != client_version_to_connect ) + return 5; - len = strlen(account->userid) - 2; + len = strnlen(account->userid, NAME_LENGTH); // Account creation with _M/_F - if (new_account_flag) + if( new_account_flag ) { - if (account->passwdenc == 0 && account->userid[len] == '_' && - (account->userid[len+1] == 'F' || account->userid[len+1] == 'M' || - account->userid[len+1] == 'f' || account->userid[len+1] == 'm') && - account_id_count <= END_ACCOUNT_NUM && len >= 4 && strlen(account->passwd) >= 4) + if( len > 2 && strnlen(account->passwd, NAME_LENGTH) >= 4 && // valid user and password lengths + account->passwdenc == 0 && // unencoded password + account->userid[len-2] == '_' && memchr("FfMm", (unsigned char)account->userid[len-1], 4) && // _M/_F suffix + account_id_count <= END_ACCOUNT_NUM ) { //only continue if amount in this time limit is allowed (account registration flood protection)[Kevin] if(DIFF_TICK(gettick(), new_reg_tick) < 0 && num_regs >= allowed_regs) { @@ -1187,20 +1186,13 @@ int mmo_auth(struct mmo_account* account, int fd) return 3; } newaccount = 1; - account->userid[len] = '\0'; + account->userid[len-2] = '\0'; } } - //Client Version check - if (check_client_version && account->version != 0 && - account->version != client_version_to_connect) - return 5; - // Strict account search - for(i = 0; i < auth_num; i++) { - if (strcmp(account->userid, auth_dat[i].userid) == 0) - break; - } + ARR_FIND(0, auth_num, i, strcmp(account->userid, auth_dat[i].userid) == 0); + // if there is no creation request and strict account search fails, we do a no sensitive case research for index if (!newaccount && i == auth_num) { i = search_account_index(account->userid); @@ -1210,28 +1202,47 @@ int mmo_auth(struct mmo_account* account, int fd) memcpy(account->userid, auth_dat[i].userid, NAME_LENGTH); // for the possible tests/checks afterwards (copy correcte sensitive case). } - if (i != auth_num) { - if (newaccount) { - login_log("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s, ip: %s)\n", - account->userid, account->userid[len+1], auth_dat[i].pass, account->passwd, ip); + if( i != auth_num ) + { + if (newaccount) + { + login_log("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s, ip: %s)\n", account->userid, account->userid[len-1], auth_dat[i].pass, account->passwd, ip); return 1; // 1 = Incorrect Password } - if(use_md5_passwds) + if( use_md5_passwds ) MD5_String(account->passwd, user_password); else - memcpy(user_password, account->passwd, NAME_LENGTH); + safestrncpy(user_password, account->passwd, NAME_LENGTH); - if (!check_password(session[fd]->session_data, account->passwdenc, user_password, auth_dat[i].pass)) + if( !check_password(session[fd]->session_data, account->passwdenc, user_password, auth_dat[i].pass) ) { - login_log("Invalid password (account: %s, pass: %s, received pass: %s, ip: %s)\n", - account->userid, auth_dat[i].pass, (account->passwdenc) ? "[MD5]" : account->passwd, ip); + login_log("Invalid password (account: %s, pass: %s, received pass: %s, ip: %s)\n", account->userid, auth_dat[i].pass, (account->passwdenc) ? "[MD5]" : account->passwd, ip); return 1; // 1 = Incorrect Password } - if (auth_dat[i].state) { - login_log("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", - account->userid, account->passwd, auth_dat[i].state, ip); + if( auth_dat[i].connect_until_time != 0 && auth_dat[i].connect_until_time < time(NULL) ) + { + login_log("Connection refused (account: %s, pass: %s, expired ID, ip: %s)\n", account->userid, account->passwd, ip); + return 2; // 2 = This ID is expired + } + + if( auth_dat[i].ban_until_time != 0 ) + { // account is banned + strftime(tmpstr, 20, date_format, localtime(&auth_dat[i].ban_until_time)); + tmpstr[19] = '\0'; + if( auth_dat[i].ban_until_time > time(NULL) ) { // always banned + login_log("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)\n", account->userid, account->passwd, tmpstr, ip); + return 6; // 6 = Your are Prohibited to log in until %s + } else { // ban is over + login_log("End of ban (account: %s, pass: %s, previously banned until %s -> not more banned, ip: %s)\n", account->userid, account->passwd, tmpstr, ip); + auth_dat[i].ban_until_time = 0; // reset the ban time + } + } + + if( auth_dat[i].state ) + { + login_log("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", account->userid, account->passwd, auth_dat[i].state, ip); switch(auth_dat[i].state) { // packet 0x006a value + 1 case 1: // 0 = Unregistered ID case 2: // 1 = Incorrect Password @@ -1261,55 +1272,38 @@ int mmo_auth(struct mmo_account* account, int fd) } } - if (online_check) { + if( online_check ) + { struct online_login_data* data = idb_get(online_db,auth_dat[i].account_id); - if (data && data->char_server > -1) { + if( data && data->char_server > -1 ) + { //Request char servers to kick this account out. [Skotlex] unsigned char buf[8]; ShowNotice("User [%d] is already online - Rejected.\n",auth_dat[i].account_id); WBUFW(buf,0) = 0x2734; WBUFL(buf,2) = auth_dat[i].account_id; charif_sendallwos(-1, buf, 6); - if (data->waiting_disconnect == -1) + if( data->waiting_disconnect == -1 ) data->waiting_disconnect = add_timer(gettick()+30000, waiting_disconnect_timer, auth_dat[i].account_id, 0); return 3; // Rejected } } - - if (auth_dat[i].ban_until_time != 0) { // if account is banned - strftime(tmpstr, 20, date_format, localtime(&auth_dat[i].ban_until_time)); - tmpstr[19] = '\0'; - if (auth_dat[i].ban_until_time > time(NULL)) { // always banned - login_log("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)\n", - account->userid, account->passwd, tmpstr, ip); - return 6; // 6 = Your are Prohibited to log in until %s - } else { // ban is finished - login_log("End of ban (account: %s, pass: %s, previously banned until %s -> not more banned, ip: %s)\n", - account->userid, account->passwd, tmpstr, ip); - auth_dat[i].ban_until_time = 0; // reset the ban time - } - } - - if (auth_dat[i].connect_until_time != 0 && auth_dat[i].connect_until_time < time(NULL)) { - login_log("Connection refused (account: %s, pass: %s, expired ID, ip: %s)\n", - account->userid, account->passwd, ip); - return 2; // 2 = This ID is expired - } - - login_log("Authentification accepted (account: %s (id: %d), ip: %s)\n", account->userid, auth_dat[i].account_id, ip); - } else { - if (!newaccount) { - login_log("Unknown account (account: %s, received pass: %s, ip: %s)\n", - account->userid, account->passwd, ip); + } + else + { + if( !newaccount ) + { + login_log("Unknown account (account: %s, received pass: %s, ip: %s)\n", account->userid, account->passwd, ip); return 0; // 0 = Unregistered ID - } else { - int new_id = mmo_auth_new(account, account->userid[len+1], "a@a.com"); + } + else + { + int new_id = mmo_auth_new(account, account->userid[len-1], "a@a.com"); unsigned int tick = gettick(); - login_log("Account creation and authentification accepted (account %s (id: %d), pass: %s, sex: %c, connection with _F/_M, ip: %s)\n", - account->userid, new_id, account->passwd, account->userid[len+1], ip); + login_log("Account creation and authentification accepted (account %s (id: %d), pass: %s, sex: %c, connection with _F/_M, ip: %s)\n", account->userid, new_id, account->passwd, account->userid[len-1], ip); auth_before_save_file = 0; // Creation of an account -> save accounts file immediatly - if(DIFF_TICK(tick, new_reg_tick) > 0) + if( DIFF_TICK(tick, new_reg_tick) > 0 ) { //Update the registration check. num_regs = 0; new_reg_tick=tick +time_allowed*1000; @@ -1318,6 +1312,8 @@ int mmo_auth(struct mmo_account* account, int fd) } } + login_log("Authentification accepted (account: %s (id: %d), ip: %s)\n", account->userid, auth_dat[i].account_id, ip); + // auth start : time seed // Platform/Compiler dependant clock() for time check is removed. [Lance] // clock() is originally used to track processing ticks on program execution. @@ -1327,13 +1323,14 @@ int mmo_auth(struct mmo_account* account, int fd) account->account_id = auth_dat[i].account_id; account->login_id1 = rand(); account->login_id2 = rand(); - memcpy(account->lastlogin, auth_dat[i].lastlogin, 24); - memcpy(auth_dat[i].lastlogin, tmpstr, 24); + safestrncpy(account->lastlogin, auth_dat[i].lastlogin, 24); account->sex = auth_dat[i].sex; - if (account->sex != 2 && account->account_id < START_ACCOUNT_NUM) + + if( account->sex != 2 && account->account_id < START_ACCOUNT_NUM ) ShowWarning("Account %s has account id %d! Account IDs must be over %d to work properly!\n", account->userid, account->account_id, START_ACCOUNT_NUM); - strncpy(auth_dat[i].last_ip, ip, 16); + safestrncpy(auth_dat[i].lastlogin, tmpstr, sizeof(auth_dat[i].lastlogin)); + safestrncpy(auth_dat[i].last_ip, ip, sizeof(auth_dat[i].last_ip)); auth_dat[i].logincount++; // Save until for change ip/time of auth is not very useful => limited save for that @@ -2952,14 +2949,8 @@ int parse_admin(int fd) int lan_subnetcheck(uint32 ip) { int i; - - for(i = 0; i < subnet_count; i++) { - if(subnet[i].subnet == (ip & subnet[i].mask)) { - return subnet[i].char_ip; - } - } - - return 0; + ARR_FIND( 0, subnet_count, i, subnet[i].subnet == (ip & subnet[i].mask) ); + return ( i < subnet_count ) ? subnet[i].char_ip : 0; } //---------------------------------------------------------------------------------------- @@ -3175,61 +3166,56 @@ int parse_login(int fd) case 0x2710: // Connection request of a char-server if (RFIFOREST(fd) < 86) return 0; + { + char* server_name; + uint32 server_ip; + uint16 server_port; + + memset(&account, 0, sizeof(account)); + safestrncpy(account.userid, RFIFOP(fd,2), NAME_LENGTH); remove_control_chars(account.userid); + safestrncpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); remove_control_chars(account.passwd); + account.passwdenc = 0; + server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0'; remove_control_chars(server_name); + server_ip = ntohl(RFIFOL(fd, 54)); + server_port = ntohs(RFIFOW(fd, 58)); + + ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, account.userid, account.passwd, ip); + login_log("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, account.userid, account.passwd, ip); + + result = mmo_auth(&account, fd); + if( result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1 ) { - char* server_name; - uint32 server_ip; - uint16 server_port; - - memset(&account, 0, sizeof(account)); - memcpy(account.userid, RFIFOP(fd,2), NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars(account.userid); - memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars(account.passwd); - account.passwdenc = 0; - server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0'; remove_control_chars(server_name); - server_ip = ntohl(RFIFOL(fd, 54)); - server_port = ntohs(RFIFOW(fd, 58)); - login_log("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)\n", - server_name, CONVIP(server_ip), server_port, ip); - - result = mmo_auth(&account, fd); - if (result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1) { - login_log("Connection of the char-server '%s' accepted (account: %s, pass: %s, ip: %s)\n", - server_name, account.userid, account.passwd, ip); - ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); - memset(&server[account.account_id], 0, sizeof(struct mmo_char_server)); - server[account.account_id].ip = ntohl(RFIFOL(fd,54)); - server[account.account_id].port = ntohs(RFIFOW(fd,58)); - memcpy(server[account.account_id].name, server_name, 20); - server[account.account_id].users = 0; - server[account.account_id].maintenance = RFIFOW(fd,82); - server[account.account_id].new_ = RFIFOW(fd,84); - server_fd[account.account_id] = fd; - - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - - session[fd]->func_parse = parse_fromchar; - realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - - send_GM_accounts(fd); // send GM account to char-server - } else { - if (server_fd[account.account_id] != -1) { - ShowNotice("Connection of the char-server '%s' REFUSED - already connected (account: %ld-%s, pass: %s, ip: %s)\n", - server_name, account.account_id, account.userid, account.passwd, ip); - login_log("Connexion of the char-server '%s' REFUSED - already connected (account: %ld-%s, pass: %s, ip: %s)\n", - server_name, account.account_id, account.userid, account.passwd, ip); - } else { - ShowNotice("Connection of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s).\n", server_name, account.userid, account.passwd, ip); - login_log("Connexion of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s)\n", - server_name, account.userid, account.passwd, ip); - } - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 3; - WFIFOSET(fd,3); - } + ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); + login_log("Connection of the char-server '%s' accepted.\n", server_name); + memset(&server[account.account_id], 0, sizeof(struct mmo_char_server)); + server[account.account_id].ip = ntohl(RFIFOL(fd,54)); + server[account.account_id].port = ntohs(RFIFOW(fd,58)); + safestrncpy(server[account.account_id].name, server_name, sizeof(server[account.account_id].name)); + server[account.account_id].users = 0; + server[account.account_id].maintenance = RFIFOW(fd,82); + server[account.account_id].new_ = RFIFOW(fd,84); + server_fd[account.account_id] = fd; + + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x2711; + WFIFOB(fd,2) = 0; + WFIFOSET(fd,3); + + session[fd]->func_parse = parse_fromchar; + realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); + + send_GM_accounts(fd); // send GM account to char-server + } + else + { + ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name); + login_log("Connection of the char-server '%s' REFUSED.\n", server_name); + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x2711; + WFIFOB(fd,2) = 3; + WFIFOSET(fd,3); } + } RFIFOSKIP(fd,86); return 0; @@ -3362,7 +3348,7 @@ int parse_login(int fd) //----------------------- // Console Command Parser [Wizputer] //----------------------- -int parse_console(char*buf) +int parse_console(char* buf) { char command[256]; @@ -3377,13 +3363,15 @@ int parse_console(char*buf) strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 ) runflag = 0; - else if( strcmpi("alive", command) == 0 || - strcmpi("status", command) == 0 ) + else + if( strcmpi("alive", command) == 0 || + strcmpi("status", command) == 0 ) ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else if( strcmpi("help", command) == 0 ){ + else + if( strcmpi("help", command) == 0 ) { printf(CL_BOLD"Help of commands:"CL_RESET"\n"); printf(" To shutdown the server:\n"); - printf(" 'shutdown|exit|qui|end'\n"); + printf(" 'shutdown|exit|quit|end'\n"); printf(" To know if server is alive:\n"); printf(" 'alive|status'\n"); } diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile deleted file mode 100644 index d87a465ea..000000000 --- a/src/login_sql/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -all sql: login-server_sql - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/md5calc.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/grfio.h ../common/mapindex.h \ - ../common/md5calc.h - -login-server_sql: login.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../login-server_sql GNUmakefile - -# DO NOT DELETE - -login.o: login.c login.h $(COMMON_H) diff --git a/src/login_sql/Makefile.in b/src/login_sql/Makefile.in new file mode 100644 index 000000000..d10b49b5f --- /dev/null +++ b/src/login_sql/Makefile.in @@ -0,0 +1,46 @@ +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/grfio.o ../common/obj/mapindex.o \ + ../common/obj/ers.o ../common/obj/md5calc.o ../common/obj_sql/sql.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/grfio.h ../common/mapindex.h \ + ../common/ers.h ../common/md5calc.h ../common/sql.h + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + LOGIN_SERVER_SQL_DEPENDS=login.o $(COMMON_OBJ) +else + LOGIN_SERVER_SQL_DEPENDS=needs_mysql +endif + +##################################################################### +.PHONY : all login-server_sql clean help + +all: login-server_sql + +login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) + @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ login.o $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ + +clean: + rm -f *.o ../../login-server_sql@EXEEXT@ + +help: + @echo "possible targets are 'login-server_sql' 'all' 'clean' 'help'" + @echo "'login-server_sql' - login server (SQL version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +# DO NOT DELETE + +login.o: login.c login.h $(COMMON_H) + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 9411c6fec..bc3c1117a 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -12,20 +12,13 @@ #include "../common/showmsg.h" #include "../common/version.h" #include "../common/md5calc.h" +#include "../common/sql.h" #include "login.h" #include #include -#include // for stat/lstat/fstat -#include -#include #include - -//add include for DBMS(mysql) -#ifdef WIN32 -#include -#endif -#include +#include // for stat/lstat/fstat struct Login_Config { @@ -59,7 +52,7 @@ int server_fd[MAX_SERVERS]; // char server sockets struct mmo_char_server server[MAX_SERVERS]; // char server data // Advanced subnet check [LuzZza] -struct _subnet { +struct s_subnet { uint32 subnet; uint32 mask; uint32 char_ip; @@ -78,13 +71,10 @@ int time_allowed = 10; //in seconds int num_regs = 0; unsigned int new_reg_tick = 0; -MYSQL mysql_handle; -MYSQL_RES* sql_res ; -MYSQL_ROW sql_row ; -char tmpsql[65535]; +Sql* sql_handle; // database parameters -int login_server_port = 3306; +uint16 login_server_port = 3306; char login_server_ip[32] = "127.0.0.1"; char login_server_id[32] = "ragnarok"; char login_server_pw[32] = "ragnarok"; @@ -127,19 +117,19 @@ struct online_login_data { //----------------------------------------------------- -struct dbt *online_db; +struct dbt* online_db; static void* create_online_user(DBKey key, va_list args) { - struct online_login_data *p; - p = aCalloc(1, sizeof(struct online_login_data)); + struct online_login_data* p; + CREATE(p, struct online_login_data, 1); p->account_id = key.i; p->char_server = -1; p->waiting_disconnect = -1; - return p; + return p; } -int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len); +int charif_sendallwos(int sfd, uint8* buf, size_t len); static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data); //----------------------------------------------------- @@ -148,12 +138,12 @@ static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data void add_online_user(int char_server, int account_id) { - struct online_login_data *p; - if (!login_config.online_check) + struct online_login_data* p; + if( !login_config.online_check ) return; p = idb_ensure(online_db, account_id, create_online_user); p->char_server = char_server; - if (p->waiting_disconnect != -1) + if( p->waiting_disconnect != -1 ) { delete_timer(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = -1; @@ -162,19 +152,20 @@ void add_online_user(int char_server, int account_id) void remove_online_user(int account_id) { - if(!login_config.online_check) + if( !login_config.online_check ) return; - if (account_id == 99) { // reset all to offline + if( account_id == 99 ) + {// reset all to offline online_db->clear(online_db, NULL); // purge db return; } - idb_remove(online_db,account_id); + idb_remove(online_db, account_id); } static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data) { - struct online_login_data *p; - if ((p= idb_get(online_db, id)) != NULL && p->waiting_disconnect == id) + struct online_login_data* p = idb_get(online_db, id); + if( p != NULL && p->waiting_disconnect == id ) { p->waiting_disconnect = -1; remove_online_user(id); @@ -184,7 +175,7 @@ static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data static int sync_ip_addresses(int tid, unsigned int tick, int id, int data) { - unsigned char buf[2]; + uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; charif_sendallwos(-1, buf, 2); @@ -196,32 +187,30 @@ static int sync_ip_addresses(int tid, unsigned int tick, int id, int data) //----------------------------------------------------- void read_gm_account(void) { - if(!login_config.login_gm_read) - return; - sprintf(tmpsql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`> '0'",login_db_account_id,login_db_level,login_db,login_db_level); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - return; //Failed to read GM list! - } + if( !login_config.login_gm_read ) + return;// char server's job - if (gm_account_db != NULL) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `%s`,`%s` FROM `%s` WHERE `%s` > '0'", login_db_account_id, login_db_level, login_db, login_db_level) ) { - aFree(gm_account_db); - gm_account_db = NULL; + Sql_ShowDebug(sql_handle); + return;// Failed to read GM list! } - GM_num = 0; - - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - gm_account_db = (struct gm_account*)aCalloc((size_t)mysql_num_rows(sql_res), sizeof(struct gm_account)); - while ((sql_row = mysql_fetch_row(sql_res))) { - gm_account_db[GM_num].account_id = atoi(sql_row[0]); - gm_account_db[GM_num].level = atoi(sql_row[1]); - GM_num++; - } - mysql_free_result(sql_res); + + RECREATE(gm_account_db, struct gm_account, (size_t)Sql_NumRows(sql_handle)); + + for( GM_num = 0; SQL_SUCCESS == Sql_NextRow(sql_handle); ++GM_num ) + { + char* account; + char* level; + + Sql_GetData(sql_handle, 0, &account, NULL); + Sql_GetData(sql_handle, 1, &level, NULL); + + gm_account_db[GM_num].account_id = atoi(account); + gm_account_db[GM_num].level = atoi(level); } + + Sql_FreeResult(sql_handle); } //----------------------------------------------------- @@ -233,27 +222,32 @@ void send_GM_accounts(int fd) uint8 buf[32767]; uint16 len; - if(!login_config.login_gm_read) + if( !login_config.login_gm_read ) return; len = 4; WBUFW(buf,0) = 0x2732; - for(i = 0; i < GM_num; i++) + for( i = 0; i < GM_num; ++i ) + { // send only existing accounts. We can not create a GM account when server is online. - if (gm_account_db[i].level > 0) { + if( gm_account_db[i].level > 0 ) + { WBUFL(buf,len) = gm_account_db[i].account_id; WBUFB(buf,len+4) = (uint8)gm_account_db[i].level; len += 5; - if (len >= 32000) { + if( len >= 32000 ) + { ShowWarning("send_GM_accounts: Too many accounts! Only %d out of %d were sent.\n", i, GM_num); break; } } + } WBUFW(buf,2) = len; - if (fd == -1) // send to all charservers + if( fd == -1 )// send to all charservers charif_sendallwos(-1, buf, len); - else { // send only to target + else + {// send only to target WFIFOHEAD(fd,len); memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); @@ -268,27 +262,20 @@ void send_GM_accounts(int fd) int login_sql_ping(int tid, unsigned int tick, int id, int data) { ShowInfo("Pinging SQL server to keep connection alive...\n"); - mysql_ping(&mysql_handle); + Sql_Ping(sql_handle); return 0; } int sql_ping_init(void) { - int connection_timeout, connection_ping_interval; + uint32 connection_timeout, connection_ping_interval; // set a default value first connection_timeout = 28800; // 8 hours // ask the mysql server for the timeout value - if (!mysql_query(&mysql_handle, "SHOW VARIABLES LIKE 'wait_timeout'") - && (sql_res = mysql_store_result(&mysql_handle)) != NULL) { - sql_row = mysql_fetch_row(sql_res); - if (sql_row) - connection_timeout = atoi(sql_row[1]); - if (connection_timeout < 60) - connection_timeout = 60; - mysql_free_result(sql_res); - } + if( SQL_SUCCESS == Sql_GetTimeout(sql_handle, &connection_timeout) && connection_timeout < 60 ) + connection_timeout = 60; // establish keepalive connection_ping_interval = connection_timeout - 30; // 30-second reserve @@ -305,34 +292,26 @@ int mmo_auth_sqldb_init(void) { ShowStatus("Login server init....\n"); - mysql_init(&mysql_handle); + sql_handle = Sql_Malloc(); // DB connection start ShowStatus("Connect Login Database Server....\n"); - if (!mysql_real_connect(&mysql_handle, login_server_ip, login_server_id, login_server_pw, login_server_db, login_server_port, (char *)NULL, 0)) { - ShowFatalError("%s\n", mysql_error(&mysql_handle)); + if( SQL_ERROR == Sql_Connect(sql_handle, login_server_id, login_server_pw, login_server_ip, login_server_port, login_server_db) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(sql_handle); exit(1); - } else { - ShowStatus("Connect success!\n"); } - if( strlen(default_codepage) > 0 ) { - sprintf( tmpsql, "SET NAMES %s", default_codepage ); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + else + { + ShowStatus("Connect success!\n"); } - if (login_config.log_login) - { - sprintf(tmpsql, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100','login server started')", loginlog_db); + if( default_codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) + Sql_ShowDebug(sql_handle); - //query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - } + if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s` (`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100','login server started')", loginlog_db) ) + Sql_ShowDebug(sql_handle); sql_ping_init(); @@ -348,32 +327,23 @@ void mmo_db_close(void) int i, fd; //set log. - if (login_config.log_login) - { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100', 'login server shutdown')", loginlog_db); - - //query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - } + if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100', 'login server shutdown')", loginlog_db) ) + Sql_ShowDebug(sql_handle); - for (i = 0; i < MAX_SERVERS; i++) { - if ((fd = server_fd[i]) >= 0) - { //Clean only data related to servers we are connected to. [Skotlex] - sprintf(tmpsql,"DELETE FROM `sstatus` WHERE `index` = '%d'", i); - if (mysql_query(&mysql_handle, tmpsql)) - { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + for( i = 0; i < MAX_SERVERS; ++i ) + { + fd = server_fd[i]; + if( session_isValid(fd) ) + {// Clean only data related to servers we are connected to. [Skotlex] + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `sstatus` WHERE `index` = '%d'", i) ) + Sql_ShowDebug(sql_handle); do_close(fd); } } - mysql_close(&mysql_handle); + Sql_Free(sql_handle); + sql_handle = NULL; ShowStatus("close DB connect....\n"); - if (login_fd > 0) + if( login_fd > 0 ) do_close(login_fd); } @@ -383,75 +353,66 @@ void mmo_db_close(void) int mmo_auth_new(struct mmo_account* account, char sex) { unsigned int tick = gettick(); - char user_password[256]; + char md5buf[32+1]; + SqlStmt* stmt; + //Account Registration Flood Protection by [Kevin] - if(DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs) { + if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) + { ShowNotice("Account registration denied (registration limit exceeded)\n"); return 3; } - //Check for preexisting account - sprintf(tmpsql, "SELECT `%s` FROM `%s` WHERE `userid` = '%s'", login_db_userid, login_db, account->userid); - if(mysql_query(&mysql_handle, tmpsql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - return 1; //Return Incorrect user/pass? + // check if the account doesn't exist already + stmt = SqlStmt_Malloc(sql_handle); + if ( SQL_SUCCESS != SqlStmt_Prepare(stmt, "SELECT `%s` FROM `%s` WHERE `userid` = ?", login_db_userid, login_db) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) + || SqlStmt_NumRows(stmt) > 0 ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + return 1; // incorrect user/pass } - - sql_res = mysql_store_result(&mysql_handle); - if(mysql_num_rows(sql_res) > 0){ - mysql_free_result(sql_res); - return 1; //Already exists, return incorrect user/pass. + SqlStmt_Free(stmt); + + // insert new entry into db + //TODO: error checking + stmt = SqlStmt_Malloc(sql_handle); + SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`%s`, `%s`, `sex`, `email`) VALUES (?, ?, '%c', 'a@a.com')", login_db, login_db_userid, login_db_user_pass, TOUPPER(sex)); + SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)); + if( login_config.use_md5_passwds ) + { + MD5_String(account->passwd, md5buf); + SqlStmt_BindParam(stmt, 1, SQLDT_STRING, md5buf, 32); } - mysql_free_result(sql_res); //Only needed for the already-exists check... - - mysql_real_escape_string(&mysql_handle, account->userid, account->userid, strlen(account->userid)); - mysql_real_escape_string(&mysql_handle, account->passwd, account->passwd, strlen(account->passwd)); - - sex = TOUPPER(sex); - - if (login_config.use_md5_passwds) - MD5_String(account->passwd, user_password); else - jstrescapecpy(user_password, account->passwd); - - ShowInfo("New account: user: %s with passwd: %s sex: %c\n", account->userid, user_password, sex); - - sprintf(tmpsql, "INSERT INTO `%s` (`%s`, `%s`, `sex`, `email`) VALUES ('%s', '%s', '%c', '%s')", login_db, login_db_userid, login_db_user_pass, account->userid, user_password, sex, "a@a.com"); + SqlStmt_BindParam(stmt, 1, SQLDT_STRING, account->passwd, strnlen(account->passwd, NAME_LENGTH)); + SqlStmt_Execute(stmt); + SqlStmt_Free(stmt); - if(mysql_query(&mysql_handle, tmpsql)){ - //Failed to insert new acc :/ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - return 1; - } + ShowInfo("New account: userid='%s' passwd='%s' sex='%c'\n", account->userid, account->passwd, TOUPPER(sex)); - if(mysql_field_count(&mysql_handle) == 0 && - mysql_insert_id(&mysql_handle) < START_ACCOUNT_NUM) { - //Invalid Account ID! Must update it. - int id = (int)mysql_insert_id(&mysql_handle); - sprintf(tmpsql, "UPDATE `%s` SET `%s`='%d' WHERE `%s`='%d'", login_db, login_db_account_id, START_ACCOUNT_NUM, login_db_account_id, id); - if(mysql_query(&mysql_handle, tmpsql)){ - ShowError("New account %s has an invalid account ID [%d] which could not be updated (account_id must be %d or higher).", account->userid, id, START_ACCOUNT_NUM); - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); + if( Sql_LastInsertId(sql_handle) < START_ACCOUNT_NUM ) + {// Invalid Account ID! Must update it. + uint64 id = Sql_LastInsertId(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `%s`='%d' WHERE `%s`='%lld'", login_db, login_db_account_id, START_ACCOUNT_NUM, login_db_account_id, id) ) + { + Sql_ShowDebug(sql_handle); + ShowError("New account '%s' has an invalid account ID [%lld] which could not be updated (account_id must be %d or higher).", account->userid, id, START_ACCOUNT_NUM); //Just delete it and fail. - sprintf(tmpsql, "DELETE FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, id); - if(mysql_query(&mysql_handle, tmpsql)){ - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `%s`='%lld'", login_db, login_db_account_id, id) ) + Sql_ShowDebug(sql_handle); return 1; } - ShowNotice("Updated New account %s's ID %d->%d (account_id must be %d or higher).", account->userid, id, START_ACCOUNT_NUM, START_ACCOUNT_NUM); + ShowNotice("Updated New account '%s' ID %d->%d (account_id must be %d or higher).", account->userid, id, START_ACCOUNT_NUM, START_ACCOUNT_NUM); } - if(DIFF_TICK(tick, new_reg_tick) > 0) - { //Update the registration check. - num_regs=0; - new_reg_tick=tick+time_allowed*1000; + if( DIFF_TICK(tick, new_reg_tick) > 0 ) + {// Update the registration check. + num_regs = 0; + new_reg_tick = tick + time_allowed*1000; } - num_regs++; - + ++num_regs; return 0; } @@ -459,16 +420,19 @@ int mmo_auth_new(struct mmo_account* account, char sex) //-------------------------------------------------------------------- // Packet send to all char-servers, except one (wos: without our self) //-------------------------------------------------------------------- -int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) +int charif_sendallwos(int sfd, uint8* buf, size_t len) { - int i, c, fd; + int i, c; - for(i = 0, c = 0; i < MAX_SERVERS; i++) { - if ((fd = server_fd[i]) > 0 && fd != sfd) { + for( i = 0, c = 0; i < MAX_SERVERS; ++i ) + { + int fd = server_fd[i]; + if( session_isValid(fd) && fd != sfd ) + { WFIFOHEAD(fd,len); memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); - c++; + ++c; } } @@ -482,7 +446,9 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) bool check_encrypted(const char* str1, const char* str2, const char* passwd) { char md5str[64], md5bin[32]; - snprintf(md5str, sizeof(md5str), "%s%s", str1, str2); md5str[sizeof(md5str)-1] = '\0'; + + snprintf(md5str, sizeof(md5str), "%s%s", str1, str2); + md5str[sizeof(md5str)-1] = '\0'; MD5_String2binary(md5str, md5bin); return (0==memcmp(passwd, md5bin, 16)); @@ -512,134 +478,144 @@ bool check_password(struct login_session_data* ld, int passwdenc, const char* pa int mmo_auth(struct mmo_account* account, int fd) { time_t ban_until_time; - char t_uid[256]; + char esc_userid[NAME_LENGTH*2+1];// escaped username char user_password[256], password[256]; long connect_until; int state; + size_t len; + char* data; char ip[16]; - uint32 ipl = session[fd]->client_addr; - uint8* sin_addr = (uint8*)&ipl; - sprintf(ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]); + uint8* sin_addr = (uint8*)&session[fd]->client_addr; + sprintf(ip, "%u.%u.%u.%u", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]); // DNS Blacklist check - if(login_config.use_dnsbl) + if( login_config.use_dnsbl ) { char r_ip[16]; char ip_dnsbl[256]; char *dnsbl_serv; bool matched = false; - sprintf(r_ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); + sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); - for (dnsbl_serv = strtok(login_config.dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",")) + for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) { - if (!matched) { - sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); - if(host2ip(ip_dnsbl)) - matched = true; - } + sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); + if( host2ip(ip_dnsbl) ) + matched = true; } - if (matched) { + if( matched ) + { ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); return 3; } } + //Client Version check + if( login_config.check_client_version && account->version != 0 && + account->version != login_config.client_version_to_connect ) + return 5; + + len = strnlen(account->userid, NAME_LENGTH); + // Account creation with _M/_F - if (login_config.new_account_flag) + if( login_config.new_account_flag ) { - int len = strlen(account->userid) - 2; - if (account->passwdenc == 0 && account->userid[len] == '_' && - (account->userid[len+1] == 'F' || account->userid[len+1] == 'M' || - account->userid[len+1] == 'f' || account->userid[len+1] == 'm') && - len >= 4 && strlen(account->passwd) >= 4) + if( len > 2 && strnlen(account->passwd, NAME_LENGTH) >= 4 && // valid user and password lengths + account->passwdenc == 0 &&// unencoded password + account->userid[len-2] == '_' && memchr("FfMm", (unsigned char)account->userid[len-1], 4) ) // _M/_F suffix { int result; - account->userid[len] = '\0'; //Terminating the name. - if ((result = mmo_auth_new(account, account->userid[len+1]))) - return result; //Failed to make account. [Skotlex]. + account->userid[len-2] = '\0';// terminate the name. + result = mmo_auth_new(account, account->userid[len-1]); + if( result ) + return result;// Failed to make account. [Skotlex]. } } - jstrescapecpy(t_uid,account->userid); + // escape username + Sql_EscapeStringLen(sql_handle, esc_userid, account->userid, len); // retrieve login entry for the specified username - sprintf(tmpsql, "SELECT `%s`,`%s`,`lastlogin`,`sex`,`connect_until`,`ban_until`,`state`,`%s`" - " FROM `%s` WHERE `%s`= %s '%s'", login_db_account_id, login_db_user_pass, login_db_level, login_db, login_db_userid, login_config.case_sensitive ? "BINARY" : "", t_uid); + if( SQL_ERROR == Sql_Query(sql_handle, + "SELECT `%s`,`%s`,`lastlogin`,`sex`,`connect_until`,`ban_until`,`state`,`%s` FROM `%s` WHERE `%s`= %s '%s'", + login_db_account_id, login_db_user_pass, login_db_level, + login_db, login_db_userid, (login_config.case_sensitive ? "BINARY" : ""), esc_userid) ) + Sql_ShowDebug(sql_handle); //login {0-account_id/1-user_pass/2-lastlogin/3-sex/4-connect_untl/5-ban_until/6-state/7-level} - // query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (!sql_res) { - ShowError("mmo_auth DB result error ! \n"); - return 0; - } - sql_row = mysql_fetch_row(sql_res); - if (!sql_row) { - //there's no id. - ShowNotice("auth failed: no such account %s\n", account->userid); - mysql_free_result(sql_res); + if( Sql_NumRows(sql_handle) == 0 ) // no such entry + { + ShowNotice("auth failed: no such account '%s'\n", esc_userid); + Sql_FreeResult(sql_handle); return 0; } - account->account_id = atoi(sql_row[0]); - strncpy(password, sql_row[1], sizeof(password)-1); - strncpy(account->lastlogin, sql_row[2], 24); - account->sex = sql_row[3][0] == 'S' ? 2 : sql_row[3][0]=='M' ? 1 : 0; - connect_until = atol(sql_row[4]); - ban_until_time = atol(sql_row[5]); - state = atoi(sql_row[6]); - account->level = atoi(sql_row[7]); - if (account->level > 99) account->level = 99; - - //This function has too many leaks because this is only free'd on the end. - //Better avoid that and free it as soon as possible. [Skotlex] - mysql_free_result(sql_res); + Sql_NextRow(sql_handle); //TODO: error checking? - //Client Version check - if(login_config.check_client_version && account->version != 0 && - account->version != login_config.client_version_to_connect) - return 5; + Sql_GetData(sql_handle, 0, &data, &len); + account->account_id = atoi(data); - switch (state) { - case -3: //id is banned - case -2: //dynamic ban - return state; + Sql_GetData(sql_handle, 1, &data, &len); + if( len > sizeof(password) - 1 ) + { +#if defined(DEBUG) + ShowDebug("mmo_auth: password buffer is too small (len=%u,buflen=%u)\n", len, sizeof(password)); +#endif + len = sizeof(password) - 1; } + memcpy(password, data, len); + password[len] = '\0'; + + Sql_GetData(sql_handle, 2, &data, &len); safestrncpy(account->lastlogin, data, sizeof(account->lastlogin)); + Sql_GetData(sql_handle, 3, &data, &len); account->sex = (*data == 'S' ? 2 : *data == 'M' ? 1 : 0); + Sql_GetData(sql_handle, 4, &data, &len); connect_until = atol(data); + Sql_GetData(sql_handle, 5, &data, &len); ban_until_time = atol(data); + Sql_GetData(sql_handle, 6, &data, &len); state = atoi(data); + Sql_GetData(sql_handle, 7, &data, &len); account->level = atoi(data); + if( account->level > 99 ) + account->level = 99; - if (login_config.use_md5_passwds) + Sql_FreeResult(sql_handle); + + if( login_config.use_md5_passwds ) MD5_String(account->passwd, user_password); else - memcpy(user_password, account->passwd, NAME_LENGTH); + safestrncpy(user_password, account->passwd, NAME_LENGTH); - if (!check_password(session[fd]->session_data, account->passwdenc, user_password, password)) + if( !check_password(session[fd]->session_data, account->passwdenc, user_password, password) ) { - ShowInfo("Invalid password (account: %s, pass: %s, received pass: %s, ip: %s)\n", - account->userid, password, (account->passwdenc) ? "[MD5]" : account->passwd, ip); + ShowInfo("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", + esc_userid, password, (account->passwdenc) ? "[MD5]" : user_password, ip); return 1; // 1 = Incorrect Password } - if (ban_until_time != 0) { // if account is banned - if (ban_until_time > time(NULL)) // always banned + if( connect_until != 0 && connect_until < time(NULL) ) + return 2; // 2 = This ID is expired + + if( ban_until_time != 0 ) + {// account is banned + if( ban_until_time > time(NULL) )// still banned return 6; // 6 = Your are Prohibited to log in until %s - sprintf(tmpsql, "UPDATE `%s` SET `ban_until`='0' %s WHERE `%s`= '%d'", - login_db, state==7?",state='0'":"", - login_db_account_id, account->account_id); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `ban_until`='0' %s WHERE `%s`= '%d'", + login_db, (state == 7 ? ",state='0'" : ""), login_db_account_id, account->account_id) ) + Sql_ShowDebug(sql_handle); } - if (state) - switch(state) { // packet 0x006a value + 1 + switch( state ) + { + case -3: //id is banned + case -2: //dynamic ban + return state; + } + + switch( state ) + {// packet 0x006a value + 1 + case 0: + break; case 1: // 0 = Unregistered ID case 2: // 1 = Incorrect Password case 3: // 2 = This ID is expired @@ -668,19 +644,18 @@ int mmo_auth(struct mmo_account* account, int fd) return 99; // 99 = ID has been totally erased } - if (connect_until != 0 && connect_until < time(NULL)) - return 2; // 2 = This ID is expired - - if (login_config.online_check) { - struct online_login_data* data = idb_get(online_db,account->account_id); - if (data && data->char_server > -1) { + if( login_config.online_check ) + { + struct online_login_data* data = idb_get(online_db, account->account_id); + if( data && data->char_server > -1 ) + { //Request char servers to kick this account out. [Skotlex] - unsigned char buf[8]; - ShowNotice("User [%s] is already online - Rejected.\n",account->userid); + uint8 buf[8]; + ShowNotice("User '%s' is already online - Rejected.\n", account->userid); WBUFW(buf,0) = 0x2734; WBUFL(buf,2) = account->account_id; charif_sendallwos(-1, buf, 6); - if (data->waiting_disconnect == -1) + if( data->waiting_disconnect == -1 ) data->waiting_disconnect = add_timer(gettick()+30000, waiting_disconnect_timer, account->account_id, 0); return 3; // Rejected } @@ -689,30 +664,30 @@ int mmo_auth(struct mmo_account* account, int fd) account->login_id1 = rand(); account->login_id2 = rand(); - if (account->sex != 2 && account->account_id < START_ACCOUNT_NUM) + if( account->sex != 2 && account->account_id < START_ACCOUNT_NUM ) ShowWarning("Account %s has account id %d! Account IDs must be over %d to work properly!\n", account->userid, account->account_id, START_ACCOUNT_NUM); - sprintf(tmpsql, "UPDATE `%s` SET `lastlogin` = NOW(), `logincount`=`logincount` +1, `last_ip`='%s' WHERE `%s` = '%d'", - login_db, ip, login_db_account_id, account->account_id); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - return -1; + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `lastlogin` = NOW(), `logincount`=`logincount`+1, `last_ip`='%s' WHERE `%s` = '%d'", + login_db, ip, login_db_account_id, account->account_id) ) + Sql_ShowDebug(sql_handle); + + return -1; // account OK } static int online_db_setoffline(DBKey key, void* data, va_list ap) { - struct online_login_data *p = (struct online_login_data *)data; + struct online_login_data* p = (struct online_login_data*)data; int server = va_arg(ap, int); - if (server == -1) { + if( server == -1 ) + { p->char_server = -1; - if (p->waiting_disconnect != -1) + if( p->waiting_disconnect != -1 ) { delete_timer(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = -1; } - } else if (p->char_server == server) + } + else if( p->char_server == server ) p->char_server = -2; //Char server disconnected. return 0; } @@ -728,44 +703,40 @@ int parse_fromchar(int fd) char ip[16]; ip2str(ipl, ip); - for(id = 0; id < MAX_SERVERS; id++) - if (server_fd[id] == fd) + for( id = 0; id < MAX_SERVERS; ++id ) + if( server_fd[id] == fd ) break; - if (id == MAX_SERVERS) { // not a char server + if( id == MAX_SERVERS ) + {// not a char server set_eof(fd); do_close(fd); return 0; } - if(session[fd]->eof) { + if( session[fd]->eof ) + { ShowStatus("Char-server '%s' has disconnected.\n", server[id].name); server_fd[id] = -1; memset(&server[id], 0, sizeof(struct mmo_char_server)); - online_db->foreach(online_db,online_db_setoffline,id); //Set all chars from this char server to offline. - sprintf(tmpsql, "DELETE FROM `sstatus` WHERE `index`='%d'", id); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char server to offline. + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `sstatus` WHERE `index`='%d'", id) ) + Sql_ShowDebug(sql_handle); do_close(fd); return 0; } - while (RFIFOREST(fd) >= 2) + while( RFIFOREST(fd) >= 2 ) { uint16 command = RFIFOW(fd,0); - switch (command) + switch( command ) { case 0x2709: // request from map-server via char-server to reload GM accounts - if (login_config.log_login) + if( login_config.log_login ) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`log`) VALUES (NOW(), '%u', '%s', 'GM reload request')", loginlog_db, ipl, server[id].name); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`log`) VALUES (NOW(), '%u', '%s', 'GM reload request')", loginlog_db, ipl, server[id].name) ) + Sql_ShowDebug(sql_handle); } read_gm_account(); // send GM accounts to all char-servers @@ -774,12 +745,13 @@ int parse_fromchar(int fd) break; case 0x2712: // request from char-server to authenticate an account - if (RFIFOREST(fd) < 19) + if( RFIFOREST(fd) < 19 ) return 0; { int account_id; account_id = RFIFOL(fd,2); // speed up - for(i = 0; i < AUTH_FIFO_SIZE; i++) { + for( i = 0; i < AUTH_FIFO_SIZE; ++i ) + { if( auth_fifo[i].account_id == account_id && auth_fifo[i].login_id1 == RFIFOL(fd,6) && auth_fifo[i].login_id2 == RFIFOL(fd,10) && @@ -792,30 +764,45 @@ int parse_fromchar(int fd) } } - if (i != AUTH_FIFO_SIZE && account_id > 0) { // send ack - time_t connect_until_time = 0; - char email[40] = ""; - account_id=RFIFOL(fd,2); - sprintf(tmpsql, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - sql_row = mysql_fetch_row(sql_res); - connect_until_time = atol(sql_row[1]); - strncpy(email, sql_row[0], 40); email[39] = 0; - mysql_free_result(sql_res); + if( i != AUTH_FIFO_SIZE && account_id > 0 ) + {// send ack + uint32 connect_until_time = 0; + char email[40]; + + memset(email, 0, sizeof(email)); + account_id = RFIFOL(fd,2); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data = NULL; + size_t len = 0; + + Sql_GetData(sql_handle, 0, &data, &len); + if( len > sizeof(email) ) + { +#if defined(DEBUG) + ShowDebug("parse_fromchar:0x2712: email is too long (len=%u,maxlen=%u)\n", len, sizeof(email)); +#endif + len = sizeof(email); + } + memcpy(email, data, len); + + Sql_GetData(sql_handle, 1, &data, NULL); + connect_until_time = (uint32)strtoul(data, NULL, 10); + + Sql_FreeResult(sql_handle); } WFIFOHEAD(fd,51); WFIFOW(fd,0) = 0x2713; WFIFOL(fd,2) = account_id; WFIFOB(fd,6) = 0; memcpy(WFIFOP(fd, 7), email, 40); - WFIFOL(fd,47) = (unsigned long) connect_until_time; + WFIFOL(fd,47) = connect_until_time; WFIFOSET(fd,51); - } else { + } + else + { WFIFOHEAD(fd,51); WFIFOW(fd,0) = 0x2713; WFIFOL(fd,2) = account_id; @@ -832,17 +819,13 @@ int parse_fromchar(int fd) return 0; // how many users on world? (update) - if (server[id].users != RFIFOL(fd,2)) + if( server[id].users != RFIFOL(fd,2) ) { ShowStatus("set users %s : %d\n", server[id].name, RFIFOL(fd,2)); server[id].users = RFIFOL(fd,2); - sprintf(tmpsql,"UPDATE `sstatus` SET `user` = '%d' WHERE `index` = '%d'", server[id].users, id); - // query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `sstatus` SET `user` = '%d' WHERE `index` = '%d'", server[id].users, id) ) + Sql_ShowDebug(sql_handle); } // send some answer WFIFOHEAD(fd,6); @@ -853,31 +836,44 @@ int parse_fromchar(int fd) break; case 0x2716: // received an e-mail/limited time request, because a player comes back from a map-server to the char-server - if (RFIFOREST(fd) < 6) + if( RFIFOREST(fd) < 6 ) return 0; { int account_id; - time_t connect_until_time = 0; - char email[40] = ""; + uint32 connect_until_time = 0; + char email[40]; + + memset(email, 0, sizeof(email)); account_id = RFIFOL(fd,2); - sprintf(tmpsql,"SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'",login_db, login_db_account_id, account_id); - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res) { - sql_row = mysql_fetch_row(sql_res); - connect_until_time = atol(sql_row[1]); - strcpy(email, sql_row[0]); + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + size_t len; + + Sql_GetData(sql_handle, 0, &data, &len); + if( len > sizeof(email) ) + { +#if defined(DEBUG) + ShowDebug("parse_fromchar:0x2716: email is too long (len=%u,maxlen=%u)\n", len, sizeof(email)); +#endif + len = sizeof(email); + } + memcpy(email, data, len); + + Sql_GetData(sql_handle, 1, &data, NULL); + connect_until_time = (uint32)strtoul(data, NULL, 10); + + Sql_FreeResult(sql_handle); } - mysql_free_result(sql_res); //printf("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, RFIFOL(fd,2)); WFIFOHEAD(fd,50); WFIFOW(fd,0) = 0x2717; WFIFOL(fd,2) = RFIFOL(fd,2); memcpy(WFIFOP(fd, 6), email, 40); - WFIFOL(fd,46) = (unsigned long) connect_until_time; + WFIFOL(fd,46) = connect_until_time; WFIFOSET(fd,50); RFIFOSKIP(fd,6); @@ -905,43 +901,58 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 86) return 0; { - int acc; + int account_id; char actual_email[40], new_email[40]; - acc = RFIFOL(fd,2); + + account_id = RFIFOL(fd,2); memcpy(actual_email, RFIFOP(fd,6), 40); memcpy(new_email, RFIFOP(fd,46), 40); - if (e_mail_check(actual_email) == 0) + if( e_mail_check(actual_email) == 0 ) ShowWarning("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", - server[id].name, acc, ip); - else if (e_mail_check(new_email) == 0) + server[id].name, account_id, ip); + else if( e_mail_check(new_email) == 0 ) ShowWarning("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", - server[id].name, acc, ip); - else if (strcmpi(new_email, "a@a.com") == 0) + server[id].name, account_id, ip); + else if( strcmpi(new_email, "a@a.com") == 0 ) ShowWarning("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", - server[id].name, acc, ip); - else { - sprintf(tmpsql, "SELECT `%s`,`email` FROM `%s` WHERE `%s` = '%d'", login_db_userid, login_db, login_db_account_id, acc); - if (mysql_query(&mysql_handle, tmpsql)) + server[id].name, account_id, ip); + else if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `%s`,`email` FROM `%s` WHERE `%s` = '%d'", login_db_userid, login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + size_t len; + + Sql_GetData(sql_handle, 1, &data, &len); + if( len > sizeof(actual_email) ) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); +#if defined(DEBUG) + ShowDebug("parse_fromchar:0x2722: email is too long (len=%u,maxlen=%u)\n", len, sizeof(actual_email)); +#endif + len = sizeof(actual_email); } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - sql_row = mysql_fetch_row(sql_res); //row fetching - - if (strcmpi(sql_row[1], actual_email) == 0) { - sprintf(tmpsql, "UPDATE `%s` SET `email` = '%s' WHERE `%s` = '%d'", login_db, new_email, login_db_account_id, acc); - // query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - ShowInfo("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", - server[id].name, acc, sql_row[0], actual_email, ip); + if( strncasecmp(data, actual_email, sizeof(actual_email)) == 0 ) + { + char esc_user_id[NAME_LENGTH*2+1]; + char esc_new_email[sizeof(new_email)*2+1]; + + Sql_GetData(sql_handle, 0, &data, &len); + if( len > NAME_LENGTH ) + { +#if defined(DEBUG) + ShowDebug("parse_fromchar:0x2722: userid is too long (len=%u,maxlen=%u)\n", len, NAME_LENGTH); +#endif + len = NAME_LENGTH; } - } + Sql_EscapeStringLen(sql_handle, esc_user_id, data, len); + Sql_EscapeStringLen(sql_handle, esc_new_email, new_email, strnlen(new_email, sizeof(new_email))); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `email` = '%s' WHERE `%s` = '%d'", login_db, esc_new_email, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + ShowInfo("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d ('%s'), new e-mail: '%s', ip: %s).\n", + server[id].name, account_id, esc_user_id, esc_new_email, ip); + } + Sql_FreeResult(sql_handle); } RFIFOSKIP(fd, 86); @@ -952,33 +963,31 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - int acc, statut; - acc = RFIFOL(fd,2); - statut = RFIFOL(fd,6); - sprintf(tmpsql, "SELECT `state` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, acc); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - sql_row = mysql_fetch_row(sql_res); // row fetching - } - if (atoi(sql_row[0]) != statut && statut != 0) { - unsigned char buf[16]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = acc; - WBUFB(buf,6) = 0; // 0: change of statut, 1: ban - WBUFL(buf,7) = statut; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - sprintf(tmpsql,"UPDATE `%s` SET `state` = '%d' WHERE `%s` = '%d'", login_db, statut,login_db_account_id,acc); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); + int account_id, state; + account_id = RFIFOL(fd,2); + state = RFIFOL(fd,6); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `state` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + if( atoi(data) != state && state != 0 ) + { + uint8 buf[11]; + WBUFW(buf,0) = 0x2731; + WBUFL(buf,2) = account_id; + WBUFB(buf,6) = 0; // 0: change of state, 1: ban + WBUFL(buf,7) = state; // status or final date of a banishment + charif_sendallwos(-1, buf, 11); + } + Sql_FreeResult(sql_handle); } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state` = '%d' WHERE `%s` = '%d'", login_db, state, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + RFIFOSKIP(fd,10); } break; @@ -987,51 +996,49 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 18) return 0; { - int acc; + int account_id; struct tm *tmtime; - time_t timestamp, tmptime; - acc = RFIFOL(fd,2); - sprintf(tmpsql, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - sql_res = mysql_store_result(&mysql_handle); - if (sql_res) { - sql_row = mysql_fetch_row(sql_res); // row fetching + time_t tmptime = 0; + time_t timestamp = time(NULL); + + account_id = RFIFOL(fd,2); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + tmptime = (time_t)strtoul(data, NULL, 10); + if( tmptime > time(NULL) ) + timestamp = tmptime; } - tmptime = atol(sql_row[0]); - if (tmptime == 0 || tmptime < time(NULL)) - timestamp = time(NULL); - else - timestamp = tmptime; tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6); - tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8); - tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10); - tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,12); - tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,14); - tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,16); + tmtime->tm_year = tmtime->tm_year + (int16)RFIFOW(fd,6); + tmtime->tm_mon = tmtime->tm_mon + (int16)RFIFOW(fd,8); + tmtime->tm_mday = tmtime->tm_mday + (int16)RFIFOW(fd,10); + tmtime->tm_hour = tmtime->tm_hour + (int16)RFIFOW(fd,12); + tmtime->tm_min = tmtime->tm_min + (int16)RFIFOW(fd,14); + tmtime->tm_sec = tmtime->tm_sec + (int16)RFIFOW(fd,16); timestamp = mktime(tmtime); - if (timestamp != -1) { - if (timestamp <= time(NULL)) + if( timestamp != (time_t)-1 ) + { + if( timestamp <= time(NULL) ) timestamp = 0; - if (tmptime != timestamp) { - if (timestamp != 0) { - unsigned char buf[16]; + if( tmptime != timestamp ) + { + if( timestamp != 0 ) + { + uint8 buf[11]; WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = acc; + WBUFL(buf,2) = account_id; WBUFB(buf,6) = 1; // 0: change of statut, 1: ban - WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment + WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment charif_sendallwos(-1, buf, 11); } - ShowNotice("Account: %d Banned until: %ld\n", acc, timestamp); - sprintf(tmpsql, "UPDATE `%s` SET `ban_until` = '%ld' WHERE `%s` = '%d'", login_db, (unsigned long)timestamp, login_db_account_id, acc); - // query - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + ShowNotice("Account: %d Banned until: %lu\n", account_id, (unsigned long)timestamp); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `ban_until` = '%lu' WHERE `%s` = '%d'", login_db, (unsigned long)timestamp, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); } } @@ -1043,110 +1050,106 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 6) return 0; { - int acc,sex; - unsigned char buf[16]; - acc = RFIFOL(fd,2); - sprintf(tmpsql,"SELECT `sex` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc); - - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - return 0; - } + int account_id; + int sex; + uint8 buf[16]; + + account_id = RFIFOL(fd,2); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `sex` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; - sql_res = mysql_store_result(&mysql_handle) ; + Sql_GetData(sql_handle, 0, &data, NULL); + if( *data == 'M' || *data == 'm' ) + sex = 0; //Change to female + else + sex = 1; //Change to male - if (sql_res) { - if (mysql_num_rows(sql_res) == 0) { - mysql_free_result(sql_res); - return 0; - } - sql_row = mysql_fetch_row(sql_res); //row fetching - } + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `sex` = '%c' WHERE `%s` = '%d'", login_db, (sex ? 'M' : 'F'), login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); - if (strcmpi(sql_row[0], "M") == 0) - sex = 0; //Change to female - else - sex = 1; //Change to make - sprintf(tmpsql,"UPDATE `%s` SET `sex` = '%c' WHERE `%s` = '%d'", login_db, (sex?'M':'F'), login_db_account_id, acc); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); + WBUFW(buf,0) = 0x2723; + WBUFL(buf,2) = account_id; + WBUFB(buf,6) = sex; + charif_sendallwos(-1, buf, 7); } - WBUFW(buf,0) = 0x2723; - WBUFL(buf,2) = acc; - WBUFB(buf,6) = sex; - charif_sendallwos(-1, buf, 7); RFIFOSKIP(fd,6); } break; case 0x2728: // save account_reg2 - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) + if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; - if (RFIFOL(fd,4) > 0) { - int acc,p,j,len; - char str[32]; - char temp_str[64]; //Needs twice as much space as the original string. - char temp_str2[512]; - char value[256]; - unsigned char *buf; - acc = RFIFOL(fd,4); - buf = (unsigned char*)aCalloc(RFIFOW(fd,2)+1, sizeof(unsigned char)); + if( RFIFOL(fd,4) > 0 ) + { + SqlStmt* stmt; + int account_id; + size_t off; + + account_id = RFIFOL(fd,4); + //Delete all global account variables.... - sprintf(tmpsql,"DELETE FROM `%s` WHERE `type`='1' AND `account_id`='%d';",reg_db,acc); - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`='1' AND `account_id`='%d';", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + //Proceed to insert them.... - for(j=0,p=13;j 0) { //Found a match - sprintf(tmpsql,"UPDATE `%s` SET `ban_until` = '0' WHERE `%s` = '%d'", login_db,login_db_account_id,acc); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + int account_id; + + account_id = RFIFOL(fd,2); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + {// Found a match + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `ban_until` = '0' WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) + Sql_ShowDebug(sql_handle); } - if (sql_res) mysql_free_result(sql_res); RFIFOSKIP(fd,6); return 0; @@ -1194,33 +1197,36 @@ int parse_fromchar(int fd) { int account_id = RFIFOL(fd, 2); int char_id = RFIFOL(fd, 6); - int p; - sprintf(tmpsql, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'",reg_db, account_id); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - break; - } - sql_res = mysql_store_result(&mysql_handle) ; - if (!sql_res) { - break; - } + size_t off; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + WFIFOHEAD(fd,10000); WFIFOW(fd,0) = 0x2729; WFIFOL(fd,4) = account_id; WFIFOL(fd,8) = char_id; WFIFOB(fd,12) = 1; //Type 1 for Account2 registry - p = 13; - while ((sql_row = mysql_fetch_row(sql_res)) && p < 9000) { - if (sql_row[0][0]) { - p+= sprintf(WFIFOP(fd,p), "%s", sql_row[0])+1; //We add 1 to consider the '\0' in place. - p+= sprintf(WFIFOP(fd,p), "%s", sql_row[1])+1; + off = 13; + while( SQL_SUCCESS == Sql_NextRow(sql_handle) && off < 9000 ) + { + char* data; + + // str + Sql_GetData(sql_handle, 0, &data, NULL); + if( *data != '\0' ) + { + off += sprintf(WFIFOP(fd,off), "%s", data)+1; //We add 1 to consider the '\0' in place. + + // value + Sql_GetData(sql_handle, 1, &data, NULL); + off += sprintf(WFIFOP(fd,off), "%s", data)+1; } } - mysql_free_result(sql_res); - if (p >= 9000) + Sql_FreeResult(sql_handle); + if( off >= 9000 ) ShowWarning("Too many account2 registries for AID %d. Some registries were not sent.\n", account_id); - WFIFOW(fd,2) = p; + WFIFOW(fd,2) = (uint16)off; WFIFOSET(fd,WFIFOW(fd,2)); RFIFOSKIP(fd,10); @@ -1258,53 +1264,39 @@ int parse_fromchar(int fd) int lan_subnetcheck(uint32 ip) { int i; - - for(i = 0; i < subnet_count; i++) { - if(subnet[i].subnet == (ip & subnet[i].mask)) { - return subnet[i].char_ip; - } - } - - return 0; + ARR_FIND( 0, subnet_count, i, subnet[i].subnet == (ip & subnet[i].mask) ); + return ( i < subnet_count ) ? subnet[i].char_ip : 0; } int login_ip_ban_check(uint32 ip) { uint8* p = (uint8*)&ip; - sprintf(tmpsql, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%d.*.*.*' OR `list` = '%d.%d.*.*' OR `list` = '%d.%d.%d.*' OR `list` = '%d.%d.%d.%d'", - p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]); - if (mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); + char* data = NULL; + int matches; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u'", + p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) + { + Sql_ShowDebug(sql_handle); // close connection because we can't verify their connectivity. return 1; } - sql_res = mysql_store_result(&mysql_handle) ; - sql_row = sql_res?mysql_fetch_row(sql_res):NULL; - if(!sql_row) { //Shouldn't happen, but just in case... - mysql_free_result(sql_res); - return 1; - } + if( SQL_ERROR == Sql_NextRow(sql_handle) ) + return 1;// Shouldn't happen, but just in case... + + Sql_GetData(sql_handle, 0, &data, NULL); + matches = atoi(data); + Sql_FreeResult(sql_handle); + + if( matches == 0 ) + return 0;// No ban - if (atoi(sql_row[0]) == 0) { //No ban - mysql_free_result(sql_res); - return 0; - } - // ip ban ok. - ShowInfo("Packet from banned ip : %d.%d.%d.%d\n", CONVIP(ip)); + ShowInfo("Packet from banned ip : %u.%u.%u.%u\n", CONVIP(ip)); - if (login_config.log_login) - { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, ip); - // query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - } - mysql_free_result(sql_res); + if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, ip) ) + Sql_ShowDebug(sql_handle); return 1; } @@ -1313,7 +1305,7 @@ int login_ip_ban_check(uint32 ip) //---------------------------------------------------------------------------------------- int parse_login(int fd) { - char t_uid[100]; + char esc_userid[NAME_LENGTH*2+1];// escaped username struct mmo_account account; int result, i; uint32 ipl = session[fd]->client_addr; @@ -1321,16 +1313,17 @@ int parse_login(int fd) ip2str(ipl, ip); - if (session[fd]->eof) { + if( session[fd]->eof ) + { do_close(fd); return 0; } - while (RFIFOREST(fd) >= 2) + while( RFIFOREST(fd) >= 2 ) { uint16 command = RFIFOW(fd,0); - switch(command) + switch( command ) { case 0x0200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) @@ -1349,10 +1342,10 @@ int parse_login(int fd) case 0x0277: // New login packet (kRO 2006-04-24aSakexe langtype 0) case 0x02b0: // New login packet (kRO 2007-05-14aSakexe langtype 0) { - int packet_len = RFIFOREST(fd); + size_t packet_len = RFIFOREST(fd); - //Perform ip-ban check - if (login_config.ipban && login_ip_ban_check(ipl)) + // Perform ip-ban check + if( login_config.ipban && login_ip_ban_check(ipl) ) { WFIFOHEAD(fd,23); WFIFOW(fd,0) = 0x6a; @@ -1376,37 +1369,38 @@ int parse_login(int fd) memset(&account, 0, sizeof(account)); account.version = RFIFOL(fd,2); - if (!account.version) account.version = 1; //Force some version... - memcpy(account.userid,RFIFOP(fd,6),NAME_LENGTH); account.userid[23] = '\0'; - memcpy(account.passwd,RFIFOP(fd,30),NAME_LENGTH); account.passwd[23] = '\0'; + if( !account.version ) + account.version = 1; //Force some version... + safestrncpy(account.userid, RFIFOP(fd,6), NAME_LENGTH);//## does it have to be nul-terminated? + safestrncpy(account.passwd, RFIFOP(fd,30), NAME_LENGTH);//## does it have to be nul-terminated? account.passwdenc = (command != 0x01dd) ? 0 : PASSWORDENC; - jstrescapecpy(t_uid, account.userid); + Sql_EscapeStringLen(sql_handle, esc_userid, account.userid, strlen(account.userid)); result = mmo_auth(&account, fd); - if (result == -1) { // auth success - if (login_config.min_level_to_connect > account.level) { + if( result == -1 ) + { // auth success + if( login_config.min_level_to_connect > account.level ) + { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; WFIFOB(fd,2) = 1; // 01 = Server closed WFIFOSET(fd,3); - } else { - if (login_config.log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','100', 'login ok')", loginlog_db, ipl, t_uid); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - } - if (account.level) + } + else + { + if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','100', 'login ok')", loginlog_db, ipl, esc_userid) ) + Sql_ShowDebug(sql_handle); + if( account.level ) ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", account.level, account.userid); else ShowStatus("Connection of the account '%s' accepted.\n", account.userid); server_num = 0; - WFIFOHEAD(fd,47+32*MAX_SERVERS); - for(i = 0; i < MAX_SERVERS; i++) { - if (server_fd[i] >= 0) { + WFIFOHEAD(fd, 47+32*MAX_SERVERS); + for( i = 0; i < MAX_SERVERS; ++i ) + { + if( session_isValid(server_fd[i]) ) + { // Advanced subnet check [LuzZza] uint32 subnet_char_ip = lan_subnetcheck(ipl); WFIFOL(fd,47+server_num*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); @@ -1443,7 +1437,9 @@ int parse_login(int fd) WFIFOSET(fd,3); } } - } else { // auth failed + } + else + { // auth failed if (login_config.log_login) { const char* error; @@ -1475,70 +1471,66 @@ int parse_login(int fd) default : error = "Unknown Error."; break; } - sprintf(tmpsql, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s', '%d','login failed : %s')", loginlog_db, ipl, t_uid, result, error); - - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s', '%d','login failed : %s')", loginlog_db, ipl, esc_userid, result, error) ) + Sql_ShowDebug(sql_handle); } - if ((result == 1) && login_config.dynamic_pass_failure_ban && login_config.log_login) { // failed password - sprintf(tmpsql,"SELECT count(*) FROM `%s` WHERE `ip` = '%u' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", - loginlog_db, ipl, login_config.dynamic_pass_failure_ban_interval); //how many times filed account? in one ip. - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - //check query result - sql_res = mysql_store_result(&mysql_handle) ; - sql_row = sql_res?mysql_fetch_row(sql_res):NULL; //row fetching + if( result == 1 && login_config.dynamic_pass_failure_ban && login_config.log_login ) // failed password + { + unsigned long failures = 0; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%u' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", + loginlog_db, ipl, login_config.dynamic_pass_failure_ban_interval) )// how many times failed account? in one ip. + Sql_ShowDebug(sql_handle); - if (sql_row && (unsigned int)atoi(sql_row[0]) >= login_config.dynamic_pass_failure_ban_limit ) { + //check query result + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + Sql_GetData(sql_handle, 0, &data, NULL); + failures = strtoul(data, NULL, 10); + Sql_FreeResult(sql_handle); + } + if( failures >= login_config.dynamic_pass_failure_ban_limit ) + { uint8* p = (uint8*)&ipl; - sprintf(tmpsql,"INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%d.%d.%d.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban: %s')", (uint8)p[3], (uint8)p[2], (uint8)p[1], login_config.dynamic_pass_failure_ban_duration, t_uid); - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban: %s')", p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration, esc_userid) ) + Sql_ShowDebug(sql_handle); } - if(sql_res) mysql_free_result(sql_res); } - else if (result == -2){ //dynamic banned - add ip to ban list. + else if( result == -2 ) + {// dynamic banned - add ip to ban list. uint8* p = (uint8*)&ipl; - sprintf(tmpsql,"INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%d.%d.%d.*', NOW() , NOW() + INTERVAL 1 MONTH ,'Dynamic banned user id : %s')", (uint8)p[3], (uint8)p[2], (uint8)p[1], t_uid); - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%d.%d.%d.*', NOW() , NOW() + INTERVAL 1 MONTH ,'Dynamic banned user id : %s')", p[3], p[2], p[1], esc_userid) ) + Sql_ShowDebug(sql_handle); result = -3; - }else if(result == 6){ //not lastet version .. - //result = 5; } - - sprintf(tmpsql,"SELECT `ban_until` FROM `%s` WHERE `%s` = %s '%s'",login_db, login_db_userid, login_config.case_sensitive ? "BINARY" : "", t_uid); - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); + else if( result == 6 ) + {// not lastet version .. + //result = 5; } - sql_res = mysql_store_result(&mysql_handle) ; - sql_row = sql_res?mysql_fetch_row(sql_res):NULL; //cannot connect login failed WFIFOHEAD(fd,23); memset(WFIFOP(fd,0), '\0', 23); WFIFOW(fd,0) = 0x6a; WFIFOB(fd,2) = (uint8)result; - if (result == 6) { // 6 = Your are Prohibited to log in until %s - char tmpstr[20]; - time_t ban_until_time = (sql_row) ? atol(sql_row[0]) : 0; - strftime(tmpstr, 20, login_config.date_format, localtime(&ban_until_time)); tmpstr[19] = '\0'; - strncpy(WFIFOP(fd,3), tmpstr, 20); // ban timestamp goes here + if( result == 6 ) + {// 6 = Your are Prohibited to log in until %s + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = %s '%s'", login_db, login_db_userid, (login_config.case_sensitive ? "BINARY" : ""), esc_userid) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + time_t ban_until_time; + + Sql_GetData(sql_handle, 0, &data, NULL); + ban_until_time = (time_t)strtoul(data, NULL, 10); + Sql_FreeResult(sql_handle); + + strftime(WFIFOP(fd,3), 20, login_config.date_format, localtime(&ban_until_time)); + } } WFIFOSET(fd,23); - - if (sql_res) mysql_free_result(sql_res); } RFIFOSKIP(fd,packet_len); @@ -1548,19 +1540,20 @@ int parse_login(int fd) case 0x01db: // Sending request of the coding key { struct login_session_data* ld; - if (session[fd]->session_data) { + if( session[fd]->session_data ) + { ShowWarning("login: abnormal request of MD5 key (already opened session).\n"); set_eof(fd); return 0; } - ld = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); + CREATE(ld, struct login_session_data, 1); session[fd]->session_data = ld; // Creation of the coding key memset(ld->md5key, '\0', sizeof(ld->md5key)); ld->md5keylen = (uint16)(12 + rand() % 4); - for(i = 0; i < ld->md5keylen; i++) + for( i = 0; i < ld->md5keylen; ++i ) ld->md5key[i] = (char)(1 + rand() % 255); WFIFOHEAD(fd,4 + ld->md5keylen); @@ -1577,37 +1570,32 @@ int parse_login(int fd) if (RFIFOREST(fd) < 86) return 0; { + char esc_server_name[20*2+1]; char* server_name; uint32 server_ip; uint16 server_port; memset(&account, 0, sizeof(account)); - memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0'; - memcpy(account.passwd,RFIFOP(fd,26),NAME_LENGTH); account.passwd[23] = '\0'; + safestrncpy(account.userid, RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwdenc = 0; - server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0'; server_ip = ntohl(RFIFOL(fd,54)); server_port = ntohs(RFIFOW(fd,58)); - ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)\n", - server_name, CONVIP(server_ip), server_port, ip); - jstrescapecpy(t_uid, server_name); - if (login_config.log_login) - { - char t_login[50]; - jstrescapecpy(t_login,account.userid); - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%u.%u.%u.%u:%d')", - loginlog_db, ipl, t_login, t_uid, t_uid, CONVIP(server_ip), server_port); - - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - } + server_name = (char*)RFIFOP(fd,60); + + Sql_EscapeStringLen(sql_handle, esc_server_name, server_name, strnlen(server_name, 20)); + Sql_EscapeStringLen(sql_handle, esc_userid, account.userid, strnlen(account.userid, NAME_LENGTH)); + + ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (account: '%s', pass: '%s', ip: '%s')\n", esc_server_name, CONVIP(server_ip), server_port, account.userid, account.passwd, ip); + + if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%u.%u.%u.%u:%d')", + loginlog_db, ipl, esc_userid, esc_server_name, esc_server_name, CONVIP(server_ip), server_port) ) + Sql_ShowDebug(sql_handle); result = mmo_auth(&account, fd); - if (result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1) { - ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); + if( result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1 ) + { + ShowStatus("Connection of the char-server '%s' accepted.\n", esc_server_name); memset(&server[account.account_id], 0, sizeof(struct mmo_char_server)); server[account.account_id].ip = ntohl(RFIFOL(fd,54)); server[account.account_id].port = ntohs(RFIFOW(fd,58)); @@ -1616,29 +1604,23 @@ int parse_login(int fd) server[account.account_id].maintenance = RFIFOW(fd,82); server[account.account_id].new_ = RFIFOW(fd,84); server_fd[account.account_id] = fd; - sprintf(tmpsql,"DELETE FROM `sstatus` WHERE `index`='%d'", account.account_id); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } - - sprintf(tmpsql,"INSERT INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%d', '%s', '%d')", - account.account_id, t_uid,0); - //query - if(mysql_query(&mysql_handle, tmpsql)) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); - } + WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x2711; WFIFOB(fd,2) = 0; WFIFOSET(fd,3); + session[fd]->func_parse = parse_fromchar; realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - + send_GM_accounts(fd); // send GM account to char-server - } else { + + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%d', '%s', '%d')", account.account_id, esc_server_name, 0) ) + Sql_ShowDebug(sql_handle); + } + else + { + ShowNotice("Connection of the char-server '%s' REFUSED.\n", esc_server_name); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x2711; WFIFOB(fd,2) = 3; @@ -1668,12 +1650,12 @@ int parse_login(int fd) break; case 0x7532: // Request to end connection - ShowStatus ("End of connection (ip: %s)\n", ip); + ShowStatus("End of connection (ip: %s)\n", ip); set_eof(fd); break; default: - ShowStatus ("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, RFIFOW(fd,0)); + ShowStatus("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, RFIFOW(fd,0)); set_eof(fd); return 0; } @@ -1683,6 +1665,9 @@ int parse_login(int fd) return 0; } +//----------------------- +// Console Command Parser [Wizputer] +//----------------------- int parse_console(char* buf) { char command[256]; @@ -1691,20 +1676,22 @@ int parse_console(char* buf) sscanf(buf, "%[^\n]", command); - //login_log("Console command :%s\n", command); + ShowInfo("Console command :%s", command); if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 ) runflag = 0; - else if( strcmpi("alive", command) == 0 || - strcmpi("status", command) == 0 ) + else + if( strcmpi("alive", command) == 0 || + strcmpi("status", command) == 0 ) ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else if( strcmpi("help", command) == 0 ){ + else + if( strcmpi("help", command) == 0 ) { printf(CL_BOLD"Help of commands:"CL_RESET"\n"); printf(" To shutdown the server:\n"); - printf(" 'shutdown|exit|qui|end'\n"); + printf(" 'shutdown|exit|quit|end'\n"); printf(" To know if server is alive:\n"); printf(" 'alive|status'\n"); } @@ -1788,10 +1775,8 @@ int login_lan_config_read(const char *lancfgName) //----------------------------------------------------- int ip_ban_flush(int tid, unsigned int tick, int id, int data) { - if(mysql_query(&mysql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()")) { - ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); - ShowDebug("at %s:%d - DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()\n", __FILE__,__LINE__); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") ) + Sql_ShowDebug(sql_handle); return 0; } @@ -1909,7 +1894,7 @@ void sql_config_read(const char* cfgName) else if (!strcmpi(w1, "login_server_ip")) strcpy(login_server_ip, w2); else if (!strcmpi(w1, "login_server_port")) - login_server_port = atoi(w2); + login_server_port = (uint16)atoi(w2); else if (!strcmpi(w1, "login_server_id")) strcpy(login_server_id, w2); else if (!strcmpi(w1, "login_server_pw")) diff --git a/src/map/Makefile b/src/map/Makefile deleted file mode 100644 index dcb14bb3a..000000000 --- a/src/map/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -all txt: txtobj map-server - -sql: sqlobj map-server_sql - -txtobj: - mkdir txtobj - -sqlobj: - mkdir sqlobj - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o - -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h \ - ../common/plugins.h ../common/lock.h ../common/nullpo.h ../common/malloc.h \ - ../common/showmsg.h ../common/utils.h ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h - -OBJECTS = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ - obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ - obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ - obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ - obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o \ - $(COMMON_OBJ) - -map-server: $(OBJECTS:obj/%=txtobj/%) - $(CC) -o ../../$@ $> $(LIBS) $(LIB_S) - -map-server_sql: $(OBJECTS:obj/%=sqlobj/%) - $(CC) -o ../../$@ $> $(LIB_S) - -txtobj/%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -sqlobj/%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -clean: - rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj GNUmakefile - -# DO NOT DELETE - -txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h irc.h $(COMMON_H) -txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) -txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h irc.h $(COMMON_H) -txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_H) -txtobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) -txtobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -txtobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -txtobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) -txtobj/path.o: path.c map.h battle.h $(COMMON_H) -txtobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) -txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h date.h irc.h $(COMMON_H) -txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) -txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) -txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h date.h $(COMMON_H) -txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) -txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) -txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) -txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) -txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h irc.h $(COMMON_H) -txtobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) -txtobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) -txtobj/log.o: log.c log.h map.h $(COMMON_H) -txtobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -txtobj/date.o: date.c date.h $(COMMON_H) -txtobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) -txtobj/unit.o: unit.c unit.h $(COMMON_H) -txtobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) - -sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h irc.h $(COMMON_H) -sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) -sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_H) -sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_H) -sqlobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) -sqlobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -sqlobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -sqlobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) -sqlobj/path.o: path.c map.h battle.h $(COMMON_H) -sqlobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) -sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h date.h irc.h $(COMMON_H) -sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) -sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) -sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h date.h $(COMMON_H) -sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) -sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) -sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_H) -sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) -sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h irc.h $(COMMON_H) -sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h irc.h $(COMMON_H) -sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) -sqlobj/mail.o: mail.c mail.h $(COMMON_H) -sqlobj/log.o: log.c log.h map.h $(COMMON_H) -sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -sqlobj/date.o: date.c date.h $(COMMON_H) -sqlobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) -sqlobj/unit.o: unit.c unit.h $(COMMON_H) -sqlobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) diff --git a/src/map/Makefile.in b/src/map/Makefile.in new file mode 100644 index 000000000..1be112d9a --- /dev/null +++ b/src/map/Makefile.in @@ -0,0 +1,148 @@ + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + ALL_DEPENDS=txt sql + SQL_DEPENDS=obj_sql map-server_sql +else + ALL_TARGET=txt + SQL_DEPENDS=needs_mysql +endif + +HAVE_PCRE=@HAVE_PCRE@ +ifeq ($(HAVE_PCRE),yes) + PCRE_CFLAGS=-DPCRE_SUPPORT @PCRE_CFLAGS@ +else + PCRE_CFLAGS= +endif + + +##################################################################### +.PHONY : all txt sql clean help + +all: $(ALL_DEPENDS) + +txt: obj_txt map-server + +sql: $(SQL_DEPENDS) + +clean: + rm -rf *.o ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ obj_txt obj_sql + +help: +ifeq ($(HAVE_MYSQL),yes) + @echo "possible targets are 'sql' 'txt' 'all' 'clean' 'help'" + @echo "'sql' - map server (SQL version)" +else + @echo "possible targets are 'txt' 'all' 'clean' 'help'" +endif + @echo "'txt' - map server (TXT version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +obj_txt: + -mkdir obj_txt + +obj_sql: + -mkdir obj_sql + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o + +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ + ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ + ../common/utils.h ../common/strlib.h ../common/grfio.h \ + ../common/mapindex.h ../common/ers.h + +COMMON_SQL_OBJ = $(COMMON_OBJ) ../common/obj_sql/sql.o + +COMMON_SQL_H = $(COMMON_H) ../common/sql.h + +MAP_OBJ = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ + obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ + obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ + obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ + obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o + +map-server: $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) @LIBS@ @PCRE_LIBS@ + +map-server_sql: $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_SQL_OBJ) + @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ + +obj_txt/%.o: %.c + @CC@ @CFLAGS@ $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +obj_sql/%.o: %.c + @CC@ @CFLAGS@ $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# DO NOT DELETE + +obj_txt/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h irc.h $(COMMON_H) +obj_txt/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) +obj_txt/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h irc.h $(COMMON_H) +obj_txt/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_H) +obj_txt/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) +obj_txt/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +obj_txt/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +obj_txt/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) +obj_txt/path.o: path.c map.h battle.h $(COMMON_H) +obj_txt/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) +obj_txt/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h date.h irc.h $(COMMON_H) +obj_txt/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) +obj_txt/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) +obj_txt/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h date.h $(COMMON_H) +obj_txt/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +obj_txt/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) +obj_txt/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) +obj_txt/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) +obj_txt/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) +obj_txt/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h irc.h $(COMMON_H) +obj_txt/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) +obj_txt/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) +obj_txt/log.o: log.c log.h map.h $(COMMON_H) +obj_txt/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +obj_txt/date.o: date.c date.h $(COMMON_H) +obj_txt/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) +obj_txt/unit.o: unit.c unit.h $(COMMON_H) +obj_txt/mercenary.o: mercenary.c mercenary.h $(COMMON_H) + +obj_sql/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h irc.h $(COMMON_SQL_H) +obj_sql/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_SQL_H) +obj_sql/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_SQL_H) +obj_sql/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_SQL_H) +obj_sql/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_SQL_H) +obj_sql/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_SQL_H) +obj_sql/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_SQL_H) +obj_sql/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_SQL_H) +obj_sql/path.o: path.c map.h battle.h $(COMMON_SQL_H) +obj_sql/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_SQL_H) +obj_sql/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h date.h irc.h $(COMMON_SQL_H) +obj_sql/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_SQL_H) +obj_sql/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_SQL_H) +obj_sql/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h date.h $(COMMON_SQL_H) +obj_sql/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_SQL_H) +obj_sql/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_SQL_H) +obj_sql/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_SQL_H) +obj_sql/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_SQL_H) +obj_sql/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_SQL_H) +obj_sql/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h irc.h $(COMMON_SQL_H) +obj_sql/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h irc.h $(COMMON_SQL_H) +obj_sql/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_SQL_H) +obj_sql/mail.o: mail.c mail.h $(COMMON_SQL_H) +obj_sql/log.o: log.c log.h map.h $(COMMON_SQL_H) +obj_sql/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_SQL_H) +obj_sql/date.o: date.c date.h $(COMMON_SQL_H) +obj_sql/irc.o: irc.c irc.h map.h pc.h $(COMMON_SQL_H) +obj_sql/unit.o: unit.c unit.h $(COMMON_SQL_H) +obj_sql/mercenary.o: mercenary.c mercenary.h $(COMMON_SQL_H) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 428ff017d..3ddac9a9d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10,6 +10,7 @@ #include "../common/malloc.h" #include "../common/socket.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "atcommand.h" #include "log.h" @@ -273,6 +274,7 @@ ACMD_FUNC(checkmail); // [Valaris] ACMD_FUNC(listmail); // [Valaris] ACMD_FUNC(listnewmail); // [Valaris] ACMD_FUNC(readmail); // [Valaris] +ACMD_FUNC(deletemail); // [Valaris] ACMD_FUNC(sendmail); // [Valaris] ACMD_FUNC(sendprioritymail); // [Valaris] ACMD_FUNC(deletemail); // [Valaris] @@ -577,7 +579,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris] { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris] { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris] - { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris] + { AtCommand_DeleteMail, "@deletemail", 1, atcommand_deletemail }, // [Valaris] { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris] { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris] { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris] @@ -7898,11 +7900,11 @@ int atcommand_listmail(const int fd, struct map_session_data* sd, const char* co nullpo_retr(-1, sd); - if(strlen(command)==12) + if(strlen(command)==12) // @listnewmail mail_check(sd,3); - else if(strlen(command)==9) + else if(strlen(command)==9) // @listmail mail_check(sd,2); - else + else // @checkmail mail_check(sd,1); return 0; } @@ -7926,10 +7928,31 @@ int atcommand_readmail(const int fd, struct map_session_data* sd, const char* co return 0; } - if(strlen(command)==11) - mail_delete(sd,index); - else - mail_read(sd,index); + mail_read(sd,index); + + return 0; +} + +int atcommand_deletemail(const int fd, struct map_session_data* sd, const char* command, const char* message) +{ + int index; + if(!mail_server_enable) + return 0; + + nullpo_retr(-1, sd); + + if (!message || !*message) { + clif_displaymessage(sd->fd,"You must specify a message number."); + return 0; + } + + index = atoi(message); + if (index < 1) { + clif_displaymessage(sd->fd,"Message number cannot be negative or zero."); + return 0; + } + + mail_delete(sd,index); return 0; } @@ -7954,7 +7977,7 @@ int atcommand_sendmail(const int fd, struct map_session_data* sd, const char* co return 0; } - if(strlen(command)==17) + if(strlen(command)==17) // @sendprioritymail mail_send(sd,name,text,1); else mail_send(sd,name,text,0); diff --git a/src/map/battle.c b/src/map/battle.c index 9264fbedf..2994dfa6a 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -8,6 +8,7 @@ #include "../common/showmsg.h" #include "../common/ers.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "map.h" #include "pc.h" diff --git a/src/map/charcommand.c b/src/map/charcommand.c index cfd3d59c8..88c32b307 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -6,6 +6,7 @@ #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/showmsg.h" +#include "../common/utils.h" #include "log.h" #include "clif.h" diff --git a/src/map/clif.c b/src/map/clif.c index 5845ee102..ff6ccb9cf 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9,6 +9,7 @@ #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "map.h" #include "chrif.h" diff --git a/src/map/guild.c b/src/map/guild.c index f9773d440..74cd0261a 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -9,6 +9,7 @@ #include "../common/showmsg.h" #include "../common/ers.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "map.h" #include "guild.h" @@ -1922,12 +1923,11 @@ int guild_save_sub(int tid,unsigned int tick,int id,int data) int guild_agit_break(struct mob_data *md) { // Run One NPC_Event[OnAgitBreak] - char *evname; + char* evname; if(!agit_flag) return 0; // Agit already End - evname=(char *)aMallocA((strlen(md->npc_event) + 1)*sizeof(char)); - strcpy(evname,md->npc_event); + evname = aStrdup(md->npc_event); // Now By User to Run [OnAgitBreak] NPC Event... // It's a little impossible to null point with player disconnect in this! // But Script will be stop, so nothing... diff --git a/src/map/intif.c b/src/map/intif.c index 9e7effef3..b6f457ee1 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1497,7 +1497,7 @@ int intif_parse(int fd) case 0x3802: intif_parse_WisEnd(fd); break; case 0x3803: mapif_parse_WisToGM(fd); break; case 0x3804: intif_parse_Registers(fd); break; - case 0x3806: intif_parse_ChangeNameOk(fd); break; + case 0x3806: intif_parse_ChangeNameOk(fd); break; case 0x3810: intif_parse_LoadStorage(fd); break; case 0x3811: intif_parse_SaveStorage(fd); break; case 0x3818: intif_parse_LoadGuildStorage(fd); break; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 1ba86cbc4..4ed47df61 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -615,369 +615,251 @@ static int itemdb_gendercheck(struct item_data *id) if (id->look == W_WHIP && id->type == IT_WEAPON) //Whips are always female-only return 0; - return (battle_config.ignore_items_gender?2:id->sex); + return (battle_config.ignore_items_gender) ? 2 : id->sex; } -#ifndef TXT_ONLY -/*====================================== - * SQL - *======================================*/ -static int itemdb_read_sqldb(void) -{ +/*========================================== + * processes one itemdb entry + *------------------------------------------*/ +static bool itemdb_parse_dbrow(char** str, char* source, int line) +{ + /* + +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ + | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | + +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ + | id | name_english | name_japanese | type | price_buy | price_sell | weight | attack | defence | range | slots | equip_jobs | equip_upper | equip_genders | equip_locations | weapon_level | equip_level | refineable | view | script | equip_script | unequip_script | + +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ + */ unsigned short nameid; - struct item_data *id; - char script[65535 + 2 + 1]; // Maximum length of MySQL TEXT type (65535) + 2 bytes for curly brackets + 1 byte for terminator - char *item_db_name[] = { item_db_db, item_db2_db }; - long unsigned int ln = 0; - int i; - - // ---------- - - for (i = 0; i < 2; i++) { - sprintf(tmp_sql, "SELECT * FROM `%s`", item_db_name[i]); - - // Execute the query; if the query execution succeeded... - if (mysql_query(&mmysql_handle, tmp_sql) == 0) { - sql_res = mysql_store_result(&mmysql_handle); - - // If the storage of the query result succeeded... - if (sql_res) { - // Parse each row in the query result into sql_row - while ((sql_row = mysql_fetch_row(sql_res))) - { /*Table structure is: - 00 id - 01 name_english - 02 name_japanese - 03 type - 04 price_buy - 05 price_sell - 06 weight - 07 attack - 08 defence - 09 range - 10 slots - 11 equip_jobs - 12 equip_upper - 13 equip_genders - 14 equip_locations - 15 weapon_level - 16 equip_level - 17 refineable - 18 view - 19 script - 20 equip_script - 21 unequip_script - */ - nameid = atoi(sql_row[0]); - - // If the identifier is not within the valid range, process the next row - if (nameid == 0) - continue; - - ln++; - - // ---------- - id = itemdb_load(nameid); - - strncpy(id->name, sql_row[1], ITEM_NAME_LENGTH-1); - strncpy(id->jname, sql_row[2], ITEM_NAME_LENGTH-1); - - id->type = atoi(sql_row[3]); - if (id->type == IT_DELAYCONSUME) - { //Items that are consumed upon target confirmation - //(yggdrasil leaf, spells & pet lures) [Skotlex] - id->type = IT_USABLE; - id->flag.delay_consume=1; - } else //In case of an itemdb reload and the item type changed. - id->flag.delay_consume=0; - - // If price_buy is not NULL and price_sell is not NULL... - if ((sql_row[4] != NULL) && (sql_row[5] != NULL)) { - id->value_buy = atoi(sql_row[4]); - id->value_sell = atoi(sql_row[5]); - } - // If price_buy is not NULL and price_sell is NULL... - else if ((sql_row[4] != NULL) && (sql_row[5] == NULL)) { - id->value_buy = atoi(sql_row[4]); - id->value_sell = atoi(sql_row[4]) / 2; - } - // If price_buy is NULL and price_sell is not NULL... - else if ((sql_row[4] == NULL) && (sql_row[5] != NULL)) { - id->value_buy = atoi(sql_row[5]) * 2; - id->value_sell = atoi(sql_row[5]); - } - // If price_buy is NULL and price_sell is NULL... - if ((sql_row[4] == NULL) && (sql_row[5] == NULL)) { - id->value_buy = 0; - id->value_sell = 0; - } - - id->weight = atoi(sql_row[6]); - id->atk = (sql_row[7] != NULL) ? atoi(sql_row[7]) : 0; - id->def = (sql_row[8] != NULL) ? atoi(sql_row[8]) : 0; - id->range = (sql_row[9] != NULL) ? atoi(sql_row[9]) : 0; - id->slot = (sql_row[10] != NULL) ? atoi(sql_row[10]) : 0; - if (id->slot > MAX_SLOTS) - { - ShowWarning("itemdb_read_sqldb: Item %d (%s) specifies %d slots, but the server only supports up to %d\n", nameid, id->jname, id->slot, MAX_SLOTS); - id->slot = MAX_SLOTS; - } - itemdb_jobid2mapid(id->class_base, (sql_row[11] != NULL) ? (unsigned int)strtoul(sql_row[11], NULL, 0) : 0); - id->class_upper= (sql_row[12] != NULL) ? atoi(sql_row[12]) : 0; - id->sex = (sql_row[13] != NULL) ? atoi(sql_row[13]) : 0; - id->equip = (sql_row[14] != NULL) ? atoi(sql_row[14]) : 0; - if (!id->equip && itemdb_isequip2(id)) - { - ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname); - id->type = 3; - } - id->wlv = (sql_row[15] != NULL) ? atoi(sql_row[15]) : 0; - id->elv = (sql_row[16] != NULL) ? atoi(sql_row[16]) : 0; - id->flag.no_refine = (sql_row[17] == NULL || atoi(sql_row[17]) == 1)?0:1; - id->look = (sql_row[18] != NULL) ? atoi(sql_row[18]) : 0; - id->view_id = 0; - id->sex = itemdb_gendercheck(id); //Apply gender filtering. - - // ---------- - - if (id->script) - script_free_code(id->script); - if (sql_row[19] != NULL) { - if (sql_row[19][0] == '{') - id->script = parse_script(sql_row[19],item_db_name[i], ln, 0); - else { - sprintf(script, "{%s}", sql_row[19]); - id->script = parse_script(script, item_db_name[i], ln, 0); - } - } else id->script = NULL; + struct item_data* id; - if (id->equip_script) - script_free_code(id->equip_script); - if (sql_row[20] != NULL) { - if (sql_row[20][0] == '{') - id->equip_script = parse_script(sql_row[20], item_db_name[i], ln, 0); - else { - sprintf(script, "{%s}", sql_row[20]); - id->equip_script = parse_script(script, item_db_name[i], ln, 0); - } - } else id->equip_script = NULL; + nameid = atoi(str[0]); + if(nameid <= 0) + return false; - if (id->unequip_script) - script_free_code(id->unequip_script); - if (sql_row[21] != NULL) { - if (sql_row[21][0] == '{') - id->unequip_script = parse_script(sql_row[21],item_db_name[i], ln, 0); - else { - sprintf(script, "{%s}", sql_row[21]); - id->unequip_script = parse_script(script, item_db_name[i], ln, 0); - } - } else id->unequip_script = NULL; - - // ---------- - - id->flag.available = 1; - id->flag.value_notdc = 0; - id->flag.value_notoc = 0; - } + //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View + id = itemdb_load(nameid); + safestrncpy(id->name, str[1], ITEM_NAME_LENGTH-1); + safestrncpy(id->jname, str[2], ITEM_NAME_LENGTH-1); + + id->type = atoi(str[3]); + if (id->type == IT_DELAYCONSUME) + { //Items that are consumed only after target confirmation + id->type = IT_USABLE; + id->flag.delay_consume = 1; + } else //In case of an itemdb reload and the item type changed. + id->flag.delay_consume = 0; + + id->value_buy = atoi(str[4]); + id->value_sell = atoi(str[5]); + if (id->value_buy < id->value_sell * 2) id->value_buy = id->value_sell * 2; // prevent exploit + if (id->value_buy == 0 && id->value_sell > 0) id->value_buy = id->value_sell * 2; + if (id->value_sell == 0 && id->value_buy > 0) id->value_sell = id->value_buy / 2; + + id->weight = atoi(str[6]); + id->atk = atoi(str[7]); + id->def = atoi(str[8]); + id->range = atoi(str[9]); + id->slot = atoi(str[10]); + + if (id->slot > MAX_SLOTS) + { + ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d\n", nameid, id->jname, id->slot, MAX_SLOTS); + id->slot = MAX_SLOTS; + } + + itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0)); + id->class_upper = atoi(str[12]); + id->sex = atoi(str[13]); + id->equip = atoi(str[14]); + + if (!id->equip && itemdb_isequip2(id)) + { + ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname); + id->type = IT_ETC; + } + + id->wlv = atoi(str[15]); + id->elv = atoi(str[16]); + id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this + id->look = atoi(str[18]); + + id->flag.available = 1; + id->flag.value_notdc = 0; + id->flag.value_notoc = 0; + id->view_id = 0; + id->sex = itemdb_gendercheck(id); //Apply gender filtering. - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, item_db_name[i]); - ln = 0; - } else { - ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if (id->script) + script_free_code(id->script); + if (id->equip_script) + script_free_code(id->equip_script); + if (id->unequip_script) + script_free_code(id->unequip_script); - // Free the query result - mysql_free_result(sql_res); - } else { - ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } + if (*str[19]) + id->script = parse_script(str[19], source, line, 0); + if (*str[20]) + id->equip_script = parse_script(str[20], source, line, 0); + if (*str[21]) + id->unequip_script = parse_script(str[21], source, line, 0); - return 0; + return true; } -#endif /* not TXT_ONLY */ /*========================================== * ƒAƒCƒeƒ€ƒf[ƒ^ƒx[ƒX‚̓ǂݞ‚Ý *------------------------------------------*/ static int itemdb_readdb(void) { - FILE *fp; - char line[1024]; - int ln=0,lines=0; - int nameid,j; - char *str[32],*p,*np; - struct item_data *id; - int i=0; - char *filename[]={ "item_db.txt","item_db2.txt" }; - - for(i=0;i<2;i++){ - sprintf(line, "%s/%s", db_path, filename[i]); - fp=fopen(line,"r"); - if(fp==NULL){ - if(i>0) + char* filename[] = { "item_db.txt", "item_db2.txt" }; + int fi; + + for(fi = 0; fi < 2; fi++) + { + uint32 lines = 0, count = 0; + char line[1024]; + + char path[256]; + FILE* fp; + + sprintf(path, "%s/%s", db_path, filename[fi]); + fp = fopen(path, "r"); + if(fp == NULL) { + if(fi > 0) continue; - ShowFatalError("can't read %s\n",line); - exit(1); + return -1; } - lines=0; + // process rows one by one while(fgets(line, sizeof(line), fp)) { - lines++; - if(line[0]=='/' && line[1]=='/') - continue; - memset(str,0,sizeof(str)); - for(j=0,np=p=line;j<19 && p;j++){ - str[j]=p; - p=strchr(p,','); - if(p){ *p++=0; np=p; } - } - if(str[0]==NULL) - continue; + char *str[32], *p, *np; + int i; - nameid=atoi(str[0]); - if(nameid<=0) - continue; - if (j < 19) - { //Crash-fix on broken item lines. [Skotlex] - ShowWarning("Reading %s: Insufficient fields for item with id %d, skipping.\n", filename[i], nameid); + lines++; + if(line[0] == '/' && line[1] == '/') continue; - } - ln++; - - //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View - id=itemdb_load(nameid); - strncpy(id->name, str[1], ITEM_NAME_LENGTH-1); - strncpy(id->jname, str[2], ITEM_NAME_LENGTH-1); - id->type=atoi(str[3]); - if (id->type == IT_DELAYCONSUME) - { //Items that are consumed upon target confirmation - //(yggdrasil leaf, spells & pet lures) [Skotlex] - id->type = IT_USABLE; - id->flag.delay_consume=1; - } else //In case of an itemdb reload and the item type changed. - id->flag.delay_consume=0; - + memset(str, 0, sizeof(str)); + for(i = 0, np = p = line; i < 19 && p; i++) { - int buy = atoi(str[4]), sell = atoi(str[5]); - // if buying price > selling price * 2 consider it valid and don't change it [celest] - if (buy && sell && buy > sell*2){ - id->value_buy = buy; - id->value_sell = sell; - } else { - // buy‚sell*2 ‚Í item_value_db.txt ‚ÅŽw’肵‚Ä‚­‚¾‚³‚¢B - if (sell) { // sell’l‚ð—Dæ‚Æ‚·‚é - id->value_buy = sell*2; - id->value_sell = sell; - } else { - id->value_buy = buy; - id->value_sell = buy/2; - } + str[i] = p; + if ((p = strchr(p,',')) != NULL) { + *p++ = '\0'; np = p; } - // check for bad prices that can possibly cause exploits - if (id->value_buy*75/100 < id->value_sell*124/100) { - ShowWarning ("Item %s [%d] buying:%d < selling:%d\n", - id->name, id->nameid, id->value_buy*75/100, id->value_sell*124/100); - } - } - id->weight=atoi(str[6]); - id->atk=atoi(str[7]); - id->def=atoi(str[8]); - id->range=atoi(str[9]); - id->slot=atoi(str[10]); - if (id->slot > MAX_SLOTS) - { - ShowWarning("itemdb_readdb: Item %d (%s) specifies %d slots, but the server only supports up to %d\n", nameid, id->jname, id->slot, MAX_SLOTS); - id->slot = MAX_SLOTS; - } - itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0)); - id->class_upper = atoi(str[12]); - id->sex = atoi(str[13]); - if(id->equip != atoi(str[14])){ - id->equip=atoi(str[14]); - } - if (!id->equip && itemdb_isequip2(id)) - { - ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname); - id->type = 3; - } - id->wlv=atoi(str[15]); - id->elv=atoi(str[16]); - id->flag.no_refine = atoi(str[17])?0:1; //If the refine column is 1, no_refine is 0 - id->look=atoi(str[18]); - id->flag.available=1; - id->flag.value_notdc=0; - id->flag.value_notoc=0; - id->view_id=0; - id->sex = itemdb_gendercheck(id); //Apply gender filtering. - - if (id->script) { - script_free_code(id->script); - id->script=NULL; } - if (id->equip_script) { - script_free_code(id->equip_script); - id->equip_script=NULL; - } - if (id->unequip_script) { - script_free_code(id->unequip_script); - id->unequip_script=NULL; + + if (i < 19) { + ShowWarning("itemdb_readdb: Insufficient columns for item with id %d, skipping.\n", atoi(str[0])); + continue; } - if((p=strchr(np,'{'))==NULL) + if((p=strchr(np,'{')) == NULL) continue; - str[19] = p; //Script np = strchr(p,'}'); - while (np && np[1] && np[1] != ',') np = strchr(np+1,'}'); //Jump close brackets until the next field is found. if (!np || !np[1]) { - //Couldn't find the end of the script field. - id->script = parse_script(str[19],filename[i],lines,0); - continue; + continue; //Couldn't find the end of the script field. } np[1] = '\0'; //Set end of script - id->script = parse_script(str[19],filename[i],lines,0); - np+=2; //Skip to next field + np += 2; //Skip to next field if(!np || (p=strchr(np,'{'))==NULL) continue; - str[20] = p; //Equip Script np = strchr(p,'}'); - while (np && np[1] && np[1] != ',') np = strchr(np+1,'}'); //Jump close brackets until the next field is found. if (!np || !np[1]) { - //Couldn't find the end of the script field. - id->equip_script = parse_script(str[20],filename[i],lines,0); - continue; + continue; //Couldn't find the end of the script field. } - np[1] = '\0'; //Set end of script - id->equip_script = parse_script(str[20],filename[i],lines,0); - np+=2; //Skip comma, to next field + np += 2; //Skip comma, to next field if(!np || (p=strchr(np,'{'))==NULL) continue; - //Unequip script, last column. - id->unequip_script = parse_script(p,filename[i],lines,0); + str[21] = p; //Unequip script, last column. + + if (!itemdb_parse_dbrow(str, filename[fi], lines)) + continue; + + count++; } + fclose(fp); - if (ln > 0) { - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]); + + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename[fi]); + } + + return 0; +} + +#ifndef TXT_ONLY +/*====================================== + * item_db table reading + *======================================*/ +static int itemdb_read_sqldb(void) +{ + char* item_db_name[] = { item_db_db, item_db2_db }; + int fi; + + for (fi = 0; fi < 2; fi++) + { + uint32 lines = 0, count = 0; + + // retrieve all rows from the item database + if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) + { + Sql_ShowDebug(mmysql_handle); + continue; + } + + // process rows one by one + while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) + { + // wrap the result into a TXT-compatible format + char line[1024]; + char* str[22]; + char* p; + int i; + + lines++; + for (i = 0, p = line; i < 22; i++) + { + char* data; + size_t len; + Sql_GetData(mmysql_handle, i, &data, &len); + + if (data == NULL) + p[0] = '\0'; + else if (i >= 19 && data[0] != '{') { + sprintf(p, "{ %s }", data); len+= 4; + } else + strcpy(p, data); + str[i] = p; + p+= len + 1; + } + + if (!itemdb_parse_dbrow(str, item_db_name[fi], lines)) + continue; + + count++; } - ln=0; // reset to 0 + + // free the query result + Sql_FreeResult(mmysql_handle); + + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]); } + return 0; } +#endif /* not TXT_ONLY */ /*==================================== - * Removed item_value_db, don't re-add + * read all item-related databases *------------------------------------*/ static void itemdb_read(void) { diff --git a/src/map/log.c b/src/map/log.c index fdbb4470f..b5c4a3d9c 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -19,6 +19,8 @@ struct Log_Config log_config; char timestring[255]; time_t curtime; +static int should_log_item(int filter, int nameid, int amount); //log filter check + //FILTER OPTIONS //0 = Don't log //1 = Log any item @@ -58,104 +60,105 @@ int should_log_item(int filter, int nameid, int amount) int log_branch(struct map_session_data *sd) { -#ifndef TXT_ONLY - char t_name[NAME_LENGTH*2]; -#endif - FILE *logfp; - if(!log_config.enable_logs) return 0; + nullpo_retr(0, sd); + #ifndef TXT_ONLY if(log_config.sql_logs > 0) { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", - log_config.log_branch_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex)); - if(mysql_query(&logmysql_handle, tmp_sql)) + SqlStmt* stmt; + stmt = SqlStmt_Malloc(logmysql_handle); + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return 0; } - return 1; + SqlStmt_Free(stmt); } + else #endif - if((logfp=fopen(log_config.log_branch,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %s[%d:%d]\t%s\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex)); - fclose(logfp); + { + FILE* logfp; + if((logfp = fopen(log_config.log_branch, "a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp,"%s - %s[%d:%d]\t%s\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex)); + fclose(logfp); + } + return 1; } int log_pick_pc(struct map_session_data *sd, const char *type, int nameid, int amount, struct item *itm) { - FILE *logfp; - char *mapname; - nullpo_retr(0, sd); - //Should we log this item? [Lupus] - if (!should_log_item(log_config.filter,nameid, amount)) - return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus] - mapname = (char*)mapindex_id2name(sd->mapindex); - - if(mapname==NULL) - mapname=""; + if (!should_log_item(log_config.filter, nameid, amount)) + return 0; //we skip logging this item set - it doesn't meet our logging conditions [Lupus] #ifndef TXT_ONLY if(log_config.sql_logs > 0) { - if (itm==NULL) { - //We log common item - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')", - log_config.log_pick_db, sd->status.char_id, type, nameid, amount, mapname); + if (itm == NULL) { + //We log common item + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')", + log_config.log_pick_db, sd->status.char_id, type, nameid, amount, mapindex_id2name(sd->mapindex)) ) + { + Sql_ShowDebug(logmysql_handle); + return 0; + } } else { - //We log Extended item - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", - log_config.log_pick_db, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname); + //We log Extended item + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", + log_config.log_pick_db, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex)) ) + { + Sql_ShowDebug(logmysql_handle); + return 0; + } } + } + else +#endif + { + FILE* logfp; - if(mysql_query(&logmysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if((logfp = fopen(log_config.log_pick, "a+")) == NULL) return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + + if (itm == NULL) { + //We log common item + fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n", + timestring, sd->status.char_id, type, nameid, amount, mapindex_id2name(sd->mapindex)); + + } else { + //We log Extended item + fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n", + timestring, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex)); } - return 1; + fclose(logfp); } -#endif - if((logfp=fopen(log_config.log_pick,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - - if (itm==NULL) { - //We log common item - fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n", - timestring, sd->status.char_id, type, nameid, amount, mapname); - - } else { - //We log Extended item - fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n", - timestring, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname); - } - fclose(logfp); + return 1; //Logged } //Mob picked item int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, struct item *itm) { - FILE *logfp; - char *mapname; + char* mapname; nullpo_retr(0, md); - //Should we log this item? [Lupus] - if (!should_log_item(log_config.filter,nameid, amount)) - return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus] + + if (!should_log_item(log_config.filter, nameid, amount)) + return 0; //we skip logging this item set - it doesn't meet our logging conditions [Lupus] //either PLAYER or MOB (here we get map name and objects ID) mapname = map[md->bl.m].name; @@ -167,180 +170,200 @@ int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, { if (itm==NULL) { //We log common item - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')", - log_config.log_pick_db, md->class_, type, nameid, amount, mapname); + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')", + log_config.log_pick_db, md->class_, type, nameid, amount, mapname) ) + { + Sql_ShowDebug(logmysql_handle); + return 0; + } } else { //We log Extended item - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", - log_config.log_pick_db, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname); + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", + log_config.log_pick_db, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname) ) + { + Sql_ShowDebug(logmysql_handle); + return 0; + } } + } + else +#endif + { + FILE *logfp; - if(mysql_query(&logmysql_handle, tmp_sql)) - { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if((logfp=fopen(log_config.log_pick,"a+")) == NULL) return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + + if (itm==NULL) { + //We log common item + fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n", + timestring, md->class_, type, nameid, amount, mapname); + + } else { + //We log Extended item + fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n", + timestring, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname); } - return 1; - } -#endif - if((logfp=fopen(log_config.log_pick,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - - if (itm==NULL) { - //We log common item - fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n", - timestring, md->class_, type, nameid, amount, mapname); - - } else { - //We log Extended item - fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n", - timestring, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname); + fclose(logfp); } - fclose(logfp); + return 1; //Logged } int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount) { -// FILE *logfp; - if(!log_config.enable_logs || (log_config.zeny!=1 && abs(amount) 0) { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%s')", - log_config.log_zeny_db, sd->status.char_id, src_sd->status.char_id, type, amount, mapindex_id2name(sd->mapindex)); - if(mysql_query(&logmysql_handle, tmp_sql)) + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%s')", + log_config.log_zeny_db, sd->status.char_id, src_sd->status.char_id, type, amount, mapindex_id2name(sd->mapindex)) ) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(logmysql_handle); return 0; } - return 1; } + else #endif -// if((logfp=fopen(log_config.log_zeny,"a+")) == NULL) -// return 0; -// time(&curtime); -// strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); -// fprintf(logfp,"%s - %s[%d]\t%s[%d]\t%d\n", timestring, sd->status.name, sd->status.account_id, target_sd->status.name, target_sd->status.account_id, sd->deal.zeny); -// fclose(logfp); -// return 1; - return 0; + { + FILE* logfp; + if((logfp=fopen(log_config.log_zeny,"a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp, "%s - %s[%d]\t%s[%d]\t%d\t\n", timestring, src_sd->status.name, src_sd->status.account_id, sd->status.name, sd->status.account_id, amount); + fclose(logfp); + } + + return 1; } int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp) { - FILE *logfp; - if(!log_config.enable_logs) return 0; + nullpo_retr(0, sd); + #ifndef TXT_ONLY if(log_config.sql_logs > 0) { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)); - if(mysql_query(&logmysql_handle, tmp_sql)) + if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", + log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) ) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + Sql_ShowDebug(logmysql_handle); return 0; } - return 1; } + else #endif - if((logfp=fopen(log_config.log_mvpdrop,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1]); - fclose(logfp); - return 0; + { + FILE* logfp; + if((logfp=fopen(log_config.log_mvpdrop,"a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1]); + fclose(logfp); + } + + return 1; } -int log_atcommand(struct map_session_data *sd, const char *message) +int log_atcommand(struct map_session_data* sd, const char* message) { - FILE *logfp; -#ifndef TXT_ONLY - char t_name[NAME_LENGTH*2]; - char t_msg[CHAT_SIZE*2+1]; //These are the contents of an @ call, so there shouldn't be overflow danger here? -#endif - if(!log_config.enable_logs) return 0; + nullpo_retr(0, sd); + #ifndef TXT_ONLY if(log_config.sql_logs > 0) { + SqlStmt* stmt; + if (strlen(message) > CHAT_SIZE) { if (battle_config.error_log) - ShowError("log atcommand: Received message too long from player %s (%d:%d)!\n", - sd->status.name, sd->status.account_id, sd->status.char_id); + ShowError("log atcommand: Received message too long from player %s (%d:%d)!\n", sd->status.name, sd->status.account_id, sd->status.char_id); return 0; } - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", - log_config.log_gm_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message)); - if(mysql_query(&logmysql_handle, tmp_sql)) + + stmt = SqlStmt_Malloc(logmysql_handle); + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, strnlen(message, 255)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return 0; } - return 1; + SqlStmt_Free(stmt); } + else #endif - if((logfp=fopen(log_config.log_gm,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %s[%d]: %s\n",timestring,sd->status.name,sd->status.account_id,message); - fclose(logfp); + { + FILE* logfp; + if((logfp = fopen(log_config.log_gm, "a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message); + fclose(logfp); + } + return 1; } -int log_npc(struct map_session_data *sd, const char *message) -{ //[Lupus] - FILE *logfp; -#ifndef TXT_ONLY - char t_name[NAME_LENGTH*2]; - char t_msg[255+1]; //it's 255 chars MAX. -#endif - +int log_npc(struct map_session_data* sd, const char* message) +{ if(!log_config.enable_logs) return 0; + nullpo_retr(0, sd); + #ifndef TXT_ONLY if(log_config.sql_logs > 0) { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", - log_config.log_npc_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message)); - if(mysql_query(&logmysql_handle, tmp_sql)) + SqlStmt* stmt; + stmt = SqlStmt_Malloc(logmysql_handle); + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, strnlen(message, 255)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return 0; } - return 1; + SqlStmt_Free(stmt); } + else #endif - if((logfp=fopen(log_config.log_npc,"a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %s[%d]: %s\n",timestring,sd->status.name,sd->status.account_id,message); - fclose(logfp); + { + FILE* logfp; + if((logfp = fopen(log_config.log_npc, "a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message); + fclose(logfp); + } + return 1; } - int log_chat(const char* type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) { + //FIXME: the actual filtering is being done by the calling code instead of in here, why!? + // Log CHAT (Global, Whisper, Party, Guild, Main chat) // LOGGING FILTERS [Lupus] //============================================================= @@ -353,42 +376,45 @@ int log_chat(const char* type, int type_id, int src_charid, int src_accid, const //16 - Log Main chat messages //32 - Don't log anything when WOE is on - FILE *logfp; -#ifndef TXT_ONLY - char t_charname[NAME_LENGTH*2]; - char t_msg[CHAT_SIZE*2+1]; //Chat line fully escaped, with an extra space just in case. -#endif - //Check ON/OFF if(log_config.chat <= 0) return 0; //Deactivated #ifndef TXT_ONLY - if(log_config.sql_logs > 0){ + if(log_config.sql_logs > 0) + { + SqlStmt* stmt; + if (strlen(message) > CHAT_SIZE) { if (battle_config.error_log) - ShowError("log chat: Received message too long from type %d (%d:%d)!\n", - type_id, src_accid, src_charid); + ShowError("log chat: Received message too long from type %d (%d:%d)!\n", type_id, src_accid, src_charid); return 0; } - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", - log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y, jstrescapecpy(t_charname, dst_charname), jstrescapecpy(t_msg, message)); - - if(mysql_query(&logmysql_handle, tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; + + stmt = SqlStmt_Malloc(logmysql_handle); + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, strnlen(dst_charname, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, strnlen(message, CHAT_SIZE)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + return 0; } - return 1; + SqlStmt_Free(stmt); } + else #endif - if((logfp = fopen(log_config.log_chat, "a+")) == NULL) - return 0; - time(&curtime); - strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp, "%s - %s,%d,%d,%d,%s,%d,%d,%s,%s\n", - timestring, type, type_id, src_charid, src_accid, map, x, y, dst_charname, message); - fclose(logfp); + { + FILE* logfp; + if((logfp = fopen(log_config.log_chat, "a+")) == NULL) + return 0; + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp, "%s - %s,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, type, type_id, src_charid, src_accid, map, x, y, dst_charname, message); + fclose(logfp); + } + return 1; } diff --git a/src/map/log.h b/src/map/log.h index ee0b38beb..0065b77c0 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -9,12 +9,6 @@ struct map_session_data; struct mob_data; struct item; -#ifndef TXT_ONLY - -extern char db_server_logdb[32]; - -#endif //NOT TXT_ONLY - //New logs int log_pick_pc(struct map_session_data *sd, const char *type, int nameid, int amount, struct item *itm); int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, struct item *itm); @@ -30,8 +24,6 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp); int log_config_read(char *cfgName); -int should_log_item(int filter, int nameid, int amount); //log filter check - enum log_what { LOG_ALL = 0xFFF, LOG_TRADES = 0x002, diff --git a/src/map/mail.c b/src/map/mail.c index 8433fbada..6e6dc0a91 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,9 +2,6 @@ // For more information, see LICENCE in the main folder #ifndef TXT_ONLY -// Mail System for eAthena SQL -// Created by Valaris -// moved all strings to msg_athena.conf [Lupus] #include "../common/strlib.h" #include "../common/socket.h" @@ -27,318 +24,345 @@ int MAIL_CHECK_TIME = 120000; int mail_timer; -//extern char *msg_table[1000]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) -int mail_check(struct map_session_data *sd,int type) +/// type: 0 - mail check at login, silent if there aren't any new messages +/// 1 - @checkmail, just print the number of messages +/// 2 - @listmail, shows both read and unread messages +/// 3 - @listnewmail, shows only unread messages +int mail_check(struct map_session_data* sd, int type) { - int i = 0, new_ = 0, priority = 0; + int i = 0, new_ = 0, priority = 0; // counters char message[80]; nullpo_retr (0, sd); - sprintf(tmp_sql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`read_flag`,`priority`,`check_flag` " - "FROM `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id`", mail_db, sd->status.account_id); - - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + // retrieve all existing messages for this player + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT `message_id`,`to_account_id`,`from_char_name`,`read_flag`,`priority`,`check_flag` FROM `%s` WHERE `to_account_id` = %d ORDER by `message_id`", mail_db, sd->status.account_id) ) + { + Sql_ShowDebug(mail_handle); return 0; } - mail_res = mysql_store_result(&mail_handle); - if(mail_res) { - if (mysql_num_rows(mail_res) == 0) { - //clif_displaymessage(sd->fd,"You have no messages."); - clif_displaymessage(sd->fd, msg_txt(516)); + if( Sql_NumRows(mail_handle) == 0) + { + clif_displaymessage(sd->fd, msg_txt(516)); // "You have no messages." + Sql_FreeResult(mail_handle); + return 0; + } - mysql_free_result(mail_res); - return 0; + while( SQL_SUCCESS == Sql_NextRow(mail_handle) ) + { + char* data; + int message_id; + int to_account_id; + char from_char_name[NAME_LENGTH]; + bool read_flag, priority_flag, check_flag; + + Sql_GetData(mail_handle, 0, &data, NULL); message_id = atoi(data); + Sql_GetData(mail_handle, 1, &data, NULL); to_account_id = atoi(data); + Sql_GetData(mail_handle, 2, &data, NULL); safestrncpy(from_char_name, data, sizeof(from_char_name)); + Sql_GetData(mail_handle, 3, &data, NULL); read_flag = (bool) atoi(data); + Sql_GetData(mail_handle, 4, &data, NULL); priority_flag = (bool) atoi(data); + Sql_GetData(mail_handle, 5, &data, NULL); check_flag = (bool) atoi(data); + + i++; + + if( !check_flag ) + { + // mark this message as checked + if( SQL_ERROR == Sql_Query(mail_handle, "UPDATE `%s` SET `check_flag` = 1 WHERE `message_id` = %d", mail_db, message_id) ) + Sql_ShowDebug(mail_handle); } - while ((mail_row = mysql_fetch_row(mail_res))) { - i++; - if(!atoi(mail_row[5])) { - sprintf(tmp_sql,"UPDATE `%s` SET `check_flag`='1' WHERE `message_id`= \"%d\"", mail_db, atoi(mail_row[0])); - if(mysql_query(&mail_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( !read_flag ) + { + new_++; + if(priority_flag) + priority++; + + if( type == 2 || type == 3 ) + { + if( priority_flag ) + { + snprintf(message, 80, msg_txt(511), i, from_char_name); + clif_displaymessage(sd->fd, message); // "%d - From : %s (New - Priority)" } - } - - if(!atoi(mail_row[3])) { - new_++; - if(atoi(mail_row[4])) - priority++; - if(type==2 || type==3) { - if(atoi(mail_row[4])) { - snprintf(message, 80, msg_txt(511), i, mail_row[2]); - clif_displaymessage(sd->fd, message); - } else { - //sprintf(message, "%d - From : %s (New)", i, mail_row[2]); - snprintf(message, 80, msg_txt(512), i, mail_row[2]); - clif_displaymessage(sd->fd, message); - } + else + { + snprintf(message, 80, msg_txt(512), i, from_char_name); + clif_displaymessage(sd->fd, message); // "%d - From : %s (New)" } - } else if(type==2){ - snprintf(message, 80, msg_txt(513), i, mail_row[2]); - clif_displaymessage(sd->fd, message); } } + else if( type == 2 ) + { + snprintf(message, 80, msg_txt(513), i, from_char_name); + clif_displaymessage(sd->fd, message); // "%d - From : %s" + } + } - mysql_free_result(mail_res); - } else { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - - if(i>0 && new_>0 && type==1) { - //sprintf(message, "You have %d new messages.", new_); + Sql_FreeResult(mail_handle); + + if( new_ > 0 && (type == 0 || type == 1) ) + { sprintf(message, msg_txt(514), new_); - - clif_displaymessage(sd->fd, jstrescape(message)); - } - if(i>0 && new_>0 && priority>0 && type==1) { - //sprintf(message, "You have %d unread priority messages.", priority); - sprintf(message, msg_txt(515), priority); - clif_displaymessage(sd->fd, jstrescape(message)); + clif_displaymessage(sd->fd, message); // "You have %d unread messages." + if (priority > 0) + { + sprintf(message, msg_txt(515), priority); + clif_displaymessage(sd->fd, message); // "You have %d unread priority messages." + } } - if(!new_) { - //clif_displaymessage(sd->fd, "You have no new messages."); - clif_displaymessage(sd->fd, msg_txt(516)); + if( new_ == 0 && type != 0 ) + { + clif_displaymessage(sd->fd, msg_txt(516)); // "You have no unread messages." } return 0; } -int mail_read(struct map_session_data *sd, int message_id) +/// displays the selected message +int mail_read(struct map_session_data* sd, int index) { - + char* data; + int message_id; + char from_char_name[NAME_LENGTH]; char message[80]; + bool read_flag, priority_flag, check_flag; + char output[100]; - nullpo_retr (0, sd); + nullpo_retr(0, sd); - sprintf(tmp_sql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`message`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); + // retrieve the 'index'-th message + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT `message_id`,`from_char_name`,`message`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = %d ORDER by `message_id` LIMIT %d, 1", mail_db, sd->status.account_id, index-1) ) + { + Sql_ShowDebug(mail_handle); + return 0; + } - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( 0 == Sql_NumRows(mail_handle) ) + { + clif_displaymessage(sd->fd, msg_txt(517)); // "Message not found." + Sql_FreeResult(mail_handle); return 0; - } - - mail_res = mysql_store_result(&mail_handle); - if(mail_res) { - if (mysql_num_rows(mail_res) == 0) { - mysql_free_result(mail_res); - //clif_displaymessage(sd->fd, "Message not found."); - clif_displaymessage(sd->fd, msg_txt(517)); - return 0; - } + } - if ((mail_row = mysql_fetch_row(mail_res))) { - if(!atoi(mail_row[6])) { - sprintf(tmp_sql,"UPDATE `%s` SET `check_flag`='1' WHERE `message_id`= \"%d\"", mail_db, atoi(mail_row[0])); - if(mysql_query(&mail_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } + if( SQL_ERROR == Sql_NextRow(mail_handle) ) + { + Sql_ShowDebug(mail_handle); + Sql_FreeResult(mail_handle); + return 0; + } - //sprintf(message, "Reading message from %s", mail_row[2]); - sprintf(message, msg_txt(518), mail_row[2]); - clif_displaymessage(sd->fd, jstrescape(message)); + Sql_GetData(mail_handle, 0, &data, NULL); message_id = atoi(data); + Sql_GetData(mail_handle, 1, &data, NULL); safestrncpy(from_char_name, data, sizeof(from_char_name)); + Sql_GetData(mail_handle, 2, &data, NULL); safestrncpy(message, data, sizeof(message)); + Sql_GetData(mail_handle, 3, &data, NULL); read_flag = (bool) atoi(data); + Sql_GetData(mail_handle, 4, &data, NULL); priority_flag = (bool) atoi(data); + Sql_GetData(mail_handle, 5, &data, NULL); check_flag = (bool) atoi(data); - sprintf(message, "%s", mail_row[3]); - clif_displaymessage(sd->fd, jstrescape(message)); + Sql_FreeResult(mail_handle); - sprintf(tmp_sql,"UPDATE `%s` SET `read_flag`='1' WHERE `message_id`= \"%d\"", mail_db, atoi(mail_row[0])); - if(mysql_query(&mail_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } + // mark mail as checked + if( !check_flag ) + { + if( SQL_ERROR == Sql_Query(mail_handle, "UPDATE `%s` SET `check_flag` = 1 WHERE `message_id` = %d", mail_db, message_id) ) + Sql_ShowDebug(mail_handle); + } - mysql_free_result(mail_res); + sprintf(output, msg_txt(518), from_char_name); + clif_displaymessage(sd->fd, output); // "Reading message from %s" + clif_displaymessage(sd->fd, message); - } else { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(mail_handle, "UPDATE `%s` SET `read_flag` = 1 WHERE `message_id` = %d", mail_db, message_id) ) + { + Sql_ShowDebug(mail_handle); + } return 0; } -int mail_delete(struct map_session_data *sd, int message_id) +/// message deletion +int mail_delete(struct map_session_data* sd, int index) { + char* data; + int message_id; + bool read_flag, priority_flag, check_flag; + nullpo_retr (0, sd); - sprintf(tmp_sql,"SELECT `message_id`,`to_account_id`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT `message_id`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = %d ORDER by `message_id` LIMIT %d, 1", mail_db, sd->status.account_id, index-1) ) + { + Sql_ShowDebug(mail_handle); + return 0; + } - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( 0 == Sql_NumRows(mail_handle) ) + { + clif_displaymessage(sd->fd, msg_txt(517)); // "Message not found." + Sql_FreeResult(mail_handle); return 0; - } - - mail_res = mysql_store_result(&mail_handle); - if(mail_res) { - if (mysql_num_rows(mail_res) == 0) { - mysql_free_result(mail_res); - //clif_displaymessage(sd->fd, "Message not found."); - clif_displaymessage(sd->fd, msg_txt(517)); - return 0; - } + } + + if( SQL_ERROR == Sql_NextRow(mail_handle) ) + { + Sql_ShowDebug(mail_handle); + Sql_FreeResult(mail_handle); + return 0; + } - if ((mail_row = mysql_fetch_row(mail_res))) { - if(!atoi(mail_row[2]) && atoi(mail_row[3])) { - mysql_free_result(mail_res); - //clif_displaymessage(sd->fd,"Cannot delete unread priority mail."); - clif_displaymessage(sd->fd,msg_txt(519)); + Sql_GetData(mail_handle, 0, &data, NULL); message_id = atoi(data); + Sql_GetData(mail_handle, 1, &data, NULL); read_flag = (bool)atoi(data); + Sql_GetData(mail_handle, 2, &data, NULL); priority_flag = (bool)atoi(data); + Sql_GetData(mail_handle, 3, &data, NULL); check_flag = (bool)atoi(data); - return 0; - } - if(!atoi(mail_row[4])) { - mysql_free_result(mail_res); - //clif_displaymessage(sd->fd,"You have received new mail, use @listmail before deleting."); - clif_displaymessage(sd->fd,msg_txt(520)); - return 0; - } - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `message_id` = \"%d\"", mail_db, atoi(mail_row[0])); - if(mysql_query(&mail_handle, tmp_sql) ) { - mysql_free_result(mail_res); - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - //else clif_displaymessage(sd->fd,"Message deleted."); - else clif_displaymessage(sd->fd,msg_txt(521)); - } + Sql_FreeResult(mail_handle); - mysql_free_result(mail_res); + if( !read_flag && priority_flag ) + { + clif_displaymessage(sd->fd,msg_txt(519)); // "Cannot delete unread priority mail." + return 0; + } - } else { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + if( !check_flag ) + { + clif_displaymessage(sd->fd,msg_txt(520)); // "You have received new mail, use @listmail before deleting." + return 0; } + if( SQL_ERROR == Sql_Query(mail_handle, "DELETE FROM `%s` WHERE `message_id` = %d", mail_db, message_id) ) + { + Sql_ShowDebug(mail_handle); + return 0; + } + + clif_displaymessage(sd->fd,msg_txt(521)); // "Message deleted." + return 0; } -int mail_send(struct map_session_data *sd, char *name, char *message, int flag) +/// for sending normal and priority messages +int mail_send(struct map_session_data* sd, char* name, char* message, int flag) { + SqlStmt* stmt; + nullpo_retr (0, sd); - if(pc_isGM(sd) < 80 && sd->mail_counter > 0) { - //clif_displaymessage(sd->fd,"You must wait 10 minutes before sending another message"); - clif_displaymessage(sd->fd,msg_txt(522)); + if( pc_isGM(sd) < 80 && sd->mail_counter > 0 ) + { + clif_displaymessage(sd->fd,msg_txt(522)); // "You must wait 10 minutes before sending another message" + return 0; + } + + if( strcmp(name,"*") == 0 && pc_isGM(sd) < 80 ) + { + clif_displaymessage(sd->fd, msg_txt(523)); // "Access Denied." return 0; } - if(strcmp(name,"*")==0) { - if(pc_isGM(sd) < 80) { - //clif_displaymessage(sd->fd, "Access Denied."); - clif_displaymessage(sd->fd, msg_txt(523)); + if( strcmp(name,"*") == 0 ) + { + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT DISTINCT `account_id` FROM `%s` WHERE `account_id` != '%d' ORDER BY `account_id`", char_db, sd->status.account_id) ) + { + Sql_ShowDebug(mail_handle); return 0; } - else - sprintf(tmp_sql,"SELECT DISTINCT `account_id` FROM `%s` WHERE `account_id` <> '%d' ORDER BY `account_id`", char_db, sd->status.account_id); } else - sprintf(tmp_sql,"SELECT `account_id`,`name` FROM `%s` WHERE `name` = \"%s\"", char_db, jstrescape(name)); - - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - - mail_res = mysql_store_result(&mail_handle); - if(mail_res) { - if (mysql_num_rows(mail_res) == 0) { - mysql_free_result(mail_res); - //clif_displaymessage(sd->fd,"Character does not exist."); - clif_displaymessage(sd->fd,msg_txt(524)); + { + char name_[2*NAME_LENGTH]; + Sql_EscapeString(mail_handle, name_, name); + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT `account_id` FROM `%s` WHERE `name` = '%s'", char_db, name_) ) + { + Sql_ShowDebug(mail_handle); return 0; } + } - while ((mail_row = mysql_fetch_row(mail_res))) { - if(strcmp(name,"*")==0) { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`to_account_id`,`from_account_id`,`from_char_name`,`message`,`priority`)" - " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag); - } - else { - sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`to_account_id`,`to_char_name`,`from_account_id`,`from_char_name`,`message`,`priority`)" - " VALUES ('%d', '%s', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), mail_row[1], sd->status.account_id, sd->status.name, jstrescape(message), flag); - if(pc_isGM(sd) < 80) - sd->mail_counter=5; - } + if( 0 == Sql_NumRows(mail_handle) ) + { + clif_displaymessage(sd->fd,msg_txt(524)); // "Character does not exist." + Sql_FreeResult(mail_handle); + return 0; + } - if(mysql_query(&mail_handle, tmp_sql) ) { - mysql_free_result(mail_res); - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - return 0; - } - } + stmt = SqlStmt_Malloc(mail_handle); + SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`to_account_id`,`to_char_name`,`from_account_id`,`from_char_name`,`message`,`priority`) VALUES (?, ?, '%d', ?, ?, '%d')", mail_db, sd->status.account_id, flag); + SqlStmt_BindParam(stmt, 1, SQLDT_STRING, name, strnlen(name, NAME_LENGTH)); + SqlStmt_BindParam(stmt, 2, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)); + SqlStmt_BindParam(stmt, 3, SQLDT_STRING, message, strnlen(message, 80)); + + while( SQL_SUCCESS == Sql_NextRow(mail_handle) ) + { + int id; + char* data; + Sql_GetData(mail_handle, 0, &data, NULL); id = atoi(data); + SqlStmt_BindParam(stmt, 0, SQLDT_INT, &id, sizeof(id)); + if( SQL_ERROR == SqlStmt_Execute(stmt) ) + SqlStmt_ShowDebug(stmt); } + Sql_FreeResult(mail_handle); + SqlStmt_Free(stmt); - //clif_displaymessage(sd->fd,"Mail has been sent."); - clif_displaymessage(sd->fd,msg_txt(525)); + if(pc_isGM(sd) < 80) + sd->mail_counter = 5; + + clif_displaymessage(sd->fd,msg_txt(525)); // "Mail has been sent." return 0; } -static int mail_check_timer_sub(struct map_session_data *sd, va_list va) +/// invoked every MAIL_CHECK_TIME ms, decreases the send blocking counter +static int mail_check_timer_sub(struct map_session_data* sd, va_list va) { - int id = va_arg(va, int); - if(pc_isGM(sd) < 80 && sd->mail_counter > 0) + if(sd->mail_counter > 0) sd->mail_counter--; - if(sd->status.account_id==id) - clif_displaymessage(sd->fd, msg_txt(526)); //you got new email. return 0; } -int mail_check_timer(int tid,unsigned int tick,int id,int data) +/// periodically checks for new messages and notifies about them +int mail_check_timer(int tid, unsigned int tick, int id, int data) { if(mail_timer != tid) return 0; - sprintf(tmp_sql,"SELECT DISTINCT `to_account_id` FROM `%s` WHERE `read_flag` = '0' AND `check_flag` = '0'", mail_db); + mail_timer = add_timer(gettick() + MAIL_CHECK_TIME, mail_check_timer, 0, 0); - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); + // fetch account ids of people who received new mail since the last iteration + if( SQL_ERROR == Sql_Query(mail_handle, "SELECT DISTINCT `to_account_id` FROM `%s` WHERE `read_flag` = '0' AND `check_flag` = '0'", mail_db) ) + { + Sql_ShowDebug(mail_handle); return 0; - } + } - mail_res = mysql_store_result(&mail_handle); + while( SQL_SUCCESS == Sql_NextRow(mail_handle) ) + { + char* id; + struct map_session_data* sd; + Sql_GetData(mail_handle, 0, &id, NULL); + if( (sd = map_id2sd(atoi(id))) != NULL ) + clif_displaymessage(sd->fd, msg_txt(526)); // "You have new mail." + } - if (mail_res) { - if (mysql_num_rows(mail_res) == 0) { - mysql_free_result(mail_res); - mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); - return 0; - } + Sql_FreeResult(mail_handle); - while ((mail_row = mysql_fetch_row(mail_res))) - clif_foreachclient(mail_check_timer_sub, atoi(mail_row[0])); - } + // decrease the send-blocking counter + clif_foreachclient(mail_check_timer_sub); - sprintf(tmp_sql,"UPDATE `%s` SET `check_flag`='1' WHERE `check_flag`= '0' ", mail_db); - if(mysql_query(&mail_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + // The 'check_flag' indicates whether the player was informed about the message. + // All online players were notified by the above code, and offline players will get the notice at next login. + // Therefore it is safe to simply set the flag to '1' for all existing mails. + if( SQL_ERROR == Sql_Query(mail_handle, "UPDATE `%s` SET `check_flag` = 1 WHERE `check_flag` = 0", mail_db) ) + Sql_ShowDebug(mail_handle); - mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); return 0; } int do_init_mail(void) { - add_timer_func_list(mail_check_timer,"mail_check_timer"); - mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); + add_timer_func_list(mail_check_timer, "mail_check_timer"); + mail_timer = add_timer(gettick() + MAIL_CHECK_TIME, mail_check_timer, 0, 0); + return 0; } diff --git a/src/map/mail.h b/src/map/mail.h index fca124ae4..f753d827b 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,8 +5,8 @@ #define _MAIL_H_ int mail_check(struct map_session_data *sd, int type); -int mail_read(struct map_session_data *sd, int message_id); -int mail_delete(struct map_session_data *sd, int message_id); +int mail_read(struct map_session_data *sd, int index); +int mail_delete(struct map_session_data *sd, int index); int mail_send(struct map_session_data *sd, char *name, char *message, int flag); int do_init_mail(void); diff --git a/src/map/map.c b/src/map/map.c index 7c1ba6c4c..2476e0e0e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -11,6 +11,7 @@ #include "../common/version.h" #include "../common/nullpo.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "map.h" #include "chrif.h" @@ -34,11 +35,8 @@ #include "mercenary.h" //[orn] #include "atcommand.h" #include "charcommand.h" - #include "log.h" - #include "irc.h" - #include #include #include @@ -50,10 +48,20 @@ #endif #ifndef TXT_ONLY - #include "mail.h" +#endif -char tmp_sql[65535]=""; +#include +#include +#include +#include +#include +#ifndef _WIN32 +#include +#endif + + +#ifndef TXT_ONLY char default_codepage[32] = ""; int map_server_port = 3306; @@ -61,9 +69,7 @@ char map_server_ip[32] = "127.0.0.1"; char map_server_id[32] = "ragnarok"; char map_server_pw[32] = "ragnarok"; char map_server_db[32] = "ragnarok"; -MYSQL mmysql_handle; -MYSQL_RES* sql_res; -MYSQL_ROW sql_row; +Sql* mmysql_handle; int db_use_sqldbs = 0; char item_db_db[32] = "item_db"; @@ -79,9 +85,7 @@ int log_db_port = 3306; char log_db_id[32] = "ragnarok"; char log_db_pw[32] = "ragnarok"; char log_db[32] = "log"; -MYSQL logmysql_handle; -MYSQL_RES* logsql_res; -MYSQL_ROW logsql_row; +Sql* logmysql_handle; // mail system int mail_server_enable = 0; @@ -91,9 +95,7 @@ char mail_server_id[32] = "ragnarok"; char mail_server_pw[32] = "ragnarok"; char mail_server_db[32] = "ragnarok"; char mail_db[32] = "mail"; -MYSQL mail_handle; -MYSQL_RES* mail_res; -MYSQL_ROW mail_row; +Sql* mail_handle; #endif /* not TXT_ONLY */ @@ -1096,7 +1098,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y if (length) { //Adjust final position to fit in the given area. //TODO: Find an alternate method which does not requires a square root calculation. - k = sqrt(magnitude2); + k = (int)sqrt(magnitude2); mx1 = x0 + (x1 - x0)*length/k; my1 = y0 + (y1 - y0)*length/k; len_limit = MAGNITUDE2(x0,y0, mx1,my1); @@ -2951,43 +2953,30 @@ int inter_config_read(char *cfgName) *---------------------------------------*/ int map_sql_init(void) { - mysql_init(&mmysql_handle); + // main db connection + mmysql_handle = Sql_Malloc(); - //DB connection start ShowInfo("Connecting to the Map DB Server....\n"); - if(!mysql_real_connect(&mmysql_handle, map_server_ip, map_server_id, map_server_pw, - map_server_db ,map_server_port, (char *)NULL, 0)) { - //pointer check - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - exit(1); - } - else { - ShowStatus("connect success! (Map Server Connection)\n"); - } + if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) + exit(1); + ShowStatus("connect success! (Map Server Connection)\n"); - if(mail_server_enable) { // mail system [Valaris] - mysql_init(&mail_handle); - ShowInfo("Connecting to the Mail DB Server....\n"); - if(!mysql_real_connect(&mail_handle, mail_server_ip, mail_server_id, mail_server_pw, - mail_server_db ,mail_server_port, (char *)NULL, 0)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - exit(1); - } - if( strlen(default_codepage) > 0 ) { - sprintf( tmp_sql, "SET NAMES %s", default_codepage ); - if (mysql_query(&mail_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mail_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } - } + if( strlen(default_codepage) > 0 ) + if ( SQL_ERROR == Sql_SetEncoding(mmysql_handle, default_codepage) ) + Sql_ShowDebug(mmysql_handle); - if( strlen(default_codepage) > 0 ) { - sprintf( tmp_sql, "SET NAMES %s", default_codepage ); - if (mysql_query(&mmysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if(mail_server_enable) + { + // mail system + mail_handle = Sql_Malloc(); + + ShowInfo("Connecting to the Mail DB Server....\n"); + if( SQL_ERROR == Sql_Connect(mail_handle, mail_server_id, mail_server_pw, mail_server_ip, mail_server_port, mail_server_db) ) + exit(1); + + if( strlen(default_codepage) > 0 ) + if ( SQL_ERROR == Sql_SetEncoding(mail_handle, default_codepage) ) + Sql_ShowDebug(mail_handle); } return 0; @@ -2995,13 +2984,15 @@ int map_sql_init(void) int map_sql_close(void) { - mysql_close(&mmysql_handle); ShowStatus("Close Map DB Connection....\n"); + Sql_Free(mmysql_handle); + mmysql_handle = NULL; if (log_config.sql_logs) { - mysql_close(&logmysql_handle); ShowStatus("Close Log DB Connection....\n"); + Sql_Free(logmysql_handle); + logmysql_handle = NULL; } return 0; @@ -3009,25 +3000,18 @@ int map_sql_close(void) int log_sql_init(void) { - mysql_init(&logmysql_handle); + // log db connection + logmysql_handle = Sql_Malloc(); - //DB connection start ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db,log_db_ip); - if(!mysql_real_connect(&logmysql_handle, log_db_ip, log_db_id, log_db_pw, - log_db ,log_db_port, (char *)NULL, 0)) { - //pointer check - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - exit(1); - } - + if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db) ) + exit(1); ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db); - if( strlen(default_codepage) > 0 ) { - sprintf( tmp_sql, "SET NAMES %s", default_codepage ); - if (mysql_query(&logmysql_handle, tmp_sql)) { - ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } - } + + if( strlen(default_codepage) > 0 ) + if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) ) + Sql_ShowDebug(logmysql_handle); + return 0; } @@ -3037,31 +3021,25 @@ int log_sql_init(void) int map_sql_ping(int tid, unsigned int tick, int id, int data) { ShowInfo("Pinging SQL server to keep connection alive...\n"); - mysql_ping(&mmysql_handle); + Sql_Ping(mmysql_handle); if (log_config.sql_logs) - mysql_ping(&logmysql_handle); + Sql_Ping(logmysql_handle); if(mail_server_enable) - mysql_ping(&mail_handle); + Sql_Ping(mail_handle); return 0; } int sql_ping_init(void) { - int connection_timeout, connection_ping_interval; + uint32 connection_timeout, connection_ping_interval; - // set a default value first + // set a default value connection_timeout = 28800; // 8 hours // ask the mysql server for the timeout value - if (!mysql_query(&mmysql_handle, "SHOW VARIABLES LIKE 'wait_timeout'") - && (sql_res = mysql_store_result(&mmysql_handle)) != NULL) { - sql_row = mysql_fetch_row(sql_res); - if (sql_row) - connection_timeout = atoi(sql_row[1]); - if (connection_timeout < 60) - connection_timeout = 60; - mysql_free_result(sql_res); - } + Sql_GetTimeout(mmysql_handle, &connection_timeout); + if (connection_timeout < 60) + connection_timeout = 60; // establish keepalive connection_ping_interval = connection_timeout - 30; // 30-second reserve diff --git a/src/map/map.h b/src/map/map.h index 15a0ece81..cd28f0f14 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -795,7 +795,7 @@ struct map_session_data { char fakename[NAME_LENGTH]; // fake names [Valaris] #ifndef TXT_ONLY - int mail_counter; // mail counter for mail system [Valaris] + int mail_counter; // mail counter for mail system (antiflood protection) #endif int duel_group; // duel vars [LuzZza] @@ -1396,37 +1396,6 @@ extern char *MSG_CONF_NAME; extern char *map_server_dns; -#ifndef TXT_ONLY - -#ifdef WIN32 -#include -#endif -#include - -extern char tmp_sql[65535]; - -extern int db_use_sqldbs; -extern MYSQL mmysql_handle; -extern MYSQL_RES* sql_res ; -extern MYSQL_ROW sql_row ; - -extern MYSQL logmysql_handle; -extern MYSQL_RES* logsql_res ; -extern MYSQL_ROW logsql_row ; - -extern int mail_server_enable; -extern MYSQL mail_handle; -extern MYSQL_RES* mail_res ; -extern MYSQL_ROW mail_row ; - -extern char item_db_db[32]; -extern char item_db2_db[32]; -extern char mob_db_db[32]; -extern char mob_db2_db[32]; -extern char char_db[32]; -extern char mail_db[32]; - -#endif /* not TXT_ONLY */ //Useful typedefs from jA [Skotlex] typedef struct map_session_data TBL_PC; typedef struct npc_data TBL_NPC; @@ -1444,4 +1413,24 @@ typedef struct homun_data TBL_HOM; extern int lowest_gm_level; extern char main_chat_nick[16]; +#ifndef TXT_ONLY + +#include "../common/sql.h" + +extern int db_use_sqldbs; +extern int mail_server_enable; + +extern Sql* mmysql_handle; +extern Sql* logmysql_handle; +extern Sql* mail_handle; + +extern char item_db_db[32]; +extern char item_db2_db[32]; +extern char mob_db_db[32]; +extern char mob_db2_db[32]; +extern char char_db[32]; +extern char mail_db[32]; + +#endif /* not TXT_ONLY */ + #endif /* _MAP_H_ */ diff --git a/src/map/mob.c b/src/map/mob.c index 86d60a152..b5c83413c 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -9,6 +9,7 @@ #include "../common/showmsg.h" #include "../common/ers.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "map.h" #include "clif.h" @@ -3210,7 +3211,10 @@ static unsigned int mob_drop_adjust(int rate, int rate_adjust, unsigned short ra return cap_value(rate,rate_min,rate_max); } -int mob_parse_dbrow(char** str) +/*========================================== + * processes one mobdb entry + *------------------------------------------*/ +static bool mob_parse_dbrow(char** str) { struct mob_db *db; struct status_data *status; @@ -3220,15 +3224,15 @@ int mob_parse_dbrow(char** str) class_ = str[0] ? atoi(str[0]) : 0; if (class_ == 0) - return 0; //Leave blank lines alone... [Skotlex] + return false; //Leave blank lines alone... [Skotlex] if (class_ <= 1000 || class_ > MAX_MOB_DB) { ShowWarning("Mob with ID: %d not loaded. ID must be in range [%d-%d]\n", class_, 1000, MAX_MOB_DB); - return 0; + return false; } if (pcdb_checkid(class_)) { ShowWarning("Mob with ID: %d not loaded. That ID is reserved for player classes.\n"); - return 0; + return false; } if (mob_db_data[class_] == NULL) @@ -3432,7 +3436,7 @@ int mob_parse_dbrow(char** str) } } - return 1; + return true; } /*========================================== @@ -3440,83 +3444,113 @@ int mob_parse_dbrow(char** str) *------------------------------------------*/ static int mob_readdb(void) { - FILE *fp; - char line[1024]; - char *filename[]={ "mob_db.txt","mob_db2.txt" }; - int i, fi; - unsigned int ln = 0; + char* filename[] = { "mob_db.txt", "mob_db2.txt" }; + int fi; - for(fi = 0; fi < 2; fi++) { - sprintf(line, "%s/%s", db_path, filename[fi]); - fp = fopen(line, "r"); + for(fi = 0; fi < 2; fi++) + { + uint32 lines = 0, count = 0; + char line[1024]; + char path[256]; + FILE* fp; + + sprintf(path, "%s/%s", db_path, filename[fi]); + fp = fopen(path, "r"); if(fp == NULL) { if(fi > 0) continue; return -1; } + // process rows one by one while(fgets(line, sizeof(line), fp)) { char *str[38+2*MAX_MOB_DROP], *p, *np; + int i; + lines++; if(line[0] == '/' && line[1] == '/') continue; - for(i = 0, p = line; i < 38 + 2*MAX_MOB_DROP; i++) { + for(i = 0, p = line; i < 38 + 2*MAX_MOB_DROP; i++) + { + str[i] = p; if((np = strchr(p, ',')) != NULL) { - str[i] = p; *np = 0; p = np + 1; - } else - str[i] = p; + *np = '\0'; p = np + 1; + } } if(i < 38 + 2*MAX_MOB_DROP) { - ShowWarning("mob_readdb: Insufficient columns for mob with ID: %d\n", str[0] ? atoi(str[0]) : 0); + ShowWarning("mob_readdb: Insufficient columns for mob with id: %d, skipping.\n", atoi(str[0])); continue; } if (!mob_parse_dbrow(str)) continue; - ln++; // counts the number of correctly parsed entries + count++; } + fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, filename[fi]); - ln = 0; + + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename[fi]); } + return 0; } #ifndef TXT_ONLY /*========================================== - * SQL reading + * mob_db table reading *------------------------------------------*/ static int mob_read_sqldb(void) { - char *mob_db_name[] = { mob_db_db, mob_db2_db }; + char* mob_db_name[] = { mob_db_db, mob_db2_db }; int fi; - unsigned int ln = 0; - for (fi = 0; fi < 2; fi++) { - sprintf (tmp_sql, "SELECT * FROM `%s`", mob_db_name[fi]); - if (mysql_query(&mmysql_handle, tmp_sql)) { - ShowSQL("DB error (%s) - %s\n", mob_db_name[fi], mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + for (fi = 0; fi < 2; fi++) + { + uint32 lines = 0, count = 0; + + // retrieve all rows from the mob database + if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) + { + Sql_ShowDebug(mmysql_handle); continue; } - sql_res = mysql_store_result(&mmysql_handle); - if (sql_res) { - while((sql_row = mysql_fetch_row(sql_res))){ - - if (!mob_parse_dbrow(sql_row)) - continue; + + // process rows one by one + while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) + { + // wrap the result into a TXT-compatible format + char line[1024]; + char* str[38+2*MAX_MOB_DROP]; + char* p; + int i; + + lines++; + for(i = 0, p = line; i < 38 + 2*MAX_MOB_DROP; i++) + { + char* data; + size_t len; + Sql_GetData(mmysql_handle, i, &data, &len); - ln++; // counts the number of correctly parsed entries + strcpy(p, data); + str[i] = p; + p+= len + 1; } - mysql_free_result(sql_res); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, mob_db_name[fi]); - ln = 0; + if (!mob_parse_dbrow(str)) + continue; + + count++; } + + // free the query result + Sql_FreeResult(mmysql_handle); + + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); + count = 0; } return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 4adf4b946..b469878eb 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -6,6 +6,7 @@ #include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/utils.h" #include "../common/ers.h" #include "../common/db.h" #include "map.h" diff --git a/src/map/party.c b/src/map/party.c index e4b960342..284f00a77 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -7,6 +7,7 @@ #include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/utils.h" #include "party.h" #include "atcommand.h" //msg_txt() diff --git a/src/map/pc.c b/src/map/pc.c index 3dd2289c3..d6a41db37 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8,6 +8,7 @@ #include "../common/showmsg.h" #include "../common/socket.h" // RFIFO*() #include "../common/timer.h" +#include "../common/utils.h" #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config @@ -742,7 +743,7 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t #ifndef TXT_ONLY if(mail_server_enable) - mail_check(sd,1); // check mail at login [Valaris] + mail_check(sd,0); // check mail at login [Valaris] #endif // message of the limited time of the account diff --git a/src/map/pet.c b/src/map/pet.c index b593cbdff..9bebf27bc 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -6,6 +6,7 @@ #include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/utils.h" #include "../common/ers.h" #include "pc.h" diff --git a/src/map/script.c b/src/map/script.c index d423d433e..0a5b5fbc0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -226,13 +226,10 @@ int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0; int potion_target=0; #if !defined(TXT_ONLY) && defined(MAPREGSQL) -// [zBuffer] SQL Mapreg Saving/Loading Database Declaration char mapregsql_db[32] = "mapreg"; char mapregsql_db_varname[32] = "varname"; char mapregsql_db_index[32] = "index"; char mapregsql_db_value[32] = "value"; -char tmp_sql[65535]; -// -------------------------------------------------------- #endif int get_com(unsigned char *script,int *pos); @@ -3222,85 +3219,76 @@ void run_script_main(struct script_state *st) /*========================================== * ƒ}ƒbƒv•Ï”‚Ì•ÏX *------------------------------------------*/ -int mapreg_setreg(int num,int val) +int mapreg_setreg(int num, int val) { #if !defined(TXT_ONLY) && defined(MAPREGSQL) - int i=num>>24; - char *name=str_buf+str_data[num&0x00ffffff].str; - char tmp_str[64]; -#endif + int i = num >> 24; + char* name = str_buf + str_data[num&0x00ffffff].str; - if(val!=0) { + if( val != 0 ) { if(idb_put(mapreg_db,num,(void*)val)) ; -#if !defined(TXT_ONLY) && defined(MAPREGSQL) else if(name[1] != '@') { - sprintf(tmp_sql,"INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%d')",mapregsql_db,mapregsql_db_varname,mapregsql_db_index,mapregsql_db_value,jstrescapecpy(tmp_str,name),i,val); - if(mysql_query(&mmysql_handle,tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + char tmp_str[32*2+1]; + Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%d')", mapregsql_db, mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, tmp_str, i, val) ) + Sql_ShowDebug(mmysql_handle); } -#endif - } else { // [zBuffer] -#if !defined(TXT_ONLY) && defined(MAPREGSQL) + } else { // val == 0 if(name[1] != '@') { // Remove from database because it is unused. - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'",mapregsql_db,mapregsql_db_varname,name,mapregsql_db_index,i); - if(mysql_query(&mmysql_handle,tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_varname, name, mapregsql_db_index, i) ) + Sql_ShowDebug(mmysql_handle); } -#endif idb_remove(mapreg_db,num); } +#else + if(val != 0) + idb_put(mapreg_db,num,(void*)val); + else + idb_remove(mapreg_db,num); +#endif - mapreg_dirty=1; + mapreg_dirty = 1; return 1; } /*========================================== * •¶Žš—ñŒ^ƒ}ƒbƒv•Ï”‚Ì•ÏX *------------------------------------------*/ -int mapreg_setregstr(int num,const char *str) +int mapreg_setregstr(int num, const char* str) { - char *p; -#if !defined(TXT_ONLY) && defined(MAPREGSQL) - char tmp_str[64]; - char tmp_str2[512]; - int i=num>>24; // [zBuffer] - char *name=str_buf+str_data[num&0x00ffffff].str; -#endif - - if( str==NULL || *str==0 ){ #if !defined(TXT_ONLY) && defined(MAPREGSQL) + int i = num >> 24; + char* name = str_buf + str_data[num&0x00ffffff].str; + + if( str==NULL || *str==0 ) { if(name[1] != '@') { - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'",mapregsql_db,mapregsql_db_varname,name,mapregsql_db_index,i); - if(mysql_query(&mmysql_handle,tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_varname, name, mapregsql_db_index, i) ) + Sql_ShowDebug(mmysql_handle); } -#endif idb_remove(mapregstr_db,num); - mapreg_dirty=1; + mapreg_dirty = 1; return 1; } - p=(char *)aMallocA((strlen(str)+1)*sizeof(char)); - strcpy(p,str); - if (idb_put(mapregstr_db,num,p)) + if (idb_put(mapregstr_db,num, aStrdup(str))) ; -#if !defined(TXT_ONLY) && defined(MAPREGSQL) - else if(name[1] != '@'){ //put returned null, so we must insert. + else if(name[1] != '@') { //put returned null, so we must insert. // Someone is causing a database size infinite increase here without name[1] != '@' [Lance] - sprintf(tmp_sql,"INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%s')",mapregsql_db,mapregsql_db_varname,mapregsql_db_index,mapregsql_db_value,jstrescapecpy(tmp_str,name),i,jstrescapecpy(tmp_str2,p)); - if(mysql_query(&mmysql_handle,tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + char tmp_str[32*2+1]; + char tmp_str2[255*2+1]; + Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%s')", mapregsql_db, mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, tmp_str, i, tmp_str2) ) + Sql_ShowDebug(mmysql_handle); } +#else + if( str==NULL || *str==0 ) + idb_remove(mapregstr_db,num); + else + idb_put(mapregstr_db,num,aStrdup(str)); #endif - mapreg_dirty=1; + + mapreg_dirty = 1; return 1; } @@ -3310,83 +3298,87 @@ int mapreg_setregstr(int num,const char *str) static int script_load_mapreg(void) { #if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp; + FILE* fp; char line[1024]; - if( (fp=fopen(mapreg_txt,"rt"))==NULL ) + if( (fp=fopen(mapreg_txt,"rt")) == NULL ) return -1; while(fgets(line,sizeof(line),fp)) { - char buf1[256],buf2[1024],*p; + char buf1[256],buf2[1024]; + char* p; int n,v,s,i; if( sscanf(line,"%255[^,],%d\t%n",buf1,&i,&n)!=2 && (i=0,sscanf(line,"%[^\t]\t%n",buf1,&n)!=1) ) continue; - if( buf1[strlen(buf1)-1]=='$' ){ - if( sscanf(line+n,"%[^\n\r]",buf2)!=1 ){ - ShowError("%s: %s broken data !\n",mapreg_txt,buf1); + if( buf1[strlen(buf1)-1] == '$' ) { + if( sscanf(line + n, "%[^\n\r]", buf2) != 1 ) { + ShowError("%s: %s broken data !\n", mapreg_txt, buf1); continue; } - p=(char *)aMallocA((strlen(buf2) + 1)*sizeof(char)); - strcpy(p,buf2); - s= add_str(buf1); - idb_put(mapregstr_db,(i<<24)|s,p); - }else{ - if( sscanf(line+n,"%d",&v)!=1 ){ - ShowError("%s: %s broken data !\n",mapreg_txt,buf1); + p = aStrdup(buf2); + s = add_str(buf1); + idb_put(mapregstr_db, (i<<24)|s, p); + } else { + if( sscanf(line + n, "%d", &v) != 1 ) { + ShowError("%s: %s broken data !\n", mapreg_txt, buf1); continue; } - s= add_str(buf1); - idb_put(mapreg_db,(i<<24)|s,(void*)v); + s = add_str(buf1); + idb_put(mapreg_db, (i<<24)|s, (void*)v); } } fclose(fp); - mapreg_dirty=0; + + mapreg_dirty = 0; return 0; #else - // SQL mapreg code start [zBuffer] /* - 0 1 2 - +-------------------------+ - | varname | index | value | - +-------------------------+ - */ - unsigned int perfomance = (unsigned int)time(NULL); - sprintf(tmp_sql,"SELECT * FROM `%s`",mapregsql_db); - ShowInfo("Querying script_load_mapreg ...\n"); - if(mysql_query(&mmysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); + 0 1 2 + +-------------------------+ + | varname | index | value | + +-------------------------+ + */ + + SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle); + char varname[32+1]; + int index; + char value[255+1]; + uint32 length; + + if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `%s`, `%s`, `%s` FROM `%s`", mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, mapregsql_db) + || SQL_ERROR == SqlStmt_Execute(stmt) + ) { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return -1; } - ShowInfo("Success! Returning results ...\n"); - sql_res = mysql_store_result(&mmysql_handle); - if (sql_res) { - while ((sql_row = mysql_fetch_row(sql_res))) { - char buf1[33], *p = NULL; - int i,v,s; - strcpy(buf1,sql_row[0]); - if( buf1[strlen(buf1)-1]=='$' ){ - i = atoi(sql_row[1]); - p=(char *)aMallocA((strlen(sql_row[2]) + 1)*sizeof(char)); - strcpy(p,sql_row[2]); - s= add_str(buf1); - idb_put(mapregstr_db,(i<<24)|s,p); - }else{ - s= add_str(buf1); - v= atoi(sql_row[2]); - i = atoi(sql_row[1]); - idb_put(mapreg_db,(i<<24)|s,(void *)v); - } - } + + SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], 32, &length, NULL); + SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], 255, NULL, NULL); + + while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) + { + if( varname[length-1] == '$' ) { + int s = add_str(varname); + int i = index; + char* p = aStrdup(value); + idb_put(mapregstr_db, (i<<24)|s, p); + } else { + int s = add_str(varname); + int i = index; + int v = atoi(value); + idb_put(mapreg_db, (i<<24)|s, (void *)v); + } } - ShowInfo("Freeing results...\n"); - mysql_free_result(sql_res); - mapreg_dirty=0; - perfomance = (((unsigned int)time(NULL)) - perfomance); - ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance); + + SqlStmt_Free(stmt); + + mapreg_dirty = 0; return 0; + #endif /* TXT_ONLY */ } /*========================================== @@ -3394,56 +3386,50 @@ static int script_load_mapreg(void) *------------------------------------------*/ static int script_save_mapreg_intsub(DBKey key,void *data,va_list ap) { -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp=va_arg(ap,FILE*); int num=key.i&0x00ffffff, i=key.i>>24; char *name=str_buf+str_data[num].str; - if( name[1]!='@' ){ + +#if defined(TXT_ONLY) || !defined(MAPREGSQL) + FILE *fp=va_arg(ap,FILE*); + if( name[1]!='@' ) { if(i==0) fprintf(fp,"%s\t%d\n", name, (int)data); else fprintf(fp,"%s,%d\t%d\n", name, i, (int)data); } - return 0; #else - int num=key.i&0x00ffffff, i=key.i>>24; // [zBuffer] - char *name=str_buf+str_data[num].str; if ( name[1] != '@') { - sprintf(tmp_sql,"UPDATE `%s` SET `%s`='%d' WHERE `%s`='%s' AND `%s`='%d'",mapregsql_db,mapregsql_db_value,(int)data,mapregsql_db_varname,name,mapregsql_db_index,i); - if(mysql_query(&mmysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `%s`='%d' WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_value, (int)data, mapregsql_db_varname, name, mapregsql_db_index, i) ) + Sql_ShowDebug(mmysql_handle); } - return 0; #endif + + return 0; } + static int script_save_mapreg_strsub(DBKey key,void *data,va_list ap) { -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp=va_arg(ap,FILE*); int num=key.i&0x00ffffff, i=key.i>>24; char *name=str_buf+str_data[num].str; - if( name[1]!='@' ){ + +#if defined(TXT_ONLY) || !defined(MAPREGSQL) + FILE *fp=va_arg(ap,FILE*); + if( name[1]!='@' ) { if(i==0) fprintf(fp,"%s\t%s\n", name, (char *)data); else fprintf(fp,"%s,%d\t%s\n", name, i, (char *)data); } - return 0; #else - char tmp_str2[512]; - int num=key.i&0x00ffffff, i=key.i>>24; - char *name=str_buf+str_data[num].str; if ( name[1] != '@') { - sprintf(tmp_sql,"UPDATE `%s` SET `%s`='%s' WHERE `%s`='%s' AND `%s`='%d'",mapregsql_db,mapregsql_db_value,jstrescapecpy(tmp_str2,(char *)data),mapregsql_db_varname,name,mapregsql_db_index,i); - if(mysql_query(&mmysql_handle, tmp_sql) ) { - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - } + char tmp_str2[2*255+1]; + Sql_EscapeStringLen(mmysql_handle, tmp_str2, (char*)data, strnlen((char*)data, 255)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `%s`='%s' WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_value, tmp_str2, mapregsql_db_varname, name, mapregsql_db_index, i) ) + Sql_ShowDebug(mmysql_handle); } - return 0; #endif + + return 0; } static int script_save_mapreg(void) { @@ -3459,12 +3445,8 @@ static int script_save_mapreg(void) mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub,fp); lock_fclose(fp,mapreg_txt,&lock); #else - unsigned int perfomance = (unsigned int)time(NULL); - mapreg_db->foreach(mapreg_db,script_save_mapreg_intsub); // [zBuffer] + mapreg_db->foreach(mapreg_db,script_save_mapreg_intsub); mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub); - perfomance = ((unsigned int)time(NULL) - perfomance); - if(perfomance > 2) - ShowWarning("Slow Query: MapregSQL Saving @ %d second(s).\n", perfomance); #endif mapreg_dirty=0; return 0; @@ -3688,9 +3670,8 @@ int do_init_script() script_load_mapreg(); - add_timer_func_list(script_autosave_mapreg,"script_autosave_mapreg"); - add_timer_interval(gettick()+MAPREG_AUTOSAVE_INTERVAL, - script_autosave_mapreg,0,0,MAPREG_AUTOSAVE_INTERVAL); + add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); + add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); return 0; } @@ -12098,6 +12079,7 @@ BUILDIN_FUNC(checkcell) // <--- [zBuffer] List of mathematics commands // [zBuffer] List of dynamic var commands ---> +//FIXME: some other functions are using this private function void setd_sub(struct script_state *st, TBL_PC *sd, char *varname, int elem, void *value, struct linkdb_node **ref) { set_reg(st, sd, add_str(varname)+(elem<<24), varname, value, ref); @@ -12131,80 +12113,78 @@ BUILDIN_FUNC(setd) BUILDIN_FUNC(query_sql) { #ifndef TXT_ONLY - char *name = NULL; - const char *query; - int num, i = 0,j, nb_rows; - struct { char * dst_var_name; char type; } row[32]; - TBL_PC *sd = (st->rid)? script_rid2sd(st) : NULL; + int i, j, nb_rows; + struct { char* dst_var_name; char type; } row[32]; + TBL_PC* sd = (st->rid) ? script_rid2sd(st) : NULL; - query = script_getstr(st,2); - strcpy(tmp_sql, query); - if(mysql_query(&mmysql_handle,tmp_sql)){ - ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle)); - ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); - script_pushint(st,0); + const char* query = script_getstr(st,2); + if (SQL_ERROR == Sql_Query(mmysql_handle, query) ) + { + Sql_ShowDebug(mmysql_handle); + script_pushint(st, 0); return 1; } - // If some data was returned - if((sql_res = mysql_store_result(&mmysql_handle))){ - // Count the number of rows to store - nb_rows = mysql_num_fields(sql_res); + // Count the number of rows to store + nb_rows = Sql_NumColumns(mmysql_handle); + //FIXME: what sick mind would write something like this? - // Can't store more row than variable - if (nb_rows > st->end - (st->start+3)) - nb_rows = st->end - (st->start+3); + // Can't store more row than variable + if (nb_rows > st->end - (st->start+3)) + nb_rows = st->end - (st->start+3); - if (!nb_rows) - { - script_pushint(st,0); - return 0; // Nothing to store - } + if (!nb_rows) + { + script_pushint(st,0); + return 0; // Nothing to store + } - if (nb_rows > 32) - { - ShowWarning("buildin_query_sql: too many rows!\n"); - script_pushint(st,0); - return 1; - } + if (nb_rows > 32) + { + ShowWarning("buildin_query_sql: too many rows!\n"); + script_pushint(st,0); + return 1; + } - memset(row, 0, sizeof(row)); - // Verify argument types - for(j=0; j < nb_rows; j++) - { - if(!data_isreference(script_getdata(st, 3+j))){ - ShowWarning("buildin_query_sql: Parameter %d is not a variable!\n", j); - script_pushint(st,0); - return 0; - } else { - // Store type of variable (string = 0/int = 1) - num=st->stack->stack_data[st->start+3+j].u.num; - name=(char *)(str_buf+str_data[num&0x00ffffff].str); - if(name[strlen(name)-1] != '$') { - row[j].type = 1; - } - row[j].dst_var_name = name; + memset(row, 0, sizeof(row)); + // Verify argument types + for(j=0; j < nb_rows; j++) + { + if(!data_isreference(script_getdata(st, 3+j))){ + ShowWarning("buildin_query_sql: Parameter %d is not a variable!\n", j); + script_pushint(st,0); + return 0; + } else { + // Store type of variable (string = 0/int = 1) + int num = st->stack->stack_data[st->start+3+j].u.num; + char* name = str_buf + str_data[num&0x00ffffff].str; + if(name[strlen(name)-1] != '$') { + row[j].type = 1; } + row[j].dst_var_name = name; } - // Store data - while(i<128 && (sql_row = mysql_fetch_row(sql_res))){ - for(j=0; j < nb_rows; j++) - { - if (row[j].type == 1) - setd_sub(st,sd, row[j].dst_var_name, i, (void *)atoi(sql_row[j]),script_getref(st,3+j)); - else - setd_sub(st,sd, row[j].dst_var_name, i, (void *)sql_row[j],script_getref(st,3+j)); - } - i++; + } + // Store data + for (i = 0; i < 128 && SQL_SUCCESS == Sql_NextRow(mmysql_handle); i++) + { + char* data; + Sql_GetData(mmysql_handle, j, &data, NULL); + for(j = 0; j < nb_rows; j++) { + if (row[j].type == 1) + setd_sub(st,sd, row[j].dst_var_name, i, (void *)atoi(data), script_getref(st,3+j)); + else + setd_sub(st,sd, row[j].dst_var_name, i, (void *)data, script_getref(st,3+j)); } - // Free data - mysql_free_result(sql_res); } + // Free data + Sql_FreeResult(mmysql_handle); + script_pushint(st,i); #else //for TXT version, we always return -1 script_pushint(st,-1); #endif + return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index fc365b7d3..df7564629 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -7,6 +7,7 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" +#include "../common/utils.h" #include "../common/ers.h" #include "skill.h" diff --git a/src/map/status.c b/src/map/status.c index b1e2bb1df..b5f0dbfe8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6,6 +6,7 @@ #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/malloc.h" +#include "../common/utils.h" #include "pc.h" #include "map.h" diff --git a/src/plugins/Makefile b/src/plugins/Makefile deleted file mode 100644 index bac69f70f..000000000 --- a/src/plugins/Makefile +++ /dev/null @@ -1,42 +0,0 @@ - -OBJECTS = sample.dll sig.dll pid.dll gui.dll upnp.dll console.dll - -ifdef CYGWIN - PLUGINEXT = dll -else - PLUGINEXT = so -endif - -PLUGINS = $(OBJECTS:%.dll=%.$(PLUGINEXT)) -COMMON_H = ../common/plugin.h ../common/cbasetypes.h - -txt sql all: $(PLUGINS) - -%.$(PLUGINEXT): %.c - $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< - -sig.$(PLUGINEXT): sig.c - $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \ - ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/minimalloc.o - -gui.$(PLUGINEXT): ../../plugins/gui.conf -upnp.$(PLUGINEXT): ../../plugins/upnp.conf - -../../plugins/%.conf: %.txt - cp -r $< $@ - -../../plugins/gui.conf: gui.txt -../../plugins/upnp.conf: upnp.txt - -depend: - makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c $(PLUGINS:%=../../plugins/%) -clean: - rm -rf $(PLUGINS) GNUmakefile - -# DO NOT DELETE - -sample.$(PLUGINEXT): sample.c $(COMMON_H) -sig.$(PLUGINEXT): sig.c $(COMMON_H) -pid.$(PLUGINEXT): pid.c $(COMMON_H) -gui.$(PLUGINEXT): gui.c $(COMMON_H) diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in new file mode 100644 index 000000000..769771aca --- /dev/null +++ b/src/plugins/Makefile.in @@ -0,0 +1,67 @@ +@SET_MAKE@ + +PLUGINS = sample sig pid gui upnp console + +COMMON_H = ../common/plugin.h ../common/cbasetypes.h + +##################################################################### +.PHONY : all $(PLUGINS) clean help + +all: $(PLUGINS) + +sample: sample@DLLEXT@ + +sig: sig@DLLEXT@ + +pid: pid@DLLEXT@ + +gui: gui@DLLEXT@ + +upnp: upnp@DLLEXT@ + +console: console@DLLEXT@ + +clean: + rm -rf *.o + +help: + @echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'" + @echo "'sample' - sample plugin" + @echo "'sig' - signal handler plugin" + @echo "'pid' - process id plugin" + @echo "'gui' - gui plugin" + @echo "'upnp' - upnp plugin" + @echo "'console' - console plugin" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +%@DLLEXT@: %.c + @CC@ @CFLAGS@ @CPPFLAGS@ -shared -o ../../plugins/$@ $< + +sig@DLLEXT@: sig.c + @$(MAKE) -C ../common txt + @CC@ @CFLAGS@ @CPPFLAGS@ -shared -o ../../plugins/$@ $< \ + ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o \ + ../common/obj/minimalloc.o + +gui@DLLEXT@: ../../plugins/gui.conf +upnp@DLLEXT@: ../../plugins/upnp.conf + +../../plugins/%.conf: %.txt + cp -r $< $@ + +../../plugins/gui.conf: gui.txt +../../plugins/upnp.conf: upnp.txt + +# DO NOT DELETE + +sample@DLLEXT@: sample.c $(COMMON_H) +sig@DLLEXT@: sig.c $(COMMON_H) +pid@DLLEXT@: pid.c $(COMMON_H) +gui@DLLEXT@: gui.c $(COMMON_H) +#TODO where is upnp.c? [FlavioJS] +#upnp@DLLEXT@: upnp.c $(COMMON_H) +console@DLLEXT@: console.c $(COMMON_H) diff --git a/src/tool/Makefile b/src/tool/Makefile deleted file mode 100644 index fef165ba5..000000000 --- a/src/tool/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -all: adduser convert mapcache - -adduser: - $(CC) -o ../../tools/$@ adduser.c - -convert: - $(CC) -o ../../tools/$@ convert.c - -mapcache: - $(CC) -c -o grfio.o grfio.c - $(CC) -o ../../$@ mapcache.c grfio.o -lz - -clean: - rm -rf *.o ../../tools/adduser ../../tools/convert ../../mapcache diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in new file mode 100644 index 000000000..7c0d1e1ee --- /dev/null +++ b/src/tool/Makefile.in @@ -0,0 +1,28 @@ +##################################################################### +.PHONY : all adduser convert mapcache clean help + +all: adduser convert mapcache + +adduser: + @CC@ -o ../../tools/adduser@EXEEXT@ adduser.c + +convert: + @CC@ -o ../../tools/convert@EXEEXT@ convert.c + +mapcache: + @CC@ -c -o grfio.o grfio.c + @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.o -lz + +clean: + rm -rf *.o ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ + +help: + @echo "possible targets are 'adduser' 'convert' 'mapcache' 'all' 'clean' 'help'" + @echo "'adduser' - ???" + @echo "'convert' - ???" + @echo "'mapcache' - mapcache generator" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### diff --git a/src/txt-converter/Makefile b/src/txt-converter/Makefile deleted file mode 100644 index 419029e19..000000000 --- a/src/txt-converter/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -all sql: char-converter login-converter - -char-converter: char-converter.o ../common/obj/minicore.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/utils.o \ - ../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \ - ../char/int_party.o ../char/int_guild.o \ - ../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \ - ../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o - $(CC) -o ../../tools/$@ $^ $(LIB_S) - -login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o ../common/obj/utils.o - $(CC) -o ../../tools/$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../tools/login-converter ../../tools/char-converter GNUmakefile - -# DO NOT DELETE - -%.o: %.c - $(COMPILE.c) -DTXT_SQL_CONVERT $(OUTPUT_OPTION) $< - -char-converter.o: char-converter.c -login-converter.o: login-converter.c diff --git a/src/txt-converter/Makefile.in b/src/txt-converter/Makefile.in new file mode 100644 index 000000000..31d593743 --- /dev/null +++ b/src/txt-converter/Makefile.in @@ -0,0 +1,68 @@ +LOGIN_CONVERTER_OBJ = login-converter.o ../common/obj/minicore.o \ + ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/ers.o ../common/obj/db.o \ + ../common/obj_sql/sql.o +CHAR_CONVERTER_OBJ = char-converter.o ../common/obj/minicore.o \ + ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/ers.o ../common/obj/mapindex.o \ + ../common/obj_sql/sql.o \ + obj_txt/char.o obj_txt/int_pet.o obj_txt/int_storage.o obj_txt/inter.o \ + obj_txt/int_party.o obj_txt/int_guild.o \ + obj_sql/char.o obj_sql/int_pet.o obj_sql/int_storage.o \ + obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + LOGIN_CONVERTER_DEPENDS=$(LOGIN_CONVERTER_OBJ) + CHAR_CONVERTER_DEPENDS=obj $(CHAR_CONVERTER_OBJ) +else + LOGIN_CONVERTER_DEPENDS=needs_mysql + CHAR_CONVERTER_DEPENDS=needs_mysql +endif + +##################################################################### +.PHONY : all login-converter char-converter clean help + +all: login-converter char-converter + +login-converter: $(LOGIN_CONVERTER_DEPENDS) + @CC@ @LDFLAGS@ -o ../../tools/login-converter@EXEEXT@ $(LOGIN_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@ + +char-converter: $(CHAR_CONVERTER_DEPENDS) + @CC@ @LDFLAGS@ -o ../../tools/char-converter@EXEEXT@ $(CHAR_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@ + +clean: + rm -rf *.o obj_txt obj_sql ../../tools/login-converter@EXEEXT@ ../../tools/char-converter@EXEEXT@ + +help: + @echo "possible targets are 'login-converter' 'char-converter' 'all' 'clean' 'help'" + @echo "'login-converter' - login server converter" + @echo "'char-converter' - char server converter" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### + +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +obj: + -mkdir obj_txt + -mkdir obj_sql + + +# DO NOT DELETE + +%.o: %.c + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< + +obj_txt/%.o: ../char/%.c + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< + +obj_sql/%.o: ../char_sql/%.c + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< + +char-converter.o: char-converter.c +login-converter.o: login-converter.c diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c index 63c261604..8168e0ee3 100644 --- a/src/txt-converter/char-converter.c +++ b/src/txt-converter/char-converter.c @@ -7,6 +7,7 @@ #include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/mapindex.h" +#include "../common/utils.h" #include "../char/char.h" #include "../char/int_storage.h" diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c index 6c194b9d5..114ec7735 100644 --- a/src/txt-converter/login-converter.c +++ b/src/txt-converter/login-converter.c @@ -6,16 +6,12 @@ #include "../common/core.h" #include "../common/db.h" #include "../common/showmsg.h" +#include "../common/sql.h" #include #include #include -#ifdef WIN32 -#include -#endif -#include - char login_account_id[256]="account_id"; char login_userid[256]="userid"; char login_user_pass[256]="user_pass"; @@ -90,8 +86,8 @@ int read_gm_account() int convert_login(void) { - MYSQL mysql_handle; - char tmpsql[1024]; + Sql* mysql_handle; + SqlStmt* stmt; int line_counter = 0; FILE *fp; int account_id, logincount, user_level, state, n, i; @@ -100,11 +96,12 @@ int convert_login(void) time_t connect_until_time; char dummy[2048]; - mysql_init(&mysql_handle); - if(!mysql_real_connect(&mysql_handle, db_server_ip, db_server_id, db_server_pw, db_server_logindb ,db_server_port, (char *)NULL, 0)) { - //pointer check - printf("%s\n",mysql_error(&mysql_handle)); - exit(1); + mysql_handle = Sql_Malloc(); + if ( SQL_ERROR == Sql_Connect(mysql_handle, db_server_id, db_server_pw, db_server_ip, db_server_port, db_server_logindb) ) + { + Sql_ShowDebug(mysql_handle); + Sql_Free(mysql_handle); + exit(1); } ShowStatus("Connect: Success!\n"); @@ -133,21 +130,27 @@ int convert_login(void) user_level = isGM(account_id); ShowInfo("Converting user (id: %d, name: %s, gm level: %d)\n", account_id, userid, user_level); - sprintf(tmpsql, + + stmt = SqlStmt_Malloc(mysql_handle); + if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `login` " "(`account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`, `error_message`, `connect_until`, `last_ip`, `memo`, `ban_until`, `state`) " "VALUES " - "(%d, '%s', '%s', '%s', '%c', %d, '%s', %d, '%s', %u, '%s', '%s', %u, %d)", - account_id , userid, pass, lastlogin, sex, logincount, email, user_level, error_message, (uint32)connect_until_time, last_ip, memo, (uint32)ban_until_time, state); - if(mysql_query(&mysql_handle, tmpsql) ) { - ShowError("DB server Error - %s\n", mysql_error(&mysql_handle) ); - ShowError("Query: %s\n", tmpsql); + "(%d, ?, ?, '%s', '%c', %d, '%s', %d, '%s', %u, '%s', '%s', %u, %d)", + account_id, lastlogin, sex, logincount, email, user_level, error_message, (uint32)connect_until_time, last_ip, memo, (uint32)ban_until_time, state) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_STRING, userid, strnlen(userid, 255)) + || SQL_ERROR == SqlStmt_BindParam(stmt, 1, SQLDT_STRING, pass, strnlen(pass, 32)) + || SQL_ERROR == SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); } + SqlStmt_Free(stmt); //TODO: parse the rest of the line to read the login-stored account variables, and import them to `global_reg_value` // then remove the 'dummy' buffer } fclose(fp); + Sql_Free(mysql_handle); ShowStatus("Convert end...\n"); diff --git a/vcproj-6/char-server_sql.dsp b/vcproj-6/char-server_sql.dsp index aa85a3344..f84332a7b 100644 --- a/vcproj-6/char-server_sql.dsp +++ b/vcproj-6/char-server_sql.dsp @@ -147,6 +147,14 @@ SOURCE=..\src\common\socket.h # End Source File # Begin Source File +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + SOURCE=..\src\common\strlib.c # End Source File # Begin Source File @@ -233,14 +241,6 @@ SOURCE=..\src\char_sql\inter.c SOURCE=..\src\char_sql\inter.h # End Source File -# Begin Source File - -SOURCE=..\src\char_sql\itemdb.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\itemdb.h -# End Source File # End Group # End Target # End Project diff --git a/vcproj-6/login-server_sql.dsp b/vcproj-6/login-server_sql.dsp index 17bcff167..07f853727 100644 --- a/vcproj-6/login-server_sql.dsp +++ b/vcproj-6/login-server_sql.dsp @@ -155,6 +155,14 @@ SOURCE=..\src\common\socket.h # End Source File # Begin Source File +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + SOURCE=..\src\common\strlib.c # End Source File # Begin Source File diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp index f41048829..f18eda8c6 100644 --- a/vcproj-6/map-server_sql.dsp +++ b/vcproj-6/map-server_sql.dsp @@ -155,6 +155,14 @@ SOURCE=..\src\common\socket.h # End Source File # Begin Source File +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + SOURCE=..\src\common\strlib.c # End Source File # Begin Source File diff --git a/vcproj-7.1/char-server_sql.vcproj b/vcproj-7.1/char-server_sql.vcproj index 09316641b..ec46bb71c 100644 --- a/vcproj-7.1/char-server_sql.vcproj +++ b/vcproj-7.1/char-server_sql.vcproj @@ -185,12 +185,6 @@ - - - - + + + + diff --git a/vcproj-7.1/login-server_sql.vcproj b/vcproj-7.1/login-server_sql.vcproj index 30313087d..37028adc5 100644 --- a/vcproj-7.1/login-server_sql.vcproj +++ b/vcproj-7.1/login-server_sql.vcproj @@ -223,6 +223,12 @@ + + + + diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj index 1c9649547..ff3662304 100644 --- a/vcproj-7.1/map-server_sql.vcproj +++ b/vcproj-7.1/map-server_sql.vcproj @@ -394,6 +394,12 @@ + + + + diff --git a/vcproj-8/char-server_sql.vcproj b/vcproj-8/char-server_sql.vcproj index 8d704bbdf..0427e7c27 100644 --- a/vcproj-8/char-server_sql.vcproj +++ b/vcproj-8/char-server_sql.vcproj @@ -1,7 +1,7 @@ + + + + @@ -385,14 +393,6 @@ RelativePath="..\src\char_sql\inter.h" > - - - - diff --git a/vcproj-8/char-server_txt.vcproj b/vcproj-8/char-server_txt.vcproj index fd8a87dfe..531c5519e 100644 --- a/vcproj-8/char-server_txt.vcproj +++ b/vcproj-8/char-server_txt.vcproj @@ -223,6 +223,10 @@ RelativePath="..\src\char\int_homun.c" > + + diff --git a/vcproj-8/login-server_sql.vcproj b/vcproj-8/login-server_sql.vcproj index c7f4bf252..9a128df80 100644 --- a/vcproj-8/login-server_sql.vcproj +++ b/vcproj-8/login-server_sql.vcproj @@ -1,7 +1,7 @@ + + + + diff --git a/vcproj-8/map-server_sql.vcproj b/vcproj-8/map-server_sql.vcproj index bdad0a326..913422ea2 100644 --- a/vcproj-8/map-server_sql.vcproj +++ b/vcproj-8/map-server_sql.vcproj @@ -304,6 +304,14 @@ RelativePath="..\src\common\socket.h" > + + + + diff --git a/vcproj-8/txt-converter-char.vcproj b/vcproj-8/txt-converter-char.vcproj index e53bed304..7e2b1bd45 100644 --- a/vcproj-8/txt-converter-char.vcproj +++ b/vcproj-8/txt-converter-char.vcproj @@ -204,24 +204,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/vcproj-8/txt-converter-login.vcproj b/vcproj-8/txt-converter-login.vcproj index 2997e471b..3036b0f3f 100644 --- a/vcproj-8/txt-converter-login.vcproj +++ b/vcproj-8/txt-converter-login.vcproj @@ -1,7 +1,7 @@ + @@ -190,6 +193,9 @@ + @@ -242,11 +248,19 @@ > + + + + -- cgit v1.2.3-70-g09d2 From 1285deb746735dd189c859b2090b580fddc2672e Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 21 Sep 2007 04:08:32 +0000 Subject: * Configure script detects 64bit distributions of MySQL. * Generated the configure script with cygwin's autoconf. You can re-generate the configure script by executing autoconf. To compile everything just execute these two commands: ./configure make git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11252 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 + configure | 5416 +++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 5 +- 3 files changed, 5423 insertions(+), 1 deletion(-) create mode 100644 configure (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 5a1178a99..c98951b1c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/09/21 + * Configure script detects 64bit distributions of MySQL. + * Generated the configure script with cygwin's autoconf. [FlavioJS] 2007/09/20 * Merged the tmpsql branch: [FlavioJS] - Abstraction for the sql code (sql.c/h). diff --git a/configure b/configure new file mode 100644 index 000000000..9a2377e76 --- /dev/null +++ b/configure @@ -0,0 +1,5416 @@ +#! /bin/sh +# From configure.in Revision: 11245 . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="eAthena" +ac_unique_file="src/common/cbasetypes.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +SET_MAKE +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +GREP +EGREP +MYSQL_CONFIG_HOME +HAVE_MYSQL +MYSQL_VERSION +MYSQL_CFLAGS +MYSQL_LIBS +HAVE_PCRE +PCRE_LIBS +PCRE_CFLAGS +DLLEXT +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-mysql=[ARG] use MySQL client library [default=yes], optionally + specify path to the mysql_config executable + --with-pcre=[ARG] use PCRE library [default=yes], optionally specify + the root directory path of pcre installation + --with-zlib=DIR root directory path of zlib installation (defaults + to /usr/local or /usr if not found in /usr/local) + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + +ac_config_files="$ac_config_files Makefile src/common/Makefile" + +ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" + +ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" + +ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" + + + +# +# Enable/disable MySql and optionally specify the path (optional library) +# + +# Check whether --with-mysql was given. +if test "${with_mysql+set}" = set; then + withval=$with_mysql; + if test "$withval" = "no" ; then + want_mysql="no" + elif test "$withval" = "yes" ; then + want_mysql="yes" + else + want_mysql="yes" + MYSQL_CONFIG_HOME="$withval" + fi + +else + want_mysql="yes" + +fi + + + +# +# Enable/disable PCRE and optionally specify the path (optional library) +# + +# Check whether --with-pcre was given. +if test "${with_pcre+set}" = set; then + withval=$with_pcre; + if test "$withval" = "no" ; then + want_pcre="no" + elif test "$withval" = "yes" ; then + want_pcre="yes" + else + want_pcre="yes" + PCRE_HOME="$withval" + fi + +else + want_pcre="yes" + +fi + + + +# +# Specify the path of the zlib library (required library) +# + +# Check whether --with-zlib was given. +if test "${with_zlib+set}" = set; then + withval=$with_zlib; + test -n "$withval" && ZLIB_HOME="$withval" + +else + + ZLIB_HOME=/usr/local + test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr + + +fi + + + + +############################################################################### +# Checks for programs and types. + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare" +CPPFLAGS="$CPPFLAGS -I../common" + + + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_bigendian=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +case $ac_cv_c_bigendian in + yes) + { { echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 +echo "$as_me: error: bigendian is not supported... stopping" >&2;} + { (exit 1); exit 1; }; } ;; + no) + ;; + *) + { echo "$as_me:$LINENO: WARNING: unable to determine endianess, only little endian is supported" >&5 +echo "$as_me: WARNING: unable to determine endianess, only little endian is supported" >&2;} + ;; +esac + + + +{ echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 +echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6; } +pointers_fit_in_ints="no" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int hw[(sizeof(int) == sizeof(void *))]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + pointers_fit_in_ints="yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "$pointers_fit_in_ints" = "no" ; then + CFLAGS="$CFLAGS -m32" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int hw[(sizeof(int) == sizeof(void *))]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + pointers_fit_in_ints="yes (with -m32)" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 +echo "${ECHO_T}$pointers_fit_in_ints" >&6; } +if test "$pointers_fit_in_ints" = "no" ; then + { { echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 +echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6; } +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-unused-parameter" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6; } +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CPPFLAGS -Wno-pointer-sign" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +############################################################################### +# Checks for libraries and header files. + + + + +MYSQL_VERSION="" +MYSQL_CFLAGS="" +MYSQL_LIBS="" + +if test "$want_mysql" = "no" ; then + { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 +echo "$as_me: ignoring MySQL (optional)" >&6;} +else + if test -z "$MYSQL_CONFIG_HOME"; then + # Extract the first word of "mysql_config", so it can be a program name with args. +set dummy mysql_config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MYSQL_CONFIG_HOME in + [\\/]* | ?:[\\/]*) + ac_cv_path_MYSQL_CONFIG_HOME="$MYSQL_CONFIG_HOME" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_MYSQL_CONFIG_HOME" && ac_cv_path_MYSQL_CONFIG_HOME="no" + ;; +esac +fi +MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME +if test -n "$MYSQL_CONFIG_HOME"; then + { echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 +echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi + + { echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 +echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6; } + if test "$MYSQL_CONFIG_HOME" != "no" ; then + HAVE_MYSQL="yes" + MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`" + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + { echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6; } + if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then + { { echo "$as_me:$LINENO: error: $MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping" >&5 +echo "$as_me: error: $MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping" >&2;} + { (exit 1); exit 1; }; } + fi + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 +echo "$as_me: disabling MySQL (optional)" >&6;} + fi +fi + + + + + + + + + +##TODO PCRE version +PCRE_LIBS="" +PCRE_CFLAGS="" + +if test "$want_pcre" = "no" ; then + { echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 +echo "$as_me: ignoring PCRE (optional)" >&6;} +else + if test -z "$PCRE_HOME" ; then + { echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 +echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6; } +if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcre $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcre_study (); +int +main () +{ +return pcre_study (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_pcre_pcre_study=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pcre_pcre_study=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6; } +if test $ac_cv_lib_pcre_pcre_study = yes; then + HAVE_PCRE="yes" +fi + + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-lpcre" + fi + else + PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" + PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" + { echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6; } +if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcre $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcre_compile (); +int +main () +{ +return pcre_compile (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_pcre_pcre_compile=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pcre_pcre_compile=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6; } +if test $ac_cv_lib_pcre_pcre_compile = yes; then + HAVE_PCRE="yes" +fi + + CPPFLAGS="$PCRE_OLD_CPPFLAGS" + LDFLAGS="$PCRE_OLD_LDFLAGS" + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-L$PCRE_HOME/lib -lpcre" + test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" + fi + fi + { echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 +echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6; } + if test "$HAVE_PCRE" = "yes" ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 +echo "$as_me: disabling PCRE (optional)" >&6;} + fi +fi + + + + + + + + +if test -n "${ZLIB_HOME}" ; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" +fi + +{ echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 +echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6; } +if test "${ac_cv_lib_z_inflateEnd+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inflateEnd (); +int +main () +{ +return inflateEnd (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_z_inflateEnd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_z_inflateEnd=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 +echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6; } +if test $ac_cv_lib_z_inflateEnd = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +else + { { echo "$as_me:$LINENO: error: zlib library not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib library not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + +if test "${ac_cv_header_zlib_h+set}" = set; then + { echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } + +fi +if test $ac_cv_header_zlib_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + +{ echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 +echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6; } +if test "${ac_cv_lib_m_sqrt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqrt (); +int +main () +{ +return sqrt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_m_sqrt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_m_sqrt=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 +echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6; } +if test $ac_cv_lib_m_sqrt = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +else + { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 +echo "$as_me: error: math library not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + +{ echo "$as_me:$LINENO: checking host OS" >&5 +echo $ECHO_N "checking host OS... $ECHO_C" >&6; } +host_os="`uname`" +{ echo "$as_me:$LINENO: result: $host_os" >&5 +echo "${ECHO_T}$host_os" >&6; } +fd_setsize="" +DLLEXT=".so" +case $host_os in +Solaris* ) + LIBS="$LIBS -lsocket -lnsl -ldl" + ;; +Linux* ) + LIBS="$LIBS -ldl" + ;; +FreeBSD*) + CPPFLAGS="$CPPFLAGS -D__FREEBSD__" + ;; +NetBSD*) + CPPFLAGS="$CPPFLAGS -D__NETBSD__" + ;; +CYGWIN*) + CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN" + fd_setsize="done" + DLLEXT=".dll" + ;; +esac + + +{ echo "$as_me:$LINENO: checking for MinGW" >&5 +echo $ECHO_N "checking for MinGW... $ECHO_C" >&6; } +if test -n "`$CC --version | grep -i mingw`" ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + CPPFLAGS="$CPPFLAGS -DMINGW" + if test -z "$fd_setsize" ; then + CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" + fi + LIBS="$LIBS -lws2_32" +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + +############################################################################### +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "src/char/Makefile") CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; + "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; + "src/ladmin/Makefile") CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; + "src/char_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; + "src/login_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; + "src/txt-converter/Makefile") CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; + "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; + "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; + "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim +HAVE_MYSQL!$HAVE_MYSQL$ac_delim +MYSQL_VERSION!$MYSQL_VERSION$ac_delim +MYSQL_CFLAGS!$MYSQL_CFLAGS$ac_delim +MYSQL_LIBS!$MYSQL_LIBS$ac_delim +HAVE_PCRE!$HAVE_PCRE$ac_delim +PCRE_LIBS!$PCRE_LIBS$ac_delim +PCRE_CFLAGS!$PCRE_CFLAGS$ac_delim +DLLEXT!$DLLEXT$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + + + + esac + +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in index 080df746b..206de53f9 100644 --- a/configure.in +++ b/configure.in @@ -160,7 +160,7 @@ MYSQL_LIBS="" if test "$want_mysql" = "no" ; then AC_MSG_NOTICE([ignoring MySQL (optional)]) else - if test -z "$MYSQL_CONFIG_HOME" -o test; then + if test -z "$MYSQL_CONFIG_HOME"; then AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no]) fi @@ -171,6 +171,9 @@ else MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`" MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" AC_MSG_RESULT([yes ($MYSQL_VERSION)]) + if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then + AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping]) + fi else AC_MSG_RESULT([no]) AC_MSG_NOTICE([disabling MySQL (optional)]) -- cgit v1.2.3-70-g09d2 From 8e2d7056fb461b04d20c868ffeed73468c6e1f3e Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 21 Sep 2007 05:22:13 +0000 Subject: * Makefile deleting .svn in save folder. * Limited the number of packets parsed per cycle to 3. (packet spammers create less lag) * Fixed sql login throwing an out-of-place debug message and escaping too much of the name string when creating a new login with _M/F. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11253 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++++ Makefile.in | 4 +++- configure | 2 +- src/login_sql/login.c | 25 ++++++++++++++++--------- src/map/clif.c | 6 +++++- 5 files changed, 29 insertions(+), 12 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index c98951b1c..db6ef9435 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/09/21 + * Makefile deleting .svn in save folder. + * Limited the number of packets parsed per cycle to 3. + * Fixed sql login throwing an out-of-place debug message and escaping too + much of the name string when creating a new login with _M/F. * Configure script detects 64bit distributions of MySQL. * Generated the configure script with cygwin's autoconf. [FlavioJS] 2007/09/20 diff --git a/Makefile.in b/Makefile.in index a1075c85a..c2c5efc2d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -78,11 +78,13 @@ conf: @for f in $$(ls conf-tmpl) ; do if test "$$f" != "import" ; then cp -rf conf-tmpl/$$f conf ; fi ; done @rm -rf conf/*/.svn # save: -# 1) create save folder +# 1) create save folder # 2) add missing files +# 3) remove remaining .svn folder @echo "building save folder..." @if test ! -d save ; then mkdir save ; fi @for f in $$(ls save-tmpl) ; do if test ! -e save/$$f ; then cp save-tmpl/$$f save ; fi ; done + @rm -rf save/.svn clean: @$(MAKE) -C src/common $@ diff --git a/configure b/configure index 9a2377e76..ef4c50cbb 100644 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11245 . +# From configure.in Revision: 11252 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # diff --git a/src/login_sql/login.c b/src/login_sql/login.c index d3200893b..d1b06547d 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -411,6 +411,7 @@ int mmo_auth_new(struct mmo_account* account, char sex) unsigned int tick = gettick(); char md5buf[32+1]; SqlStmt* stmt; + int result = 0; //Account Registration Flood Protection by [Kevin] if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) @@ -421,17 +422,19 @@ int mmo_auth_new(struct mmo_account* account, char sex) // check if the account doesn't exist already stmt = SqlStmt_Malloc(sql_handle); - if ( SQL_SUCCESS != SqlStmt_Prepare(stmt, "SELECT `%s` FROM `%s` WHERE `userid` = ?", login_db_userid, login_db) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_Execute(stmt) - || SqlStmt_NumRows(stmt) > 0 ) + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "SELECT `%s` FROM `%s` WHERE `userid` = ?", login_db_userid, login_db) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) { SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - return 1; // incorrect user/pass + result = 1;// error } + else if( SqlStmt_NumRows(stmt) > 0 ) + result = 1;// incorrect user/pass SqlStmt_Free(stmt); - + if( result ) + return result;// error or incorrect user/pass + // insert new entry into db //TODO: error checking stmt = SqlStmt_Malloc(sql_handle); @@ -515,8 +518,12 @@ int mmo_auth(struct mmo_account* account, int fd) account->userid[len-2] == '_' && memchr("FfMm", (unsigned char)account->userid[len-1], 4) ) // _M/_F suffix { int result; - account->userid[len-2] = '\0';// terminate the name. - result = mmo_auth_new(account, account->userid[len-1]); + char sex; + + len -= 2; + account->userid[len] = '\0';// nul-terminate the name. + sex = account->userid[len+1]; + result = mmo_auth_new(account, sex); if( result ) return result;// Failed to make account. [Skotlex]. } diff --git a/src/map/clif.c b/src/map/clif.c index ff6ccb9cf..fab1e00ad 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11521,8 +11521,12 @@ int clif_parse(int fd) { int cmd, packet_ver, packet_len, err; TBL_PC* sd; + int pnum; - while(1) + //TODO apply deplays or disconnect based on packet throughput [FlavioJS] + // Note: "click masters" can do 80+ clicks in 10 seconds + + for( pnum = 0; pnum < 3; ++pnum )// Limit max packets per cycle to 3 (delay packet spammers) [FlavioJS] { // begin main client packet processing loop sd = (TBL_PC *)session[fd]->session_data; -- cgit v1.2.3-70-g09d2 From 8da521018cf81a474464895df02e1ef410045ead Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 21 Sep 2007 16:42:42 +0000 Subject: * itemdb.c/h using a static array of 32k struct item_data* entries (faster itemdb loockup and a first step to remove map_session_data->inventory_data). * Fixed a typo in the configure script that replaced CFLAGS with CPPFLAGS when -Wno-pointer-sign is supported by the compiler. [FlavioJS] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11259 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 + configure | 4 +- configure.in | 2 +- src/map/itemdb.c | 245 ++++++++++++++++++++++++++++++++++------------------ 4 files changed, 169 insertions(+), 86 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 835313a0f..7a48082c0 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/09/21 + * itemdb.c/h using a static array of 32k struct item_data* entries (faster + itemdb loockup and a first step to remove map_session_data->inventory_data). + * Fixed a typo in the configure script that replaced CFLAGS with CPPFLAGS + when -Wno-pointer-sign is supported by the compiler. [FlavioJS] * Corrected skill Charge Attack as described in bugreport:67 [ultramage] - cast time is between 100% and 300% (+ infinite waiting fixed) - damage is also between 100% and 300% (doesn't increase past range 9) diff --git a/configure b/configure index ef4c50cbb..6f6028911 100644 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11252 . +# From configure.in Revision: 11259 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -3748,7 +3748,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6; } OLD_CFLAGS="$CFLAGS" -CFLAGS="$CPPFLAGS -Wno-pointer-sign" +CFLAGS="$CFLAGS -Wno-pointer-sign" cat >conftest.$ac_ext <<_ACEOF int foo; _ACEOF diff --git a/configure.in b/configure.in index 206de53f9..8e5cec894 100644 --- a/configure.in +++ b/configure.in @@ -133,7 +133,7 @@ AC_COMPILE_IFELSE( AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign]) OLD_CFLAGS="$CFLAGS" -CFLAGS="$CPPFLAGS -Wno-pointer-sign" +CFLAGS="$CFLAGS -Wno-pointer-sign" AC_COMPILE_IFELSE( [int foo;], [AC_MSG_RESULT([yes])], diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 4ed47df61..101738989 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -15,18 +15,25 @@ #include #include +// 32k array entries (the rest goes to the db) +#define MAX_ITEMDB 0x8000 -static struct dbt* item_db; + + +static struct item_data* itemdb_array[MAX_ITEMDB]; +static struct dbt* itemdb_other; static struct item_group itemgroup_db[MAX_ITEMGROUP]; struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex] + + /*========================================== * –¼‘O‚ÅŒŸõ—p *------------------------------------------*/ // name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) -int itemdb_searchname_sub(DBKey key,void *data,va_list ap) +static int itemdb_searchname_sub(DBKey key,void *data,va_list ap) { struct item_data *item=(struct item_data *)data,**dst,**dst2; char *str; @@ -52,9 +59,27 @@ int itemdb_searchname_sub(DBKey key,void *data,va_list ap) *------------------------------------------*/ struct item_data* itemdb_searchname(const char *str) { - struct item_data *item=NULL, *item2=NULL; + struct item_data* item; + struct item_data* item2=NULL; + int i; + + for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) + { + item = itemdb_array[i]; + if( item == NULL ) + continue; + + // Absolute priority to Aegis code name. + if( strcasecmp(item->name,str) == 0 ) + return item; + + //Second priority to Client displayed name. + if( strcasecmp(item->name,str) == 0 ) + item2 = item; + } - item_db->foreach(item_db,itemdb_searchname_sub,str,&item,&item2); + item = NULL; + itemdb_other->foreach(itemdb_other,itemdb_searchname_sub,str,&item,&item2); return item?item:item2; } @@ -77,7 +102,37 @@ static int itemdb_searchname_array_sub(DBKey key,void * data,va_list ap) *------------------------------------------*/ int itemdb_searchname_array(struct item_data** data, int size, const char *str) { - return item_db->getall(item_db,(void**)data,size,itemdb_searchname_array_sub,str); + struct item_data* item; + int i; + int count=0; + + // Search in the array + for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) + { + item = itemdb_array[i]; + if( item == NULL ) + continue; + + if( stristr(item->jname,str) || stristr(item->name,str) ) + { + if( count < size ) + data[count] = item; + ++count; + } + } + + // search in the db + if( count >= size ) + { + data = NULL; + size = 0; + } + else + { + data -= count; + size -= count; + } + return count + itemdb_other->getall(itemdb_other,(void**)data,size,itemdb_searchname_array_sub,str); } @@ -119,18 +174,18 @@ int itemdb_group_bonus(struct map_session_data* sd, int itemid) return bonus; } -/*========================================== - * DB‚Ì‘¶ÝŠm”F - *------------------------------------------*/ +/// Searches for the item_data. +/// Returns the item_data or NULL if it does not exist. struct item_data* itemdb_exists(int nameid) { - struct item_data* id; - if (!nameid) return NULL; - id = idb_get(item_db,nameid); - //Adjust nameid in case it's used outside. [Skotlex] - if (id == &dummy_item) - dummy_item.nameid = nameid; - return id; + struct item_data* item; + + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) + return itemdb_array[nameid]; + item = idb_get(itemdb_other,nameid); + if( item == &dummy_item ) + return NULL;// dummy data, doesn't exist + return item; } /*========================================== @@ -199,18 +254,18 @@ static void create_dummy_data(void) memset(&dummy_item, 0, sizeof(struct item_data)); dummy_item.nameid=500; dummy_item.weight=1; - dummy_item.value_sell = 1; - dummy_item.type=3; //Etc item - strncpy(dummy_item.name,"UNKNOWN_ITEM",ITEM_NAME_LENGTH-1); - strncpy(dummy_item.jname,"UNKNOWN_ITEM",ITEM_NAME_LENGTH-1); - dummy_item.view_id = UNKNOWN_ITEM_ID; + dummy_item.value_sell=1; + dummy_item.type=IT_ETC; //Etc item + safestrncpy(dummy_item.name,"UNKNOWN_ITEM",sizeof(dummy_item.name)); + safestrncpy(dummy_item.jname,"UNKNOWN_ITEM",sizeof(dummy_item.jname)); + dummy_item.view_id=UNKNOWN_ITEM_ID; } static void* create_item_data(DBKey key, va_list args) { struct item_data *id; - id=(struct item_data *)aCalloc(1,sizeof(struct item_data)); - id->nameid = key.i; + CREATE(id, struct item_data, 1); + id->nameid=key.i; id->weight=1; id->type=IT_ETC; return id; @@ -221,14 +276,26 @@ static void* create_item_data(DBKey key, va_list args) *------------------------------------------*/ struct item_data* itemdb_load(int nameid) { - struct item_data *id = idb_ensure(item_db,nameid,create_item_data); - if (id == &dummy_item) - { //Remove dummy_item, replace by real data. - DBKey key; + struct item_data *id; + DBKey key; + + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) + { + id = itemdb_array[nameid]; + if( id == NULL ) + { + key.i = nameid; + id = itemdb_array[nameid] = create_item_data(key, NULL); + } + return id; + } + + id = idb_ensure(itemdb_other, nameid, create_item_data); + if( id == &dummy_item ) + {// Remove dummy_item, replace by real data. key.i = nameid; - idb_remove(item_db,nameid); id = create_item_data(key, NULL); - idb_put(item_db,nameid,id); + idb_put(itemdb_other, nameid, id); } return id; } @@ -246,7 +313,15 @@ static void* return_dummy_data(DBKey key, va_list args) *------------------------------------------*/ struct item_data* itemdb_search(int nameid) { - return idb_ensure(item_db,nameid,return_dummy_data); + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) + { + DBKey key; + if( itemdb_array[nameid] ) + return itemdb_array[nameid]; + key.i = nameid; + return (struct item_data*)return_dummy_data(key, NULL); + } + return idb_ensure(itemdb_other,nameid,return_dummy_data); } /*========================================== @@ -630,18 +705,21 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line) | id | name_english | name_japanese | type | price_buy | price_sell | weight | attack | defence | range | slots | equip_jobs | equip_upper | equip_genders | equip_locations | weapon_level | equip_level | refineable | view | script | equip_script | unequip_script | +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ */ - unsigned short nameid; + int nameid; struct item_data* id; nameid = atoi(str[0]); - if(nameid <= 0) + if( nameid <= 0 ) + { + ShowWarning("itemdb_parse_dbrow: Invalid id %d in line %d of \"%s\", skipping.\n", nameid, line, source); return false; - + } + //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View id = itemdb_load(nameid); - safestrncpy(id->name, str[1], ITEM_NAME_LENGTH-1); - safestrncpy(id->jname, str[2], ITEM_NAME_LENGTH-1); - + safestrncpy(id->name, str[1], sizeof(id->name)); + safestrncpy(id->jname, str[2], sizeof(id->jname)); + id->type = atoi(str[3]); if (id->type == IT_DELAYCONSUME) { //Items that are consumed only after target confirmation @@ -655,13 +733,13 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line) if (id->value_buy < id->value_sell * 2) id->value_buy = id->value_sell * 2; // prevent exploit if (id->value_buy == 0 && id->value_sell > 0) id->value_buy = id->value_sell * 2; if (id->value_sell == 0 && id->value_buy > 0) id->value_sell = id->value_buy / 2; - + id->weight = atoi(str[6]); id->atk = atoi(str[7]); id->def = atoi(str[8]); id->range = atoi(str[9]); id->slot = atoi(str[10]); - + if (id->slot > MAX_SLOTS) { ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d\n", nameid, id->jname, id->slot, MAX_SLOTS); @@ -672,18 +750,18 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line) id->class_upper = atoi(str[12]); id->sex = atoi(str[13]); id->equip = atoi(str[14]); - + if (!id->equip && itemdb_isequip2(id)) { ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname); id->type = IT_ETC; } - + id->wlv = atoi(str[15]); id->elv = atoi(str[16]); id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this id->look = atoi(str[18]); - + id->flag.available = 1; id->flag.value_notdc = 0; id->flag.value_notoc = 0; @@ -715,7 +793,7 @@ static int itemdb_readdb(void) char* filename[] = { "item_db.txt", "item_db2.txt" }; int fi; - for(fi = 0; fi < 2; fi++) + for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { uint32 lines = 0, count = 0; char line[1024]; @@ -725,10 +803,10 @@ static int itemdb_readdb(void) sprintf(path, "%s/%s", db_path, filename[fi]); fp = fopen(path, "r"); - if(fp == NULL) { - if(fi > 0) - continue; - return -1; + if( fp == NULL ) + { + ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path); + continue; } // process rows one by one @@ -749,8 +827,9 @@ static int itemdb_readdb(void) } } - if (i < 19) { - ShowWarning("itemdb_readdb: Insufficient columns for item with id %d, skipping.\n", atoi(str[0])); + if( i < 19 ) + { + ShowWarning("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); continue; } @@ -782,7 +861,7 @@ static int itemdb_readdb(void) continue; str[21] = p; //Unequip script, last column. - if (!itemdb_parse_dbrow(str, filename[fi], lines)) + if (!itemdb_parse_dbrow(str, path, lines)) continue; count++; @@ -879,30 +958,34 @@ static void itemdb_read(void) /*========================================== * Initialize / Finalize *------------------------------------------*/ -static int itemdb_final_sub (DBKey key,void *data,va_list ap) + +/// Destroys the item_data. +static void destroy_item_data(struct item_data* self, int free_self) +{ + if( self == NULL ) + return; + // free scripts + if( self->script ) + script_free_code(self->script); + if( self->equip_script ) + script_free_code(self->equip_script); + if( self->unequip_script ) + script_free_code(self->unequip_script); +#if defined(DEBUG) + // trash item + memset(self, 0xDD, sizeof(struct item_data)); +#endif + // free self + if( free_self ) + aFree(self); +} + +static int itemdb_final_sub(DBKey key,void *data,va_list ap) { - int flag; struct item_data *id = (struct item_data *)data; - flag = va_arg(ap, int); - if (id->script) - { - script_free_code(id->script); - id->script = NULL; - } - if (id->equip_script) - { - script_free_code(id->equip_script); - id->equip_script = NULL; - } - if (id->unequip_script) - { - script_free_code(id->unequip_script); - id->unequip_script = NULL; - } - // Whether to clear the item data (exception: do not clear the dummy item data - if (flag && id != &dummy_item) - aFree(id); + if( id != &dummy_item ) + destroy_item_data(id, 1); return 0; } @@ -915,24 +998,20 @@ void itemdb_reload(void) void do_final_itemdb(void) { - item_db->destroy(item_db, itemdb_final_sub, 1); - if (dummy_item.script) { - script_free_code(dummy_item.script); - dummy_item.script = NULL; - } - if (dummy_item.equip_script) { - script_free_code(dummy_item.equip_script); - dummy_item.equip_script = NULL; - } - if (dummy_item.unequip_script) { - script_free_code(dummy_item.unequip_script); - dummy_item.unequip_script = NULL; - } + int i; + + for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) + if( itemdb_array[i] ) + destroy_item_data(itemdb_array[i], 1); + + itemdb_other->destroy(itemdb_other, itemdb_final_sub); + destroy_item_data(&dummy_item, 0); } int do_init_itemdb(void) { - item_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); + memset(itemdb_array, 0, sizeof(itemdb_array)); + itemdb_other = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); create_dummy_data(); //Dummy data item. itemdb_read(); -- cgit v1.2.3-70-g09d2 From 7791397d95512088dca065a4e187bb443b3a6a96 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sun, 23 Sep 2007 19:55:37 +0000 Subject: * Added flag svn:executable to the configure script. * Added code for MySQL versions (below 5.0) that don't have MYSQL_DATA_TRUNCATED. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11281 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ configure | 0 src/common/sql.c | 49 ++++++++++++++++++++++++++++++++++++------------- 3 files changed, 39 insertions(+), 13 deletions(-) mode change 100644 => 100755 configure (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 26e8242f9..8de95ff3c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/09/23 + * Added flag svn:executable to the configure script. + * Added code for MySQL versions (below 5.0) that don't have + MYSQL_DATA_TRUNCATED. * map_addflooritem and struct item_drop_list using id's instead of struct map_session_data's (fixes bugreport:36). * Fixed buildin_escape_sql not properly escaping in sql servers. [FlavioJS] diff --git a/configure b/configure old mode 100644 new mode 100755 diff --git a/src/common/sql.c b/src/common/sql.c index cc6e81009..6b69c8ce4 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -487,6 +487,30 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty +/// Reports debug information about a truncated column. +/// +/// @private +static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i) +{ + MYSQL_RES* meta; + MYSQL_FIELD* field; + MYSQL_BIND* column; + + meta = mysql_stmt_result_metadata(self->stmt); + field = mysql_fetch_field_direct(meta, (unsigned int)i); + ShowSQL("DB error - data of field '%s' was truncated.\n", field->name); + ShowDebug("column - %lu\n", (unsigned long)i); + Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, ""); + column = &self->columns[i]; + if( column->buffer_type == MYSQL_TYPE_STRING ) + Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)"); + else + Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, ""); + mysql_free_result(meta); +} + + + /// Allocates and initializes a new SqlStmt handle. SqlStmt* SqlStmt_Malloc(Sql* sql) { @@ -741,6 +765,8 @@ int SqlStmt_NextRow(SqlStmt* self) // check for errors if( err == MYSQL_NO_DATA ) return SQL_NO_DATA; +#if defined(MYSQL_DATA_TRUNCATED) + // MySQL 5.0/5.1 defines and returns MYSQL_DATA_TRUNCATED [FlavioJS] if( err == MYSQL_DATA_TRUNCATED ) { my_bool truncated; @@ -761,25 +787,14 @@ int SqlStmt_NextRow(SqlStmt* self) column->error = NULL; if( truncated ) {// report truncated column - MYSQL_RES* meta; - MYSQL_FIELD* field; - - meta = mysql_stmt_result_metadata(self->stmt); - field = mysql_fetch_field_direct(meta, (unsigned int)i); - ShowSQL("DB error - data of field '%s' was truncated.\n", field->name); - ShowDebug("column - %lu\n", (unsigned long)i); - Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, ""); - if( column->buffer_type == MYSQL_TYPE_STRING ) - Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)"); - else - Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, ""); - mysql_free_result(meta); + SqlStmt_P_ShowDebugTruncatedColumn(self, i); return SQL_ERROR; } } ShowSQL("DB error - data truncated (unknown source)\n"); return SQL_ERROR; } +#endif if( err ) { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); @@ -791,6 +806,14 @@ int SqlStmt_NextRow(SqlStmt* self) for( i = 0; i < cols; ++i ) { length = self->column_lengths[i].length; +#if !defined(MYSQL_DATA_TRUNCATED) + // MySQL 4.1/(below?) returns success even if data is truncated, so we test truncation manually [FlavioJS] + if( self->columns[i].buffer_length < length ) + {// report truncated column + SqlStmt_P_ShowDebugTruncatedColumn(self, i); + return SQL_ERROR; + } +#endif if( self->column_lengths[i].out_length ) *self->column_lengths[i].out_length = (uint32)length; column = &self->columns[i]; -- cgit v1.2.3-70-g09d2 From 61aacc083393bead3227a049b57fb9e76186c7c5 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 27 Sep 2007 15:24:06 +0000 Subject: * Loot code using charid's instead of id's in pick priority. * configure script using svn:eol-style LF and require mysql/pcre when --with-mysql/pcre is used. Added a forgotten file from r11311. (script_commands.txt) Note: charid's are globally unique, id's are equal for characters in the same account. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11312 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 ++++- configure | 36 +++++++++++++++++++++++++----------- configure.in | 30 ++++++++++++++++++++---------- doc/script_commands.txt | 2 +- src/map/map.c | 8 ++++---- src/map/map.h | 4 ++-- src/map/mob.c | 26 +++++++++++++------------- src/map/mob.h | 2 +- src/map/party.c | 6 +++--- src/map/party.h | 2 +- src/map/pc.c | 14 +++++++------- src/map/pet.c | 14 +++++++------- 12 files changed, 88 insertions(+), 61 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 0c13a3bd2..076c32904 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,9 +4,12 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/09/27 + * Loot code using charid's instead of id's in pick priority. + * configure script using svn:eol-style LF and require mysql/pcre when + --with-mysql/pcre is used. * Reimplemented mmo_char_fromsql using sql statements. (fixes bugreport:93) * Fixed buildin_gethominfo not being included in the script engine. (bugreport:124) - * homunculus_evolution -> homevolution in script_commands.txt. (bugreport:125) + * homunculus_evolution -> homevolution in script_commands.txt. * Deleted item DEFAULT from item_db.txt and regenerated item_db.sql. (bugreport:103) * Skip empty lines and give more feedback (for invalid lines) when reading item_db.txt/item_db2.txt. [FlavioJS] diff --git a/configure b/configure index 6f6028911..78bfd9ec3 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11259 . +# From configure.in Revision: 11312 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1713,15 +1713,16 @@ if test "${with_mysql+set}" = set; then withval=$with_mysql; if test "$withval" = "no" ; then want_mysql="no" - elif test "$withval" = "yes" ; then - want_mysql="yes" else want_mysql="yes" - MYSQL_CONFIG_HOME="$withval" + require_mysql="yes" + if test "$withval" != "yes" ; then + MYSQL_CONFIG_HOME="$withval" + fi fi else - want_mysql="yes" + want_mysql="yes" require_mysql="no" fi @@ -1736,15 +1737,16 @@ if test "${with_pcre+set}" = set; then withval=$with_pcre; if test "$withval" = "no" ; then want_pcre="no" - elif test "$withval" = "yes" ; then - want_pcre="yes" else want_pcre="yes" - PCRE_HOME="$withval" + require_pcre="yes" + if test "$withval" != "yes" ; then + PCRE_HOME="$withval" + fi fi else - want_pcre="yes" + want_pcre="yes" require_pcre="no" fi @@ -3861,8 +3863,14 @@ echo "$as_me: error: $MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bi else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 + if test "$require_mysql" = "yes" ; then + { { echo "$as_me:$LINENO: error: MySQL not found (requested)" >&5 +echo "$as_me: error: MySQL not found (requested)" >&2;} + { (exit 1); exit 1; }; } + else + { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 echo "$as_me: disabling MySQL (optional)" >&6;} + fi fi fi @@ -4034,8 +4042,14 @@ echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 + if test "$require_pcre" = "yes" ; then + { { echo "$as_me:$LINENO: error: PCRE not found (requested)" >&5 +echo "$as_me: error: PCRE not found (requested)" >&2;} + { (exit 1); exit 1; }; } + else + { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 echo "$as_me: disabling PCRE (optional)" >&6;} + fi fi fi diff --git a/configure.in b/configure.in index 8e5cec894..092e22f3a 100644 --- a/configure.in +++ b/configure.in @@ -23,14 +23,15 @@ AC_ARG_WITH( [ if test "$withval" = "no" ; then want_mysql="no" - elif test "$withval" = "yes" ; then - want_mysql="yes" else want_mysql="yes" - MYSQL_CONFIG_HOME="$withval" + require_mysql="yes" + if test "$withval" != "yes" ; then + MYSQL_CONFIG_HOME="$withval" + fi fi ], - [want_mysql="yes"] + [want_mysql="yes" require_mysql="no"] ) @@ -46,14 +47,15 @@ AC_ARG_WITH( [ if test "$withval" = "no" ; then want_pcre="no" - elif test "$withval" = "yes" ; then - want_pcre="yes" else want_pcre="yes" - PCRE_HOME="$withval" + require_pcre="yes" + if test "$withval" != "yes" ; then + PCRE_HOME="$withval" + fi fi ], - [want_pcre="yes"] + [want_pcre="yes" require_pcre="no"] ) @@ -176,7 +178,11 @@ else fi else AC_MSG_RESULT([no]) - AC_MSG_NOTICE([disabling MySQL (optional)]) + if test "$require_mysql" = "yes" ; then + AC_MSG_ERROR([MySQL not found (requested)]) + else + AC_MSG_NOTICE([disabling MySQL (optional)]) + fi fi fi @@ -219,7 +225,11 @@ else AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) - AC_MSG_NOTICE([disabling PCRE (optional)]) + if test "$require_pcre" = "yes" ; then + AC_MSG_ERROR([PCRE not found (requested)]) + else + AC_MSG_NOTICE([disabling PCRE (optional)]) + fi fi fi diff --git a/doc/script_commands.txt b/doc/script_commands.txt index c236adbb7..c19ad9716 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4590,7 +4590,7 @@ summon "--ja--",-1; --------------------------------------- -* homunculus_evolution; +*homevolution; This command will try to evolve the current player's homunculus. If it doesn't work, the /swt emoticon is shown. diff --git a/src/map/map.c b/src/map/map.c index a60e059b4..668929dfc 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1549,7 +1549,7 @@ int map_search_freecell(struct block_list *src, int m, short *x,short *y, int rx * item_data‚ÍamountˆÈŠO‚ðcopy‚·‚é * type flag: &1 MVP item. &2 do stacking check. *------------------------------------------*/ -int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_id,int second_id,int third_id,int flags) +int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_charid,int second_charid,int third_charid,int flags) { int r; struct flooritem_data *fitem=NULL; @@ -1572,11 +1572,11 @@ int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int fir return 0; } - fitem->first_get_id = first_id; + fitem->first_get_charid = first_charid; fitem->first_get_tick = gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); - fitem->second_get_id = second_id; + fitem->second_get_charid = second_charid; fitem->second_get_tick = fitem->first_get_tick + (flags&1 ? battle_config.mvp_item_second_get_time : battle_config.item_second_get_time); - fitem->third_get_id = third_id; + fitem->third_get_charid = third_charid; fitem->third_get_tick = fitem->second_get_tick + (flags&1 ? battle_config.mvp_item_third_get_time : battle_config.item_third_get_time); memcpy(&fitem->item_data,item_data,sizeof(*item_data)); diff --git a/src/map/map.h b/src/map/map.h index cdae79a78..d894dffa9 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1127,7 +1127,7 @@ struct flooritem_data { struct block_list bl; unsigned char subx,suby; int cleartimer; - int first_get_id,second_get_id,third_get_id; + int first_get_charid,second_get_charid,third_get_charid; unsigned int first_get_tick,second_get_tick,third_get_tick; struct item item_data; }; @@ -1325,7 +1325,7 @@ int map_addnpc(int,struct npc_data *); int map_clearflooritem_timer(int,unsigned int,int,int); int map_removemobs_timer(int,unsigned int,int,int); #define map_clearflooritem(id) map_clearflooritem_timer(0,0,id,1) -int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_id,int second_id,int third_id,int flags); +int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_charid,int second_charid,int third_charid,int flags); // ƒLƒƒƒ‰id„ƒLƒƒƒ‰–¼ •ÏŠ·ŠÖ˜A void map_addnickdb(int charid, const char* nick); diff --git a/src/map/mob.c b/src/map/mob.c index 07fc2db22..8f45a1fc1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1502,7 +1502,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, int data) while (ditem) { map_addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, - list->first_id,list->second_id,list->third_id,0); + list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1528,16 +1528,16 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str log_pick_mob(md, "M", ditem->item_data.nameid, -ditem->item_data.amount, NULL); } - sd = map_id2sd(dlist->first_id); - if( sd == NULL ) sd = map_id2sd(dlist->second_id); - if( sd == NULL ) sd = map_id2sd(dlist->third_id); + sd = map_charid2sd(dlist->first_charid); + if( sd == NULL ) sd = map_charid2sd(dlist->second_charid); + if( sd == NULL ) sd = map_charid2sd(dlist->third_charid); if( sd && drop_rate <= sd->state.autoloot #ifdef AUTOLOOT_DISTANCE && check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE) #endif ) { //Autoloot. if (party_share_loot(party_search(sd->status.party_id), - sd, &ditem->item_data, sd->bl.id) == 0 + sd, &ditem->item_data, sd->status.char_id) == 0 ) { ers_free(item_drop_ers, ditem); return; @@ -1986,11 +1986,11 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->m = md->bl.m; dlist->x = md->bl.x; dlist->y = md->bl.y; - dlist->first_id = (mvp_sd ? mvp_sd->bl.id : 0); - dlist->second_id = (second_sd ? second_sd->bl.id : 0); - dlist->third_id = (third_sd ? third_sd->bl.id : 0); + dlist->first_charid = (mvp_sd ? mvp_sd->status.char_id : 0); + dlist->second_charid = (second_sd ? second_sd->status.char_id : 0); + dlist->third_charid = (third_sd ? third_sd->status.char_id : 0); dlist->item = NULL; - + for (i = 0; i < MAX_MOB_DROP; i++) { if (md->db->dropitem[i].nameid <= 0) @@ -2094,9 +2094,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->m = md->bl.m; dlist->x = md->bl.x; dlist->y = md->bl.y; - dlist->first_id = (mvp_sd ? mvp_sd->bl.id : 0); - dlist->second_id = (second_sd ? second_sd->bl.id : 0); - dlist->third_id = (third_sd ? third_sd->bl.id : 0); + dlist->first_charid = (mvp_sd ? mvp_sd->status.char_id : 0); + dlist->second_charid = (second_sd ? second_sd->status.char_id : 0); + dlist->third_charid = (third_sd ? third_sd->status.char_id : 0); dlist->item = NULL; for(i = 0; i < md->lootitem_count; i++) mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000); @@ -2163,7 +2163,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if((temp = pc_additem(mvp_sd,&item,1)) != 0) { clif_additem(sd,0,0,temp); - map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->bl.id,(second_sd?second_sd->bl.id:0),(third_sd?third_sd->bl.id:0),1); + map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); } if(log_config.enable_logs&0x200) {//Logs items, MVP prizes [Lupus] diff --git a/src/map/mob.h b/src/map/mob.h index a3b589964..367640e07 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -143,7 +143,7 @@ struct item_drop { }; struct item_drop_list { int m, x, y; // coordinates - int first_id, second_id, third_id; // id's of players with higher pickup priority + int first_charid, second_charid, third_charid; // charid's of players with higher pickup priority struct item_drop* item; // linked list of drops }; diff --git a/src/map/party.c b/src/map/party.c index 020d02e22..3cac19240 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -763,12 +763,12 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b return 0; } -//Does party loot. first holds the id of the player who has time priority to take the item. -int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first) +//Does party loot. first_charid holds the charid of the player who has time priority to take the item. +int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first_charid) { TBL_PC* target = NULL; int i; - if (p && p->party.item&2 && (first || !(battle_config.party_share_type&1))) + if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) { //item distribution to party members. if (battle_config.party_share_type&2) diff --git a/src/map/party.h b/src/map/party.h index cb38c9d10..b3a5b9a4c 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -44,7 +44,7 @@ int party_check_conflict(struct map_session_data *sd); int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv); int party_send_xy_clear(struct party_data *p); int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny); -int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first); +int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first_charid); int party_send_dot_remove(struct map_session_data *sd); int party_sub_count(struct block_list *bl, va_list ap); int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int type,...); diff --git a/src/map/pc.c b/src/map/pc.c index 185641915..aafc2260b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2919,9 +2919,9 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) if (sd->status.party_id) p = party_search(sd->status.party_id); - if(fitem->first_get_id > 0 && fitem->first_get_id != sd->bl.id) + if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) { - first_sd = map_id2sd(fitem->first_get_id); + first_sd = map_charid2sd(fitem->first_get_charid); if(DIFF_TICK(tick,fitem->first_get_tick) < 0) { if (!(p && p->party.item&1 && first_sd && first_sd->status.party_id == sd->status.party_id @@ -2929,9 +2929,9 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->second_get_id > 0 && fitem->second_get_id != sd->bl.id) + if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) { - second_sd = map_id2sd(fitem->second_get_id); + second_sd = map_charid2sd(fitem->second_get_charid); if(DIFF_TICK(tick, fitem->second_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -2940,9 +2940,9 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->third_get_id > 0 && fitem->third_get_id != sd->bl.id) + if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) { - third_sd = map_id2sd(fitem->third_get_id); + third_sd = map_charid2sd(fitem->third_get_charid); if(DIFF_TICK(tick,fitem->third_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -2956,7 +2956,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) } //This function takes care of giving the item to whoever should have it, considering party-share options. - if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_id))) { + if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) { clif_additem(sd,0,0,flag); return 1; } diff --git a/src/map/pet.c b/src/map/pet.c index ac369bff5..0b7da5da2 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -997,14 +997,14 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) struct pet_data* pd; struct flooritem_data *fitem = (struct flooritem_data *)bl; struct block_list **target; - int sd_id =0; + int sd_charid =0; pd=va_arg(ap,struct pet_data *); target=va_arg(ap,struct block_list**); - sd_id = fitem->first_get_id; + sd_charid = fitem->first_get_charid; - if(sd_id && sd_id != pd->msd->bl.id) + if(sd_charid && sd_charid != pd->msd->status.char_id) return 0; if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) && @@ -1028,7 +1028,7 @@ static int pet_delay_item_drop(int tid,unsigned int tick,int id,int data) while (ditem) { map_addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, - list->first_id,list->second_id,list->third_id,0); + list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1049,9 +1049,9 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) dlist->m = pd->bl.m; dlist->x = pd->bl.x; dlist->y = pd->bl.y; - dlist->first_id = 0; - dlist->second_id = 0; - dlist->third_id = 0; + dlist->first_charid = 0; + dlist->second_charid = 0; + dlist->third_charid = 0; dlist->item = NULL; for(i=0;iloot->count;i++) { -- cgit v1.2.3-70-g09d2 From 9eb222426c4275cf35648ac8dc2e6c83cdbba14c Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 8 Nov 2007 09:26:46 +0000 Subject: * Updated configure script: - small correction to the help text of --with-mysql and --with-pcre - added the -Wno-switch compiler option to suppress the "enumeration value '%s' not handled in switch" warnings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11695 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 +++++ configure | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- configure.in | 23 ++++++++++++++++++----- 3 files changed, 71 insertions(+), 10 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index cefd6531f..fc9bfc072 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,11 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/11/08 + * Updated configure script: + - small correction to the help text of --with-mysql and --with-pcre + - added the -Wno-switch compiler option to suppress the + "enumeration value '%s' not handled in switch" warnings [FlavioJS] 2007/11/07 * Some updates on the mail system packets [Zephyrus] - Corrected the mail database structure on main.sql diff --git a/configure b/configure index 78bfd9ec3..ec2bb9856 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11312 . +# From configure.in Revision: 11695. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1252,10 +1252,12 @@ if test -n "$ac_init_help"; then Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-mysql=[ARG] use MySQL client library [default=yes], optionally - specify path to the mysql_config executable - --with-pcre=[ARG] use PCRE library [default=yes], optionally specify - the root directory path of pcre installation + --with-mysql[=ARG] use MySQL client library, optionally specify path to + the mysql_config executable (by default mysql is + used if found) + --with-pcre[=ARG] use PCRE library, optionally specify the root + directory path of pcre installation (by default pcre + is used if found) --with-zlib=DIR root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local) @@ -3788,6 +3790,47 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6; } +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-switch" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + ############################################################################### # Checks for libraries and header files. diff --git a/configure.in b/configure.in index 092e22f3a..dc5da9c54 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(eAthena) -AC_REVISION($Revision$) +AC_REVISION($Revision: 11695$) AC_PREREQ([2.61]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) @@ -17,8 +17,8 @@ AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) AC_ARG_WITH( [mysql], AC_HELP_STRING( - [--with-mysql=@<:@ARG@:>@], - [use MySQL client library @<:@default=yes@:>@, optionally specify path to the mysql_config executable] + [--with-mysql@<:@=ARG@:>@], + [use MySQL client library, optionally specify path to the mysql_config executable (by default mysql is used if found)] ), [ if test "$withval" = "no" ; then @@ -41,8 +41,8 @@ AC_ARG_WITH( AC_ARG_WITH( [pcre], AC_HELP_STRING( - [--with-pcre=@<:@ARG@:>@], - [use PCRE library @<:@default=yes@:>@, optionally specify the root directory path of pcre installation] + [--with-pcre@<:@=ARG@:>@], + [use PCRE library, optionally specify the root directory path of pcre installation (by default pcre is used if found)] ), [ if test "$withval" = "no" ; then @@ -146,6 +146,19 @@ AC_COMPILE_IFELSE( ) +AC_MSG_CHECKING([whether $CC supports -Wno-switch]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-switch" +AC_COMPILE_IFELSE( + [int foo;], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ] +) + + ############################################################################### # Checks for libraries and header files. -- cgit v1.2.3-70-g09d2 From aee3755b6d780c3261bdec2aef4d517bc7c7b148 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Mon, 19 Nov 2007 03:05:16 +0000 Subject: * Nullpo's disabled on release builds. * Added timestamps to the log of memory leaks. * Moved definition of __func__ to cbasetypes.h. * Configure script updated: - added option to select the memory manager - added option to enable MAPREGSQL - added option to enable DEBUG * common's Makefile deleting svnversion.h on 'clean' target. (run ./configure again to update your Makefile) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11760 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 9 + Makefile.in | 17 -- configure | 521 +++++++++++++++++++++++++++++++++++++++++++++++- configure.in | 118 ++++++++++- src/common/Makefile.in | 2 +- src/common/cbasetypes.h | 12 ++ src/common/malloc.c | 22 +- src/common/malloc.h | 35 ++-- src/common/nullpo.h | 49 ++--- src/map/path.c | 4 - 10 files changed, 709 insertions(+), 80 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b8c84d2aa..1bfd14d37 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,15 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/11/19 + * Nullpo's disabled on release builds. + * Added timestamps to the log of memory leaks. + * Moved definition of __func__ to cbasetypes.h. + * Configure script updated: + - added option to select the memory manager + - added option to enable MAPREGSQL + - added option to enable DEBUG + * common's Makefile deleting svnversion.h on 'clean' target. [FlavioJS] 2007/11/18 * Implemented a small change that was long overdue: Displaying the char-select screen now uses a single SQL query instead of up to 9. diff --git a/Makefile.in b/Makefile.in index ac121ff24..a2b1cd150 100644 --- a/Makefile.in +++ b/Makefile.in @@ -130,23 +130,6 @@ needs_mysql: ##################################################################### # TODO -# Server Packet Protocol version (also defined in src/common/mmo.h) -# CFLAGS += -DPACKETVER=8 - -# Makes map-wide script variables be saved to SQL instead of TXT files. -# CFLAGS += -DMAPREGSQL - -# OPT += -DGCOLLECT -# LIBS += -lgc - -# OPT += -DMEMWATCH - -# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK -# LIBS += -ldmalloc - -# OPT += -DBCHECK - - install: conf/%.conf conf/%.txt $(shell mkdir -p /opt/eathena/bin/) $(shell mkdir -p /opt/eathena/etc/eathena/) diff --git a/configure b/configure index ec2bb9856..6ffeda9af 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11695. +# From configure.in Revision: 11760. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1249,6 +1249,16 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, + gcollect, bcheck (defaults to builtin) + --enable-mapregsql Makes map-wide script variables be saved to SQL + instead of TXT files in the sql map-server. (defauts + to no) + --enable-debug Compiles in debug mode. (defauts to no) + Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) @@ -1706,6 +1716,76 @@ ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool +# +# Memory managers +# +# Check whether --enable-manager was given. +if test "${enable_manager+set}" = set; then + enableval=$enable_manager; + enable_manager="$enableval" + case $enableval in + "no");; + "builtin");; + "memwatch");; + "dmalloc");; + "gcollect");; + "bcheck");; + *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enable_manager'... stopping" >&5 +echo "$as_me: error: unknown memory manager '$enable_manager'... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_manager="builtin" + +fi + + + +# +# mapregsql +# +# Check whether --enable-mapregsql was given. +if test "${enable_mapregsql+set}" = set; then + enableval=$enable_mapregsql; + enable_mapregsql="$enableval" + case $enableval in + no);; + yes);; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&5 +echo "$as_me: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_mapregsql="no" + +fi + + + +# +# debug +# +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then + enableval=$enable_debug; + enable_debug="$enableval" + case $enableval in + no);; + yes);; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&5 +echo "$as_me: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_debug="no" + +fi + + + # # Enable/disable MySql and optionally specify the path (optional library) # @@ -3837,6 +3917,445 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +case $enableval in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + if test "${ac_cv_header_memwatch_h+set}" = set; then + { echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_memwatch_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } + +fi +if test $ac_cv_header_memwatch_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 +echo "$as_me: error: memwatch header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "dmalloc") + CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" + LIBS="$LIBS -ldmalloc" + if test "${ac_cv_header_dmalloc_h+set}" = set; then + { echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_dmalloc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_dmalloc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_dmalloc_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } + +fi +if test $ac_cv_header_dmalloc_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 +echo "$as_me: error: dmalloc header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "gcollect") + CFLAGS="$CFLAGS -DGCOLLECT" + LIBS="$LIBS -lgc" + if test "${ac_cv_header_gc_h+set}" = set; then + { echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_gc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking gc.h usability" >&5 +echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking gc.h presence" >&5 +echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_gc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_gc_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } + +fi +if test $ac_cv_header_gc_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 +echo "$as_me: error: gcollect header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "bcheck") + CFLAGS="$CFLAGS -DBCHECK" + ;; +esac + + + +if test "$enable_mapregsql" = "yes" ; then + CFLAGS="$CFLAGS -DMAPREGSQL" +fi + + + +if test "$enable_debug" = "yes" ; then + CFLAGS="$CFLAGS -DDEBUG" +fi + + + MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" diff --git a/configure.in b/configure.in index dc5da9c54..1ac99c495 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(eAthena) -AC_REVISION($Revision: 11695$) +AC_REVISION($Revision$) AC_PREREQ([2.61]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) @@ -11,6 +11,73 @@ AC_CONFIG_FILES([src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/ AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) +# +# Memory managers +# +AC_ARG_ENABLE( + [manager], + AC_HELP_STRING( + [--enable-manager=ARG], + [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)] + ), + [ + enable_manager="$enableval" + case $enableval in + "no");; + "builtin");; + "memwatch");; + "dmalloc");; + "gcollect");; + "bcheck");; + *) AC_MSG_ERROR([[unknown memory manager '$enable_manager'... stopping]]);; + esac + ], + [enable_manager="builtin"] +) + + +# +# mapregsql +# +AC_ARG_ENABLE( + [mapregsql], + AC_HELP_STRING( + [--enable-mapregsql], + [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no)] + ), + [ + enable_mapregsql="$enableval" + case $enableval in + no);; + yes);; + *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enable_mapregsql... stopping]]);; + esac + ], + [enable_mapregsql="no"] +) + + +# +# debug +# +AC_ARG_ENABLE( + [debug], + AC_HELP_STRING( + [--enable-debug], + [Compiles in debug mode. (defauts to no)] + ), + [ + enable_debug="$enableval" + case $enableval in + no);; + yes);; + *) AC_MSG_ERROR([[invalid argument --enable-debug=$enable_mapregsql... stopping]]);; + esac + ], + [enable_debug="no"] +) + + # # Enable/disable MySql and optionally specify the path (optional library) # @@ -164,6 +231,55 @@ AC_COMPILE_IFELSE( +dnl +dnl Memory manager +dnl + +case $enableval in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])]) + ;; + "dmalloc") + CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" + LIBS="$LIBS -ldmalloc" + AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])]) + ;; + "gcollect") + CFLAGS="$CFLAGS -DGCOLLECT" + LIBS="$LIBS -lgc" + AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])]) + ;; + "bcheck") + CFLAGS="$CFLAGS -DBCHECK" + ;; +esac + + +dnl +dnl Memory manager +dnl + +if test "$enable_mapregsql" = "yes" ; then + CFLAGS="$CFLAGS -DMAPREGSQL" +fi + + +dnl +dnl Debug +dnl + +if test "$enable_debug" = "yes" ; then + CFLAGS="$CFLAGS -DDEBUG" +fi + + dnl dnl Check MySQL library (optional) dnl diff --git a/src/common/Makefile.in b/src/common/Makefile.in index c22cc721c..94f42a956 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -17,7 +17,7 @@ txt: obj common sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj obj_sql + rm -rf *.o obj obj_sql svnversion.h help: @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index d31d515a8..557e263fb 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -52,6 +52,18 @@ #define DEBUG #endif +// debug function name +#ifndef __NETBSD__ +#if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +#endif +#endif + + // disable attributed stuff on non-GNU #if !defined(__GNUC__) && !defined(MINGW) # define __attribute__(x) diff --git a/src/common/malloc.c b/src/common/malloc.c index 414770156..a65ee7eed 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -1,15 +1,18 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include #include "../common/malloc.h" #include "../common/core.h" #include "../common/showmsg.h" -#ifdef MINICORE - #undef LOG_MEMMGR +#include +#include +#include +#include + +// no logging for minicore +#if defined(MINICORE) && defined(LOG_MEMMGR) +#undef LOG_MEMMGR #endif void* aMalloc_(size_t size, const char *file, int line, const char *func) @@ -553,12 +556,17 @@ static FILE *log_fp; static void memmgr_log (char *buf) { - if (!log_fp) { + time_t raw; + struct tm* t; + if( !log_fp ) + { log_fp = fopen(memmer_logfile,"w"); if (!log_fp) log_fp = stdout; fprintf(log_fp, "Memory manager: Memory leaks found (Revision %s).\n", get_svn_revision()); } - fprintf(log_fp, buf); + time(&raw); + t = localtime(&raw); + fprintf(log_fp, "%04d%02d%02d%02d%02d%02d %s", (t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, buf); return; } #endif diff --git a/src/common/malloc.h b/src/common/malloc.h index 43eff40f1..1efc4686f 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -13,28 +13,28 @@ // and I have doubts our implementation works. // -> They should NOT be used, period. -#ifndef __NETBSD__ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif +#define ALC_MARK __FILE__, __LINE__, __func__ + +// disable built-in memory manager when using another manager +#if defined(MEMWATCH) || defined(DMALLOC) || defined(GCOLLECT) || defined(BCHECK) +#if !defined(NO_MEMMGR) +#define NO_MEMMGR #endif #endif -#define ALC_MARK __FILE__, __LINE__, __func__ -////////////////////////////////////////////////////////////////////// -// Whether to use Athena's built-in Memory Manager (enabled by default) -// To disable just comment the following line -#if !defined(DMALLOC) && !defined(BCHECK) - #define USE_MEMMGR +// Use built-in memory manager by default +#if !defined(NO_MEMMGR) && !defined(USE_MEMMGR) +#define USE_MEMMGR #endif -// Whether to enable Memory Manager's logging -#define LOG_MEMMGR + +////////////////////////////////////////////////////////////////////// +// Athena's built-in Memory Manager #ifdef USE_MEMMGR +// Enable memory manager logging by default +#define LOG_MEMMGR + # define aMalloc(n) _mmalloc(n,ALC_MARK) # define aMallocA(n) _mmalloc(n,ALC_MARK) # define aCalloc(m,n) _mcalloc(m,n,ALC_MARK) @@ -71,7 +71,7 @@ ////////////// Memory Managers ////////////////// -#ifdef MEMWATCH +#if defined(MEMWATCH) # include "memwatch.h" # define MALLOC(n,file,line,func) mwMalloc((n),(file),(line)) @@ -108,7 +108,6 @@ void * _bcallocA(size_t, size_t); char * _bstrdup(const char *); -/* FIXME Why is this the same as #else? [FlavioJS] #elif defined(BCHECK) # define MALLOC(n,file,line,func) malloc(n) @@ -118,7 +117,7 @@ # define REALLOC(p,n,file,line,func) realloc((p),(n)) # define STRDUP(p,file,line,func) strdup(p) # define FREE(p,file,line,func) free(p) -*/ + #else # define MALLOC(n,file,line,func) malloc(n) diff --git a/src/common/nullpo.h b/src/common/nullpo.h index 0238d2b6d..8ee86a782 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -5,28 +5,15 @@ #define _NULLPO_H_ -#define NULLPO_CHECK 1 - // ‘S‘̂̃XƒCƒbƒ`‚ð錾‚µ‚Ä‚¢‚éƒwƒbƒ_‚ª‚ ‚ê‚Î - // ‚»‚±‚Ɉړ®‚µ‚Ä‚¢‚½‚¾‚¯‚邯 - -#ifndef __NETBSD__ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -#endif -#endif +#include "../common/cbasetypes.h" +#define NLP_MARK __FILE__, __LINE__, __func__ -#if !defined(__GNUC__) && !defined(MINGW) -# define __attribute__(x) /* nothing */ +// enabled by default on debug builds +#if defined(DEBUG) && !defined(NULLPO_CHECK) +#define NULLPO_CHECK #endif - -#define NLP_MARK __FILE__, __LINE__, __func__ - /*---------------------------------------------------------------------------- * Macros *---------------------------------------------------------------------------- @@ -81,7 +68,7 @@ *-------------------------------------- */ -#if NULLPO_CHECK +#if defined(NULLPO_CHECK) #define nullpo_ret(t) \ if (nullpo_chk(NLP_MARK, (void *)(t))) {return(0);} @@ -137,25 +124,25 @@ // —Ç‚¢•û–@‚ªŽv‚¢‚‚©‚È‚©‚Á‚½‚Ì‚ÅEEE‹ê“÷‚Ìô‚Å‚·B // ˆê‰žƒ[ƒjƒ“ƒO‚Ío‚È‚¢‚Í‚¸ -#define nullpo_ret(t) if((t)){;} -#define nullpo_retv(t) if((t)){;} -#define nullpo_retr(ret, t) if((t)){;} -#define nullpo_retb(t) if((t)){;} +#define nullpo_ret(t) (void)(t) +#define nullpo_retv(t) (void)(t) +#define nullpo_retr(ret, t) (void)(t) +#define nullpo_retb(t) (void)(t) // ‰Â•ψø”ƒ}ƒNƒ‚ÉŠÖ‚·‚éðŒƒRƒ“ƒpƒCƒ‹ #if __STDC_VERSION__ >= 199901L /* C99‚ɑΉž */ -#define nullpo_ret_f(t, fmt, ...) if((t)){;} -#define nullpo_retv_f(t, fmt, ...) if((t)){;} -#define nullpo_retr_f(ret, t, fmt, ...) if((t)){;} -#define nullpo_retb_f(t, fmt, ...) if((t)){;} +#define nullpo_ret_f(t, fmt, ...) (void)(t) +#define nullpo_retv_f(t, fmt, ...) (void)(t) +#define nullpo_retr_f(ret, t, fmt, ...) (void)(t) +#define nullpo_retb_f(t, fmt, ...) (void)(t) #elif __GNUC__ >= 2 /* GCC—p */ -#define nullpo_ret_f(t, fmt, args...) if((t)){;} -#define nullpo_retv_f(t, fmt, args...) if((t)){;} -#define nullpo_retr_f(ret, t, fmt, args...) if((t)){;} -#define nullpo_retb_f(t, fmt, args...) if((t)){;} +#define nullpo_ret_f(t, fmt, args...) (void)(t) +#define nullpo_retv_f(t, fmt, args...) (void)(t) +#define nullpo_retr_f(ret, t, fmt, args...) (void)(t) +#define nullpo_retb_f(t, fmt, args...) (void)(t) #else /* ‚»‚Ì‘¼‚Ìê‡EEE orz */ diff --git a/src/map/path.c b/src/map/path.c index 50c2f2192..3d4b99fc9 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -8,10 +8,6 @@ #include "map.h" #include "battle.h" -#ifdef MEMWATCH -#include "memwatch.h" -#endif - #include #include #include -- cgit v1.2.3-70-g09d2 From a6b815ce9fd7f6e7faaaaa1c5b56be655ee838be Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 19 Dec 2007 17:17:29 +0000 Subject: * Changes to the configure script. - fixed the 'pointers can be stored in ints' test not working - fixed the linker trying to build 64 bit executables with 32 bit code on x86_64 (missing -m32 flag in LDFLAGS) - made MYSQL_CFLAGS be built from the --include option to be more portable - made --with-mysql check if the optional argument is an executable file - make --with-pcre check if the optional argument is a directory - other minor changes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11952 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 8 + configure | 5148 +++++++++++++++++++++++---------------------------- configure.in | 91 +- 3 files changed, 2366 insertions(+), 2881 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 8a595585c..dbe617805 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,14 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/12/19 + * Changes to the configure script. [FlavioJS] + - fixed the 'pointers can be stored in ints' test not working + - fixed the linker trying to build 64 bit executables with 32 bit code on + x86_64 (missing -m32 flag in LDFLAGS) + - made MYSQL_CFLAGS be built from the --include option to be more portable + - made --with-mysql check if the optional argument is an executable file + - make --with-pcre check if the optional argument is a directory + - other minor changes * Corrected SC_MIRACLE to trigger Bless of the Stars on all defeated mobs. [Skotlex] 2007/12/18 diff --git a/configure b/configure index 6ffeda9af..2145b05d2 100755 --- a/configure +++ b/configure @@ -1,55 +1,26 @@ #! /bin/sh -# From configure.in Revision: 11760. +# From configure.in Revision: 11952. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61. +# Generated by GNU Autoconf 2.59. # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh +# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -59,43 +30,8 @@ else fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - # Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done +$as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' @@ -109,19 +45,18 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -129,388 +64,157 @@ fi # Name of the executable. -as_me=`$as_basename -- "$0" || +as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi -test \$exitcode = 0) || { (exit 1); exit 1; } + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - case $as_dir in + for as_base in sh bash ksh sh5; do + case $as_dir in /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell autoconf@gnu.org about your system, - echo including any error possibly output before this - echo message -} - - - + if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop - s/-\n.*// + s,-$,, + s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && - chmod +x "$as_me.lineno" || + chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno # Exit status is that of the last command. exit } -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null +rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -519,28 +223,7 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -549,27 +232,39 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH -exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` +exec 6>&1 + # # Initializations. # ac_default_prefix=/usr/local -ac_clean_files= ac_config_libobj_dir=. -LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= @@ -582,109 +277,42 @@ ac_unique_file="src/common/cbasetypes.h" # Factoring default headers for most tests. ac_includes_default="\ #include -#ifdef HAVE_SYS_TYPES_H +#if HAVE_SYS_TYPES_H # include #endif -#ifdef HAVE_SYS_STAT_H +#if HAVE_SYS_STAT_H # include #endif -#ifdef STDC_HEADERS +#if STDC_HEADERS # include # include #else -# ifdef HAVE_STDLIB_H +# if HAVE_STDLIB_H # include # endif #endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif -#ifdef HAVE_STRINGS_H +#if HAVE_STRINGS_H # include #endif -#ifdef HAVE_INTTYPES_H +#if HAVE_INTTYPES_H # include +#else +# if HAVE_STDINT_H +# include +# endif #endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H +#if HAVE_UNISTD_H # include #endif" -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -SET_MAKE -CC -CFLAGS -LDFLAGS -CPPFLAGS -ac_ct_CC -EXEEXT -OBJEXT -CPP -GREP -EGREP -MYSQL_CONFIG_HOME -HAVE_MYSQL -MYSQL_VERSION -MYSQL_CFLAGS -MYSQL_LIBS -HAVE_PCRE -PCRE_LIBS -PCRE_CFLAGS -DLLEXT -LIBOBJS -LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS' ac_subst_files='' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - # Initialize some variables set by options. ac_init_help= @@ -711,48 +339,34 @@ x_libraries=NONE # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' +datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' +infodir='${prefix}/info' +mandir='${prefix}/man' ac_prev= -ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option + eval "$ac_prev=\$ac_option" ac_prev= continue fi - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -774,45 +388,33 @@ do --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad) + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) datadir=$ac_optarg ;; - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -839,12 +441,6 @@ do -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -869,16 +465,13 @@ do | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -943,16 +536,6 @@ do | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -1005,20 +588,24 @@ do -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=\$ac_optarg ;; + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=no ;; + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -1049,7 +636,8 @@ Try \`$0 --help' for more information." >&2 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) @@ -1069,19 +657,27 @@ if test -n "$ac_prev"; then { (exit 1); exit 1; }; } fi -# Be sure to have absolute directory names. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix do - eval ac_val=\$$ac_var + eval ac_val=$`echo $ac_var` case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -1108,76 +704,74 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then + if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP # # Report the --help message. @@ -1206,6 +800,9 @@ Configuration: -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] +_ACEOF + + cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] @@ -1223,22 +820,15 @@ Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF @@ -1262,12 +852,13 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-mysql[=ARG] use MySQL client library, optionally specify path to - the mysql_config executable (by default mysql is + --with-mysql[=ARG] + use MySQL client library, optionally specify the + path to the mysql_config executable (by default + mysql is used if found) + --with-pcre[=ARG] use PCRE library, optionally specify the full path + of pcre installation directory (by default pcre is used if found) - --with-pcre[=ARG] use PCRE library, optionally specify the root - directory path of pcre installation (by default pcre - is used if found) --with-zlib=DIR root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local) @@ -1276,95 +867,126 @@ Some influential environment variables: CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF -ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. + ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue + test -d $ac_dir || continue ac_builddir=. -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) +if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi case $srcdir in - .) # We are building in place. + .) # No --srcdir option. We are building in place. ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } + fi + cd $ac_popdir done fi -test -n "$ac_init_help" && exit $ac_status +test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -configure -generated by GNU Autoconf 2.61 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit + exit 0 fi -cat >config.log <<_ACEOF +exec 5>config.log +cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.61. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF -exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -1383,7 +1005,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -1397,7 +1019,6 @@ do test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done -IFS=$as_save_IFS } >&5 @@ -1419,6 +1040,7 @@ _ACEOF ac_configure_args= ac_configure_args0= ac_configure_args1= +ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1429,7 +1051,7 @@ do -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *\'*) + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in @@ -1451,7 +1073,9 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " ;; esac done @@ -1462,8 +1086,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1476,34 +1100,20 @@ trap 'exit_status=$? _ASBOX echo # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done +{ (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; - esac | - sort -) + esac; +} echo cat <<\_ASBOX @@ -1514,28 +1124,22 @@ _ASBOX echo for ac_var in $ac_subst_vars do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## +## ------------- ## +## Output files. ## +## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi @@ -1547,24 +1151,26 @@ _ASBOX ## ----------- ## _ASBOX echo - cat confdefs.h + sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status -' 0 + ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h # Predefined preprocessor variables. @@ -1595,17 +1201,14 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. -if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" -elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" -else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi fi -shift -for ac_site_file -do +for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} @@ -1621,8 +1224,8 @@ if test -r "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; esac fi else @@ -1634,11 +1237,12 @@ fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 @@ -1663,7 +1267,8 @@ echo "$as_me: current value: $ac_new_val" >&2;} # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1680,6 +1285,12 @@ echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start ov { (exit 1); exit 1; }; } fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + @@ -1696,32 +1307,28 @@ fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_files="$ac_config_files Makefile src/common/Makefile" + ac_config_files="$ac_config_files Makefile src/common/Makefile" -ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" + ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" -ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" + ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" -ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" + ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" # # Memory managers # -# Check whether --enable-manager was given. +# Check whether --enable-manager or --disable-manager was given. if test "${enable_manager+set}" = set; then - enableval=$enable_manager; + enableval="$enable_manager" + enable_manager="$enableval" case $enableval in "no");; @@ -1738,16 +1345,16 @@ echo "$as_me: error: unknown memory manager '$enable_manager'... stopping" >&2;} else enable_manager="builtin" -fi - +fi; # # mapregsql # -# Check whether --enable-mapregsql was given. +# Check whether --enable-mapregsql or --disable-mapregsql was given. if test "${enable_mapregsql+set}" = set; then - enableval=$enable_mapregsql; + enableval="$enable_mapregsql" + enable_mapregsql="$enableval" case $enableval in no);; @@ -1760,16 +1367,16 @@ echo "$as_me: error: invalid argument --enable-mapregsql=$enable_mapregsql... st else enable_mapregsql="no" -fi - +fi; # # debug # -# Check whether --enable-debug was given. +# Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then - enableval=$enable_debug; + enableval="$enable_debug" + enable_debug="$enableval" case $enableval in no);; @@ -1782,23 +1389,28 @@ echo "$as_me: error: invalid argument --enable-debug=$enable_mapregsql... stoppi else enable_debug="no" -fi - +fi; # -# Enable/disable MySql and optionally specify the path (optional library) +# Enable/disable MySql and optionally specify the path to mysql_config (optional library) # -# Check whether --with-mysql was given. +# Check whether --with-mysql or --without-mysql was given. if test "${with_mysql+set}" = set; then - withval=$with_mysql; + withval="$with_mysql" + if test "$withval" = "no" ; then want_mysql="no" else want_mysql="yes" require_mysql="yes" if test "$withval" != "yes" ; then + if test ! -x "$withval" ; then + { { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 +echo "$as_me: error: $withval is not an executable file" >&2;} + { (exit 1); exit 1; }; } + fi MYSQL_CONFIG_HOME="$withval" fi fi @@ -1806,23 +1418,28 @@ if test "${with_mysql+set}" = set; then else want_mysql="yes" require_mysql="no" -fi - +fi; # # Enable/disable PCRE and optionally specify the path (optional library) # -# Check whether --with-pcre was given. +# Check whether --with-pcre or --without-pcre was given. if test "${with_pcre+set}" = set; then - withval=$with_pcre; + withval="$with_pcre" + if test "$withval" = "no" ; then want_pcre="no" else want_pcre="yes" require_pcre="yes" if test "$withval" != "yes" ; then + if test ! -d "$withval" ; then + { { echo "$as_me:$LINENO: error: $withval is not a directoy" >&5 +echo "$as_me: error: $withval is not a directoy" >&2;} + { (exit 1); exit 1; }; } + fi PCRE_HOME="$withval" fi fi @@ -1830,17 +1447,17 @@ if test "${with_pcre+set}" = set; then else want_pcre="yes" require_pcre="no" -fi - +fi; # # Specify the path of the zlib library (required library) # -# Check whether --with-zlib was given. +# Check whether --with-zlib or --without-zlib was given. if test "${with_zlib+set}" = set; then - withval=$with_zlib; + withval="$with_zlib" + test -n "$withval" && ZLIB_HOME="$withval" else @@ -1849,41 +1466,42 @@ else test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr -fi - +fi; ############################################################################### -# Checks for programs and types. +# Check for programs and types. +# + -{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } -set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF -SHELL = /bin/sh all: - @echo '@@@%%%=$(MAKE)=@@@%%%' + @echo 'ac_maketemp="$(MAKE)"' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi rm -f conftest.make fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 SET_MAKE= else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -1895,8 +1513,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1909,34 +1527,32 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1949,51 +1565,36 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi + CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2006,34 +1607,74 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2047,7 +1688,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2058,7 +1699,6 @@ do fi done done -IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -2076,23 +1716,22 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe + for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2105,38 +1744,36 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl.exe + for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2149,45 +1786,29 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - test -n "$ac_ct_CC" && break done - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi + CC=$ac_ct_CC fi fi @@ -2200,35 +1821,21 @@ See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C compiler version" >&5 +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -v >&5") 2>&5 +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -V >&5") 2>&5 +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } @@ -2253,77 +1860,47 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -# -# List of possible output files, starting from the most likely. -# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) -# only as a last resort. b.out is created by i960 compilers. -ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' -# -# The IRIX 6 linker writes into existing files which may not be -# executable, retaining their permissions. Remove them first so a -# subsequent execution test works. -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { (ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link_default") 2>&5 +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext break;; * ) break;; esac done -test "$ac_cv_exeext" = no && ac_cv_exeext= - else - ac_file='' -fi - -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } -if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -2335,21 +1912,19 @@ See \`config.log' for more details." >&2;} fi ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 -# Check that the compiler produces executables we can run. If not, either +# Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -2368,27 +1943,22 @@ See \`config.log' for more details." >&2;} fi fi fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either +# Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } -{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6; } - -{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then @@ -2399,8 +1969,9 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext break;; * ) break;; esac @@ -2414,14 +1985,14 @@ See \`config.log' for more details." >&2;} fi rm -f conftest$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2441,20 +2012,14 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>&5 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac @@ -2472,12 +2037,12 @@ fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2500,49 +2065,50 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_compiler_gnu=no +ac_compiler_gnu=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2558,118 +2124,38 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_prog_cc_g=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2685,12 +2171,12 @@ else CFLAGS= fi fi -{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_c89=no + ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2724,17 +2210,12 @@ static char *f (char * (*g) (char **, int), char **p, ...) /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get + as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ + that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2749,87 +2230,235 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_c89=$ac_arg + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - fi - -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break +rm -f conftest.err conftest.$ac_objext done -rm -f conftest.$ac_ext +rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6; } ;; - xno) - { echo "$as_me:$LINENO: result: unsupported" >&5 -echo "${ECHO_T}unsupported" >&6; } ;; + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; *) - CC="$CC $ac_cv_prog_cc_c89" - { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. @@ -2846,22 +2475,24 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 @@ -2870,10 +2501,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers + # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2883,22 +2513,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else @@ -2909,7 +2541,6 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done @@ -2927,8 +2558,8 @@ fi else ac_cv_prog_CPP=$CPP fi -{ echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6; } +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -2951,22 +2582,24 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 @@ -2975,10 +2608,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers + # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2988,22 +2620,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else @@ -3014,7 +2648,6 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done @@ -3049,414 +2682,8 @@ CPPFLAGS="$CPPFLAGS -I../common" - -{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Extract the first word of "grep ggrep" to use in msg output -if test -z "$GREP"; then -set dummy grep ggrep; ac_prog_name=$2 -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_GREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue - # Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_GREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -GREP="$ac_cv_path_GREP" -if test -z "$GREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_GREP=$GREP -fi - - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -echo "${ECHO_T}$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - # Extract the first word of "egrep" to use in msg output -if test -z "$EGREP"; then -set dummy egrep; ac_prog_name=$2 -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_EGREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue - # Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_EGREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -EGREP="$ac_cv_path_EGREP" -if test -z "$EGREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_EGREP=$EGREP -fi - - - fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3473,8 +2700,7 @@ cat >>conftest.$ac_ext <<_ACEOF int main () { -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ - && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif @@ -3483,22 +2709,27 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3521,36 +2752,40 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_c_bigendian=no +ac_cv_c_bigendian=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - # It does not; compile a test program. +# It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown @@ -3560,11 +2795,11 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () @@ -3575,22 +2810,27 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi @@ -3606,10 +2846,8 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3617,41 +2855,27 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default int main () { - /* Are we little or big endian? From Harbison&Steele. */ union { - long int l; - char c[sizeof (long int)]; + long l; + char c[sizeof (long)]; } u; u.l = 1; - return u.c[sizeof (long int) - 1] == 1; - - ; - return 0; + exit (u.c[sizeof (long) - 1] == 1); } _ACEOF rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -3664,16 +2888,13 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - - fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 case $ac_cv_c_bigendian in yes) { { echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 @@ -3689,8 +2910,8 @@ esac -{ echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 -echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 +echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6 pointers_fit_in_ints="no" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3698,7 +2919,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -int hw[(sizeof(int) == sizeof(void *))]; +static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1]; int main () { @@ -3708,22 +2929,27 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then pointers_fit_in_ints="yes" else echo "$as_me: failed program was:" >&5 @@ -3732,17 +2958,17 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test "$pointers_fit_in_ints" = "no" ; then CFLAGS="$CFLAGS -m32" + LDFLAGS="$LDFLAGS -m32" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -int hw[(sizeof(int) == sizeof(void *))]; +static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1]; int main () { @@ -3752,22 +2978,27 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then pointers_fit_in_ints="yes (with -m32)" else echo "$as_me: failed program was:" >&5 @@ -3776,11 +3007,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 -echo "${ECHO_T}$pointers_fit_in_ints" >&6; } +echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 +echo "${ECHO_T}$pointers_fit_in_ints" >&6 if test "$pointers_fit_in_ints" = "no" ; then { { echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} @@ -3788,156 +3018,425 @@ echo "$as_me: error: pointers cannot be stored in ints, required for old code... fi -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6 OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-unused-parameter" cat >conftest.$ac_ext <<_ACEOF int foo; _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + +echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-pointer-sign" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + +echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-switch" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + + +############################################################################### +# Check for libraries and header files. +# + + +# +# Memory manager +# +case $enableval in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - CFLAGS="$OLD_CFLAGS" - +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# On IRIX 5.3, sys/types and inttypes.h are conflicting. -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6; } -OLD_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-pointer-sign" -cat >conftest.$ac_ext <<_ACEOF -int foo; -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - CFLAGS="$OLD_CFLAGS" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6; } -OLD_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-switch" -cat >conftest.$ac_ext <<_ACEOF -int foo; +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - CFLAGS="$OLD_CFLAGS" - - +eval "$as_ac_Header=no" fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - -############################################################################### -# Checks for libraries and header files. - +fi +done -case $enableval in - "no") - CFLAGS="$CFLAGS -DNO_MEMMGR" - ;; - "builtin") - # enabled by default - ;; - "memwatch") - CFLAGS="$CFLAGS -DMEMWATCH" - if test "${ac_cv_header_memwatch_h+set}" = set; then - { echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 if test "${ac_cv_header_memwatch_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 else # Is the header compilable? -{ echo "$as_me:$LINENO: checking memwatch.h usability" >&5 -echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3948,37 +3447,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ echo "$as_me:$LINENO: checking memwatch.h presence" >&5 -echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3987,22 +3490,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -4010,10 +3515,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -4037,18 +3541,25 @@ echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\ echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} - + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 if test "${ac_cv_header_memwatch_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_memwatch_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 fi if test $ac_cv_header_memwatch_h = yes; then @@ -4065,17 +3576,17 @@ fi CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" LIBS="$LIBS -ldmalloc" if test "${ac_cv_header_dmalloc_h+set}" = set; then - { echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 else # Is the header compilable? -{ echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 -echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4086,37 +3597,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 -echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4125,22 +3640,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -4148,10 +3665,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -4175,18 +3691,25 @@ echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\" echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} - + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dmalloc_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 fi if test $ac_cv_header_dmalloc_h = yes; then @@ -4203,17 +3726,17 @@ fi CFLAGS="$CFLAGS -DGCOLLECT" LIBS="$LIBS -lgc" if test "${ac_cv_header_gc_h+set}" = set; then - { echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 if test "${ac_cv_header_gc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6 else # Is the header compilable? -{ echo "$as_me:$LINENO: checking gc.h usability" >&5 -echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking gc.h usability" >&5 +echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4224,37 +3747,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ echo "$as_me:$LINENO: checking gc.h presence" >&5 -echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking gc.h presence" >&5 +echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4263,22 +3790,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -4286,10 +3815,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -4313,18 +3841,25 @@ echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2 echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} - + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 if test "${ac_cv_header_gc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_gc_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6 fi if test $ac_cv_header_gc_h = yes; then @@ -4343,19 +3878,25 @@ fi esac - +# +# Mapregsql +# if test "$enable_mapregsql" = "yes" ; then CFLAGS="$CFLAGS -DMAPREGSQL" fi - +# +# Debug +# if test "$enable_debug" = "yes" ; then CFLAGS="$CFLAGS -DDEBUG" fi - +# +# MySQL library (optional) +# MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" @@ -4367,8 +3908,8 @@ else if test -z "$MYSQL_CONFIG_HOME"; then # Extract the first word of "mysql_config", so it can be a program name with args. set dummy mysql_config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4383,48 +3924,47 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS test -z "$ac_cv_path_MYSQL_CONFIG_HOME" && ac_cv_path_MYSQL_CONFIG_HOME="no" ;; esac fi MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME + if test -n "$MYSQL_CONFIG_HOME"; then - { echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 -echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6; } + echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 +echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi - { echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 -echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 +echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6 if test "$MYSQL_CONFIG_HOME" != "no" ; then HAVE_MYSQL="yes" MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`" + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - { echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 -echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6; } - if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then - { { echo "$as_me:$LINENO: error: $MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping" >&5 -echo "$as_me: error: $MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping" >&2;} + echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6 + if test -n "`$MYSQL_CONFIG_HOME --cflags | grep -i '\-m64'`"; then + { { echo "$as_me:$LINENO: error: $MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping" >&5 +echo "$as_me: error: $MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping" >&2;} { (exit 1); exit 1; }; } fi else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 if test "$require_mysql" = "yes" ; then { { echo "$as_me:$LINENO: error: MySQL not found (requested)" >&5 echo "$as_me: error: MySQL not found (requested)" >&2;} @@ -4443,7 +3983,9 @@ fi - +# +# PCRE library (optional) +# ##TODO PCRE version PCRE_LIBS="" PCRE_CFLAGS="" @@ -4453,8 +3995,8 @@ if test "$want_pcre" = "no" ; then echo "$as_me: ignoring PCRE (optional)" >&6;} else if test -z "$PCRE_HOME" ; then - { echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 -echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 +echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6 if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4467,53 +4009,56 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char pcre_study (); int main () { -return pcre_study (); +pcre_study (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_pcre_pcre_study=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pcre_pcre_study=no +ac_cv_lib_pcre_pcre_study=no fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6 if test $ac_cv_lib_pcre_pcre_study = yes; then HAVE_PCRE="yes" fi @@ -4524,8 +4069,8 @@ fi else PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" - { echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 -echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6 if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4538,53 +4083,56 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char pcre_compile (); int main () { -return pcre_compile (); +pcre_compile (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_pcre_pcre_compile=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pcre_pcre_compile=no +ac_cv_lib_pcre_pcre_compile=no fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6 if test $ac_cv_lib_pcre_pcre_compile = yes; then HAVE_PCRE="yes" fi @@ -4596,14 +4144,14 @@ fi test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" fi fi - { echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 -echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 +echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6 if test "$HAVE_PCRE" = "yes" ; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 if test "$require_pcre" = "yes" ; then { { echo "$as_me:$LINENO: error: PCRE not found (requested)" >&5 echo "$as_me: error: PCRE not found (requested)" >&2;} @@ -4621,14 +4169,16 @@ fi - +# +# zlib library (required) +# if test -n "${ZLIB_HOME}" ; then LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" fi -{ echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 -echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 +echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6 if test "${ac_cv_lib_z_inflateEnd+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4641,53 +4191,56 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char inflateEnd (); int main () { -return inflateEnd (); +inflateEnd (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_z_inflateEnd=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_z_inflateEnd=no +ac_cv_lib_z_inflateEnd=no fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 -echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 +echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6 if test $ac_cv_lib_z_inflateEnd = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 @@ -4702,17 +4255,17 @@ echo "$as_me: error: zlib library not found, please specify the correct path wit fi if test "${ac_cv_header_zlib_h+set}" = set; then - { echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 else # Is the header compilable? -{ echo "$as_me:$LINENO: checking zlib.h usability" >&5 -echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4723,37 +4276,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ echo "$as_me:$LINENO: checking zlib.h presence" >&5 -echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4762,22 +4319,24 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -4785,10 +4344,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -4812,18 +4370,25 @@ echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" > echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} - + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_zlib_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 fi if test $ac_cv_header_zlib_h = yes; then @@ -4838,10 +4403,12 @@ fi +# +# math library (required) +# - -{ echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 -echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 +echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_sqrt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -4854,53 +4421,56 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char sqrt (); int main () { -return sqrt (); +sqrt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_m_sqrt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_m_sqrt=no +ac_cv_lib_m_sqrt=no fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 -echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 +echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6 if test $ac_cv_lib_m_sqrt = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 @@ -4917,12 +4487,14 @@ fi - -{ echo "$as_me:$LINENO: checking host OS" >&5 -echo $ECHO_N "checking host OS... $ECHO_C" >&6; } +# +# Host specific stuff +# +echo "$as_me:$LINENO: checking host OS" >&5 +echo $ECHO_N "checking host OS... $ECHO_C" >&6 host_os="`uname`" -{ echo "$as_me:$LINENO: result: $host_os" >&5 -echo "${ECHO_T}$host_os" >&6; } +echo "$as_me:$LINENO: result: $host_os" >&5 +echo "${ECHO_T}$host_os" >&6 fd_setsize="" DLLEXT=".so" case $host_os in @@ -4946,19 +4518,19 @@ CYGWIN*) esac -{ echo "$as_me:$LINENO: checking for MinGW" >&5 -echo $ECHO_N "checking for MinGW... $ECHO_C" >&6; } +echo "$as_me:$LINENO: checking for MinGW" >&5 +echo $ECHO_N "checking for MinGW... $ECHO_C" >&6 if test -n "`$CC --version | grep -i mingw`" ; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 CPPFLAGS="$CPPFLAGS -DMINGW" if test -z "$fd_setsize" ; then CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" fi LIBS="$LIBS -lws2_32" else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi @@ -4982,58 +4554,39 @@ _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. +# So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - +{ (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( + ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; - esac | - sort -) | + esac; +} | sed ' - /^ac_cv_env_/b end t clear - :clear + : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} + echo "not updating unwritable cache $cache_file" fi fi rm -f confcache @@ -5042,48 +4595,63 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, +# take arguments), then we branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. -ac_script=' +cat >confdef2opt.sed <<\_ACEOF t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -5109,50 +4677,22 @@ ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -5162,43 +4702,8 @@ else fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - # Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done +$as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' @@ -5212,19 +4717,18 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -5232,120 +4736,159 @@ fi # Name of the executable. -as_me=`$as_basename -- "$0" || +as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` -# CDPATH. -$as_unset CDPATH + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop - s/-\n.*// + s,-$,, + s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno # Exit status is that of the last command. exit } -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null +rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -5354,28 +4897,7 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -5384,14 +4906,31 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + exec 6>&1 -# Save the log message, to keep $[0] and so on meaningful, and to +# Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + This file was extended by $as_me, which was -generated by GNU Autoconf 2.61. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5399,18 +4938,30 @@ generated by GNU Autoconf 2.61. Invocation command line was CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. -config_files="$ac_config_files" +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi -_ACEOF +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi cat >>$CONFIG_STATUS <<\_ACEOF + ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -5418,7 +4969,7 @@ current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit + -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -5429,20 +4980,18 @@ Configuration files: $config_files Report bugs to ." - _ACEOF + cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.61, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2006 Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' +srcdir=$srcdir _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -5453,42 +5002,60 @@ while test $# != 0 do case $1 in --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; - *) + -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; esac case $ac_option in # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; + *) ac_config_targets="$ac_config_targets $1" ;; esac shift @@ -5504,52 +5071,38 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL - export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - echo "$ac_log" -} >&5 -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -# Handling of arguments. + + +cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; - "src/char/Makefile") CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; - "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; - "src/ladmin/Makefile") CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; - "src/char_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; - "src/login_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; - "src/txt-converter/Makefile") CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; - "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; - "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; - "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; - + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/common/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; + "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; + "src/ladmin/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; + "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; + "src/login_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; + "src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; + "src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; + "src/plugins/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; + "src/tool/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done - # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -5559,369 +5112,301 @@ if $ac_need_defaults; then fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, +# simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. +# Create a temporary directory, and hook for its removal unless debugging. $debug || { - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } + # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + # -# Set up the sed scripts for CONFIG_FILES section. +# CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h -if test -n "$CONFIG_FILES"; then - -_ACEOF - - +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@MYSQL_CONFIG_HOME@,$MYSQL_CONFIG_HOME,;t t +s,@HAVE_MYSQL@,$HAVE_MYSQL,;t t +s,@MYSQL_VERSION@,$MYSQL_VERSION,;t t +s,@MYSQL_CFLAGS@,$MYSQL_CFLAGS,;t t +s,@MYSQL_LIBS@,$MYSQL_LIBS,;t t +s,@HAVE_PCRE@,$HAVE_PCRE,;t t +s,@PCRE_LIBS@,$PCRE_LIBS,;t t +s,@PCRE_CFLAGS@,$PCRE_CFLAGS,;t t +s,@DLLEXT@,$DLLEXT,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -SHELL!$SHELL$ac_delim -PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim -PACKAGE_NAME!$PACKAGE_NAME$ac_delim -PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim -PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim -PACKAGE_STRING!$PACKAGE_STRING$ac_delim -PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim -exec_prefix!$exec_prefix$ac_delim -prefix!$prefix$ac_delim -program_transform_name!$program_transform_name$ac_delim -bindir!$bindir$ac_delim -sbindir!$sbindir$ac_delim -libexecdir!$libexecdir$ac_delim -datarootdir!$datarootdir$ac_delim -datadir!$datadir$ac_delim -sysconfdir!$sysconfdir$ac_delim -sharedstatedir!$sharedstatedir$ac_delim -localstatedir!$localstatedir$ac_delim -includedir!$includedir$ac_delim -oldincludedir!$oldincludedir$ac_delim -docdir!$docdir$ac_delim -infodir!$infodir$ac_delim -htmldir!$htmldir$ac_delim -dvidir!$dvidir$ac_delim -pdfdir!$pdfdir$ac_delim -psdir!$psdir$ac_delim -libdir!$libdir$ac_delim -localedir!$localedir$ac_delim -mandir!$mandir$ac_delim -DEFS!$DEFS$ac_delim -ECHO_C!$ECHO_C$ac_delim -ECHO_N!$ECHO_N$ac_delim -ECHO_T!$ECHO_T$ac_delim -LIBS!$LIBS$ac_delim -build_alias!$build_alias$ac_delim -host_alias!$host_alias$ac_delim -target_alias!$target_alias$ac_delim -SET_MAKE!$SET_MAKE$ac_delim -CC!$CC$ac_delim -CFLAGS!$CFLAGS$ac_delim -LDFLAGS!$LDFLAGS$ac_delim -CPPFLAGS!$CPPFLAGS$ac_delim -ac_ct_CC!$ac_ct_CC$ac_delim -EXEEXT!$EXEEXT$ac_delim -OBJEXT!$OBJEXT$ac_delim -CPP!$CPP$ac_delim -GREP!$GREP$ac_delim -EGREP!$EGREP$ac_delim -MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim -HAVE_MYSQL!$HAVE_MYSQL$ac_delim -MYSQL_VERSION!$MYSQL_VERSION$ac_delim -MYSQL_CFLAGS!$MYSQL_CFLAGS$ac_delim -MYSQL_LIBS!$MYSQL_LIBS$ac_delim -HAVE_PCRE!$HAVE_PCRE$ac_delim -PCRE_LIBS!$PCRE_LIBS$ac_delim -PCRE_CFLAGS!$PCRE_CFLAGS$ac_delim -DLLEXT!$DLLEXT$ac_delim -LIBOBJS!$LIBOBJS$ac_delim -LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then - break - elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat fi -done - -ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` -if test -n "$ac_eof"; then - ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` - ac_eof=`expr $ac_eof + 1` -fi +fi # test -n "$CONFIG_FILES" -cat >>$CONFIG_STATUS <<_ACEOF -cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end -_ACEOF -sed ' -s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g -s/^/s,@/; s/!/@,|#_!!_#|/ -:n -t n -s/'"$ac_delim"'$/,g/; t -s/$/\\/; p -N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n -' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF -:end -s/|#_!!_#|//g -CEOF$ac_eof _ACEOF - - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - cat >>$CONFIG_STATUS <<\_ACEOF -fi # test -n "$CONFIG_FILES" - - -for ac_tag in :F $CONFIG_FILES -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - ac_file_inputs="$ac_file_inputs $ac_f" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - fi - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; - esac - ;; +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - ac_dir=`$as_dirname -- "$ac_file" || + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } + ac_builddir=. -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) +if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi case $srcdir in - .) # We are building in place. + .) # No --srcdir option. We are building in place. ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - case $ac_mode in - :F) - # - # CONFIG_FILE - # +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -case `sed -n '/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' $ac_file_inputs` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } _ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub @@ -5929,39 +5414,28 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac - ;; - - - - esac +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi -done # for ac_tag +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF diff --git a/configure.in b/configure.in index 1ac99c495..69a403895 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ AC_INIT(eAthena) AC_REVISION($Revision$) -AC_PREREQ([2.61]) +AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile src/ladmin/Makefile]) @@ -79,13 +79,13 @@ AC_ARG_ENABLE( # -# Enable/disable MySql and optionally specify the path (optional library) +# Enable/disable MySql and optionally specify the path to mysql_config (optional library) # AC_ARG_WITH( [mysql], AC_HELP_STRING( [--with-mysql@<:@=ARG@:>@], - [use MySQL client library, optionally specify path to the mysql_config executable (by default mysql is used if found)] + [use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)] ), [ if test "$withval" = "no" ; then @@ -94,6 +94,9 @@ AC_ARG_WITH( want_mysql="yes" require_mysql="yes" if test "$withval" != "yes" ; then + if test ! -x "$withval" ; then + AC_MSG_ERROR([$withval is not an executable file]) + fi MYSQL_CONFIG_HOME="$withval" fi fi @@ -109,7 +112,7 @@ AC_ARG_WITH( [pcre], AC_HELP_STRING( [--with-pcre@<:@=ARG@:>@], - [use PCRE library, optionally specify the root directory path of pcre installation (by default pcre is used if found)] + [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)] ), [ if test "$withval" = "no" ; then @@ -118,6 +121,9 @@ AC_ARG_WITH( want_pcre="yes" require_pcre="yes" if test "$withval" != "yes" ; then + if test ! -d "$withval" ; then + AC_MSG_ERROR([$withval is not a directoy]) + fi PCRE_HOME="$withval" fi fi @@ -147,7 +153,10 @@ AC_ARG_WITH( ############################################################################### -# Checks for programs and types. +# Check for programs and types. +# + + AC_PROG_MAKE_SET AC_PROG_CC @@ -169,14 +178,15 @@ AC_C_BIGENDIAN( AC_MSG_CHECKING([whether pointers can be stored in ints (old code)]) pointers_fit_in_ints="no" AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])], + [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])], [pointers_fit_in_ints="yes"], [] ) if test "$pointers_fit_in_ints" = "no" ; then CFLAGS="$CFLAGS -m32" + LDFLAGS="$LDFLAGS -m32" AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])], + [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])], [pointers_fit_in_ints="yes (with -m32)"], [] ) @@ -226,15 +236,15 @@ AC_COMPILE_IFELSE( ) -############################################################################### -# Checks for libraries and header files. - +############################################################################### +# Check for libraries and header files. +# -dnl -dnl Memory manager -dnl +# +# Memory manager +# case $enableval in "no") CFLAGS="$CFLAGS -DNO_MEMMGR" @@ -262,28 +272,25 @@ case $enableval in esac -dnl -dnl Memory manager -dnl - +# +# Mapregsql +# if test "$enable_mapregsql" = "yes" ; then CFLAGS="$CFLAGS -DMAPREGSQL" fi -dnl -dnl Debug -dnl - +# +# Debug +# if test "$enable_debug" = "yes" ; then CFLAGS="$CFLAGS -DDEBUG" fi -dnl -dnl Check MySQL library (optional) -dnl - +# +# MySQL library (optional) +# MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" @@ -299,11 +306,11 @@ else if test "$MYSQL_CONFIG_HOME" != "no" ; then HAVE_MYSQL="yes" MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`" + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" AC_MSG_RESULT([yes ($MYSQL_VERSION)]) - if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then - AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=... stopping]) + if test -n "`$MYSQL_CONFIG_HOME --cflags | grep -i '\-m64'`"; then + AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping]) fi else AC_MSG_RESULT([no]) @@ -322,10 +329,9 @@ AC_SUBST([MYSQL_LIBS]) -dnl -dnl Check PCRE libraries (optional) -dnl - +# +# PCRE library (optional) +# ##TODO PCRE version PCRE_LIBS="" PCRE_CFLAGS="" @@ -368,10 +374,9 @@ AC_SUBST([PCRE_CFLAGS]) -dnl -dnl zlib library (required) -dnl - +# +# zlib library (required) +# if test -n "${ZLIB_HOME}" ; then LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" @@ -381,18 +386,16 @@ AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify -dnl -dnl math library (required) -dnl - +# +# math library (required) +# AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])]) -dnl -dnl Host specific stuff -dnl - +# +# Host specific stuff +# AC_MSG_CHECKING([host OS]) host_os="`uname`" AC_MSG_RESULT([$host_os]) -- cgit v1.2.3-70-g09d2 From 9599b05c3cd2145ea9cd9fe7ce98912705942740 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 27 Dec 2007 12:08:07 +0000 Subject: * Changed the configure script: - refined the mysql test (wasn't detecting 64 libraries compiled without -m64) - added a test for clock_gettime in -lrt (required for Debian) (run ./configure to update the Makefiles) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11985 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 + configure | 5636 +++++++++++++++++++++++++++++---------------------- configure.in | 66 +- 3 files changed, 3274 insertions(+), 2431 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 6e0fb2558..2a0b5bc53 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/12/27 + * Changed the configure script: + - refined the mysql test (wasn't detecting 64 libraries compiled without -m64) + - added a test for clock_gettime in -lrt (required for Debian) * Corrected description of scope and npc variables in script_commands.txt. * Made temporary character string variables not have a limited length. (now all temporary string variables don't have limited length) diff --git a/configure b/configure index 2145b05d2..27468aa87 100755 --- a/configure +++ b/configure @@ -1,26 +1,55 @@ #! /bin/sh -# From configure.in Revision: 11952. +# From configure.in Revision: 11985. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59. +# Generated by GNU Autoconf 2.61. # -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -30,8 +59,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -45,18 +109,19 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -64,157 +129,388 @@ fi # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` +# CDPATH. +$as_unset CDPATH -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no fi + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in + case $as_dir in /*) - if ("$as_dir/$as_base" -c ' + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || + chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -223,7 +519,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -232,39 +549,27 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH +exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -exec 6>&1 - # # Initializations. # ac_default_prefix=/usr/local +ac_clean_files= ac_config_libobj_dir=. +LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= @@ -277,42 +582,109 @@ ac_unique_file="src/common/cbasetypes.h" # Factoring default headers for most tests. ac_includes_default="\ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include -#else -# if HAVE_STDINT_H -# include -# endif #endif -#if HAVE_UNISTD_H +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +SET_MAKE +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +GREP +EGREP +MYSQL_CONFIG_HOME +HAVE_MYSQL +MYSQL_VERSION +MYSQL_CFLAGS +MYSQL_LIBS +HAVE_PCRE +PCRE_LIBS +PCRE_CFLAGS +DLLEXT +LIBOBJS +LTLIBOBJS' ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + # Initialize some variables set by options. ac_init_help= @@ -339,34 +711,48 @@ x_libraries=NONE # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' ac_prev= +ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option ac_prev= continue fi - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -388,33 +774,45 @@ do --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -441,6 +839,12 @@ do -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -465,13 +869,16 @@ do | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -536,6 +943,16 @@ do | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -588,24 +1005,20 @@ do -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. @@ -636,8 +1049,7 @@ Try \`$0 --help' for more information." >&2 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" + eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) @@ -657,27 +1069,19 @@ if test -n "$ac_prev"; then { (exit 1); exit 1; }; } fi -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir do - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -704,74 +1108,76 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done # # Report the --help message. @@ -800,9 +1206,6 @@ Configuration: -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] -_ACEOF - - cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] @@ -820,15 +1223,22 @@ Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -852,11 +1262,10 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-mysql[=ARG] - use MySQL client library, optionally specify the + --with-mysql[=ARG] use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found) - --with-pcre[=ARG] use PCRE library, optionally specify the full path + --with-pcre[=ARG] use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found) --with-zlib=DIR root directory path of zlib installation (defaults @@ -867,126 +1276,95 @@ Some influential environment variables: CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF +ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue + test -d "$ac_dir" || continue ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd $ac_popdir + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } done fi -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit 0 + exit fi -exec 5>config.log -cat >&5 <<_ACEOF +cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF +exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -1005,7 +1383,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -1019,6 +1397,7 @@ do test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done +IFS=$as_save_IFS } >&5 @@ -1040,7 +1419,6 @@ _ACEOF ac_configure_args= ac_configure_args0= ac_configure_args1= -ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1051,7 +1429,7 @@ do -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in @@ -1073,9 +1451,7 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done @@ -1086,8 +1462,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1100,20 +1476,34 @@ trap 'exit_status=$? _ASBOX echo # The following way of writing the cache mishandles newlines in values, -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} + esac | + sort +) echo cat <<\_ASBOX @@ -1124,22 +1514,28 @@ _ASBOX echo for ac_var in $ac_subst_vars do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## +## ------------------- ## +## File substitutions. ## +## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1151,26 +1547,24 @@ _ASBOX ## ----------- ## _ASBOX echo - sed "/^$/d" confdefs.h | sort + cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status - ' 0 +' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h # Predefined preprocessor variables. @@ -1201,14 +1595,17 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" fi -for ac_site_file in $CONFIG_SITE; do +shift +for ac_site_file +do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} @@ -1224,8 +1621,8 @@ if test -r "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; esac fi else @@ -1237,12 +1634,11 @@ fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 @@ -1267,8 +1663,7 @@ echo "$as_me: current value: $ac_new_val" >&2;} # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1285,12 +1680,6 @@ echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start ov { (exit 1); exit 1; }; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - @@ -1307,28 +1696,32 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu - ac_config_files="$ac_config_files Makefile src/common/Makefile" +ac_config_files="$ac_config_files Makefile src/common/Makefile" - ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" +ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" - ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" +ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" - ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" +ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" # # Memory managers # -# Check whether --enable-manager or --disable-manager was given. +# Check whether --enable-manager was given. if test "${enable_manager+set}" = set; then - enableval="$enable_manager" - + enableval=$enable_manager; enable_manager="$enableval" case $enableval in "no");; @@ -1345,16 +1738,16 @@ echo "$as_me: error: unknown memory manager '$enable_manager'... stopping" >&2;} else enable_manager="builtin" -fi; +fi + # # mapregsql # -# Check whether --enable-mapregsql or --disable-mapregsql was given. +# Check whether --enable-mapregsql was given. if test "${enable_mapregsql+set}" = set; then - enableval="$enable_mapregsql" - + enableval=$enable_mapregsql; enable_mapregsql="$enableval" case $enableval in no);; @@ -1367,16 +1760,16 @@ echo "$as_me: error: invalid argument --enable-mapregsql=$enable_mapregsql... st else enable_mapregsql="no" -fi; +fi + # # debug # -# Check whether --enable-debug or --disable-debug was given. +# Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then - enableval="$enable_debug" - + enableval=$enable_debug; enable_debug="$enableval" case $enableval in no);; @@ -1389,17 +1782,17 @@ echo "$as_me: error: invalid argument --enable-debug=$enable_mapregsql... stoppi else enable_debug="no" -fi; +fi + # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # -# Check whether --with-mysql or --without-mysql was given. +# Check whether --with-mysql was given. if test "${with_mysql+set}" = set; then - withval="$with_mysql" - + withval=$with_mysql; if test "$withval" = "no" ; then want_mysql="no" else @@ -1418,17 +1811,17 @@ echo "$as_me: error: $withval is not an executable file" >&2;} else want_mysql="yes" require_mysql="no" -fi; +fi + # # Enable/disable PCRE and optionally specify the path (optional library) # -# Check whether --with-pcre or --without-pcre was given. +# Check whether --with-pcre was given. if test "${with_pcre+set}" = set; then - withval="$with_pcre" - + withval=$with_pcre; if test "$withval" = "no" ; then want_pcre="no" else @@ -1447,17 +1840,17 @@ echo "$as_me: error: $withval is not a directoy" >&2;} else want_pcre="yes" require_pcre="no" -fi; +fi + # # Specify the path of the zlib library (required library) # -# Check whether --with-zlib or --without-zlib was given. +# Check whether --with-zlib was given. if test "${with_zlib+set}" = set; then - withval="$with_zlib" - + withval=$with_zlib; test -n "$withval" && ZLIB_HOME="$withval" else @@ -1466,7 +1859,8 @@ else test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr -fi; +fi + @@ -1476,32 +1870,33 @@ fi; -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF +SHELL = /bin/sh all: - @echo 'ac_maketemp="$(MAKE)"' + @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac rm -f conftest.make fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } SET_MAKE= else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -1513,8 +1908,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1527,32 +1922,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1565,36 +1962,51 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1607,74 +2019,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1688,7 +2060,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -1699,6 +2071,7 @@ do fi done done +IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -1716,22 +2089,23 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1744,36 +2118,38 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1786,29 +2162,45 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$ac_ct_CC" && break done - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi fi fi @@ -1821,21 +2213,35 @@ See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 +echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } @@ -1860,47 +2266,77 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. break;; * ) break;; esac done +test "$ac_cv_exeext" = no && ac_cv_exeext= + else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -1912,19 +2348,21 @@ See \`config.log' for more details." >&2;} fi ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -1943,22 +2381,27 @@ See \`config.log' for more details." >&2;} fi fi fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then @@ -1969,9 +2412,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext break;; * ) break;; esac @@ -1985,14 +2427,14 @@ See \`config.log' for more details." >&2;} fi rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2012,14 +2454,20 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac @@ -2037,12 +2485,12 @@ fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2065,50 +2513,49 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2124,38 +2571,118 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_prog_cc_g=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2171,12 +2698,12 @@ else CFLAGS= fi fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2210,12 +2737,17 @@ static char *f (char * (*g) (char **, int), char **p, ...) /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ + that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2230,240 +2762,92 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext CC=$ac_save_CC fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF @@ -2475,24 +2859,22 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -2501,9 +2883,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi + rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2513,24 +2896,22 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -2541,6 +2922,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done @@ -2558,8 +2940,8 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -2582,24 +2964,22 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -2608,9 +2988,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi + rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2620,24 +3001,22 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -2648,6 +3027,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done @@ -2682,110 +3062,508 @@ CPPFLAGS="$CPPFLAGS -I../common" -echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 -if test "${ac_cv_c_bigendian+set}" = set; then + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - # See if sys/param.h defines the BYTE_ORDER macro. -cat >conftest.$ac_ext <<_ACEOF + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include +#include +#include +#include +#include int main () { -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - # It does; now see whether it defined to BIG_ENDIAN or not. -cat >conftest.$ac_ext <<_ACEOF + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif +#include - ; - return 0; -} _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -# It does not; compile a test program. + # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown @@ -2795,11 +3573,11 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () @@ -2810,27 +3588,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi @@ -2846,8 +3619,10 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2855,27 +3630,41 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default int main () { + /* Are we little or big endian? From Harbison&Steele. */ union { - long l; - char c[sizeof (long)]; + long int l; + char c[sizeof (long int)]; } u; u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -2888,13 +3677,16 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in yes) { { echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 @@ -2910,8 +3702,8 @@ esac -echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 -echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 +echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6; } pointers_fit_in_ints="no" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2929,27 +3721,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then pointers_fit_in_ints="yes" else echo "$as_me: failed program was:" >&5 @@ -2958,7 +3745,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$pointers_fit_in_ints" = "no" ; then CFLAGS="$CFLAGS -m32" LDFLAGS="$LDFLAGS -m32" @@ -2978,27 +3766,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then pointers_fit_in_ints="yes (with -m32)" else echo "$as_me: failed program was:" >&5 @@ -3007,10 +3790,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 -echo "${ECHO_T}$pointers_fit_in_ints" >&6 +{ echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 +echo "${ECHO_T}$pointers_fit_in_ints" >&6; } if test "$pointers_fit_in_ints" = "no" ; then { { echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} @@ -3018,139 +3802,127 @@ echo "$as_me: error: pointers cannot be stored in ints, required for old code... fi -echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-unused-parameter" cat >conftest.$ac_ext <<_ACEOF int foo; _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } CFLAGS="$OLD_CFLAGS" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-pointer-sign" cat >conftest.$ac_ext <<_ACEOF int foo; _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } CFLAGS="$OLD_CFLAGS" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6 + +{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-switch" cat >conftest.$ac_ext <<_ACEOF int foo; _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } CFLAGS="$OLD_CFLAGS" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -3171,272 +3943,18 @@ case $enableval in ;; "memwatch") CFLAGS="$CFLAGS -DMEMWATCH" - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then + if test "${ac_cv_header_memwatch_h+set}" = set; then + { echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -if test "${ac_cv_header_memwatch_h+set}" = set; then - echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 -if test "${ac_cv_header_memwatch_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking memwatch.h usability" >&5 -echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3447,41 +3965,37 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking memwatch.h presence" >&5 -echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3490,24 +4004,22 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -3515,9 +4027,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -3541,25 +4054,18 @@ echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\ echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + ;; esac -echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } if test "${ac_cv_header_memwatch_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_memwatch_h=$ac_header_preproc fi -echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } fi if test $ac_cv_header_memwatch_h = yes; then @@ -3576,17 +4082,17 @@ fi CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" LIBS="$LIBS -ldmalloc" if test "${ac_cv_header_dmalloc_h+set}" = set; then - echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 -echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3597,41 +4103,37 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 -echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3640,24 +4142,22 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -3665,9 +4165,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -3691,25 +4192,18 @@ echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\" echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + ;; esac -echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dmalloc_h=$ac_header_preproc fi -echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } fi if test $ac_cv_header_dmalloc_h = yes; then @@ -3726,17 +4220,17 @@ fi CFLAGS="$CFLAGS -DGCOLLECT" LIBS="$LIBS -lgc" if test "${ac_cv_header_gc_h+set}" = set; then - echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } if test "${ac_cv_header_gc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking gc.h usability" >&5 -echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking gc.h usability" >&5 +echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3747,41 +4241,37 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking gc.h presence" >&5 -echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking gc.h presence" >&5 +echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3790,24 +4280,22 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -3815,9 +4303,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in @@ -3841,25 +4330,18 @@ echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2 echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + ;; esac -echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } if test "${ac_cv_header_gc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_gc_h=$ac_header_preproc fi -echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } fi if test $ac_cv_header_gc_h = yes; then @@ -3895,113 +4377,234 @@ fi # -# MySQL library (optional) +# zlib library (required) # -MYSQL_VERSION="" -MYSQL_CFLAGS="" -MYSQL_LIBS="" +if test -n "${ZLIB_HOME}" ; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" +fi -if test "$want_mysql" = "no" ; then - { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 -echo "$as_me: ignoring MySQL (optional)" >&6;} -else - if test -z "$MYSQL_CONFIG_HOME"; then - # Extract the first word of "mysql_config", so it can be a program name with args. -set dummy mysql_config; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then +{ echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 +echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6; } +if test "${ac_cv_lib_z_inflateEnd+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $MYSQL_CONFIG_HOME in - [\\/]* | ?:[\\/]*) - ac_cv_path_MYSQL_CONFIG_HOME="$MYSQL_CONFIG_HOME" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ - test -z "$ac_cv_path_MYSQL_CONFIG_HOME" && ac_cv_path_MYSQL_CONFIG_HOME="no" - ;; +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inflateEnd (); +int +main () +{ +return inflateEnd (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_z_inflateEnd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_z_inflateEnd=no fi -MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME -if test -n "$MYSQL_CONFIG_HOME"; then - echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 -echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 +echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6; } +if test $ac_cv_lib_z_inflateEnd = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF - fi + LIBS="-lz $LIBS" - echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 -echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6 - if test "$MYSQL_CONFIG_HOME" != "no" ; then - HAVE_MYSQL="yes" - MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" - MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 -echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6 - if test -n "`$MYSQL_CONFIG_HOME --cflags | grep -i '\-m64'`"; then - { { echo "$as_me:$LINENO: error: $MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping" >&5 -echo "$as_me: error: $MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping" >&2;} - { (exit 1); exit 1; }; } - fi - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - if test "$require_mysql" = "yes" ; then - { { echo "$as_me:$LINENO: error: MySQL not found (requested)" >&5 -echo "$as_me: error: MySQL not found (requested)" >&2;} +else + { { echo "$as_me:$LINENO: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&2;} { (exit 1); exit 1; }; } - else - { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 -echo "$as_me: disabling MySQL (optional)" >&6;} - fi - fi fi +if test "${ac_cv_header_zlib_h+set}" = set; then + { echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ;; +esac +{ echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +fi +if test $ac_cv_header_zlib_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { (exit 1); exit 1; }; } +fi # -# PCRE library (optional) +# math library (required) # -##TODO PCRE version -PCRE_LIBS="" -PCRE_CFLAGS="" -if test "$want_pcre" = "no" ; then - { echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 -echo "$as_me: ignoring PCRE (optional)" >&6;} -else - if test -z "$PCRE_HOME" ; then - echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 -echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6 -if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then +{ echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 +echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6; } +if test "${ac_cv_lib_m_sqrt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lpcre $LIBS" +LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4009,73 +4612,79 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char pcre_study (); +char sqrt (); int main () { -pcre_study (); +return sqrt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_pcre_pcre_study=yes + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_m_sqrt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_pcre_pcre_study=no + ac_cv_lib_m_sqrt=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6 -if test $ac_cv_lib_pcre_pcre_study = yes; then - HAVE_PCRE="yes" +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 +echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6; } +if test $ac_cv_lib_m_sqrt = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +else + { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 +echo "$as_me: error: math library not found... stopping" >&2;} + { (exit 1); exit 1; }; } fi - if test "$HAVE_PCRE" = "yes" ; then - PCRE_LIBS="-lpcre" - fi - else - PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" - PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" - echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 -echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6 -if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then + + +# +# clock_gettime (rt on Debian) +# + +{ echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 +echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6; } +if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lpcre $LIBS" +LIBS="-lrt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4083,107 +4692,133 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char pcre_compile (); +char clock_gettime (); int main () { -pcre_compile (); +return clock_gettime (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_pcre_pcre_compile=yes + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_rt_clock_gettime=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_pcre_pcre_compile=no + ac_cv_lib_rt_clock_gettime=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6 -if test $ac_cv_lib_pcre_pcre_compile = yes; then - HAVE_PCRE="yes" +{ echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 +echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6; } +if test $ac_cv_lib_rt_clock_gettime = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRT 1 +_ACEOF + + LIBS="-lrt $LIBS" + fi - CPPFLAGS="$PCRE_OLD_CPPFLAGS" - LDFLAGS="$PCRE_OLD_LDFLAGS" - if test "$HAVE_PCRE" = "yes" ; then - PCRE_LIBS="-L$PCRE_HOME/lib -lpcre" - test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" - fi - fi - echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 -echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6 - if test "$HAVE_PCRE" = "yes" ; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - if test "$require_pcre" = "yes" ; then - { { echo "$as_me:$LINENO: error: PCRE not found (requested)" >&5 -echo "$as_me: error: PCRE not found (requested)" >&2;} - { (exit 1); exit 1; }; } - else - { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 -echo "$as_me: disabling PCRE (optional)" >&6;} - fi - fi + + +# +# MySQL library (optional) +# +MYSQL_VERSION="" +MYSQL_CFLAGS="" +MYSQL_LIBS="" + +if test "$want_mysql" = "no" ; then + { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 +echo "$as_me: ignoring MySQL (optional)" >&6;} +else + if test -z "$MYSQL_CONFIG_HOME"; then + # Extract the first word of "mysql_config", so it can be a program name with args. +set dummy mysql_config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MYSQL_CONFIG_HOME in + [\\/]* | ?:[\\/]*) + ac_cv_path_MYSQL_CONFIG_HOME="$MYSQL_CONFIG_HOME" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_MYSQL_CONFIG_HOME" && ac_cv_path_MYSQL_CONFIG_HOME="no" + ;; +esac +fi +MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME +if test -n "$MYSQL_CONFIG_HOME"; then + { echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 +echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi + if test "$MYSQL_CONFIG_HOME" != "no" ; then + MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - - - -# -# zlib library (required) -# -if test -n "${ZLIB_HOME}" ; then - LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" - CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" -fi - -echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 -echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6 -if test "${ac_cv_lib_z_inflateEnd+set}" = set; then + MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" + MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" + { echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 +echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6; } +if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-lmysqlclient $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4191,81 +4826,69 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char inflateEnd (); +char mysql_init (); int main () { -inflateEnd (); +return mysql_init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_z_inflateEnd=yes + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_mysqlclient_mysql_init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_z_inflateEnd=no + ac_cv_lib_mysqlclient_mysql_init=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 -echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6 -if test $ac_cv_lib_z_inflateEnd = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 -_ACEOF - - LIBS="-lz $LIBS" - -else - { { echo "$as_me:$LINENO: error: zlib library not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 -echo "$as_me: error: zlib library not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} - { (exit 1); exit 1; }; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 +echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6; } +if test $ac_cv_lib_mysqlclient_mysql_init = yes; then + HAVE_MYSQL="yes" fi -if test "${ac_cv_header_zlib_h+set}" = set; then - echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -if test "${ac_cv_header_zlib_h+set}" = set; then + if test "${ac_cv_header_mysql_h+set}" = set; then + { echo "$as_me:$LINENO: checking for mysql.h" >&5 +echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6; } +if test "${ac_cv_header_mysql_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +echo "${ECHO_T}$ac_cv_header_mysql_h" >&6; } else # Is the header compilable? -echo "$as_me:$LINENO: checking zlib.h usability" >&5 -echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking mysql.h usability" >&5 +echo $ECHO_N "checking mysql.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4273,70 +4896,64 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -#include +#include _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no + ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -echo "$as_me:$LINENO: checking zlib.h presence" >&5 -echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking mysql.h presence" >&5 +echo $ECHO_N "checking mysql.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -4344,76 +4961,104 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi + rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: mysql.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + { echo "$as_me:$LINENO: WARNING: mysql.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: mysql.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: mysql.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: mysql.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: mysql.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: mysql.h: in the future, the compiler will take precedence" >&2;} + ;; esac -echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -if test "${ac_cv_header_zlib_h+set}" = set; then +{ echo "$as_me:$LINENO: checking for mysql.h" >&5 +echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6; } +if test "${ac_cv_header_mysql_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_header_zlib_h=$ac_header_preproc + ac_cv_header_mysql_h=$ac_header_preproc fi -echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +echo "${ECHO_T}$ac_cv_header_mysql_h" >&6; } fi -if test $ac_cv_header_zlib_h = yes; then +if test $ac_cv_header_mysql_h = yes; then : else - { { echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 -echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + HAVE_MYSQL="" +fi + + + CPPFLAGS="$MYSQL_OLD_CPPFLAGS" + LDFLAGS="$MYSQL_OLD_LDFLAGS" + fi + { echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 +echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6; } + if test "$HAVE_MYSQL" = "yes" ; then + { echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + if test "$require_mysql" = "yes" ; then + { { echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 +echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } + else + { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 +echo "$as_me: disabling MySQL (optional)" >&6;} + MYSQL_VERSION="" + MYSQL_CFLAGS="" + MYSQL_LIBS="" + fi + fi fi + + # -# math library (required) +# PCRE library (optional) # +##TODO PCRE version +PCRE_LIBS="" +PCRE_CFLAGS="" -echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 -echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6 -if test "${ac_cv_lib_m_sqrt+set}" = set; then +if test "$want_pcre" = "no" ; then + { echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 +echo "$as_me: ignoring PCRE (optional)" >&6;} +else + if test -z "$PCRE_HOME" ; then + { echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 +echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6; } +if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" +LIBS="-lpcre $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4421,80 +5066,167 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sqrt (); +char pcre_study (); int main () { -sqrt (); +return pcre_study (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_m_sqrt=yes + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_pcre_pcre_study=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_m_sqrt=no + ac_cv_lib_pcre_pcre_study=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 -echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6 -if test $ac_cv_lib_m_sqrt = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBM 1 -_ACEOF +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6; } +if test $ac_cv_lib_pcre_pcre_study = yes; then + HAVE_PCRE="yes" +fi - LIBS="-lm $LIBS" + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-lpcre" + fi + else + PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" + PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" + { echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6; } +if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcre $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcre_compile (); +int +main () +{ +return pcre_compile (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_pcre_pcre_compile=yes else - { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 -echo "$as_me: error: math library not found... stopping" >&2;} + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pcre_pcre_compile=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6; } +if test $ac_cv_lib_pcre_pcre_compile = yes; then + HAVE_PCRE="yes" +fi + + CPPFLAGS="$PCRE_OLD_CPPFLAGS" + LDFLAGS="$PCRE_OLD_LDFLAGS" + if test "$HAVE_PCRE" = "yes" ; then + PCRE_LIBS="-L$PCRE_HOME/lib -lpcre" + test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" + fi + fi + { echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 +echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6; } + if test "$HAVE_PCRE" = "yes" ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + if test "$require_pcre" = "yes" ; then + { { echo "$as_me:$LINENO: error: PCRE not found or incompatible (requested)" >&5 +echo "$as_me: error: PCRE not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } + else + { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 +echo "$as_me: disabling PCRE (optional)" >&6;} + fi + fi fi + + # # Host specific stuff # -echo "$as_me:$LINENO: checking host OS" >&5 -echo $ECHO_N "checking host OS... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking host OS" >&5 +echo $ECHO_N "checking host OS... $ECHO_C" >&6; } host_os="`uname`" -echo "$as_me:$LINENO: result: $host_os" >&5 -echo "${ECHO_T}$host_os" >&6 +{ echo "$as_me:$LINENO: result: $host_os" >&5 +echo "${ECHO_T}$host_os" >&6; } fd_setsize="" DLLEXT=".so" case $host_os in @@ -4518,19 +5250,19 @@ CYGWIN*) esac -echo "$as_me:$LINENO: checking for MinGW" >&5 -echo $ECHO_N "checking for MinGW... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for MinGW" >&5 +echo $ECHO_N "checking for MinGW... $ECHO_C" >&6; } if test -n "`$CC --version | grep -i mingw`" ; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } CPPFLAGS="$CPPFLAGS -DMINGW" if test -z "$fd_setsize" ; then CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" fi LIBS="$LIBS -lws2_32" else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -4554,39 +5286,58 @@ _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} | + esac | + sort +) | sed ' + /^ac_cv_env_/b end t clear - : clear + :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - echo "not updating unwritable cache $cache_file" + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -4595,63 +5346,48 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, +# take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF +ac_script=' t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -4682,17 +5418,45 @@ cat >>$CONFIG_STATUS <<\_ACEOF ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -4702,8 +5466,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -4717,18 +5516,19 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -4736,159 +5536,120 @@ fi # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi +# CDPATH. +$as_unset CDPATH - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -4897,7 +5658,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -4906,31 +5688,14 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - exec 6>&1 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +# Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - +# values after options handling. +ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -4938,30 +5703,18 @@ generated by GNU Autoconf 2.59. Invocation command line was CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi +config_files="$ac_config_files" -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF - ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -4969,7 +5722,7 @@ current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -4980,18 +5733,20 @@ Configuration files: $config_files Report bugs to ." -_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir + +ac_pwd='$ac_pwd' +srcdir='$srcdir' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -5002,60 +5757,42 @@ while test $# != 0 do case $1 in --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - -*) + *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; esac case $ac_option in # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" ;; + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; esac shift @@ -5071,38 +5808,52 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 - - - +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. for ac_config_target in $ac_config_targets do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "src/common/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; - "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; - "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; - "src/ladmin/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; - "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; - "src/login_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; - "src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; - "src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; - "src/plugins/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; - "src/tool/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "src/char/Makefile") CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; + "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; + "src/ladmin/Makefile") CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; + "src/char_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; + "src/login_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; + "src/txt-converter/Makefile") CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; + "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; + "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; + "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done + # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -5112,301 +5863,369 @@ if $ac_need_defaults; then fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. $debug || { - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } - # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - # -# CONFIG_FILES section. +# Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@SET_MAKE@,$SET_MAKE,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@CPP@,$CPP,;t t -s,@EGREP@,$EGREP,;t t -s,@MYSQL_CONFIG_HOME@,$MYSQL_CONFIG_HOME,;t t -s,@HAVE_MYSQL@,$HAVE_MYSQL,;t t -s,@MYSQL_VERSION@,$MYSQL_VERSION,;t t -s,@MYSQL_CFLAGS@,$MYSQL_CFLAGS,;t t -s,@MYSQL_LIBS@,$MYSQL_LIBS,;t t -s,@HAVE_PCRE@,$HAVE_PCRE,;t t -s,@PCRE_LIBS@,$PCRE_LIBS,;t t -s,@PCRE_CFLAGS@,$PCRE_CFLAGS,;t t -s,@DLLEXT@,$DLLEXT,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF +if test -n "$CONFIG_FILES"; then _ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim +HAVE_MYSQL!$HAVE_MYSQL$ac_delim +MYSQL_VERSION!$MYSQL_VERSION$ac_delim +MYSQL_CFLAGS!$MYSQL_CFLAGS$ac_delim +MYSQL_LIBS!$MYSQL_LIBS$ac_delim +HAVE_PCRE!$HAVE_PCRE$ac_delim +PCRE_LIBS!$PCRE_LIBS$ac_delim +PCRE_CFLAGS!$PCRE_CFLAGS$ac_delim +DLLEXT!$DLLEXT$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi -fi # test -n "$CONFIG_FILES" +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof _ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; esac - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } - ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + case $ac_mode in + :F) + # + # CONFIG_FILE + # +_ACEOF - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub @@ -5414,28 +6233,39 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF + + esac + +done # for ac_tag + { (exit 0); exit 0; } _ACEOF diff --git a/configure.in b/configure.in index 69a403895..2751d945e 100644 --- a/configure.in +++ b/configure.in @@ -288,6 +288,29 @@ if test "$enable_debug" = "yes" ; then fi +# +# zlib library (required) +# +if test -n "${ZLIB_HOME}" ; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" +fi +AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])]) +AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])]) + + +# +# math library (required) +# +AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])]) + + +# +# clock_gettime (rt on Debian) +# +AC_CHECK_LIB([rt], [clock_gettime]) + + # # MySQL library (optional) # @@ -302,22 +325,30 @@ else AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no]) fi - AC_MSG_CHECKING([MySQL library (optional)]) if test "$MYSQL_CONFIG_HOME" != "no" ; then - HAVE_MYSQL="yes" MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + + MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" + MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" + AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], []) + AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""]) + CPPFLAGS="$MYSQL_OLD_CPPFLAGS" + LDFLAGS="$MYSQL_OLD_LDFLAGS" + fi + AC_MSG_CHECKING([MySQL library (optional)]) + if test "$HAVE_MYSQL" = "yes" ; then AC_MSG_RESULT([yes ($MYSQL_VERSION)]) - if test -n "`$MYSQL_CONFIG_HOME --cflags | grep -i '\-m64'`"; then - AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=... stopping]) - fi else AC_MSG_RESULT([no]) if test "$require_mysql" = "yes" ; then - AC_MSG_ERROR([MySQL not found (requested)]) + AC_MSG_ERROR([MySQL not found or incompatible (requested)]) else AC_MSG_NOTICE([disabling MySQL (optional)]) + MYSQL_VERSION="" + MYSQL_CFLAGS="" + MYSQL_LIBS="" fi fi fi @@ -328,7 +359,6 @@ AC_SUBST([MYSQL_CFLAGS]) AC_SUBST([MYSQL_LIBS]) - # # PCRE library (optional) # @@ -361,7 +391,7 @@ else else AC_MSG_RESULT([no]) if test "$require_pcre" = "yes" ; then - AC_MSG_ERROR([PCRE not found (requested)]) + AC_MSG_ERROR([PCRE not found or incompatible (requested)]) else AC_MSG_NOTICE([disabling PCRE (optional)]) fi @@ -373,26 +403,6 @@ AC_SUBST([PCRE_LIBS]) AC_SUBST([PCRE_CFLAGS]) - -# -# zlib library (required) -# -if test -n "${ZLIB_HOME}" ; then - LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" - CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" -fi -AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])]) -AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])]) - - - -# -# math library (required) -# -AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])]) - - - # # Host specific stuff # -- cgit v1.2.3-70-g09d2 From dc99d88746c2175dfa5007ae2cbbde795dd357d1 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sun, 13 Apr 2008 17:46:24 +0000 Subject: * Changes to the configure script: - clarified how --with-zlib is used - added --enable-packetver to set the PACKETVER define (used often enough to get it's own option, but unnecessary since it can be set with CFLAGS) - added -g compiler option to --enable-debug git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12578 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 +++++ configure | 31 ++++++++++++++++++++++++++++--- configure.in | 27 +++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 92ae65a49..a0c012245 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2008/04/13 + * Changes to the configure script: [FlavioJS] + - clarified how --with-zlib is used + - added --enable-packetver to set the PACKETVER define (used often enough + to get it's own option, but unnecessary since it can be set with CFLAGS) + - added -g compiler option to --enable-debug * Changed LOG_ALL definition to really log everything [Toms] 2008/04/12 * Login will no longer set character offline when going from map diff --git a/configure b/configure index 27468aa87..51846550b 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11985. +# From configure.in Revision: 12578 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1254,6 +1254,8 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin) + --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see + src/map/clif.h) --enable-mapregsql Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no) @@ -1269,7 +1271,9 @@ Optional Packages: of pcre installation directory (by default pcre is used if found) --with-zlib=DIR root directory path of zlib installation (defaults - to /usr/local or /usr if not found in /usr/local) + to /usr/local or /usr if not found in /usr/local). + Assumes that the header files are in DIR/include and + the library files are in DIR/lib Some influential environment variables: CC C compiler command @@ -1742,6 +1746,19 @@ fi +# +# packetver +# +# Check whether --enable-packetver was given. +if test "${enable_packetver+set}" = set; then + enableval=$enable_packetver; enable_packetver="$enableval" +else + enable_packetver="" + +fi + + + # # mapregsql # @@ -4360,6 +4377,14 @@ fi esac +# +# Packetver +# +if test -n "$enable_packetver" ; then + CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver" +fi + + # # Mapregsql # @@ -4372,7 +4397,7 @@ fi # Debug # if test "$enable_debug" = "yes" ; then - CFLAGS="$CFLAGS -DDEBUG" + CFLAGS="$CFLAGS -g -DDEBUG" fi diff --git a/configure.in b/configure.in index 2751d945e..ac0e7b436 100644 --- a/configure.in +++ b/configure.in @@ -36,6 +36,20 @@ AC_ARG_ENABLE( ) +# +# packetver +# +AC_ARG_ENABLE( + [packetver], + AC_HELP_STRING( + [--enable-packetver=ARG], + [Sets the PACKETVER define of the map-server. (see src/map/clif.h)] + ), + [enable_packetver="$enableval"], + [enable_packetver=""] +) + + # # mapregsql # @@ -139,7 +153,8 @@ AC_ARG_WITH( [zlib], AC_HELP_STRING( [--with-zlib=DIR], - [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)] + [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local). + Assumes that the header files are in DIR/include and the library files are in DIR/lib] ), [ test -n "$withval" && ZLIB_HOME="$withval" @@ -272,6 +287,14 @@ case $enableval in esac +# +# Packetver +# +if test -n "$enable_packetver" ; then + CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver" +fi + + # # Mapregsql # @@ -284,7 +307,7 @@ fi # Debug # if test "$enable_debug" = "yes" ; then - CFLAGS="$CFLAGS -DDEBUG" + CFLAGS="$CFLAGS -g -DDEBUG" fi -- cgit v1.2.3-70-g09d2 From 364b6c4bb3463f7ffdf55b7f7adc3b515febb7c7 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Mon, 14 Apr 2008 03:45:05 +0000 Subject: * Changes to the configure script: - added options --with-MYSQL_CFLAGS and --with-MYSQL_LIBS to allow manual setting of those variables git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12586 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ configure | 71 +++++++++++++++++++++++++++++++++++++++++++---------- configure.in | 65 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 114 insertions(+), 25 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 68690ceb3..3e7ba8b78 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2008/04/14 + * Changes to the configure script: [FlavioJS] + - added options --with-MYSQL_CFLAGS and --with-MYSQL_LIBS to allow manual setting of those variables 2008/04/13 * More major updates to the quest log system. [Kevin] * Followup to r12579 (all other players appeared as female on sql branch). [FlavioJS] diff --git a/configure b/configure index 51846550b..b44e53d20 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 12578 . +# From configure.in Revision: 12586 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1267,6 +1267,10 @@ Optional Packages: --with-mysql[=ARG] use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found) + --with-MYSQL_CFLAGS=ARG specify MYSQL_CFLAGS manually (instead of using + "mysql_config --include") + --with-MYSQL_LIBS=ARG specify MYSQL_LIBS manually (instead of using + "mysql_config --libs") --with-pcre[=ARG] use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found) @@ -1832,6 +1836,40 @@ fi +# +# Manual MYSQL_CFLAGS (optional) +# + +# Check whether --with-MYSQL_CFLAGS was given. +if test "${with_MYSQL_CFLAGS+set}" = set; then + withval=$with_MYSQL_CFLAGS; + manual_MYSQL_CFLAGS="yes" + MYSQL_CFLAGS="$withval" + +else + manual_MYSQL_CFLAGS="no" + +fi + + + +# +# Manual MYSQL_LIBS (optional) +# + +# Check whether --with-MYSQL_LIBS was given. +if test "${with_MYSQL_LIBS+set}" = set; then + withval=$with_MYSQL_LIBS; + manual_MYSQL_LIBS="yes" + MYSQL_LIBS="$withval" + +else + manual_MYSQL_LIBS="no" + +fi + + + # # Enable/disable PCRE and optionally specify the path (optional library) # @@ -4778,11 +4816,11 @@ fi # # MySQL library (optional) # -MYSQL_VERSION="" -MYSQL_CFLAGS="" -MYSQL_LIBS="" if test "$want_mysql" = "no" ; then + MYSQL_VERSION="" + MYSQL_CFLAGS="" + MYSQL_LIBS="" { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 echo "$as_me: ignoring MySQL (optional)" >&6;} else @@ -4832,12 +4870,19 @@ fi if test "$MYSQL_CONFIG_HOME" != "no" ; then MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" - MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + if test "$manual_MYSQL_CFLAGS" = "no" ; then + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" + fi + if test "$manual_MYSQL_LIBS" = "no" ; then + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + fi + else + MYSQL_VERSION="unknown" + fi - MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" - MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - { echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 + MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" + MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" + { echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6; } if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4902,7 +4947,7 @@ if test $ac_cv_lib_mysqlclient_mysql_init = yes; then HAVE_MYSQL="yes" fi - if test "${ac_cv_header_mysql_h+set}" = set; then + if test "${ac_cv_header_mysql_h+set}" = set; then { echo "$as_me:$LINENO: checking for mysql.h" >&5 echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6; } if test "${ac_cv_header_mysql_h+set}" = set; then @@ -5034,9 +5079,9 @@ else fi - CPPFLAGS="$MYSQL_OLD_CPPFLAGS" - LDFLAGS="$MYSQL_OLD_LDFLAGS" - fi + CPPFLAGS="$MYSQL_OLD_CPPFLAGS" + LDFLAGS="$MYSQL_OLD_LDFLAGS" + { echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6; } if test "$HAVE_MYSQL" = "yes" ; then diff --git a/configure.in b/configure.in index ac0e7b436..6bc3d3918 100644 --- a/configure.in +++ b/configure.in @@ -119,6 +119,40 @@ AC_ARG_WITH( ) +# +# Manual MYSQL_CFLAGS (optional) +# +AC_ARG_WITH( + [MYSQL_CFLAGS], + AC_HELP_STRING( + [--with-MYSQL_CFLAGS=ARG], + [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")] + ), + [ + manual_MYSQL_CFLAGS="yes" + MYSQL_CFLAGS="$withval" + ], + [manual_MYSQL_CFLAGS="no"] +) + + +# +# Manual MYSQL_LIBS (optional) +# +AC_ARG_WITH( + [MYSQL_LIBS], + AC_HELP_STRING( + [--with-MYSQL_LIBS=ARG], + [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")] + ), + [ + manual_MYSQL_LIBS="yes" + MYSQL_LIBS="$withval" + ], + [manual_MYSQL_LIBS="no"] +) + + # # Enable/disable PCRE and optionally specify the path (optional library) # @@ -337,11 +371,11 @@ AC_CHECK_LIB([rt], [clock_gettime]) # # MySQL library (optional) # -MYSQL_VERSION="" -MYSQL_CFLAGS="" -MYSQL_LIBS="" if test "$want_mysql" = "no" ; then + MYSQL_VERSION="" + MYSQL_CFLAGS="" + MYSQL_LIBS="" AC_MSG_NOTICE([ignoring MySQL (optional)]) else if test -z "$MYSQL_CONFIG_HOME"; then @@ -350,16 +384,23 @@ else if test "$MYSQL_CONFIG_HOME" != "no" ; then MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" - MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - - MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" - MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], []) - AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""]) - CPPFLAGS="$MYSQL_OLD_CPPFLAGS" - LDFLAGS="$MYSQL_OLD_LDFLAGS" + if test "$manual_MYSQL_CFLAGS" = "no" ; then + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" + fi + if test "$manual_MYSQL_LIBS" = "no" ; then + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + fi + else + MYSQL_VERSION="unknown" fi + + MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" + MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" + AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], []) + AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""]) + CPPFLAGS="$MYSQL_OLD_CPPFLAGS" + LDFLAGS="$MYSQL_OLD_LDFLAGS" + AC_MSG_CHECKING([MySQL library (optional)]) if test "$HAVE_MYSQL" = "yes" ; then AC_MSG_RESULT([yes ($MYSQL_VERSION)]) -- cgit v1.2.3-70-g09d2 From 8f1dd2d150b774b5cbaf7a656d635a1b20da029d Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Mon, 26 May 2008 17:42:21 +0000 Subject: * Updating configure script: - fixed memory manager using the argument of the last enable/disable option (any option) - other minor changes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12729 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ configure | 22 +++++++++++----------- configure.in | 12 ++++++------ 3 files changed, 20 insertions(+), 17 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index c6f705e31..dd6514e84 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2008/05/26 + * Updating configure script: [FlavioJS] + - fixed memory manager using the argument of the last enable/disable option (any option) + - other minor changes * Increased the allowed packet size for chat messages [ultramage] - changed the capacity of the message column in chatlog (see sql update) 2008/05/25 diff --git a/configure b/configure index b44e53d20..fcf9e42d7 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 12586 . +# From configure.in Revision: 12729 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1257,9 +1257,9 @@ Optional Features: --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see src/map/clif.h) --enable-mapregsql Makes map-wide script variables be saved to SQL - instead of TXT files in the sql map-server. (defauts - to no) - --enable-debug Compiles in debug mode. (defauts to no) + instead of TXT files in the sql map-server. + (disabled by default) + --enable-debug Compiles in debug mode. (disabled by default) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1738,8 +1738,8 @@ if test "${enable_manager+set}" = set; then "dmalloc");; "gcollect");; "bcheck");; - *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enable_manager'... stopping" >&5 -echo "$as_me: error: unknown memory manager '$enable_manager'... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enableval'... stopping" >&5 +echo "$as_me: error: unknown memory manager '$enableval'... stopping" >&2;} { (exit 1); exit 1; }; };; esac @@ -1773,8 +1773,8 @@ if test "${enable_mapregsql+set}" = set; then case $enableval in no);; yes);; - *) { { echo "$as_me:$LINENO: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&5 -echo "$as_me: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-mapregsql=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-mapregsql=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac @@ -1795,8 +1795,8 @@ if test "${enable_debug+set}" = set; then case $enableval in no);; yes);; - *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&5 -echo "$as_me: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac @@ -3989,7 +3989,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # # Memory manager # -case $enableval in +case $enable_manager in "no") CFLAGS="$CFLAGS -DNO_MEMMGR" ;; diff --git a/configure.in b/configure.in index 6bc3d3918..5134ee3cc 100644 --- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ AC_ARG_ENABLE( "dmalloc");; "gcollect");; "bcheck");; - *) AC_MSG_ERROR([[unknown memory manager '$enable_manager'... stopping]]);; + *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);; esac ], [enable_manager="builtin"] @@ -57,14 +57,14 @@ AC_ARG_ENABLE( [mapregsql], AC_HELP_STRING( [--enable-mapregsql], - [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no)] + [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (disabled by default)] ), [ enable_mapregsql="$enableval" case $enableval in no);; yes);; - *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enable_mapregsql... stopping]]);; + *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enableval... stopping]]);; esac ], [enable_mapregsql="no"] @@ -78,14 +78,14 @@ AC_ARG_ENABLE( [debug], AC_HELP_STRING( [--enable-debug], - [Compiles in debug mode. (defauts to no)] + [Compiles in debug mode. (disabled by default)] ), [ enable_debug="$enableval" case $enableval in no);; yes);; - *) AC_MSG_ERROR([[invalid argument --enable-debug=$enable_mapregsql... stopping]]);; + *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);; esac ], [enable_debug="no"] @@ -294,7 +294,7 @@ AC_COMPILE_IFELSE( # # Memory manager # -case $enableval in +case $enable_manager in "no") CFLAGS="$CFLAGS -DNO_MEMMGR" ;; -- cgit v1.2.3-70-g09d2 From d43aab71e6d7eccc1d7710c351c708da388f3388 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Mon, 9 Jun 2008 23:44:52 +0000 Subject: * Added experimental code to set the socket limit at runtime. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12803 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ configure | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++- configure.in | 7 ++++ src/common/socket.c | 21 ++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 0c41078a4..2a18ed491 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,8 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2008/06/10 + * Added experimental code to set the socket limit at runtime. [FlavioJS] 2008/06/09 * Fixed SN_SHARPSHOOTING doing 100% atk less damage than it should, bugreport:1654 * Fixed Active Guild skills not working when WoE is OFF, follow up on r12770, bugreport:1653 and bugreport:1637 diff --git a/configure b/configure index fcf9e42d7..39e0ecdcd 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 12729 . +# From configure.in Revision: 12803 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -3986,6 +3986,97 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # +# +# setrlimit - used to set the socket limit +# +{ echo "$as_me:$LINENO: checking for setrlimit" >&5 +echo $ECHO_N "checking for setrlimit... $ECHO_C" >&6; } +if test "${ac_cv_func_setrlimit+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define setrlimit to an innocuous variant, in case declares setrlimit. + For example, HP-UX 11i declares gettimeofday. */ +#define setrlimit innocuous_setrlimit + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char setrlimit (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef setrlimit + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char setrlimit (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_setrlimit || defined __stub___setrlimit +choke me +#endif + +int +main () +{ +return setrlimit (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_setrlimit=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_setrlimit=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_setrlimit" >&5 +echo "${ECHO_T}$ac_cv_func_setrlimit" >&6; } +if test $ac_cv_func_setrlimit = yes; then + CFLAGS="$CFLAGS -DHAVE_SETRLIMIT" +fi + + + + # # Memory manager # diff --git a/configure.in b/configure.in index 5134ee3cc..d9deb8710 100644 --- a/configure.in +++ b/configure.in @@ -291,6 +291,13 @@ AC_COMPILE_IFELSE( # +# +# setrlimit - used to set the socket limit +# +AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"]) + + + # # Memory manager # diff --git a/src/common/socket.c b/src/common/socket.c index 9b48f0401..7addc271b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -32,6 +32,10 @@ #ifndef SIOCGIFCONF #include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] #endif + + #ifdef HAVE_SETRLIMIT + #include + #endif #endif ///////////////////////////////////////////////////////////////////// @@ -1200,6 +1204,23 @@ void socket_init(void) return; } } +#elif defined(HAVE_SETRLIMIT) + {// set socket limit to FD_SETSIZE + struct rlimit rlp; + if( 0 == getrlimit(RLIMIT_NOFILE, &rlp) ) + { + rlp.rlim_cur = FD_SETSIZE; + if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) ) + {// failed, try setting the maximum too (permission to change system limits is required) + rlp.rlim_max = FD_SETSIZE; + if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) ) + {// failed + getrlimit(RLIMIT_NOFILE, &rlp); + ShowWarning("socket_init: %s - failed to set socket limit to %d (current limit %d).\n", strerror(errno), FD_SETSIZE, (int)rlp.rlim_cur); + } + } + } + } #endif // Get initial local ips -- cgit v1.2.3-70-g09d2 From 1624d1d57db3cfde3b4f42a55580f5a1e742f28e Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 26 Jul 2008 20:45:57 +0000 Subject: Merged the /loginmerge branch (topic:192754) * the login server storage, ipban and logging systems have been abstracted and now provide a common interface; the rest has been merged into a single login server core (no more login/login_sql duplicity) * storage systems are now added via compiler options (WITH_SQL / WITH_TXT) * multiple storage engines can be compiled in at the same time, and the config option account.engine defines which one will be used. * due to MySQL autoincrement limitations, accounts with id '0' will not be supported; account IDs from this point on should start from '1'. * login_log() functions now again record IP addresses in dotted format, not as 4-byte integers (undo from r6868). * removed config options that defined column names in the login table * removed `memo` and `error message` columns from login db/savefile * moved `loginlog` table to the logs database * added sql files upgrade_svn12975.sql and upgrade_svn12975_log.sql * due to changes to the login table layout, I added an !optional! sql file (upgrade_svn12975_view.sql) that will provide a certain degree of backwards compatibility with existing software; read the instructions inside carefully! * moved third-party includes/libs to a separate directory * updated project files / makefiles Changed the way GM levels are handled * removed conf/gm_account.txt * added the gm level column to the txt savefile (after 'email' column) * gm level information is now transferred along with account data For open problems see bugreport:1889. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13000 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/mysql/include/config-win.h | 470 ++++ 3rdparty/mysql/include/m_ctype.h | 493 +++++ 3rdparty/mysql/include/my_alloc.h | 52 + 3rdparty/mysql/include/my_dbug.h | 101 + 3rdparty/mysql/include/my_global.h | 1306 +++++++++++ 3rdparty/mysql/include/my_list.h | 46 + 3rdparty/mysql/include/my_pthread.h | 717 ++++++ 3rdparty/mysql/include/my_sys.h | 904 ++++++++ 3rdparty/mysql/include/mysql.h | 847 +++++++ 3rdparty/mysql/include/mysql_com.h | 452 ++++ 3rdparty/mysql/include/mysql_time.h | 56 + 3rdparty/mysql/include/mysql_version.h | 29 + 3rdparty/mysql/include/raid.h | 159 ++ 3rdparty/mysql/include/typelib.h | 34 + 3rdparty/mysql/lib/libmysql.lib | Bin 0 -> 34900 bytes 3rdparty/mysql/mysql-5.0.20 | 0 3rdparty/pcre/include/pcre.h | 294 +++ 3rdparty/pcre/lib/pcre.lib | Bin 0 -> 7378 bytes 3rdparty/pcre/pcre-7.0 | 0 3rdparty/zlib/include/zconf.h | 332 +++ 3rdparty/zlib/include/zlib.h | 1357 ++++++++++++ 3rdparty/zlib/lib/zdll.lib | Bin 0 -> 10590 bytes 3rdparty/zlib/zlib-1.2.3 | 0 Changelog-Trunk.txt | 27 + Makefile.in | 5 +- conf/Changelog.txt | 8 + conf/GM_account.txt | 10 - conf/battle/gm.conf | 5 + conf/inter_athena.conf | 39 +- conf/ladmin_athena.conf | 5 - conf/login_athena.conf | 55 +- configure | 41 +- configure.in | 4 +- lib/libmysql.lib | Bin 34900 -> 0 bytes lib/mysql-5.0.20 | 0 lib/pcre-7.0 | 0 lib/pcre.lib | Bin 7378 -> 0 bytes lib/zdll.lib | Bin 10590 -> 0 bytes lib/zlib-1.2.3 | 0 save-tmpl/account.txt | 27 +- save-tmpl/castle.txt | 68 +- sql-files/logs.sql | 12 + sql-files/main.sql | 26 +- sql-files/upgrade_svn12975.sql | 24 + sql-files/upgrade_svn12975_log.sql | 20 + sql-files/upgrade_svn12975_view.sql | 17 + src/char/char.c | 165 +- src/char/char.h | 1 - src/char/inter.c | 34 +- src/char/inter.h | 3 - src/char_sql/char.c | 188 +- src/char_sql/char.h | 8 - src/char_sql/inter.c | 177 +- src/char_sql/inter.h | 15 - src/common/mmo.h | 6 +- src/common/plugins.c | 2 +- src/common/plugins.h | 2 +- src/common/sql.c | 51 + src/common/utils.c | 6 +- src/ladmin/ladmin.c | 2809 +++++++---------------- src/login/Makefile.in | 63 +- src/login/account.h | 159 ++ src/login/account_sql.c | 578 +++++ src/login/account_txt.c | 622 ++++++ src/login/admin.c | 606 +++-- src/login/ipban.h | 25 + src/login/ipban_sql.c | 209 ++ src/login/ipban_txt.c | 50 + src/login/login.c | 2067 +++++++---------- src/login/login.h | 43 +- src/login/loginlog.h | 14 + src/login/loginlog_sql.c | 93 + src/login/loginlog_txt.c | 74 + src/login_sql/Makefile.in | 60 - src/login_sql/login.c | 1982 ----------------- src/login_sql/login.h | 94 - src/map/atcommand.c | 18 +- src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/chrif.c | 127 +- src/map/chrif.h | 1 - src/map/map.c | 44 +- src/map/map.h | 1 - src/map/npc_chat.c | 2 +- src/map/party.c | 1 - src/map/party.h | 2 - src/map/pc.c | 54 +- src/map/pc.h | 5 +- src/map/pcre.h | 294 --- src/map/trade.c | 4 +- src/mysql/config-win.h | 470 ---- src/mysql/m_ctype.h | 493 ----- src/mysql/my_alloc.h | 52 - src/mysql/my_dbug.h | 101 - src/mysql/my_global.h | 1306 ----------- src/mysql/my_list.h | 46 - src/mysql/my_pthread.h | 717 ------ src/mysql/my_sys.h | 904 -------- src/mysql/mysql-5.0.20 | 0 src/mysql/mysql.h | 847 ------- src/mysql/mysql_com.h | 452 ---- src/mysql/mysql_time.h | 56 - src/mysql/mysql_version.h | 29 - src/mysql/raid.h | 159 -- src/mysql/typelib.h | 34 - src/txt-converter/login-converter.c | 205 +- src/zlib/zconf.h | 332 --- src/zlib/zlib-1.2.3 | 0 src/zlib/zlib.h | 1357 ------------ tools/cgi/addaccount.cgi | 204 -- tools/ladmin | 3793 -------------------------------- vcproj-6/char-server_sql.dsp | 540 ++--- vcproj-6/char-server_txt.dsp | 492 ++--- vcproj-6/login-server_sql.dsp | 448 ++-- vcproj-6/login-server_txt.dsp | 432 ++-- vcproj-6/map-server_sql.dsp | 884 ++++---- vcproj-6/map-server_txt.dsp | 876 ++++---- vcproj-7.1/char-server_sql.vcproj | 20 +- vcproj-7.1/char-server_txt.vcproj | 12 +- vcproj-7.1/login-server_sql.vcproj | 41 +- vcproj-7.1/login-server_txt.vcproj | 35 +- vcproj-7.1/map-server_sql.vcproj | 37 +- vcproj-7.1/map-server_txt.vcproj | 37 +- vcproj-7.1/mapcache.vcproj | 322 ++- vcproj-8/char-server_sql.vcproj | 20 +- vcproj-8/char-server_txt.vcproj | 12 +- vcproj-8/ladmin.vcproj | 8 +- vcproj-8/login-server_sql.vcproj | 48 +- vcproj-8/login-server_txt.vcproj | 42 +- vcproj-8/map-server_sql.vcproj | 38 +- vcproj-8/map-server_txt.vcproj | 38 +- vcproj-8/mapcache.vcproj | 20 +- vcproj-8/txt-converter-char.vcproj | 12 +- vcproj-8/txt-converter-login.vcproj | 12 +- vcproj-9/char-server_sql.vcproj | 14 +- vcproj-9/char-server_txt.vcproj | 12 +- vcproj-9/ladmin.vcproj | 8 +- vcproj-9/login-server_sql.vcproj | 48 +- vcproj-9/login-server_txt.vcproj | 38 +- vcproj-9/map-server_sql.vcproj | 26 +- vcproj-9/map-server_txt.vcproj | 24 +- vcproj-9/mapcache.vcproj | 18 +- vcproj-9/txt-converter-char.vcproj | 20 +- vcproj-9/txt-converter-login.vcproj | 40 +- 144 files changed, 14204 insertions(+), 20830 deletions(-) create mode 100644 3rdparty/mysql/include/config-win.h create mode 100644 3rdparty/mysql/include/m_ctype.h create mode 100644 3rdparty/mysql/include/my_alloc.h create mode 100644 3rdparty/mysql/include/my_dbug.h create mode 100644 3rdparty/mysql/include/my_global.h create mode 100644 3rdparty/mysql/include/my_list.h create mode 100644 3rdparty/mysql/include/my_pthread.h create mode 100644 3rdparty/mysql/include/my_sys.h create mode 100644 3rdparty/mysql/include/mysql.h create mode 100644 3rdparty/mysql/include/mysql_com.h create mode 100644 3rdparty/mysql/include/mysql_time.h create mode 100644 3rdparty/mysql/include/mysql_version.h create mode 100644 3rdparty/mysql/include/raid.h create mode 100644 3rdparty/mysql/include/typelib.h create mode 100644 3rdparty/mysql/lib/libmysql.lib create mode 100644 3rdparty/mysql/mysql-5.0.20 create mode 100644 3rdparty/pcre/include/pcre.h create mode 100644 3rdparty/pcre/lib/pcre.lib create mode 100644 3rdparty/pcre/pcre-7.0 create mode 100644 3rdparty/zlib/include/zconf.h create mode 100644 3rdparty/zlib/include/zlib.h create mode 100644 3rdparty/zlib/lib/zdll.lib create mode 100644 3rdparty/zlib/zlib-1.2.3 delete mode 100644 conf/GM_account.txt delete mode 100644 lib/libmysql.lib delete mode 100644 lib/mysql-5.0.20 delete mode 100644 lib/pcre-7.0 delete mode 100644 lib/pcre.lib delete mode 100644 lib/zdll.lib delete mode 100644 lib/zlib-1.2.3 create mode 100644 sql-files/upgrade_svn12975.sql create mode 100644 sql-files/upgrade_svn12975_log.sql create mode 100644 sql-files/upgrade_svn12975_view.sql create mode 100644 src/login/account.h create mode 100644 src/login/account_sql.c create mode 100644 src/login/account_txt.c create mode 100644 src/login/ipban.h create mode 100644 src/login/ipban_sql.c create mode 100644 src/login/ipban_txt.c create mode 100644 src/login/loginlog.h create mode 100644 src/login/loginlog_sql.c create mode 100644 src/login/loginlog_txt.c delete mode 100644 src/login_sql/Makefile.in delete mode 100644 src/login_sql/login.c delete mode 100644 src/login_sql/login.h delete mode 100644 src/map/pcre.h delete mode 100644 src/mysql/config-win.h delete mode 100644 src/mysql/m_ctype.h delete mode 100644 src/mysql/my_alloc.h delete mode 100644 src/mysql/my_dbug.h delete mode 100644 src/mysql/my_global.h delete mode 100644 src/mysql/my_list.h delete mode 100644 src/mysql/my_pthread.h delete mode 100644 src/mysql/my_sys.h delete mode 100644 src/mysql/mysql-5.0.20 delete mode 100644 src/mysql/mysql.h delete mode 100644 src/mysql/mysql_com.h delete mode 100644 src/mysql/mysql_time.h delete mode 100644 src/mysql/mysql_version.h delete mode 100644 src/mysql/raid.h delete mode 100644 src/mysql/typelib.h delete mode 100644 src/zlib/zconf.h delete mode 100644 src/zlib/zlib-1.2.3 delete mode 100644 src/zlib/zlib.h delete mode 100644 tools/cgi/addaccount.cgi delete mode 100644 tools/ladmin (limited to 'configure') diff --git a/3rdparty/mysql/include/config-win.h b/3rdparty/mysql/include/config-win.h new file mode 100644 index 000000000..b2e1c9831 --- /dev/null +++ b/3rdparty/mysql/include/config-win.h @@ -0,0 +1,470 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* Defines for Win32 to make it compatible for MySQL */ + +#ifdef __WIN2000__ +/* We have to do this define before including windows.h to get the AWE API +functions */ +#define _WIN32_WINNT 0x0500 +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1400 +/* Avoid endless warnings about sprintf() etc. being unsafe. */ +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +#include +#include +#include /* Because of rint() */ +#include +#include +#include + +#define HAVE_SMEM 1 + +#if defined(_WIN64) || defined(WIN64) +#define SYSTEM_TYPE "Win64" +#elif defined(_WIN32) || defined(WIN32) +#define SYSTEM_TYPE "Win32" +#else +#define SYSTEM_TYPE "Windows" +#endif + +#if defined(_M_IA64) +#define MACHINE_TYPE "ia64" +#elif defined(_M_IX86) +#define MACHINE_TYPE "ia32" +#elif defined(_M_ALPHA) +#define MACHINE_TYPE "axp" +#else +#define MACHINE_TYPE "unknown" /* Define to machine type name */ +#endif + +#if !(defined(_WIN64) || defined(WIN64)) +#ifndef _WIN32 +#define _WIN32 /* Compatible with old source */ +#endif +#ifndef __WIN32__ +#define __WIN32__ +#endif +#endif /* _WIN64 */ +#ifndef __WIN__ +#define __WIN__ /* To make it easier in VC++ */ +#endif + +#ifndef MAX_INDEXES +#define MAX_INDEXES 64 +#endif + +/* File and lock constants */ +#define O_SHARE 0x1000 /* Open file in sharing mode */ +#ifdef __BORLANDC__ +#define F_RDLCK LK_NBLCK /* read lock */ +#define F_WRLCK LK_NBRLCK /* write lock */ +#define F_UNLCK LK_UNLCK /* remove lock(s) */ +#else +#define F_RDLCK _LK_NBLCK /* read lock */ +#define F_WRLCK _LK_NBRLCK /* write lock */ +#define F_UNLCK _LK_UNLCK /* remove lock(s) */ +#endif + +#define F_EXCLUSIVE 1 /* We have only exclusive locking */ +#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ +#define F_OK 0 /* parameter to access() */ +#define W_OK 2 + +#define S_IROTH S_IREAD /* for my_lib */ + +#ifdef __BORLANDC__ +#define FILE_BINARY O_BINARY /* my_fopen in binary mode */ +#define O_TEMPORARY 0 +#define O_SHORT_LIVED 0 +#define SH_DENYNO _SH_DENYNO +#else +#define O_BINARY _O_BINARY /* compability with MSDOS */ +#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */ +#define O_TEMPORARY _O_TEMPORARY +#define O_SHORT_LIVED _O_SHORT_LIVED +#define SH_DENYNO _SH_DENYNO +#endif +#define NO_OPEN_3 /* For my_create() */ + +#define SIGQUIT SIGTERM /* No SIGQUIT */ + +#undef _REENTRANT /* Crashes something for win32 */ +#undef SAFE_MUTEX /* Can't be used on windows */ + +#if defined(_MSC_VER) && _MSC_VER >= 1310 +#define LL(A) A##ll +#define ULL(A) A##ull +#else +#define LL(A) ((__int64) A) +#define ULL(A) ((unsigned __int64) A) +#endif + +#define LONGLONG_MIN LL(0x8000000000000000) +#define LONGLONG_MAX LL(0x7FFFFFFFFFFFFFFF) +#define ULONGLONG_MAX ULL(0xFFFFFFFFFFFFFFFF) + +/* Type information */ + +#if defined(__EMX__) || !defined(HAVE_UINT) +#undef HAVE_UINT +#define HAVE_UINT +typedef unsigned short ushort; +typedef unsigned int uint; +#endif /* defined(__EMX__) || !defined(HAVE_UINT) */ + +typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ +typedef __int64 longlong; +#ifndef HAVE_SIGSET_T +typedef int sigset_t; +#endif +#define longlong_defined +/* + off_t should not be __int64 because of conflicts in header files; + Use my_off_t or os_off_t instead +*/ +#ifndef HAVE_OFF_T +typedef long off_t; +#endif +typedef __int64 os_off_t; +#ifdef _WIN64 +typedef UINT_PTR rf_SetTimer; +#else +#ifndef HAVE_SIZE_T +typedef unsigned int size_t; +#endif +typedef uint rf_SetTimer; +#endif + +#define Socket_defined +#define my_socket SOCKET +#define bool BOOL +#define SIGPIPE SIGINT +#define RETQSORTTYPE void +#define QSORT_TYPE_IS_VOID +#define RETSIGTYPE void +#define SOCKET_SIZE_TYPE int +#define my_socket_defined +#define bool_defined +#define byte_defined +#define HUGE_PTR +#define STDCALL __stdcall /* Used by libmysql.dll */ +#define isnan(X) _isnan(X) +#define finite(X) _finite(X) + +#ifndef UNDEF_THREAD_HACK +#define THREAD +#endif +#define VOID_SIGHANDLER +#define SIZEOF_CHAR 1 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_OFF_T 8 +#ifdef _WIN64 +#define SIZEOF_CHARP 8 +#else +#define SIZEOF_CHARP 4 +#endif +#define HAVE_BROKEN_NETINET_INCLUDES +#ifdef __NT__ +#define HAVE_NAMED_PIPE /* We can only create pipes on NT */ +#endif + +/* ERROR is defined in wingdi.h */ +#undef ERROR + +/* We need to close files to break connections on shutdown */ +#ifndef SIGNAL_WITH_VIO_CLOSE +#define SIGNAL_WITH_VIO_CLOSE +#endif + +/* Use all character sets in MySQL */ +#define USE_MB 1 +#define USE_MB_IDENT 1 +#define USE_STRCOLL 1 + +/* All windows servers should support .sym files */ +#undef USE_SYMDIR +#define USE_SYMDIR + +/* If LOAD DATA LOCAL INFILE should be enabled by default */ +#define ENABLED_LOCAL_INFILE 1 + +/* Convert some simple functions to Posix */ + +#define my_sigset(A,B) signal((A),(B)) +#define finite(A) _finite(A) +#define sleep(A) Sleep((A)*1000) +#define popen(A,B) _popen((A),(B)) +#define pclose(A) _pclose(A) + +#ifndef __BORLANDC__ +#define access(A,B) _access(A,B) +#endif + +#if !defined(__cplusplus) +#define inline __inline +#endif /* __cplusplus */ + +inline double rint(double nr) +{ + double f = floor(nr); + double c = ceil(nr); + return (((c-nr) >= (nr-f)) ? f :c); +} + +#ifdef _WIN64 +#define ulonglong2double(A) ((double) (ulonglong) (A)) +#define my_off_t2double(A) ((double) (my_off_t) (A)) + +#else +inline double ulonglong2double(ulonglong value) +{ + longlong nr=(longlong) value; + if (nr >= 0) + return (double) nr; + return (18446744073709551616.0 + (double) nr); +} +#define my_off_t2double(A) ulonglong2double(A) +#endif /* _WIN64 */ + +#if SIZEOF_OFF_T > 4 +#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) +#define tell(A) _telli64(A) +#endif + +#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } + +#define STACK_DIRECTION -1 + +/* Optimized store functions for Intel x86 */ + +#ifndef _WIN64 +#define sint2korr(A) (*((int16 *) (A))) +#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ + (((uint32) 255L << 24) | \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0])) : \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0]))) +#define sint4korr(A) (*((long *) (A))) +#define uint2korr(A) (*((uint16 *) (A))) +/* + ATTENTION ! + + Please, note, uint3korr reads 4 bytes (not 3) ! + It means, that you have to provide enough allocated space ! +*/ +#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) +#define uint4korr(A) (*((unsigned long *) (A))) +#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16) +\ + (((uint32) ((uchar) (A)[3])) << 24)) +\ + (((ulonglong) ((uchar) (A)[4])) << 32)) +#define uint8korr(A) (*((ulonglong *) (A))) +#define sint8korr(A) (*((longlong *) (A))) +#define int2store(T,A) *((uint16*) (T))= (uint16) (A) +#define int3store(T,A) { *(T)= (uchar) ((A));\ + *(T+1)=(uchar) (((uint) (A) >> 8));\ + *(T+2)=(uchar) (((A) >> 16)); } +#define int4store(T,A) *((long *) (T))= (long) (A) +#define int5store(T,A) { *(T)= (uchar)((A));\ + *((T)+1)=(uchar) (((A) >> 8));\ + *((T)+2)=(uchar) (((A) >> 16));\ + *((T)+3)=(uchar) (((A) >> 24)); \ + *((T)+4)=(uchar) (((A) >> 32)); } +#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) + +#define doubleget(V,M) do { *((long *) &V) = *((long*) M); \ + *(((long *) &V)+1) = *(((long*) M)+1); } while(0) +#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \ + *(((long *) T)+1) = *(((long*) &V)+1); } while(0) +#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } +#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) +#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float)) +#define float8get(V,M) doubleget((V),(M)) +#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) +#define float8store(V,M) doublestore((V),(M)) +#endif /* _WIN64 */ + +#define HAVE_PERROR +#define HAVE_VFPRINT +#define HAVE_RENAME /* Have rename() as function */ +#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */ +#define HAVE_LONG_JMP /* Have long jump function */ +#define HAVE_LOCKING /* have locking() call */ +#define HAVE_ERRNO_AS_DEFINE /* errno is a define */ +#define HAVE_STDLIB /* everything is include in this file */ +#define HAVE_MEMCPY +#define HAVE_MEMMOVE +#define HAVE_GETCWD +#define HAVE_TELL +#define HAVE_TZNAME +#define HAVE_PUTENV +#define HAVE_SELECT +#define HAVE_SETLOCALE +#define HAVE_SOCKET /* Giangi */ +#define HAVE_FLOAT_H +#define HAVE_LIMITS_H +#define HAVE_STDDEF_H +#define HAVE_RINT /* defined in this file */ +#define NO_FCNTL_NONBLOCK /* No FCNTL */ +#define HAVE_ALLOCA +#define HAVE_STRPBRK +#define HAVE_STRSTR +#define HAVE_COMPRESS +#define HAVE_CREATESEMAPHORE +#define HAVE_ISNAN +#define HAVE_FINITE +#define HAVE_QUERY_CACHE +#define SPRINTF_RETURNS_INT +#define HAVE_SETFILEPOINTER +#define HAVE_VIO_READ_BUFF +#define HAVE_STRNLEN + +#ifndef __NT__ +#undef FILE_SHARE_DELETE +#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */ +#endif + +#ifdef NOT_USED +#define HAVE_SNPRINTF /* Gave link error */ +#define _snprintf snprintf +#endif + +#ifdef _MSC_VER +#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ +#define HAVE_ANSI_INCLUDE +#define HAVE_SYS_UTIME_H +#define HAVE_STRTOUL +#endif +#define my_reinterpret_cast(A) reinterpret_cast +#define my_const_cast(A) const_cast + + +/* MYSQL OPTIONS */ + +#ifdef _CUSTOMCONFIG_ +#include +#else +#define DEFAULT_MYSQL_HOME "c:\\mysql" +#define PACKAGE "mysql" +#define DEFAULT_BASEDIR "C:\\" +#define SHAREDIR "share" +#define DEFAULT_CHARSET_HOME "C:/mysql/" +#endif +#ifndef DEFAULT_HOME_ENV +#define DEFAULT_HOME_ENV MYSQL_HOME +#endif +#ifndef DEFAULT_GROUP_SUFFIX_ENV +#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX +#endif + +/* File name handling */ + +#define FN_LIBCHAR '\\' +#define FN_ROOTDIR "\\" +#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ +#define FN_NO_CASE_SENCE /* Files are not case-sensitive */ +#define OS_FILE_LIMIT 2048 + +#define DO_NOT_REMOVE_THREAD_WRAPPERS +#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V)) +#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V)) +/* The following is only used for statistics, so it should be good enough */ +#ifdef __NT__ /* This should also work on Win98 but .. */ +#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) +#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C)) +#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) +#else +#define thread_safe_add(V,C,L) \ + pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L)); +#define thread_safe_sub(V,C,L) \ + pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L)); +#define statistic_add(V,C,L) (V)+=(C) +#endif +#define statistic_increment(V,L) thread_safe_increment((V),(L)) +#define statistic_decrement(V,L) thread_safe_decrement((V),(L)) + +#define shared_memory_buffer_length 16000 +#define default_shared_memory_base_name "MYSQL" + +#ifdef CYBOZU +#define MYSQL_DEFAULT_CHARSET_NAME "utf8" +#define MYSQL_DEFAULT_COLLATION_NAME "utf8_general_cs" +#define HAVE_UTF8_GENERAL_CS 1 +#else +#define MYSQL_DEFAULT_CHARSET_NAME "latin1" +#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" +#endif + +#define HAVE_SPATIAL 1 +#define HAVE_RTREE_KEYS 1 + +#define HAVE_OPENSSL 1 +#define HAVE_YASSL 1 + +/* Define charsets you want */ +/* #undef HAVE_CHARSET_armscii8 */ +/* #undef HAVE_CHARSET_ascii */ +#ifndef CYBOZU +#define HAVE_CHARSET_big5 1 +#define HAVE_CHARSET_cp1250 1 +#endif +/* #undef HAVE_CHARSET_cp1251 */ +/* #undef HAVE_CHARSET_cp1256 */ +/* #undef HAVE_CHARSET_cp1257 */ +/* #undef HAVE_CHARSET_cp850 */ +/* #undef HAVE_CHARSET_cp852 */ +/* #undef HAVE_CHARSET_cp866 */ +#define HAVE_CHARSET_cp932 1 +/* #undef HAVE_CHARSET_dec8 */ +#ifndef CYBOZU +#define HAVE_CHARSET_eucjpms 1 +#define HAVE_CHARSET_euckr 1 +#define HAVE_CHARSET_gb2312 1 +#define HAVE_CHARSET_gbk 1 +#endif +/* #undef HAVE_CHARSET_greek */ +/* #undef HAVE_CHARSET_hebrew */ +/* #undef HAVE_CHARSET_hp8 */ +/* #undef HAVE_CHARSET_keybcs2 */ +/* #undef HAVE_CHARSET_koi8r */ +/* #undef HAVE_CHARSET_koi8u */ +#ifndef CYBOZU +#define HAVE_CHARSET_latin1 1 +#define HAVE_CHARSET_latin2 1 +#endif +/* #undef HAVE_CHARSET_latin5 */ +/* #undef HAVE_CHARSET_latin7 */ +/* #undef HAVE_CHARSET_macce */ +/* #undef HAVE_CHARSET_macroman */ +#define HAVE_CHARSET_sjis 1 +/* #undef HAVE_CHARSET_swe7 */ +#ifndef CYBOZU +#define HAVE_CHARSET_tis620 1 +#define HAVE_CHARSET_ucs2 1 +#define HAVE_CHARSET_ujis 1 +#endif +#define HAVE_CHARSET_utf8 1 +#define HAVE_UCA_COLLATIONS 1 + diff --git a/3rdparty/mysql/include/m_ctype.h b/3rdparty/mysql/include/m_ctype.h new file mode 100644 index 000000000..54ae41bf2 --- /dev/null +++ b/3rdparty/mysql/include/m_ctype.h @@ -0,0 +1,493 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + A better inplementation of the UNIX ctype(3) library. + Notes: my_global.h should be included before ctype.h +*/ + +#ifndef _m_ctype_h +#define _m_ctype_h + +#ifdef __cplusplus +extern "C" { +#endif + +#define MY_CS_NAME_SIZE 32 +#define MY_CS_CTYPE_TABLE_SIZE 257 +#define MY_CS_TO_LOWER_TABLE_SIZE 256 +#define MY_CS_TO_UPPER_TABLE_SIZE 256 +#define MY_CS_SORT_ORDER_TABLE_SIZE 256 +#define MY_CS_TO_UNI_TABLE_SIZE 256 + +#define CHARSET_DIR "charsets/" + +#define my_wc_t ulong + +typedef struct unicase_info_st +{ + uint16 toupper; + uint16 tolower; + uint16 sort; +} MY_UNICASE_INFO; + + +extern MY_UNICASE_INFO *my_unicase_default[256]; +extern MY_UNICASE_INFO *my_unicase_turkish[256]; + + +/* wm_wc and wc_mb return codes */ +#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */ +#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */ +#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */ +#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */ +#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */ +/* These following three are currently not really used */ +#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */ +#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */ +#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */ +/* A helper macros for "need at least n bytes" */ +#define MY_CS_TOOSMALLN(n) (-100-(n)) + +#define MY_SEQ_INTTAIL 1 +#define MY_SEQ_SPACES 2 + + /* My charsets_list flags */ +#define MY_CS_COMPILED 1 /* compiled-in sets */ +#define MY_CS_CONFIG 2 /* sets that have a *.conf file */ +#define MY_CS_INDEX 4 /* sets listed in the Index file */ +#define MY_CS_LOADED 8 /* sets that are currently loaded */ +#define MY_CS_BINSORT 16 /* if binary sort order */ +#define MY_CS_PRIMARY 32 /* if primary collation */ +#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ +#define MY_CS_UNICODE 128 /* is a charset is full unicode */ +#define MY_CS_READY 256 /* if a charset is initialized */ +#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ +#define MY_CS_CSSORT 1024 /* if case sensitive sort order */ +#define MY_CHARSET_UNDEFINED 0 + + +typedef struct my_uni_idx_st +{ + uint16 from; + uint16 to; + uchar *tab; +} MY_UNI_IDX; + +typedef struct +{ + uint beg; + uint end; + uint mblen; +} my_match_t; + +enum my_lex_states +{ + MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, + MY_LEX_IDENT_SEP, MY_LEX_IDENT_START, + MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER, + MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END, + MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL, + MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, + MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, + MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, + MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR, + MY_LEX_IDENT_OR_KEYWORD, + MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR, + MY_LEX_STRING_OR_DELIMITER +}; + +struct charset_info_st; + +typedef struct my_collation_handler_st +{ + my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); + /* Collation routines */ + int (*strnncoll)(struct charset_info_st *, + const uchar *, uint, const uchar *, uint, my_bool); + int (*strnncollsp)(struct charset_info_st *, + const uchar *, uint, const uchar *, uint, + my_bool diff_if_only_endspace_difference); + int (*strnxfrm)(struct charset_info_st *, + uchar *, uint, const uchar *, uint); + uint (*strnxfrmlen)(struct charset_info_st *, uint); + my_bool (*like_range)(struct charset_info_st *, + const char *s, uint s_length, + pchar w_prefix, pchar w_one, pchar w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_len, uint *max_len); + int (*wildcmp)(struct charset_info_st *, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape,int w_one, int w_many); + + int (*strcasecmp)(struct charset_info_st *, const char *, const char *); + + uint (*instr)(struct charset_info_st *, + const char *b, uint b_length, + const char *s, uint s_length, + my_match_t *match, uint nmatch); + + /* Hash calculation */ + void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len, + ulong *nr1, ulong *nr2); + my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len); +} MY_COLLATION_HANDLER; + +extern MY_COLLATION_HANDLER my_collation_mb_bin_handler; +extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; +extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; +extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; + + +typedef struct my_charset_handler_st +{ + my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); + /* Multibyte routines */ + int (*ismbchar)(struct charset_info_st *, const char *, const char *); + int (*mbcharlen)(struct charset_info_st *, uint); + uint (*numchars)(struct charset_info_st *, const char *b, const char *e); + uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); + uint (*well_formed_len)(struct charset_info_st *, + const char *b,const char *e, + uint nchars, int *error); + uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); + uint (*numcells)(struct charset_info_st *, const char *b, const char *e); + + /* Unicode convertion */ + int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc, + const unsigned char *s,const unsigned char *e); + int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc, + unsigned char *s,unsigned char *e); + + /* Functions for case and sort convertion */ + void (*caseup_str)(struct charset_info_st *, char *); + void (*casedn_str)(struct charset_info_st *, char *); + uint (*caseup)(struct charset_info_st *, char *src, uint srclen, + char *dst, uint dstlen); + uint (*casedn)(struct charset_info_st *, char *src, uint srclen, + char *dst, uint dstlen); + + /* Charset dependant snprintf() */ + int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, + ...); + int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, + long int val); + int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, + int radix, longlong val); + + void (*fill)(struct charset_info_st *, char *to, uint len, int fill); + + /* String-to-number convertion routines */ + long (*strntol)(struct charset_info_st *, const char *s, uint l, + int base, char **e, int *err); + ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, + int base, char **e, int *err); + longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, + int base, char **e, int *err); + ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, + int base, char **e, int *err); + double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, + int *err); + longlong (*strtoll10)(struct charset_info_st *cs, + const char *nptr, char **endptr, int *error); + ulong (*scan)(struct charset_info_st *, const char *b, const char *e, + int sq); +} MY_CHARSET_HANDLER; + +extern MY_CHARSET_HANDLER my_charset_8bit_handler; +extern MY_CHARSET_HANDLER my_charset_ucs2_handler; + + +typedef struct charset_info_st +{ + uint number; + uint primary_number; + uint binary_number; + uint state; + const char *csname; + const char *name; + const char *comment; + const char *tailoring; + uchar *ctype; + uchar *to_lower; + uchar *to_upper; + uchar *sort_order; + uint16 *contractions; + uint16 **sort_order_big; + uint16 *tab_to_uni; + MY_UNI_IDX *tab_from_uni; + MY_UNICASE_INFO **caseinfo; + uchar *state_map; + uchar *ident_map; + uint strxfrm_multiply; + uchar caseup_multiply; + uchar casedn_multiply; + uint mbminlen; + uint mbmaxlen; + uint16 min_sort_char; + uint16 max_sort_char; /* For LIKE optimization */ + uchar pad_char; + my_bool escape_with_backslash_is_dangerous; + + MY_CHARSET_HANDLER *cset; + MY_COLLATION_HANDLER *coll; + +} CHARSET_INFO; + + +extern CHARSET_INFO my_charset_bin; +extern CHARSET_INFO my_charset_big5_chinese_ci; +extern CHARSET_INFO my_charset_big5_bin; +extern CHARSET_INFO my_charset_cp932_japanese_ci; +extern CHARSET_INFO my_charset_cp932_bin; +extern CHARSET_INFO my_charset_eucjpms_japanese_ci; +extern CHARSET_INFO my_charset_eucjpms_bin; +extern CHARSET_INFO my_charset_euckr_korean_ci; +extern CHARSET_INFO my_charset_euckr_bin; +extern CHARSET_INFO my_charset_gb2312_chinese_ci; +extern CHARSET_INFO my_charset_gb2312_bin; +extern CHARSET_INFO my_charset_gbk_chinese_ci; +extern CHARSET_INFO my_charset_gbk_bin; +extern CHARSET_INFO my_charset_latin1; +extern CHARSET_INFO my_charset_latin1_german2_ci; +extern CHARSET_INFO my_charset_latin1_bin; +extern CHARSET_INFO my_charset_latin2_czech_ci; +extern CHARSET_INFO my_charset_sjis_japanese_ci; +extern CHARSET_INFO my_charset_sjis_bin; +extern CHARSET_INFO my_charset_tis620_thai_ci; +extern CHARSET_INFO my_charset_tis620_bin; +extern CHARSET_INFO my_charset_ucs2_general_ci; +extern CHARSET_INFO my_charset_ucs2_bin; +extern CHARSET_INFO my_charset_ucs2_general_uca; +extern CHARSET_INFO my_charset_ujis_japanese_ci; +extern CHARSET_INFO my_charset_ujis_bin; +extern CHARSET_INFO my_charset_utf8_general_ci; +extern CHARSET_INFO my_charset_utf8_bin; +extern CHARSET_INFO my_charset_cp1250_czech_ci; + +/* declarations for simple charsets */ +extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, + uint); +uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); +extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, + const uchar *, uint, my_bool); + +extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint, + const uchar *, uint, + my_bool diff_if_only_endspace_difference); + +extern void my_hash_sort_simple(CHARSET_INFO *cs, + const uchar *key, uint len, + ulong *nr1, ulong *nr2); + +extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length); + +extern uint my_instr_simple(struct charset_info_st *, + const char *b, uint b_length, + const char *s, uint s_length, + my_match_t *match, uint nmatch); + + +/* Functions for 8bit */ +extern void my_caseup_str_8bit(CHARSET_INFO *, char *); +extern void my_casedn_str_8bit(CHARSET_INFO *, char *); +extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen, + char *dst, uint dstlen); +extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen, + char *dst, uint dstlen); + +extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *); + +int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e); +int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e); + +ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); + +int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, + const char *fmt, ...); + +long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, + char **e, int *err); +ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base, + char **e, int *err); +longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base, + char **e, int *err); +ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base, + char **e, int *err); +double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e, + int *err); +int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, + long int val); +int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, + longlong val); + +longlong my_strtoll10_8bit(CHARSET_INFO *cs, + const char *nptr, char **endptr, int *error); +longlong my_strtoll10_ucs2(CHARSET_INFO *cs, + const char *nptr, char **endptr, int *error); + +void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); + +my_bool my_like_range_simple(CHARSET_INFO *cs, + const char *ptr, uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_length, uint *max_length); + +my_bool my_like_range_mb(CHARSET_INFO *cs, + const char *ptr, uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_length, uint *max_length); + +my_bool my_like_range_ucs2(CHARSET_INFO *cs, + const char *ptr, uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_length, uint *max_length); + + +int my_wildcmp_8bit(CHARSET_INFO *, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many); + +int my_wildcmp_bin(CHARSET_INFO *, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many); + +uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); +uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); +uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, + uint pos, int *error); +int my_mbcharlen_8bit(CHARSET_INFO *, uint c); + + +/* Functions for multibyte charsets */ +extern void my_caseup_str_mb(CHARSET_INFO *, char *); +extern void my_casedn_str_mb(CHARSET_INFO *, char *); +extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen, + char *dst, uint dstlen); +extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen, + char *dst, uint dstlen); +extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *); + +int my_wildcmp_mb(CHARSET_INFO *, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many); +uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); +uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); +uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, + uint pos, int *error); +uint my_instr_mb(struct charset_info_st *, + const char *b, uint b_length, + const char *s, uint s_length, + my_match_t *match, uint nmatch); + +int my_wildcmp_unicode(CHARSET_INFO *cs, + const char *str, const char *str_end, + const char *wildstr, const char *wildend, + int escape, int w_one, int w_many, + MY_UNICASE_INFO **weights); + +extern my_bool my_parse_charset_xml(const char *bug, uint len, + int (*add)(CHARSET_INFO *cs)); + +my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len); +my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); + + +#define _MY_U 01 /* Upper case */ +#define _MY_L 02 /* Lower case */ +#define _MY_NMR 04 /* Numeral (digit) */ +#define _MY_SPC 010 /* Spacing character */ +#define _MY_PNT 020 /* Punctuation */ +#define _MY_CTR 040 /* Control character */ +#define _MY_B 0100 /* Blank */ +#define _MY_X 0200 /* heXadecimal digit */ + + +#define my_isascii(c) (!((c) & ~0177)) +#define my_toascii(c) ((c) & 0177) +#define my_tocntrl(c) ((c) & 31) +#define my_toprint(c) ((c) | 64) +#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)]) +#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)]) +#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L)) +#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U) +#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L) +#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR) +#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X) +#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR)) +#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC) +#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT) +#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B)) +#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR)) +#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR) + +/* Some macros that should be cleaned up a little */ +#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_') +#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_') + +#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT) +#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM) +#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d))) +#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0)) +#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \ + ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j))) +#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m))) +#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b))) +#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num)) + + +#define use_mb(s) ((s)->cset->ismbchar != NULL) +#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b))) +#ifdef USE_MB +#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a))) +#else +#define my_mbcharlen(s, a) 1 +#endif + +#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a))) +#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a))) +#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e))) +#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e))) +#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e))) +#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e))) +#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d))) + + +/* XXX: still need to take care of this one */ +#ifdef MY_CHARSET_TIS620 +#error The TIS620 charset is broken at the moment. Tell tim to fix it. +#define USE_TIS620 +#include "t_ctype.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _m_ctype_h */ diff --git a/3rdparty/mysql/include/my_alloc.h b/3rdparty/mysql/include/my_alloc.h new file mode 100644 index 000000000..1641b3acf --- /dev/null +++ b/3rdparty/mysql/include/my_alloc.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + Data structures for mysys/my_alloc.c (root memory allocator) +*/ + +#ifndef _my_alloc_h +#define _my_alloc_h + +#define ALLOC_MAX_BLOCK_TO_DROP 4096 +#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 + +typedef struct st_used_mem +{ /* struct for once_alloc (block) */ + struct st_used_mem *next; /* Next block in use */ + unsigned int left; /* memory left in block */ + unsigned int size; /* size of block */ +} USED_MEM; + + +typedef struct st_mem_root +{ + USED_MEM *free; /* blocks with free memory in it */ + USED_MEM *used; /* blocks almost without free memory */ + USED_MEM *pre_alloc; /* preallocated block */ + /* if block have less memory it will be put in 'used' list */ + unsigned int min_malloc; + unsigned int block_size; /* initial block size */ + unsigned int block_num; /* allocated blocks counter */ + /* + first free block in queue test counter (if it exceed + MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) + */ + unsigned int first_block_usage; + + void (*error_handler)(void); +} MEM_ROOT; +#endif diff --git a/3rdparty/mysql/include/my_dbug.h b/3rdparty/mysql/include/my_dbug.h new file mode 100644 index 000000000..b76a3fcc8 --- /dev/null +++ b/3rdparty/mysql/include/my_dbug.h @@ -0,0 +1,101 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _dbug_h +#define _dbug_h + +#ifdef __cplusplus +extern "C" { +#endif +#if !defined(DBUG_OFF) && !defined(_lint) +extern int _db_on_,_no_db_; +extern FILE *_db_fp_; +extern char *_db_process_; +extern int _db_keyword_(const char *keyword); +extern int _db_strict_keyword_(const char *keyword); +extern void _db_setjmp_(void); +extern void _db_longjmp_(void); +extern void _db_push_(const char *control); +extern void _db_pop_(void); +extern void _db_enter_(const char *_func_,const char *_file_,uint _line_, + const char **_sfunc_,const char **_sfile_, + uint *_slevel_, char ***); +extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_, + uint *_slevel_); +extern void _db_pargs_(uint _line_,const char *keyword); +extern void _db_doprnt_ _VARARGS((const char *format,...)); +extern void _db_dump_(uint _line_,const char *keyword,const char *memory, + uint length); +extern void _db_output_(uint flag); +extern void _db_lock_file(void); +extern void _db_unlock_file(void); + +#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \ + char **_db_framep_; \ + _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \ + &_db_framep_) +#define DBUG_LEAVE \ + (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)) +#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);} +#define DBUG_VOID_RETURN {DBUG_LEAVE; return;} +#define DBUG_EXECUTE(keyword,a1) \ + {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}} +#define DBUG_PRINT(keyword,arglist) \ + {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}} +#define DBUG_PUSH(a1) _db_push_ (a1) +#define DBUG_POP() _db_pop_ () +#define DBUG_PROCESS(a1) (_db_process_ = a1) +#define DBUG_FILE (_db_fp_) +#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1)) +#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2)) +#define DBUG_DUMP(keyword,a1,a2)\ + {if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}} +#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr) +#define DEBUGGER_OFF _no_db_=1;_db_on_=0; +#define DEBUGGER_ON _no_db_=0 +#define DBUG_LOCK_FILE { _db_lock_file(); } +#define DBUG_UNLOCK_FILE { _db_unlock_file(); } +#define DBUG_OUTPUT(A) { _db_output_(A); } +#define DBUG_ASSERT(A) assert(A) +#define DBUG_EXECUTE_IF(keyword,a1) \ + {if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}} +#else /* No debugger */ + +#define DBUG_ENTER(a1) +#define DBUG_RETURN(a1) return(a1) +#define DBUG_VOID_RETURN return +#define DBUG_EXECUTE(keyword,a1) {} +#define DBUG_EXECUTE_IF(keyword,a1) {} +#define DBUG_PRINT(keyword,arglist) {} +#define DBUG_PUSH(a1) {} +#define DBUG_POP() {} +#define DBUG_PROCESS(a1) {} +#define DBUG_FILE (stderr) +#define DBUG_SETJMP setjmp +#define DBUG_LONGJMP longjmp +#define DBUG_DUMP(keyword,a1,a2) {} +#define DBUG_IN_USE 0 +#define DEBUGGER_OFF +#define DEBUGGER_ON +#define DBUG_LOCK_FILE +#define DBUG_UNLOCK_FILE +#define DBUG_OUTPUT(A) +#define DBUG_ASSERT(A) {} +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/3rdparty/mysql/include/my_global.h b/3rdparty/mysql/include/my_global.h new file mode 100644 index 000000000..2417477e2 --- /dev/null +++ b/3rdparty/mysql/include/my_global.h @@ -0,0 +1,1306 @@ +/* Copyright (C) 2000-2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* This is the include file that should be included 'first' in every C file. */ + +#ifndef _global_h +#define _global_h + +#ifndef EMBEDDED_LIBRARY +#define HAVE_REPLICATION +#define HAVE_EXTERNAL_CLIENT +#endif + +#if defined( __EMX__) && !defined( MYSQL_SERVER) +/* moved here to use below VOID macro redefinition */ +#define INCL_BASE +#define INCL_NOPMAPI +#include +#endif /* __EMX__ */ + +#ifdef __CYGWIN__ +/* We use a Unix API, so pretend it's not Windows */ +#undef WIN +#undef WIN32 +#undef _WIN +#undef _WIN32 +#undef _WIN64 +#undef __WIN__ +#undef __WIN32__ +#define HAVE_ERRNO_AS_DEFINE +#endif /* __CYGWIN__ */ + +#if defined(__QNXNTO__) && !defined(FD_SETSIZE) +#define FD_SETSIZE 1024 /* Max number of file descriptor bits in + fd_set, used when calling 'select' + Must be defined before including + "sys/select.h" and "sys/time.h" + */ +#endif + + +/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */ +#ifdef USE_PRAGMA_IMPLEMENTATION +#define USE_PRAGMA_INTERFACE +#endif + +#if defined(i386) && !defined(__i386__) +#define __i386__ +#endif + +/* Macros to make switching between C and C++ mode easier */ +#ifdef __cplusplus +#define C_MODE_START extern "C" { +#define C_MODE_END } +#else +#define C_MODE_START +#define C_MODE_END +#endif + +#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) +#include +#elif defined(OS2) +#include +#elif defined(__NETWARE__) +#include +#include +#if defined(__cplusplus) && defined(inline) +#undef inline /* fix configure problem */ +#endif +#else +#include +#if defined(__cplusplus) && defined(inline) +#undef inline /* fix configure problem */ +#endif +#endif /* _WIN32... */ + +/* Some defines to avoid ifdefs in the code */ +#ifndef NETWARE_YIELD +#define NETWARE_YIELD +#define NETWARE_SET_SCREEN_MODE(A) +#endif + +#include "../common/strlib.h" + +/* + The macros below are borrowed from include/linux/compiler.h in the + Linux kernel. Use them to indicate the likelyhood of the truthfulness + of a condition. This serves two purposes - newer versions of gcc will be + able to optimize for branch predication, which could yield siginficant + performance gains in frequently executed sections of the code, and the + other reason to use them is for documentation +*/ + +#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +#define __builtin_expect(x, expected_value) (x) +#endif + +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) + + +/* Fix problem with S_ISLNK() on Linux */ +#if defined(TARGET_OS_LINUX) +#undef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +/* + Temporary solution to solve bug#7156. Include "sys/types.h" before + the thread headers, else the function madvise() will not be defined +*/ +#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) ) +#include +#endif + +/* The client defines this to avoid all thread code */ +#if defined(UNDEF_THREADS_HACK) +#undef THREAD +#undef HAVE_mit_thread +#undef HAVE_LINUXTHREADS +#undef HAVE_NPTL +#undef HAVE_UNIXWARE7_THREADS +#endif + +#ifdef HAVE_THREADS_WITHOUT_SOCKETS +/* MIT pthreads does not work with unix sockets */ +#undef HAVE_SYS_UN_H +#endif + +#define __EXTENSIONS__ 1 /* We want some extension */ +#ifndef __STDC_EXT__ +#define __STDC_EXT__ 1 /* To get large file support on hpux */ +#endif + +/* + Solaris 9 include file refers to X/Open document + + System Interfaces and Headers, Issue 5 + + saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes, + but apparently other systems (namely FreeBSD) don't agree. + + On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600. + Furthermore, it tests that if a program requires older standard + (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be + run on a new compiler (that defines _STDC_C99) and issues an #error. + It's also an #error if a program requires new standard (_XOPEN_SOURCE=600 + or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99. + + To add more to this mess, Sun Studio C compiler defines _STDC_C99 while + C++ compiler does not! + + So, in a desperate attempt to get correct prototypes for both + C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500 + depending on the compiler's announced C standard support. + + Cleaner solutions are welcome. +*/ +#ifdef __sun +#if __STDC_VERSION__ - 0 >= 199901L +#define _XOPEN_SOURCE 600 +#else +#define _XOPEN_SOURCE 500 +#endif +#endif + +#if defined(THREAD) && !defined(__WIN__) && !defined(OS2) +#ifndef _POSIX_PTHREAD_SEMANTICS +#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ +#endif + +#if !defined(SCO) +#define _REENTRANT 1 /* Some thread libraries require this */ +#endif +#if !defined(_THREAD_SAFE) && !defined(_AIX) +#define _THREAD_SAFE /* Required for OSF1 */ +#endif +#ifndef HAVE_mit_thread +#ifdef HAVE_UNIXWARE7_THREADS +#include +#else +#if defined(HPUX10) || defined(HPUX11) +C_MODE_START /* HPUX needs this, signal.h bug */ +#include +C_MODE_END +#else +#include /* AIX must have this included first */ +#endif +#endif /* HAVE_UNIXWARE7_THREADS */ +#endif /* HAVE_mit_thread */ +#if !defined(SCO) && !defined(_REENTRANT) +#define _REENTRANT 1 /* Threads requires reentrant code */ +#endif +#endif /* THREAD */ + +/* Go around some bugs in different OS and compilers */ +#ifdef _AIX /* By soren@t.dk */ +#define _H_STRINGS +#define _SYS_STREAM_H +/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */ +#define ulonglong2double(A) my_ulonglong2double(A) +#define my_off_t2double(A) my_ulonglong2double(A) +C_MODE_START +double my_ulonglong2double(unsigned long long A); +C_MODE_END +#endif /* _AIX */ + +#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ +#undef HAVE_SNPRINTF +#endif +#ifdef HAVE_BROKEN_PREAD +/* + pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without + installing the kernel patch PHKL_20349 or greater +*/ +#undef HAVE_PREAD +#undef HAVE_PWRITE +#endif +#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus) +#undef inline +#define inline +#endif + +#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */ +#undef HAVE_GETHOSTBYNAME_R +#endif +#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */ +#undef HAVE_INITGROUPS +#endif + +/* gcc/egcs issues */ + +#if defined(__GNUC) && defined(__EXCEPTIONS) +#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile" +#endif + + +/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */ +#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8) +#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */ +#define __LONG_MAX__ 2147483647 +#endif + +/* egcs 1.1.2 has a problem with memcpy on Alpha */ +#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) +#define BAD_MEMCPY +#endif + +#if defined(_lint) && !defined(lint) +#define lint +#endif +#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) +#define _LONG_LONG 1 /* For AIX string library */ +#endif + +#ifndef stdin +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STDDEF_H +#include +#endif + +#include +#ifdef HAVE_LIMITS_H +#include +#endif +#ifdef HAVE_FLOAT_H +#include +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_SYS_TIMEB_H +#include /* Avoid warnings on SCO */ +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif /* TIME_WITH_SYS_TIME */ +#ifdef HAVE_UNISTD_H +#include +#endif +#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) +#undef HAVE_ALLOCA +#undef HAVE_ALLOCA_H +#endif +#ifdef HAVE_ALLOCA_H +#include +#endif +#ifdef HAVE_ATOMIC_ADD +#define new my_arg_new +#define need_to_restore_new 1 +C_MODE_START +#include +C_MODE_END +#ifdef need_to_restore_new /* probably safer than #ifdef new */ +#undef new +#undef need_to_restore_new +#endif +#endif +#include /* Recommended by debian */ +/* We need the following to go around a problem with openssl on solaris */ +#if defined(HAVE_CRYPT_H) +#include +#endif + +/* + A lot of our programs uses asserts, so better to always include it + This also fixes a problem when people uses DBUG_ASSERT without including + assert.h +*/ +#include + +/* Go around some bugs in different OS and compilers */ +#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H) +#include /* HPUX 10.20 defines ulong here. UGLY !!! */ +#define HAVE_ULONG +#endif +#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ +#undef HAVE_FINITE +#endif +#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) +/* Fix bug in setrlimit */ +#undef setrlimit +#define setrlimit cma_setrlimit64 +#endif +/* Declare madvise where it is not declared for C++, like Solaris */ +#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus) +extern "C" int madvise(void *addr, size_t len, int behav); +#endif + +#ifdef __QNXNTO__ +/* This has to be after include limits.h */ +#define HAVE_ERRNO_AS_DEFINE +#define HAVE_FCNTL_LOCK +#undef HAVE_FINITE +#undef LONGLONG_MIN /* These get wrongly defined in QNX 6.2 */ +#undef LONGLONG_MAX /* standard system library 'limits.h' */ +#ifdef __cplusplus +#ifndef HAVE_RINT +#define HAVE_RINT +#endif /* rint() and isnan() functions are not */ +#define rint(a) std::rint(a) /* visible in C++ scope due to an error */ +#define isnan(a) std::isnan(a) /* in the usr/include/math.h on QNX */ +#endif +#endif + +/* We can not live without the following defines */ + +#define USE_MYFUNC 1 /* Must use syscall indirection */ +#define MASTER 1 /* Compile without unireg */ +#define ENGLISH 1 /* Messages in English */ +#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ +#define USE_REGEX 1 /* We want the use the regex library */ +/* Do not define for ultra sparcs */ +#ifndef OS2 +#define USE_BMOVE512 1 /* Use this unless system bmove is faster */ +#endif + +#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */ +#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */ + +/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */ +#ifdef I_AM_PARANOID +#define DONT_ALLOW_USER_CHANGE 1 +#define DONT_USE_MYSQL_PWD 1 +#endif + +/* Does the system remember a signal handler after a signal ? */ +#ifndef HAVE_BSD_SIGNALS +#define DONT_REMEMBER_SIGNAL +#endif + +/* Define void to stop lint from generating "null effekt" comments */ +#ifndef DONT_DEFINE_VOID +#ifdef _lint +int __void__; +#define VOID(X) (__void__ = (int) (X)) +#else +#undef VOID +#define VOID(X) (X) +#endif +#endif /* DONT_DEFINE_VOID */ + +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) +#define LINT_INIT(var) var=0 /* No uninitialize-warning */ +#else +#define LINT_INIT(var) +#endif + +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify) +#define PURIFY_OR_LINT_INIT(var) var=0 +#else +#define PURIFY_OR_LINT_INIT(var) +#endif + +/* Define some useful general macros */ +#if !defined(max) +#define max(a, b) ((a) > (b) ? (a) : (b)) +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#if defined(__EMX__) || !defined(HAVE_UINT) +#undef HAVE_UINT +#define HAVE_UINT +typedef unsigned int uint; +typedef unsigned short ushort; +#endif + +#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) +#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) +#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; } +#define test(a) ((a) ? 1 : 0) +#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) +#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) +#define test_all_bits(a,b) (((a) & (b)) == (b)) +#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) +#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) +#ifndef HAVE_RINT +#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5)) +#endif + +/* Define some general constants */ +#ifndef TRUE +#define TRUE (1) /* Logical true */ +#define FALSE (0) /* Logical false */ +#endif + +#if defined(__GNUC__) +#define function_volatile volatile +#define my_reinterpret_cast(A) reinterpret_cast +#define my_const_cast(A) const_cast +#elif !defined(my_reinterpret_cast) +#define my_reinterpret_cast(A) (A) +#define my_const_cast(A) (A) +#endif +#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +#define __attribute__(A) +#endif + +/* + Wen using the embedded library, users might run into link problems, + dupicate declaration of __cxa_pure_virtual, solved by declaring it a + weak symbol. +*/ +#ifdef USE_MYSYS_NEW +C_MODE_START +int __cxa_pure_virtual () __attribute__ ((weak)); +C_MODE_END +#endif + +/* From old s-system.h */ + +/* + Support macros for non ansi & other old compilers. Since such + things are no longer supported we do nothing. We keep then since + some of our code may still be needed to upgrade old customers. +*/ +#define _VARARGS(X) X +#define _STATIC_VARARGS(X) X +#define _PC(X) X + +#if defined(DBUG_ON) && defined(DBUG_OFF) +#undef DBUG_OFF +#endif + +#if defined(_lint) && !defined(DBUG_OFF) +#define DBUG_OFF +#endif + +#include + +#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ +#define ASCII_BITS_USED 8 /* Bit char used */ +#define NEAR_F /* No near function handling */ + +/* Some types that is different between systems */ + +typedef int File; /* File descriptor */ +#ifndef Socket_defined +typedef int my_socket; /* File descriptor for sockets */ +#define INVALID_SOCKET -1 +#endif +/* Type for fuctions that handles signals */ +#define sig_handler RETSIGTYPE +C_MODE_START +typedef void (*sig_return)();/* Returns type from signal */ +C_MODE_END +#if defined(__GNUC__) && !defined(_lint) +typedef char pchar; /* Mixed prototypes can take char */ +typedef char puchar; /* Mixed prototypes can take char */ +typedef char pbool; /* Mixed prototypes can take char */ +typedef short pshort; /* Mixed prototypes can take short int */ +typedef float pfloat; /* Mixed prototypes can take float */ +#else +typedef int pchar; /* Mixed prototypes can't take char */ +typedef uint puchar; /* Mixed prototypes can't take char */ +typedef int pbool; /* Mixed prototypes can't take char */ +typedef int pshort; /* Mixed prototypes can't take short int */ +typedef double pfloat; /* Mixed prototypes can't take float */ +#endif +C_MODE_START +typedef int (*qsort_cmp)(const void *,const void *); +typedef int (*qsort_cmp2)(void*, const void *,const void *); +C_MODE_END +#ifdef HAVE_mit_thread +#define qsort_t void +#undef QSORT_TYPE_IS_VOID +#define QSORT_TYPE_IS_VOID +#else +#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */ +#endif +#ifdef HAVE_mit_thread +#define size_socket socklen_t /* Type of last arg to accept */ +#else +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +typedef SOCKET_SIZE_TYPE size_socket; +#endif + +#ifndef SOCKOPT_OPTLEN_TYPE +#define SOCKOPT_OPTLEN_TYPE size_socket +#endif + +/* file create flags */ + +#ifndef O_SHARE /* Probably not windows */ +#define O_SHARE 0 /* Flag to my_open for shared files */ +#ifndef O_BINARY +#define O_BINARY 0 /* Flag to my_open for binary files */ +#endif +#ifndef FILE_BINARY +#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */ +#endif +#ifdef HAVE_FCNTL +#define HAVE_FCNTL_LOCK +#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ +#endif +#endif /* O_SHARE */ + +#ifndef O_TEMPORARY +#define O_TEMPORARY 0 +#endif +#ifndef O_SHORT_LIVED +#define O_SHORT_LIVED 0 +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 0 +#endif + +/* additional file share flags for win32 */ +#ifdef __WIN__ +#define _SH_DENYRWD 0x110 /* deny read/write mode & delete */ +#define _SH_DENYWRD 0x120 /* deny write mode & delete */ +#define _SH_DENYRDD 0x130 /* deny read mode & delete */ +#define _SH_DENYDEL 0x140 /* deny delete only */ +#endif /* __WIN__ */ + + +/* #define USE_RECORD_LOCK */ + + /* Unsigned types supported by the compiler */ +#define UNSINT8 /* unsigned int8 (char) */ +#define UNSINT16 /* unsigned int16 */ +#define UNSINT32 /* unsigned int32 */ + + /* General constants */ +#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */ +#define FN_LEN 256 /* Max file name len */ +#define FN_HEADLEN 253 /* Max length of filepart of file name */ +#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ +#define FN_REFLEN 512 /* Max length of full path-name */ +#define FN_EXTCHAR '.' +#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ +#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ +#define FN_PARENTDIR ".." /* Parent directory; Must be a string */ +#define FN_DEVCHAR ':' + +#ifndef FN_LIBCHAR +#ifdef __EMX__ +#define FN_LIBCHAR '\\' +#define FN_ROOTDIR "\\" +#else +#define FN_LIBCHAR '/' +#define FN_ROOTDIR "/" +#endif +#endif +#define MY_NFILE 64 /* This is only used to save filenames */ +#ifndef OS_FILE_LIMIT +#define OS_FILE_LIMIT 65535 +#endif + +/* #define EXT_IN_LIBNAME */ +/* #define FN_NO_CASE_SENCE */ +/* #define FN_UPPER_CASE TRUE */ + +/* + Io buffer size; Must be a power of 2 and a multiple of 512. May be + smaller what the disk page size. This influences the speed of the + isam btree library. eg to big to slow. +*/ +#define IO_SIZE 4096 +/* + How much overhead does malloc have. The code often allocates + something like 1024-MALLOC_OVERHEAD bytes +*/ +#ifdef SAFEMALLOC +#define MALLOC_OVERHEAD (8+24+4) +#else +#define MALLOC_OVERHEAD 8 +#endif + /* get memory in huncs */ +#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD) + /* Typical record cash */ +#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD) + /* Typical key cash */ +#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD) + /* Default size of a key cache block */ +#define KEY_CACHE_BLOCK_SIZE (uint) 1024 + + + /* Some things that this system doesn't have */ + +#define NO_HASH /* Not needed anymore */ +#ifdef __WIN__ +#define NO_DIR_LIBRARY /* Not standar dir-library */ +#define USE_MY_STAT_STRUCT /* For my_lib */ +#endif + +/* Some defines of functions for portability */ + +#undef remove /* Crashes MySQL on SCO 5.0.0 */ +#ifndef __WIN__ +#ifdef OS2 +#define closesocket(A) soclose(A) +#else +#define closesocket(A) close(A) +#endif +#ifndef ulonglong2double +#define ulonglong2double(A) ((double) (ulonglong) (A)) +#define my_off_t2double(A) ((double) (my_off_t) (A)) +#endif +#endif + +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif +#define ulong_to_double(X) ((double) (ulong) (X)) +#define SET_STACK_SIZE(X) /* Not needed on real machines */ + +#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R) +#define strtok_r(A,B,C) strtok((A),(B)) +#endif + +/* Remove some things that mit_thread break or doesn't support */ +#if defined(HAVE_mit_thread) && defined(THREAD) +#undef HAVE_PREAD +#undef HAVE_REALPATH +#undef HAVE_MLOCK +#undef HAVE_TEMPNAM /* Use ours */ +#undef HAVE_PTHREAD_SETPRIO +#undef HAVE_FTRUNCATE +#undef HAVE_READLINK +#endif + +/* This is from the old m-machine.h file */ + +#if SIZEOF_LONG_LONG > 4 +#define HAVE_LONG_LONG 1 +#endif + +/* + Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define + ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. + Also on Windows we define these constants by hand in config-win.h. +*/ + +#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) +#define LONGLONG_MIN ((long long) 0x8000000000000000LL) +#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) +#endif + +#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX) +/* First check for ANSI C99 definition: */ +#ifdef ULLONG_MAX +#define ULONGLONG_MAX ULLONG_MAX +#else +#define ULONGLONG_MAX ((unsigned long long)(~0ULL)) +#endif +#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/ + +#define INT_MIN32 (~0x7FFFFFFFL) +#define INT_MAX32 0x7FFFFFFFL +#define UINT_MAX32 0xFFFFFFFFL +#define INT_MIN24 (~0x007FFFFF) +#define INT_MAX24 0x007FFFFF +#define UINT_MAX24 0x00FFFFFF +#define INT_MIN16 (~0x7FFF) +#define INT_MAX16 0x7FFF +#define UINT_MAX16 0xFFFF +#define INT_MIN8 (~0x7F) +#define INT_MAX8 0x7F +#define UINT_MAX8 0xFF + +/* From limits.h instead */ +#ifndef DBL_MIN +#define DBL_MIN 4.94065645841246544e-324 +#define FLT_MIN ((float)1.40129846432481707e-45) +#endif +#ifndef DBL_MAX +#define DBL_MAX 1.79769313486231470e+308 +#define FLT_MAX ((float)3.40282346638528860e+38) +#endif + +#if !defined(HAVE_ISINF) && !defined(isinf) +#define isinf(X) 0 +#endif + +/* Define missing math constants. */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#ifndef M_E +#define M_E 2.7182818284590452354 +#endif +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif + +/* + Max size that must be added to a so that we know Size to make + adressable obj. +*/ +#if SIZEOF_CHARP == 4 +typedef long my_ptrdiff_t; +#else +typedef long long my_ptrdiff_t; +#endif + +#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) +#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) +/* Size to make adressable obj. */ +#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) + /* Offset of field f in structure t */ +#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) +#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) +#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) + +#define NullS (char *) 0 +/* Nowdays we do not support MessyDos */ +#ifndef NEAR +#define NEAR /* Who needs segments ? */ +#define FAR /* On a good machine */ +#ifndef HUGE_PTR +#define HUGE_PTR +#endif +#endif +#if defined(__IBMC__) || defined(__IBMCPP__) +/* This was _System _Export but caused a lot of warnings on _AIX43 */ +#define STDCALL +#elif !defined( STDCALL) +#define STDCALL +#endif + +/* Typdefs for easyier portability */ + +#if defined(VOIDTYPE) +typedef void *gptr; /* Generic pointer */ +#else +typedef char *gptr; /* Generic pointer */ +#endif +#ifndef HAVE_INT_8_16_32 +typedef signed char int8; /* Signed integer >= 8 bits */ +typedef short int16; /* Signed integer >= 16 bits */ +#endif +#ifndef HAVE_UCHAR +typedef unsigned char uchar; /* Short for unsigned char */ +#endif +typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */ +typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */ + +#if SIZEOF_INT == 4 +#ifndef HAVE_INT_8_16_32 +typedef int int32; +#endif +typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */ +#elif SIZEOF_LONG == 4 +#ifndef HAVE_INT_8_16_32 +typedef long int32; +#endif +typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */ +#else +#error "Neither int or long is of 4 bytes width" +#endif + +#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC) +typedef unsigned long ulong; /* Short for unsigned long */ +#endif +#ifndef longlong_defined +#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 +typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ +typedef long long int longlong; +#else +typedef unsigned long ulonglong; /* ulong or unsigned long long */ +typedef long longlong; +#endif +#endif + +#if defined(NO_CLIENT_LONG_LONG) +typedef unsigned long my_ulonglong; +#elif defined (__WIN__) +typedef unsigned __int64 my_ulonglong; +#else +typedef unsigned long long my_ulonglong; +#endif + +#ifdef USE_RAID +/* + The following is done with a if to not get problems with pre-processors + with late define evaluation +*/ +#if SIZEOF_OFF_T == 4 +#define SYSTEM_SIZEOF_OFF_T 4 +#else +#define SYSTEM_SIZEOF_OFF_T 8 +#endif +#undef SIZEOF_OFF_T +#define SIZEOF_OFF_T 8 +#else +#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T +#endif /* USE_RAID */ + +#if SIZEOF_OFF_T > 4 +typedef ulonglong my_off_t; +#else +typedef unsigned long my_off_t; +#endif +#define MY_FILEPOS_ERROR (~(my_off_t) 0) +#if !defined(__WIN__) && !defined(OS2) +typedef off_t os_off_t; +#endif + +#if defined(__WIN__) +#define socket_errno WSAGetLastError() +#define SOCKET_EINTR WSAEINTR +#define SOCKET_EAGAIN WSAEINPROGRESS +#define SOCKET_ETIMEDOUT WSAETIMEDOUT +#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK +#define SOCKET_EADDRINUSE WSAEADDRINUSE +#define SOCKET_ENFILE ENFILE +#define SOCKET_EMFILE EMFILE +#elif defined(OS2) +#define socket_errno sock_errno() +#define SOCKET_EINTR SOCEINTR +#define SOCKET_EAGAIN SOCEINPROGRESS +#define SOCKET_ETIMEDOUT SOCKET_EINTR +#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK +#define SOCKET_EADDRINUSE SOCEADDRINUSE +#define SOCKET_ENFILE SOCENFILE +#define SOCKET_EMFILE SOCEMFILE +#define closesocket(A) soclose(A) +#else /* Unix */ +#define socket_errno errno +#define closesocket(A) close(A) +#define SOCKET_EINTR EINTR +#define SOCKET_EAGAIN EAGAIN +#define SOCKET_ETIMEDOUT SOCKET_EINTR +#define SOCKET_EWOULDBLOCK EWOULDBLOCK +#define SOCKET_EADDRINUSE EADDRINUSE +#define SOCKET_ENFILE ENFILE +#define SOCKET_EMFILE EMFILE +#endif + +typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ +typedef short int15; /* Most effective integer 0 <= x <= 32767 */ +typedef char *my_string; /* String of characters */ +typedef unsigned long size_s; /* Size of strings (In string-funcs) */ +typedef int myf; /* Type of MyFlags in my_funcs */ +#ifndef byte_defined +typedef char byte; /* Smallest addressable unit */ +#endif +typedef char my_bool; /* Small bool */ +#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus)) +typedef char bool; /* Ordinary boolean values 0 1 */ +#endif + /* Macros for converting *constants* to the right type */ +#define INT8(v) (int8) (v) +#define INT16(v) (int16) (v) +#define INT32(v) (int32) (v) +#define MYF(v) (myf) (v) + +#ifndef LL +#ifdef HAVE_LONG_LONG +#define LL(A) A ## LL +#else +#define LL(A) A ## L +#endif +#endif + +#ifndef ULL +#ifdef HAVE_LONG_LONG +#define ULL(A) A ## ULL +#else +#define ULL(A) A ## UL +#endif +#endif + +/* + Defines to make it possible to prioritize register assignments. No + longer that important with modern compilers. +*/ +#ifndef USING_X +#define reg1 register +#define reg2 register +#define reg3 register +#define reg4 register +#define reg5 register +#define reg6 register +#define reg7 register +#define reg8 register +#define reg9 register +#define reg10 register +#define reg11 register +#define reg12 register +#define reg13 register +#define reg14 register +#define reg15 register +#define reg16 register +#endif + +/* + Sometimes we want to make sure that the variable is not put into + a register in debugging mode so we can see its value in the core +*/ + +#ifndef DBUG_OFF +#define dbug_volatile volatile +#else +#define dbug_volatile +#endif + +/* Defines for time function */ +#define SCALE_SEC 100 +#define SCALE_USEC 10000 +#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ +#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ + +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{ \ + (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ + (ABSTIME).ts_nsec=0; \ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{ \ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).ts_sec= (now / ULL(10000000)); \ + (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#else +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{\ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).tv_sec= (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + +/* + Define-funktions for reading and storing in machine independent format + (low byte first) +*/ + +/* Optimized store functions for Intel x86 */ +#if defined(__i386__) && !defined(_WIN64) +#define sint2korr(A) (*((int16 *) (A))) +#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ + (((uint32) 255L << 24) | \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0])) : \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0]))) +#define sint4korr(A) (*((long *) (A))) +#define uint2korr(A) (*((uint16 *) (A))) +#ifdef HAVE_purify +#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16)) +#else +/* + ATTENTION ! + + Please, note, uint3korr reads 4 bytes (not 3) ! + It means, that you have to provide enough allocated space ! +*/ +#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) +#endif +#define uint4korr(A) (*((unsigned long *) (A))) +#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16) +\ + (((uint32) ((uchar) (A)[3])) << 24)) +\ + (((ulonglong) ((uchar) (A)[4])) << 32)) +#define uint8korr(A) (*((ulonglong *) (A))) +#define sint8korr(A) (*((longlong *) (A))) +#define int2store(T,A) *((uint16*) (T))= (uint16) (A) +#define int3store(T,A) do { *(T)= (uchar) ((A));\ + *(T+1)=(uchar) (((uint) (A) >> 8));\ + *(T+2)=(uchar) (((A) >> 16)); } while (0) +#define int4store(T,A) *((long *) (T))= (long) (A) +#define int5store(T,A) do { *(T)= (uchar)((A));\ + *((T)+1)=(uchar) (((A) >> 8));\ + *((T)+2)=(uchar) (((A) >> 16));\ + *((T)+3)=(uchar) (((A) >> 24)); \ + *((T)+4)=(uchar) (((A) >> 32)); } while(0) +#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) + +typedef union { + double v; + long m[2]; +} doubleget_union; +#define doubleget(V,M) \ +do { doubleget_union _tmp; \ + _tmp.m[0] = *((long*)(M)); \ + _tmp.m[1] = *(((long*) (M))+1); \ + (V) = _tmp.v; } while(0) +#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \ + *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \ + } while (0) +#define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0) +#define float8get(V,M) doubleget((V),(M)) +#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) +#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V),sizeof(float)) +#define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float)) +#define float8store(V,M) doublestore((V),(M)) +#endif /* __i386__ */ + +#ifndef sint2korr +/* + We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines + were done before) +*/ +#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ + ((int16) ((int16) (A)[1]) << 8)) +#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ + (((uint32) 255L << 24) | \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0])) : \ + (((uint32) (uchar) (A)[2]) << 16) |\ + (((uint32) (uchar) (A)[1]) << 8) | \ + ((uint32) (uchar) (A)[0]))) +#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\ + (((int32) ((uchar) (A)[1]) << 8)) +\ + (((int32) ((uchar) (A)[2]) << 16)) +\ + (((int32) ((int16) (A)[3]) << 24))) +#define sint8korr(A) (longlong) uint8korr(A) +#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\ + ((uint16) ((uchar) (A)[1]) << 8)) +#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16)) +#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16) +\ + (((uint32) ((uchar) (A)[3])) << 24)) +#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16) +\ + (((uint32) ((uchar) (A)[3])) << 24)) +\ + (((ulonglong) ((uchar) (A)[4])) << 32)) +#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ + (((uint32) ((uchar) (A)[1])) << 8) +\ + (((uint32) ((uchar) (A)[2])) << 16) +\ + (((uint32) ((uchar) (A)[3])) << 24)) +\ + (((ulonglong) (((uint32) ((uchar) (A)[4])) +\ + (((uint32) ((uchar) (A)[5])) << 8) +\ + (((uint32) ((uchar) (A)[6])) << 16) +\ + (((uint32) ((uchar) (A)[7])) << 24))) <<\ + 32)) +#define int2store(T,A) do { uint def_temp= (uint) (A) ;\ + *((uchar*) (T))= (uchar)(def_temp); \ + *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \ + } while(0) +#define int3store(T,A) do { /*lint -save -e734 */\ + *((uchar*)(T))=(uchar) ((A));\ + *((uchar*) (T)+1)=(uchar) (((A) >> 8));\ + *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \ + /*lint -restore */} while(0) +#define int4store(T,A) do { *((char *)(T))=(char) ((A));\ + *(((char *)(T))+1)=(char) (((A) >> 8));\ + *(((char *)(T))+2)=(char) (((A) >> 16));\ + *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0) +#define int5store(T,A) do { *((char *)(T))=((A));\ + *(((char *)(T))+1)=(((A) >> 8));\ + *(((char *)(T))+2)=(((A) >> 16));\ + *(((char *)(T))+3)=(((A) >> 24)); \ + *(((char *)(T))+4)=(((A) >> 32)); } while(0) +#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \ + int4store((T),def_temp); \ + int4store((T+4),def_temp2); } while(0) +#ifdef WORDS_BIGENDIAN +#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\ + *((T)+1)=(char) ((byte *) &A)[2];\ + *((T)+2)=(char) ((byte *) &A)[1];\ + *((T)+3)=(char) ((byte *) &A)[0]; } while(0) + +#define float4get(V,M) do { float def_temp;\ + ((byte*) &def_temp)[0]=(M)[3];\ + ((byte*) &def_temp)[1]=(M)[2];\ + ((byte*) &def_temp)[2]=(M)[1];\ + ((byte*) &def_temp)[3]=(M)[0];\ + (V)=def_temp; } while(0) +#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\ + *((T)+1)=(char) ((byte *) &V)[6];\ + *((T)+2)=(char) ((byte *) &V)[5];\ + *((T)+3)=(char) ((byte *) &V)[4];\ + *((T)+4)=(char) ((byte *) &V)[3];\ + *((T)+5)=(char) ((byte *) &V)[2];\ + *((T)+6)=(char) ((byte *) &V)[1];\ + *((T)+7)=(char) ((byte *) &V)[0]; } while(0) + +#define float8get(V,M) do { double def_temp;\ + ((byte*) &def_temp)[0]=(M)[7];\ + ((byte*) &def_temp)[1]=(M)[6];\ + ((byte*) &def_temp)[2]=(M)[5];\ + ((byte*) &def_temp)[3]=(M)[4];\ + ((byte*) &def_temp)[4]=(M)[3];\ + ((byte*) &def_temp)[5]=(M)[2];\ + ((byte*) &def_temp)[6]=(M)[1];\ + ((byte*) &def_temp)[7]=(M)[0];\ + (V) = def_temp; } while(0) +#else +#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) +#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) + +#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\ + *(((char*)T)+1)=(char) ((byte *) &V)[5];\ + *(((char*)T)+2)=(char) ((byte *) &V)[6];\ + *(((char*)T)+3)=(char) ((byte *) &V)[7];\ + *(((char*)T)+4)=(char) ((byte *) &V)[0];\ + *(((char*)T)+5)=(char) ((byte *) &V)[1];\ + *(((char*)T)+6)=(char) ((byte *) &V)[2];\ + *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\ + while(0) +#define doubleget(V,M) do { double def_temp;\ + ((byte*) &def_temp)[0]=(M)[4];\ + ((byte*) &def_temp)[1]=(M)[5];\ + ((byte*) &def_temp)[2]=(M)[6];\ + ((byte*) &def_temp)[3]=(M)[7];\ + ((byte*) &def_temp)[4]=(M)[0];\ + ((byte*) &def_temp)[5]=(M)[1];\ + ((byte*) &def_temp)[6]=(M)[2];\ + ((byte*) &def_temp)[7]=(M)[3];\ + (V) = def_temp; } while(0) +#endif /* __FLOAT_WORD_ORDER */ + +#define float8get(V,M) doubleget((V),(M)) +#define float8store(V,M) doublestore((V),(M)) +#endif /* WORDS_BIGENDIAN */ + +#endif /* sint2korr */ + +/* + Macro for reading 32-bit integer from network byte order (big-endian) + from unaligned memory location. +*/ +#define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) |\ + (((uint32) ((uchar) (A)[2])) << 8) |\ + (((uint32) ((uchar) (A)[1])) << 16) |\ + (((uint32) ((uchar) (A)[0])) << 24)) +/* + Define-funktions for reading and storing in machine format from/to + short/long to/from some place in memory V should be a (not + register) variable, M is a pointer to byte +*/ + +#ifdef WORDS_BIGENDIAN + +#define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\ + ((uint16) ((uint16) (M)[0]) << 8)); } while(0) +#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\ + ((short) ((short) (M)[0]) << 8)); } while(0) +#define longget(V,M) do { int32 def_temp;\ + ((byte*) &def_temp)[0]=(M)[0];\ + ((byte*) &def_temp)[1]=(M)[1];\ + ((byte*) &def_temp)[2]=(M)[2];\ + ((byte*) &def_temp)[3]=(M)[3];\ + (V)=def_temp; } while(0) +#define ulongget(V,M) do { uint32 def_temp;\ + ((byte*) &def_temp)[0]=(M)[0];\ + ((byte*) &def_temp)[1]=(M)[1];\ + ((byte*) &def_temp)[2]=(M)[2];\ + ((byte*) &def_temp)[3]=(M)[3];\ + (V)=def_temp; } while(0) +#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\ + *(((char*)T)+1)=(char)(def_temp); \ + *(((char*)T)+0)=(char)(def_temp >> 8); } while(0) +#define longstore(T,A) do { *(((char*)T)+3)=((A));\ + *(((char*)T)+2)=(((A) >> 8));\ + *(((char*)T)+1)=(((A) >> 16));\ + *(((char*)T)+0)=(((A) >> 24)); } while(0) + +#define floatget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) +#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float)) +#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) +#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) +#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) +#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) + +#else + +#define ushortget(V,M) do { V = uint2korr(M); } while(0) +#define shortget(V,M) do { V = sint2korr(M); } while(0) +#define longget(V,M) do { V = sint4korr(M); } while(0) +#define ulongget(V,M) do { V = uint4korr(M); } while(0) +#define shortstore(T,V) int2store(T,V) +#define longstore(T,V) int4store(T,V) +#ifndef floatstore +#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float)) +#define floatget(V,M) memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float)) +#endif +#ifndef doubleget +#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) +#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) +#endif /* doubleget */ +#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) +#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) + +#endif /* WORDS_BIGENDIAN */ + +/* sprintf does not always return the number of bytes :- */ +#ifdef SPRINTF_RETURNS_INT +#define my_sprintf(buff,args) sprintf args +#else +#ifdef SPRINTF_RETURNS_PTR +#define my_sprintf(buff,args) ((int)(sprintf args - buff)) +#else +#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff)) +#endif +#endif + +#ifndef THREAD +#define thread_safe_increment(V,L) (V)++ +#define thread_safe_add(V,C,L) (V)+=(C) +#define thread_safe_sub(V,C,L) (V)-=(C) +#define statistic_increment(V,L) (V)++ +#define statistic_add(V,C,L) (V)+=(C) +#endif + +#ifdef HAVE_CHARSET_utf8 +#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8" +#else +#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME +#endif + +#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL) +#define NO_EMBEDDED_ACCESS_CHECKS +#endif + +#endif /* my_global_h */ diff --git a/3rdparty/mysql/include/my_list.h b/3rdparty/mysql/include/my_list.h new file mode 100644 index 000000000..92598696f --- /dev/null +++ b/3rdparty/mysql/include/my_list.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _list_h_ +#define _list_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct st_list { + struct st_list *prev,*next; + void *data; +} LIST; + +typedef int (*list_walk_action)(void *,void *); + +extern LIST *list_add(LIST *root,LIST *element); +extern LIST *list_delete(LIST *root,LIST *element); +extern LIST *list_cons(void *data,LIST *root); +extern LIST *list_reverse(LIST *root); +extern void list_free(LIST *root,unsigned int free_data); +extern unsigned int list_length(LIST *); +extern int list_walk(LIST *,list_walk_action action,gptr argument); + +#define list_rest(a) ((a)->next) +#define list_push(a,b) (a)=list_cons((b),(a)) +#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } + +#ifdef __cplusplus +} +#endif +#endif diff --git a/3rdparty/mysql/include/my_pthread.h b/3rdparty/mysql/include/my_pthread.h new file mode 100644 index 000000000..202e047dc --- /dev/null +++ b/3rdparty/mysql/include/my_pthread.h @@ -0,0 +1,717 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* Defines to make different thread packages compatible */ + +#ifndef _my_pthread_h +#define _my_pthread_h + +#include +#ifndef ETIME +#define ETIME ETIMEDOUT /* For FreeBSD */ +#endif + +#ifdef __cplusplus +#define EXTERNC extern "C" +extern "C" { +#else +#define EXTERNC +#endif /* __cplusplus */ + +#if defined(__WIN__) || defined(OS2) + +#ifdef OS2 +typedef ULONG HANDLE; +typedef ULONG DWORD; +typedef int sigset_t; +#endif + +#ifdef OS2 +typedef HMTX pthread_mutex_t; +#else +typedef CRITICAL_SECTION pthread_mutex_t; +#endif +typedef HANDLE pthread_t; +typedef struct thread_attr { + DWORD dwStackSize ; + DWORD dwCreatingFlag ; + int priority ; +} pthread_attr_t ; + +typedef struct { int dummy; } pthread_condattr_t; + +/* Implementation of posix conditions */ + +typedef struct st_pthread_link { + DWORD thread_id; + struct st_pthread_link *next; +} pthread_link; + +typedef struct { + uint32 waiting; +#ifdef OS2 + HEV semaphore; +#else + HANDLE semaphore; +#endif +} pthread_cond_t; + + +#ifndef OS2 +struct timespec { /* For pthread_cond_timedwait() */ + time_t tv_sec; + long tv_nsec; +}; +#endif + +typedef int pthread_mutexattr_t; +#define win_pthread_self my_thread_var->pthread_self +#ifdef OS2 +#define pthread_handler_t EXTERNC void * _Optlink +typedef void * (_Optlink *pthread_handler)(void *); +#else +#define pthread_handler_t EXTERNC void * __cdecl +typedef void * (__cdecl *pthread_handler)(void *); +#endif + +void win_pthread_init(void); +int win_pthread_setspecific(void *A,void *B,uint length); +int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); +int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + struct timespec *abstime); +int pthread_cond_signal(pthread_cond_t *cond); +int pthread_cond_broadcast(pthread_cond_t *cond); +int pthread_cond_destroy(pthread_cond_t *cond); +int pthread_attr_init(pthread_attr_t *connect_att); +int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack); +int pthread_attr_setprio(pthread_attr_t *connect_att,int priority); +int pthread_attr_destroy(pthread_attr_t *connect_att); +struct tm *localtime_r(const time_t *timep,struct tm *tmp); +struct tm *gmtime_r(const time_t *timep,struct tm *tmp); + + +void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ + +#ifndef OS2 +#define ETIMEDOUT 145 /* Win32 doesn't have this */ +#define getpid() GetCurrentThreadId() +#endif +#define pthread_self() win_pthread_self +#define HAVE_LOCALTIME_R 1 +#define _REENTRANT 1 +#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 + +#ifdef USE_TLS /* For LIBMYSQL.DLL */ +#undef SAFE_MUTEX /* This will cause conflicts */ +#define pthread_key(T,V) DWORD V +#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF) +#define pthread_key_delete(A) TlsFree(A) +#define pthread_getspecific(A) (TlsGetValue(A)) +#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A)) +#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V)) +#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V))) +#define pthread_setspecific(A,B) (!TlsSetValue((A),(B))) +#else +#define pthread_key(T,V) __declspec(thread) T V +#define pthread_key_create(A,B) pthread_dummy(0) +#define pthread_key_delete(A) pthread_dummy(0) +#define pthread_getspecific(A) (&(A)) +#define my_pthread_getspecific(T,A) (&(A)) +#define my_pthread_getspecific_ptr(T,V) (V) +#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0) +#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) +#endif /* USE_TLS */ + +#define pthread_equal(A,B) ((A) == (B)) +#ifdef OS2 +extern int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *); +extern int pthread_mutex_lock (pthread_mutex_t *); +extern int pthread_mutex_unlock (pthread_mutex_t *); +extern int pthread_mutex_destroy (pthread_mutex_t *); +#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A) +#define pthread_kill(A,B) raise(B) +#define pthread_exit(A) pthread_dummy() +#else +#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) +#define pthread_mutex_lock(A) (EnterCriticalSection(A),0) +#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT) +#define pthread_mutex_unlock(A) LeaveCriticalSection(A) +#define pthread_mutex_destroy(A) DeleteCriticalSection(A) +#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) +#define pthread_kill(A,B) pthread_dummy(0) +#endif /* OS2 */ + +/* Dummy defines for easier code */ +#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) +#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B) +#define pthread_attr_setscope(A,B) +#define pthread_detach_this_thread() +#define pthread_condattr_init(A) +#define pthread_condattr_destroy(A) + +/*Irena: compiler does not like this: */ +/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ +#define my_pthread_getprio(thread_id) pthread_dummy(0) + +#elif defined(HAVE_UNIXWARE7_THREADS) + +#include +#include + +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#define HAVE_NONPOSIX_SIGWAIT +#define pthread_t thread_t +#define pthread_cond_t cond_t +#define pthread_mutex_t mutex_t +#define pthread_key_t thread_key_t +typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */ + +#define pthread_key_create(A,B) thr_keycreate((A),(B)) +#define pthread_key_delete(A) thr_keydelete(A) + +#define pthread_handler_t EXTERNC void * +#define pthread_key(T,V) pthread_key_t V + +void * my_pthread_getspecific_imp(pthread_key_t key); +#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B)) +#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V) + +#define pthread_setspecific(A,B) thr_setspecific(A,B) +#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V) + +#define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A)) +#define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL) +#define pthread_cond_destroy(a) cond_destroy(a) +#define pthread_cond_signal(a) cond_signal(a) +#define pthread_cond_wait(a,b) cond_wait((a),(b)) +#define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c)) +#define pthread_cond_broadcast(a) cond_broadcast(a) + +#define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL) +#define pthread_mutex_lock(a) mutex_lock(a) +#define pthread_mutex_unlock(a) mutex_unlock(a) +#define pthread_mutex_destroy(a) mutex_destroy(a) + +#define pthread_self() thr_self() +#define pthread_exit(A) thr_exit(A) +#define pthread_equal(A,B) (((A) == (B)) ? 1 : 0) +#define pthread_kill(A,B) thr_kill((A),(B)) +#define HAVE_PTHREAD_KILL + +#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C)) + +extern int my_sigwait(const sigset_t *set,int *sig); + +#define pthread_detach_this_thread() pthread_dummy(0) + +#define pthread_attr_init(A) pthread_dummy(0) +#define pthread_attr_destroy(A) pthread_dummy(0) +#define pthread_attr_setscope(A,B) pthread_dummy(0) +#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) +#define my_pthread_setprio(A,B) pthread_dummy (0) +#define my_pthread_getprio(A) pthread_dummy (0) +#define my_pthread_attr_setprio(A,B) pthread_dummy(0) + +#else /* Normal threads */ + +#ifdef HAVE_rts_threads +#define sigwait org_sigwait +#include +#undef sigwait +#endif +#include +#ifndef _REENTRANT +#define _REENTRANT +#endif +#ifdef HAVE_THR_SETCONCURRENCY +#include /* Probably solaris */ +#endif +#ifdef HAVE_SCHED_H +#include +#endif +#ifdef HAVE_SYNCH_H +#include +#endif +#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2)) +#error Requires at least rev 2 of EMX pthreads library. +#endif + +#ifdef __NETWARE__ +void my_pthread_exit(void *status); +#define pthread_exit(A) my_pthread_exit(A) +#endif + +extern int my_pthread_getprio(pthread_t thread_id); + +#define pthread_key(T,V) pthread_key_t V +#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V)) +#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V)) +#define pthread_detach_this_thread() +#define pthread_handler_t EXTERNC void * +typedef void *(* pthread_handler)(void *); + +/* Test first for RTS or FSU threads */ + +#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) +#define HAVE_rts_threads +extern int my_pthread_create_detached; +#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) +#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL +#define USE_ALARM_THREAD +#elif defined(HAVE_mit_thread) +#define USE_ALARM_THREAD +#undef HAVE_LOCALTIME_R +#define HAVE_LOCALTIME_R +#undef HAVE_GMTIME_R +#define HAVE_GMTIME_R +#undef HAVE_PTHREAD_ATTR_SETSCOPE +#define HAVE_PTHREAD_ATTR_SETSCOPE +#undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE /* If we are running linux */ +#undef HAVE_RWLOCK_T +#undef HAVE_RWLOCK_INIT +#undef HAVE_PTHREAD_RWLOCK_RDLOCK +#undef HAVE_SNPRINTF + +#define my_pthread_attr_setprio(A,B) +#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */ + +#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910 +int sigwait(sigset_t *set, int *sig); +#endif + +#ifndef HAVE_NONPOSIX_SIGWAIT +#define my_sigwait(A,B) sigwait((A),(B)) +#else +int my_sigwait(const sigset_t *set,int *sig); +#endif + +#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT +#ifndef SAFE_MUTEX +#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b)) +extern int my_pthread_mutex_init(pthread_mutex_t *mp, + const pthread_mutexattr_t *attr); +#endif /* SAFE_MUTEX */ +#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b)) +extern int my_pthread_cond_init(pthread_cond_t *mp, + const pthread_condattr_t *attr); +#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */ + +#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK) +#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C)) +#endif + +#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX) +int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ +#endif + + +/* + We define my_sigset() and use that instead of the system sigset() so that + we can favor an implementation based on sigaction(). On some systems, such + as Mac OS X, sigset() results in flags such as SA_RESTART being set, and + we want to make sure that no such flags are set. +*/ +#if defined(HAVE_SIGACTION) && !defined(my_sigset) +#define my_sigset(A,B) do { struct sigaction s; sigset_t set; \ + sigemptyset(&set); \ + s.sa_handler = (B); \ + s.sa_mask = set; \ + s.sa_flags = 0; \ + sigaction((A), &s, (struct sigaction *) NULL); \ + } while (0) +#elif defined(HAVE_SIGSET) && !defined(my_sigset) +#define my_sigset(A,B) sigset((A),(B)) +#elif !defined(my_sigset) +#define my_sigset(A,B) signal((A),(B)) +#endif + +#ifndef my_pthread_setprio +#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */ +#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B)) +#elif defined(HAVE_PTHREAD_SETPRIO) +#define my_pthread_setprio(A,B) pthread_setprio((A),(B)) +#else +extern void my_pthread_setprio(pthread_t thread_id,int prior); +#endif +#endif + +#ifndef my_pthread_attr_setprio +#ifdef HAVE_PTHREAD_ATTR_SETPRIO +#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B)) +#else +extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority); +#endif +#endif + +#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS) +#define pthread_attr_setscope(A,B) +#undef HAVE_GETHOSTBYADDR_R /* No definition */ +#endif + +#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX) +extern int my_pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, + struct timespec *abstime); +#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C)) +#endif + +#if defined(OS2) +#define my_pthread_getspecific(T,A) ((T) &(A)) +#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) +#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC) +#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B)) +#else +#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B)) +void *my_pthread_getspecific_imp(pthread_key_t key); +#endif /* OS2 */ + +#ifndef HAVE_LOCALTIME_R +struct tm *localtime_r(const time_t *clock, struct tm *res); +#endif + +#ifndef HAVE_GMTIME_R +struct tm *gmtime_r(const time_t *clock, struct tm *res); +#endif + +#ifdef HAVE_PTHREAD_CONDATTR_CREATE +/* DCE threads on HPUX 10.20 */ +#define pthread_condattr_init pthread_condattr_create +#define pthread_condattr_destroy pthread_condattr_delete +#endif + +/* FSU THREADS */ +#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete) +#define pthread_key_delete(A) pthread_dummy(0) +#endif + +#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */ +#define pthread_cond_destroy(A) pthread_dummy(0) +#define pthread_mutex_destroy(A) pthread_dummy(0) +#define pthread_attr_delete(A) pthread_dummy(0) +#define pthread_condattr_delete(A) pthread_dummy(0) +#define pthread_attr_setstacksize(A,B) pthread_dummy(0) +#define pthread_equal(A,B) ((A) == (B)) +#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b)) +#define pthread_attr_init(A) pthread_attr_create(A) +#define pthread_attr_destroy(A) pthread_attr_delete(A) +#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) +#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) +#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) +#define pthread_kill(A,B) pthread_dummy(0) +#undef pthread_detach_this_thread +#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } +#endif + +#ifdef HAVE_DARWIN5_THREADS +#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) +#define pthread_kill(A,B) pthread_dummy(0) +#define pthread_condattr_init(A) pthread_dummy(0) +#define pthread_condattr_destroy(A) pthread_dummy(0) +#undef pthread_detach_this_thread +#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); } +#endif + +#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER) +/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */ +#define pthread_key_create(A,B) \ + pthread_keycreate(A,(B) ?\ + (pthread_destructor_t) (B) :\ + (pthread_destructor_t) pthread_dummy) +#define pthread_attr_init(A) pthread_attr_create(A) +#define pthread_attr_destroy(A) pthread_attr_delete(A) +#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) +#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) +#ifndef pthread_sigmask +#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) +#endif +#define pthread_kill(A,B) pthread_dummy(0) +#undef pthread_detach_this_thread +#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } +#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */ +#define HAVE_PTHREAD_KILL +#endif + +#endif /* defined(__WIN__) */ + +#if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) +#undef pthread_cond_timedwait +#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c)) +int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + struct timespec *abstime); +#endif + +#if defined(HPUX10) +#define pthread_attr_getstacksize(A,B) my_pthread_attr_getstacksize(A,B) +void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); +#endif + +#if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) +#undef pthread_mutex_trylock +#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a)) +int my_pthread_mutex_trylock(pthread_mutex_t *mutex); +#endif + + /* safe_mutex adds checking to mutex for easier debugging */ + +#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) +#define SAFE_MUTEX_DETECT_DESTROY +#endif + +typedef struct st_safe_mutex_t +{ + pthread_mutex_t global,mutex; + const char *file; + uint line,count; + pthread_t thread; +#ifdef SAFE_MUTEX_DETECT_DESTROY + struct st_safe_mutex_info_t *info; /* to track destroying of mutexes */ +#endif +} safe_mutex_t; + +#ifdef SAFE_MUTEX_DETECT_DESTROY +/* + Used to track the destroying of mutexes. This needs to be a seperate + structure because the safe_mutex_t structure could be freed before + the mutexes are destroyed. +*/ + +typedef struct st_safe_mutex_info_t +{ + struct st_safe_mutex_info_t *next; + struct st_safe_mutex_info_t *prev; + const char *init_file; + uint32 init_line; +} safe_mutex_info_t; +#endif /* SAFE_MUTEX_DETECT_DESTROY */ + +int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, + const char *file, uint line); +int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line); +int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); +int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); +int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, + uint line); +int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, + struct timespec *abstime, const char *file, uint line); +void safe_mutex_global_init(void); +void safe_mutex_end(FILE *file); + + /* Wrappers if safe mutex is actually used */ +#ifdef SAFE_MUTEX +#undef pthread_mutex_init +#undef pthread_mutex_lock +#undef pthread_mutex_unlock +#undef pthread_mutex_destroy +#undef pthread_mutex_wait +#undef pthread_mutex_timedwait +#undef pthread_mutex_t +#undef pthread_cond_wait +#undef pthread_cond_timedwait +#undef pthread_mutex_trylock +#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) +#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__) +#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) +#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) +#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) +#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) +#define pthread_mutex_trylock(A) pthread_mutex_lock(A) +#define pthread_mutex_t safe_mutex_t +#define safe_mutex_assert_owner(mp) \ + DBUG_ASSERT((mp)->count > 0 && \ + pthread_equal(pthread_self(), (mp)->thread)) +#define safe_mutex_assert_not_owner(mp) \ + DBUG_ASSERT(! (mp)->count || \ + ! pthread_equal(pthread_self(), (mp)->thread)) +#else +#define safe_mutex_assert_owner(mp) +#define safe_mutex_assert_not_owner(mp) +#endif /* SAFE_MUTEX */ + + /* READ-WRITE thread locking */ + +#ifdef HAVE_BROKEN_RWLOCK /* For OpenUnix */ +#undef HAVE_PTHREAD_RWLOCK_RDLOCK +#undef HAVE_RWLOCK_INIT +#undef HAVE_RWLOCK_T +#endif + +#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS) +/* use these defs for simple mutex locking */ +#define rw_lock_t pthread_mutex_t +#define my_rwlock_init(A,B) pthread_mutex_init((A),(B)) +#define rw_rdlock(A) pthread_mutex_lock((A)) +#define rw_wrlock(A) pthread_mutex_lock((A)) +#define rw_tryrdlock(A) pthread_mutex_trylock((A)) +#define rw_trywrlock(A) pthread_mutex_trylock((A)) +#define rw_unlock(A) pthread_mutex_unlock((A)) +#define rwlock_destroy(A) pthread_mutex_destroy((A)) +#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK) +#define rw_lock_t pthread_rwlock_t +#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B)) +#define rw_rdlock(A) pthread_rwlock_rdlock(A) +#define rw_wrlock(A) pthread_rwlock_wrlock(A) +#define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A)) +#define rw_trywrlock(A) pthread_rwlock_trywrlock((A)) +#define rw_unlock(A) pthread_rwlock_unlock(A) +#define rwlock_destroy(A) pthread_rwlock_destroy(A) +#elif defined(HAVE_RWLOCK_INIT) +#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */ +#define rw_lock_t rwlock_t +#endif +#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0) +#else +/* Use our own version of read/write locks */ +typedef struct _my_rw_lock_t { + pthread_mutex_t lock; /* lock for structure */ + pthread_cond_t readers; /* waiting readers */ + pthread_cond_t writers; /* waiting writers */ + int state; /* -1:writer,0:free,>0:readers */ + int waiters; /* number of waiting writers */ +} my_rw_lock_t; + +#define rw_lock_t my_rw_lock_t +#define rw_rdlock(A) my_rw_rdlock((A)) +#define rw_wrlock(A) my_rw_wrlock((A)) +#define rw_tryrdlock(A) my_rw_tryrdlock((A)) +#define rw_trywrlock(A) my_rw_trywrlock((A)) +#define rw_unlock(A) my_rw_unlock((A)) +#define rwlock_destroy(A) my_rwlock_destroy((A)) + +extern int my_rwlock_init(my_rw_lock_t *, void *); +extern int my_rwlock_destroy(my_rw_lock_t *); +extern int my_rw_rdlock(my_rw_lock_t *); +extern int my_rw_wrlock(my_rw_lock_t *); +extern int my_rw_unlock(my_rw_lock_t *); +extern int my_rw_tryrdlock(my_rw_lock_t *); +extern int my_rw_trywrlock(my_rw_lock_t *); +#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ + +#define GETHOSTBYADDR_BUFF_SIZE 2048 + +#ifndef HAVE_THR_SETCONCURRENCY +#define thr_setconcurrency(A) pthread_dummy(0) +#endif +#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize) +#define pthread_attr_setstacksize(A,B) pthread_dummy(0) +#endif + +/* Define mutex types, see my_thr_init.c */ +#define MY_MUTEX_INIT_SLOW NULL +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +extern pthread_mutexattr_t my_fast_mutexattr; +#define MY_MUTEX_INIT_FAST &my_fast_mutexattr +#else +#define MY_MUTEX_INIT_FAST NULL +#endif +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +extern pthread_mutexattr_t my_errorcheck_mutexattr; +#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr +#else +#define MY_MUTEX_INIT_ERRCHK NULL +#endif + +extern my_bool my_thread_global_init(void); +extern void my_thread_global_end(void); +extern my_bool my_thread_init(void); +extern void my_thread_end(void); +extern const char *my_thread_name(void); +extern long my_thread_id(void); +extern int pthread_no_free(void *); +extern int pthread_dummy(int); + +/* All thread specific variables are in the following struct */ + +#define THREAD_NAME_SIZE 10 +#ifndef DEFAULT_THREAD_STACK +#if SIZEOF_CHARP > 4 +/* + MySQL can survive with 32K, but some glibc libraries require > 128K stack + To resolve hostnames. Also recursive stored procedures needs stack. +*/ +#define DEFAULT_THREAD_STACK (256*1024L) +#else +#define DEFAULT_THREAD_STACK (192*1024) +#endif +#endif + +struct st_my_thread_var +{ + int thr_errno; + pthread_cond_t suspend; + pthread_mutex_t mutex; + pthread_mutex_t * volatile current_mutex; + pthread_cond_t * volatile current_cond; + pthread_t pthread_self; + long id; + int cmp_length; + int volatile abort; + my_bool init; + struct st_my_thread_var *next,**prev; + void *opt_info; +#ifndef DBUG_OFF + gptr dbug; + char name[THREAD_NAME_SIZE+1]; +#endif +}; + +extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); +#define my_thread_var (_my_thread_var()) +#define my_errno my_thread_var->thr_errno +/* + Keep track of shutdown,signal, and main threads so that my_end() will not + report errors with them +*/ +extern pthread_t shutdown_th, main_th, signal_th; + + /* statistics_xxx functions are for not essential statistic */ + +#ifndef thread_safe_increment +#ifdef HAVE_ATOMIC_ADD +#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V) +#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V) +#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V) +#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V) +#else +#define thread_safe_increment(V,L) \ + (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L))) +#define thread_safe_decrement(V,L) \ + (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L))) +#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L))) +#define thread_safe_sub(V,C,L) \ + (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L))) +#endif /* HAVE_ATOMIC_ADD */ +#ifdef SAFE_STATISTICS +#define statistic_increment(V,L) thread_safe_increment((V),(L)) +#define statistic_decrement(V,L) thread_safe_decrement((V),(L)) +#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) +#else +#define statistic_decrement(V,L) (V)-- +#define statistic_increment(V,L) (V)++ +#define statistic_add(V,C,L) (V)+=(C) +#endif /* SAFE_STATISTICS */ +#endif /* thread_safe_increment */ + +#ifdef __cplusplus +} +#endif +#endif /* _my_ptread_h */ diff --git a/3rdparty/mysql/include/my_sys.h b/3rdparty/mysql/include/my_sys.h new file mode 100644 index 000000000..44fe383bf --- /dev/null +++ b/3rdparty/mysql/include/my_sys.h @@ -0,0 +1,904 @@ +/* Copyright (C) 2000-2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _my_sys_h +#define _my_sys_h +C_MODE_START + +#ifdef HAVE_AIOWAIT +#include /* Used by record-cache */ +typedef struct my_aio_result { + aio_result_t result; + int pending; +} my_aio_result; +#endif + +#ifndef THREAD +extern int NEAR my_errno; /* Last error in mysys */ +#else +#include +#endif + +#ifndef _m_ctype_h +#include /* for CHARSET_INFO */ +#endif + +#include +#include + +#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; } +#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} +#define MY_INIT(name); { my_progname= name; my_init(); } + +#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ +#define NRERRBUFFS (2) /* Buffers for parameters */ +#define MY_FILE_ERROR ((uint) ~0) + + /* General bitmaps for my_func's */ +#define MY_FFNF 1 /* Fatal if file not found */ +#define MY_FNABP 2 /* Fatal if not all bytes read/writen */ +#define MY_NABP 4 /* Error if not all bytes read/writen */ +#define MY_FAE 8 /* Fatal if any error */ +#define MY_WME 16 /* Write message on error */ +#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ +#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ +#define MY_RAID 64 /* Support for RAID */ +#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ +#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ +#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ +#define MY_COPYTIME 64 /* my_redel() copys time */ +#define MY_DELETE_OLD 256 /* my_create_with_symlink() */ +#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ +#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ +#define MY_REDEL_MAKE_BACKUP 256 +#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ +#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ +#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ +#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ +#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ +#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ +#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ +#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ + +#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ +#define MY_GIVE_INFO 2 /* Give time info about process*/ + +#define ME_HIGHBYTE 8 /* Shift for colours */ +#define ME_NOCUR 1 /* Don't use curses message */ +#define ME_OLDWIN 2 /* Use old window */ +#define ME_BELL 4 /* Ring bell then printing message */ +#define ME_HOLDTANG 8 /* Don't delete last keys */ +#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */ +#define ME_WAITTANG 32 /* Wait for a user action */ +#define ME_NOREFRESH 64 /* Dont refresh screen */ +#define ME_NOINPUT 128 /* Dont use the input libary */ +#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ +#define ME_COLOUR2 ((2 << ME_HIGHBYTE)) +#define ME_COLOUR3 ((3 << ME_HIGHBYTE)) + + /* Bits in last argument to fn_format */ +#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ +#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ +#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ +#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ +#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ +#define MY_RETURN_REAL_PATH 32 /* return full path for file */ +#define MY_SAFE_PATH 64 /* Return NULL if too long path */ +#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ + + /* My seek flags */ +#define MY_SEEK_SET 0 +#define MY_SEEK_CUR 1 +#define MY_SEEK_END 2 + + /* Some constants */ +#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ +#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ +#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ +#define DFLT_INIT_HITS 3 + + /* root_alloc flags */ +#define MY_KEEP_PREALLOC 1 +#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ + + /* Internal error numbers (for assembler functions) */ +#define MY_ERRNO_EDOM 33 +#define MY_ERRNO_ERANGE 34 + + /* Bits for get_date timeflag */ +#define GETDATE_DATE_TIME 1 +#define GETDATE_SHORT_DATE 2 +#define GETDATE_HHMMSSTIME 4 +#define GETDATE_GMT 8 +#define GETDATE_FIXEDLENGTH 16 + + /* defines when allocating data */ +#ifdef SAFEMALLOC +#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) +#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG ) +#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG ) +#define my_checkmalloc() _sanity( __FILE__, __LINE__ ) +#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG) +#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C) +#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C) +#define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C) +#define TRASH(A,B) bfill(A, B, 0x8F) +#define QUICK_SAFEMALLOC sf_malloc_quick=1 +#define NORMAL_SAFEMALLOC sf_malloc_quick=0 +extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; +extern ulonglong sf_malloc_mem_limit; + +#define CALLER_INFO_PROTO , const char *sFile, uint uLine +#define CALLER_INFO , __FILE__, __LINE__ +#define ORIG_CALLER_INFO , sFile, uLine +#else +#define my_checkmalloc() +#undef TERMINATE +#define TERMINATE(A) {} +#define QUICK_SAFEMALLOC +#define NORMAL_SAFEMALLOC +extern gptr my_malloc(uint Size,myf MyFlags); +#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) +extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); +extern void my_no_flags_free(gptr ptr); +extern gptr my_memdup(const byte *from,uint length,myf MyFlags); +extern char *my_strdup(const char *from,myf MyFlags); +extern char *my_strdup_with_length(const byte *from, uint length, + myf MyFlags); +/* we do use FG (as a no-op) in below so that a typo on FG is caught */ +#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) +#define CALLER_INFO_PROTO /* nothing */ +#define CALLER_INFO /* nothing */ +#define ORIG_CALLER_INFO /* nothing */ +#define TRASH(A,B) /* nothing */ +#endif + +#ifdef HAVE_LARGE_PAGES +extern uint my_get_large_page_size(void); +extern gptr my_large_malloc(uint size, myf my_flags); +extern void my_large_free(gptr ptr, myf my_flags); +#else +#define my_get_large_page_size() (0) +#define my_large_malloc(A,B) my_malloc_lock((A),(B)) +#define my_large_free(A,B) my_free_lock((A),(B)) +#endif /* HAVE_LARGE_PAGES */ + +#ifdef HAVE_ALLOCA +#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) +#pragma alloca +#endif /* _AIX */ +#if defined(__MWERKS__) +#undef alloca +#define alloca _alloca +#endif /* __MWERKS__ */ +#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca) +#define alloca __builtin_alloca +#endif /* GNUC */ +#define my_alloca(SZ) alloca((size_t) (SZ)) +#define my_afree(PTR) {} +#else +#define my_alloca(SZ) my_malloc(SZ,MYF(0)) +#define my_afree(PTR) my_free(PTR,MYF(MY_WME)) +#endif /* HAVE_ALLOCA */ + +#ifdef MSDOS +#ifdef __ZTC__ +void * __CDECL halloc(long count,size_t length); +void __CDECL hfree(void *ptr); +#endif +#if defined(USE_HALLOC) +#if defined(_VCM_) || defined(M_IC80386) +#undef USE_HALLOC +#endif +#endif +#ifdef USE_HALLOC +#define malloc(a) halloc((long) (a),1) +#define free(a) hfree(a) +#endif +#endif /* MSDOS */ + +#ifndef errno /* did we already get it? */ +#ifdef HAVE_ERRNO_AS_DEFINE +#include /* errno is a define */ +#else +extern int errno; /* declare errno */ +#endif +#endif /* #ifndef errno */ +extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; +extern char *home_dir; /* Home directory for user */ +extern const char *my_progname; /* program-name (printed in errors) */ +extern char NEAR curr_dir[]; /* Current directory for user */ +extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); +extern int (*fatal_error_handler_hook)(uint my_err, const char *str, + myf MyFlags); +extern uint my_file_limit; + +#ifdef HAVE_LARGE_PAGES +extern my_bool my_use_large_pages; +extern uint my_large_page_size; +#endif + +/* charsets */ +extern CHARSET_INFO *default_charset_info; +extern CHARSET_INFO *all_charsets[256]; +extern CHARSET_INFO compiled_charsets[]; + +/* statistics */ +extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; +extern uint mysys_usage_id; +extern my_bool my_init_done; + + /* Point to current my_message() */ +extern void (*my_sigtstp_cleanup)(void), + /* Executed before jump to shell */ + (*my_sigtstp_restart)(void), + (*my_abort_hook)(int); + /* Executed when comming from shell */ +extern int NEAR my_umask, /* Default creation mask */ + NEAR my_umask_dir, + NEAR my_recived_signals, /* Signals we have got */ + NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ + NEAR my_dont_interrupt; /* call remember_intr when set */ +extern my_bool NEAR mysys_uses_curses, my_use_symdir; +extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; + +extern ulong my_default_record_cache_size; +extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, + NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; +extern char wild_many,wild_one,wild_prefix; +extern const char *charsets_dir; +extern char *defaults_extra_file; +extern const char *defaults_group_suffix; +extern const char *defaults_file; + +extern my_bool timed_mutexes; + +typedef struct wild_file_pack /* Struct to hold info when selecting files */ +{ + uint wilds; /* How many wildcards */ + uint not_pos; /* Start of not-theese-files */ + my_string *wild; /* Pointer to wildcards */ +} WF_PACK; + +enum loglevel { + ERROR_LEVEL, + WARNING_LEVEL, + INFORMATION_LEVEL +}; + +enum cache_type +{ + TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE, + SEQ_READ_APPEND /* sequential read or append */, + READ_FIFO, READ_NET,WRITE_NET}; + +enum flush_type +{ + FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE +}; + +typedef struct st_record_cache /* Used when cacheing records */ +{ + File file; + int rc_seek,error,inited; + uint rc_length,read_length,reclength; + my_off_t rc_record_pos,end_of_file; + byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; +#ifdef HAVE_AIOWAIT + int use_async_io; + my_aio_result aio_result; +#endif + enum cache_type type; +} RECORD_CACHE; + +enum file_type +{ + UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, + FILE_BY_MKSTEMP, FILE_BY_DUP +}; + +struct st_my_file_info +{ + my_string name; + enum file_type type; +#if defined(THREAD) && !defined(HAVE_PREAD) + pthread_mutex_t mutex; +#endif +}; + +extern struct st_my_file_info *my_file_info; + +typedef struct st_my_tmpdir +{ + char **list; + uint cur, max; +#ifdef THREAD + pthread_mutex_t mutex; +#endif +} MY_TMPDIR; + +typedef struct st_dynamic_array +{ + char *buffer; + uint elements,max_element; + uint alloc_increment; + uint size_of_element; +} DYNAMIC_ARRAY; + +typedef struct st_dynamic_string +{ + char *str; + uint length,max_length,alloc_increment; +} DYNAMIC_STRING; + +struct st_io_cache; +typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); + +#ifdef THREAD +typedef struct st_io_cache_share +{ + /* to sync on reads into buffer */ + pthread_mutex_t mutex; + pthread_cond_t cond; + int count, total; + /* actual IO_CACHE that filled the buffer */ + struct st_io_cache *active; +#ifdef NOT_YET_IMPLEMENTED + /* whether the structure should be free'd */ + my_bool alloced; +#endif +} IO_CACHE_SHARE; +#endif + +typedef struct st_io_cache /* Used when cacheing files */ +{ + /* Offset in file corresponding to the first byte of byte* buffer. */ + my_off_t pos_in_file; + /* + The offset of end of file for READ_CACHE and WRITE_CACHE. + For SEQ_READ_APPEND it the maximum of the actual end of file and + the position represented by read_end. + */ + my_off_t end_of_file; + /* Points to current read position in the buffer */ + byte *read_pos; + /* the non-inclusive boundary in the buffer for the currently valid read */ + byte *read_end; + byte *buffer; /* The read buffer */ + /* Used in ASYNC_IO */ + byte *request_pos; + + /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ + byte *write_buffer; + /* + Only used in SEQ_READ_APPEND, and points to the current read position + in the write buffer. Note that reads in SEQ_READ_APPEND caches can + happen from both read buffer (byte* buffer) and write buffer + (byte* write_buffer). + */ + byte *append_read_pos; + /* Points to current write position in the write buffer */ + byte *write_pos; + /* The non-inclusive boundary of the valid write area */ + byte *write_end; + + /* + Current_pos and current_end are convenience variables used by + my_b_tell() and other routines that need to know the current offset + current_pos points to &write_pos, and current_end to &write_end in a + WRITE_CACHE, and &read_pos and &read_end respectively otherwise + */ + byte **current_pos, **current_end; +#ifdef THREAD + /* + The lock is for append buffer used in SEQ_READ_APPEND cache + need mutex copying from append buffer to read buffer. + */ + pthread_mutex_t append_buffer_lock; + /* + The following is used when several threads are reading the + same file in parallel. They are synchronized on disk + accesses reading the cached part of the file asynchronously. + It should be set to NULL to disable the feature. Only + READ_CACHE mode is supported. + */ + IO_CACHE_SHARE *share; +#endif + /* + A caller will use my_b_read() macro to read from the cache + if the data is already in cache, it will be simply copied with + memcpy() and internal variables will be accordinging updated with + no functions invoked. However, if the data is not fully in the cache, + my_b_read() will call read_function to fetch the data. read_function + must never be invoked directly. + */ + int (*read_function)(struct st_io_cache *,byte *,uint); + /* + Same idea as in the case of read_function, except my_b_write() needs to + be replaced with my_b_append() for a SEQ_READ_APPEND cache + */ + int (*write_function)(struct st_io_cache *,const byte *,uint); + /* + Specifies the type of the cache. Depending on the type of the cache + certain operations might not be available and yield unpredicatable + results. Details to be documented later + */ + enum cache_type type; + /* + Callbacks when the actual read I/O happens. These were added and + are currently used for binary logging of LOAD DATA INFILE - when a + block is read from the file, we create a block create/append event, and + when IO_CACHE is closed, we create an end event. These functions could, + of course be used for other things + */ + IO_CACHE_CALLBACK pre_read; + IO_CACHE_CALLBACK post_read; + IO_CACHE_CALLBACK pre_close; + /* + Counts the number of times, when we were forced to use disk. We use it to + increase the binlog_cache_disk_use status variable. + */ + ulong disk_writes; + void* arg; /* for use by pre/post_read */ + char *file_name; /* if used with 'open_cached_file' */ + char *dir,*prefix; + File file; /* file descriptor */ + /* + seek_not_done is set by my_b_seek() to inform the upcoming read/write + operation that a seek needs to be preformed prior to the actual I/O + error is 0 if the cache operation was successful, -1 if there was a + "hard" error, and the actual number of I/O-ed bytes if the read/write was + partial. + */ + int seek_not_done,error; + /* buffer_length is memory size allocated for buffer or write_buffer */ + uint buffer_length; + /* read_length is the same as buffer_length except when we use async io */ + uint read_length; + myf myflags; /* Flags used to my_read/my_write */ + /* + alloced_buffer is 1 if the buffer was allocated by init_io_cache() and + 0 if it was supplied by the user. + Currently READ_NET is the only one that will use a buffer allocated + somewhere else + */ + my_bool alloced_buffer; +#ifdef HAVE_AIOWAIT + /* + As inidicated by ifdef, this is for async I/O, which is not currently + used (because it's not reliable on all systems) + */ + uint inited; + my_off_t aio_read_pos; + my_aio_result aio_result; +#endif +} IO_CACHE; + +typedef int (*qsort2_cmp)(const void *, const void *, const void *); + + /* defines for mf_iocache */ + + /* Test if buffer is inited */ +#define my_b_clear(info) (info)->buffer=0 +#define my_b_inited(info) (info)->buffer +#define my_b_EOF INT_MIN + +#define my_b_read(info,Buffer,Count) \ + ((info)->read_pos + (Count) <= (info)->read_end ?\ + (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \ + ((info)->read_pos+=(Count)),0) :\ + (*(info)->read_function)((info),Buffer,Count)) + +#define my_b_write(info,Buffer,Count) \ + ((info)->write_pos + (Count) <=(info)->write_end ?\ + (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ + ((info)->write_pos+=(Count)),0) : \ + (*(info)->write_function)((info),(Buffer),(Count))) + +#define my_b_get(info) \ + ((info)->read_pos != (info)->read_end ?\ + ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\ + _my_b_get(info)) + + /* my_b_write_byte dosn't have any err-check */ +#define my_b_write_byte(info,chr) \ + (((info)->write_pos < (info)->write_end) ?\ + ((*(info)->write_pos++)=(chr)) :\ + (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr)))) + +#define my_b_fill_cache(info) \ + (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) + +#define my_b_tell(info) ((info)->pos_in_file + \ + (uint) (*(info)->current_pos - (info)->request_pos)) + +/* tell write offset in the SEQ_APPEND cache */ +my_off_t my_b_append_tell(IO_CACHE* info); +my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ + +#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ + *(info)->current_pos) + +typedef uint32 ha_checksum; + +/* Define the type of function to be passed to process_default_option_files */ +typedef int (*Process_option_func)(void *ctx, const char *group_name, + const char *option); + +#include + + /* Prototypes for mysys and my_func functions */ + +extern int my_copy(const char *from,const char *to,myf MyFlags); +extern int my_append(const char *from,const char *to,myf MyFlags); +extern int my_delete(const char *name,myf MyFlags); +extern int my_getwd(my_string buf,uint size,myf MyFlags); +extern int my_setwd(const char *dir,myf MyFlags); +extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); +extern gptr my_once_alloc(uint Size,myf MyFlags); +extern void my_once_free(void); +extern char *my_once_strdup(const char *src,myf myflags); +extern char *my_once_memdup(const char *src, uint len, myf myflags); +extern File my_open(const char *FileName,int Flags,myf MyFlags); +extern File my_register_filename(File fd, const char *FileName, + enum file_type type_of_file, + uint error_message_number, myf MyFlags); +extern File my_create(const char *FileName,int CreateFlags, + int AccsesFlags, myf MyFlags); +extern int my_close(File Filedes,myf MyFlags); +extern File my_dup(File file, myf MyFlags); +extern int my_mkdir(const char *dir, int Flags, myf MyFlags); +extern int my_readlink(char *to, const char *filename, myf MyFlags); +extern int my_realpath(char *to, const char *filename, myf MyFlags); +extern File my_create_with_symlink(const char *linkname, const char *filename, + int createflags, int access_flags, + myf MyFlags); +extern int my_delete_with_symlink(const char *name, myf MyFlags); +extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); +extern int my_symlink(const char *content, const char *linkname, myf MyFlags); +extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); +extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, + myf MyFlags); +extern int my_rename(const char *from,const char *to,myf MyFlags); +extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); +extern my_off_t my_tell(File fd,myf MyFlags); +extern uint my_write(File Filedes,const byte *Buffer,uint Count, + myf MyFlags); +extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, + my_off_t offset,myf MyFlags); +extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); +extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, + myf MyFlags); +extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); +extern my_off_t my_ftell(FILE *stream,myf MyFlags); +extern gptr _mymalloc(uint uSize,const char *sFile, + uint uLine, myf MyFlag); +extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, + uint uLine, myf MyFlag); +extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); +extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); +extern int _sanity(const char *sFile,unsigned int uLine); +extern gptr _my_memdup(const byte *from,uint length, + const char *sFile, uint uLine,myf MyFlag); +extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, + myf MyFlag); +extern char *_my_strdup_with_length(const byte *from, uint length, + const char *sFile, uint uLine, + myf MyFlag); + +#ifdef __WIN__ +extern int my_access(const char *path, int amode); +extern File my_sopen(const char *path, int oflag, int shflag, int pmode); +#else +#define my_access access +#endif +extern int check_if_legal_filename(const char *path); + +#ifndef TERMINATE +extern void TERMINATE(FILE *file); +#endif +extern void init_glob_errs(void); +extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); +extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); +extern int my_fclose(FILE *fd,myf MyFlags); +extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); +extern int my_sync(File fd, myf my_flags); +extern int my_error _VARARGS((int nr,myf MyFlags, ...)); +extern int my_printf_error _VARARGS((uint my_err, const char *format, + myf MyFlags, ...) + __attribute__ ((format (printf, 2, 4)))); +extern int my_error_register(const char **errmsgs, int first, int last); +extern const char **my_error_unregister(int first, int last); +extern int my_message(uint my_err, const char *str,myf MyFlags); +extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags); +extern int my_message_curses(uint my_err, const char *str,myf MyFlags); +extern my_bool my_init(void); +extern void my_end(int infoflag); +extern int my_redel(const char *from, const char *to, int MyFlags); +extern int my_copystat(const char *from, const char *to, int MyFlags); +extern my_string my_filename(File fd); + +#ifndef THREAD +extern void dont_break(void); +extern void allow_break(void); +#else +#define dont_break() +#define allow_break() +#endif + +extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); +extern char *my_tmpdir(MY_TMPDIR *tmpdir); +extern void free_tmpdir(MY_TMPDIR *tmpdir); + +extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); +extern uint dirname_part(my_string to,const char *name); +extern uint dirname_length(const char *name); +#define base_name(A) (A+dirname_length(A)) +extern int test_if_hard_path(const char *dir_name); +extern my_bool has_path(const char *name); +extern char *convert_dirname(char *to, const char *from, const char *from_end); +extern void to_unix_path(my_string name); +extern my_string fn_ext(const char *name); +extern my_string fn_same(my_string toname,const char *name,int flag); +extern my_string fn_format(my_string to,const char *name,const char *dir, + const char *form, uint flag); +extern size_s strlength(const char *str); +extern void pack_dirname(my_string to,const char *from); +extern uint unpack_dirname(my_string to,const char *from); +extern uint cleanup_dirname(my_string to,const char *from); +extern uint system_filename(my_string to,const char *from); +extern uint unpack_filename(my_string to,const char *from); +extern my_string intern_filename(my_string to,const char *from); +extern my_string directory_file_name(my_string dst, const char *src); +extern int pack_filename(my_string to, const char *name, size_s max_length); +extern my_string my_path(my_string to,const char *progname, + const char *own_pathname_part); +extern my_string my_load_path(my_string to, const char *path, + const char *own_path_prefix); +extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern); +extern WF_PACK *wf_comp(my_string str); +extern int wf_test(struct wild_file_pack *wf_pack,const char *name); +extern void wf_end(struct wild_file_pack *buffer); +extern size_s strip_sp(my_string str); +extern void get_date(my_string to,int timeflag,time_t use_time); +extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage); +extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, + uint reclength,enum cache_type type, + pbool use_async_io); +extern int read_cache_record(RECORD_CACHE *info,byte *to); +extern int end_record_cache(RECORD_CACHE *info); +extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, + const byte *record,uint length); +extern int flush_write_cache(RECORD_CACHE *info); +extern long my_clock(void); +extern sig_handler sigtstp_handler(int signal_number); +extern void handle_recived_signals(void); + +extern sig_handler my_set_alarm_variable(int signo); +extern void my_string_ptr_sort(void *base,uint items,size_s size); +extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, + size_s size_of_element,uchar *buffer[]); +extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, + qsort2_cmp cmp, void *cmp_argument); +extern qsort2_cmp get_ptr_compare(uint); +void my_store_ptr(byte *buff, uint pack_length, my_off_t pos); +my_off_t my_get_ptr(byte *ptr, uint pack_length); +extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, + enum cache_type type,my_off_t seek_offset, + pbool use_async_io, myf cache_myflags); +extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, + my_off_t seek_offset,pbool use_async_io, + pbool clear_cache); +extern void setup_io_cache(IO_CACHE* info); +extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count); +#ifdef THREAD +extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); +extern void init_io_cache_share(IO_CACHE *info, + IO_CACHE_SHARE *s, uint num_threads); +extern void remove_io_thread(IO_CACHE *info); +#endif +extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_get(IO_CACHE *info); +extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); +extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); +extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); + +extern int my_block_write(IO_CACHE *info, const byte *Buffer, + uint Count, my_off_t pos); +extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); + +#define flush_io_cache(info) my_b_flush_io_cache((info),1) + +extern int end_io_cache(IO_CACHE *info); +extern uint my_b_fill(IO_CACHE *info); +extern void my_b_seek(IO_CACHE *info,my_off_t pos); +extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); +extern my_off_t my_b_filelength(IO_CACHE *info); +extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); +extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); +extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, + const char *prefix, uint cache_size, + myf cache_myflags); +extern my_bool real_open_cached_file(IO_CACHE *cache); +extern void close_cached_file(IO_CACHE *cache); +File create_temp_file(char *to, const char *dir, const char *pfx, + int mode, myf MyFlags); +#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) +#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) +extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, + uint init_alloc,uint alloc_increment + CALLER_INFO_PROTO); +extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); +extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); +extern byte *pop_dynamic(DYNAMIC_ARRAY*); +extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); +extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); +extern void delete_dynamic(DYNAMIC_ARRAY *array); +extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); +extern void freeze_size(DYNAMIC_ARRAY *array); +#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) +#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) +#define push_dynamic(A,B) insert_dynamic(A,B) +#define reset_dynamic(array) ((array)->elements= 0) + +extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, + uint init_alloc,uint alloc_increment); +extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); +my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, + uint length); +extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); +extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); +extern void dynstr_free(DYNAMIC_STRING *str); +#ifdef HAVE_MLOCK +extern byte *my_malloc_lock(uint length,myf flags); +extern void my_free_lock(byte *ptr,myf flags); +#else +#define my_malloc_lock(A,B) my_malloc((A),(B)) +#define my_free_lock(A,B) my_free((A),(B)) +#endif +#define alloc_root_inited(A) ((A)->min_malloc != 0) +#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) +#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) +extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, + uint pre_alloc_size); +extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); +extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...); +extern void free_root(MEM_ROOT *root, myf MyFLAGS); +extern void set_prealloc_root(MEM_ROOT *root, char *ptr); +extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, + uint prealloc_size); +extern char *strdup_root(MEM_ROOT *root,const char *str); +extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); +extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); +extern int get_defaults_options(int argc, char **argv, + char **defaults, char **extra_defaults, + char **group_suffix); +extern int load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); +extern int modify_defaults_file(const char *file_location, const char *option, + const char *option_value, + const char *section_name, int remove_option); +extern int my_search_option_files(const char *conf_file, int *argc, + char ***argv, uint *args_used, + Process_option_func func, void *func_ctx); +extern void free_defaults(char **argv); +extern void my_print_default_files(const char *conf_file); +extern void print_defaults(const char *conf_file, const char **groups); +extern my_bool my_compress(byte *, ulong *, ulong *); +extern my_bool my_uncompress(byte *, ulong *, ulong *); +extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); +extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); +extern uint my_bit_log2(ulong value); +extern uint my_count_bits(ulonglong v); +extern uint my_count_bits_ushort(ushort v); +extern void my_sleep(ulong m_seconds); +extern ulong crc32(ulong crc, const uchar *buf, uint len); +extern uint my_set_max_open_files(uint files); +void my_free_open_file_info(void); + +ulonglong my_getsystime(void); +my_bool my_gethwaddr(uchar *to); + +#ifdef HAVE_SYS_MMAN_H +#include + +#ifndef MAP_NOSYNC +#define MAP_NOSYNC 0 +#endif + +#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) +#ifdef HAVE_GETPAGESIZE +#define my_getpagesize() getpagesize() +#else +/* qnx ? */ +#define my_getpagesize() 8192 +#endif +#define my_munmap(a,b) munmap((a),(b)) + +#else +/* not a complete set of mmap() flags, but only those that nesessary */ +#define PROT_READ 1 +#define PROT_WRITE 2 +#define MAP_SHARED 0x0001 +#define MAP_NOSYNC 0x0800 +#define MAP_FAILED ((void *)-1) +#define MS_SYNC 0x0000 + +#ifndef __NETWARE__ +#define HAVE_MMAP +#endif + +int my_getpagesize(void); +void *my_mmap(void *, size_t, int, int, int, my_off_t); +int my_munmap(void *, size_t); +#endif + +int my_msync(int, void *, size_t, int); + +/* character sets */ +extern uint get_charset_number(const char *cs_name, uint cs_flags); +extern uint get_collation_number(const char *name); +extern const char *get_charset_name(uint cs_number); + +extern CHARSET_INFO *get_charset(uint cs_number, myf flags); +extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); +extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, + uint cs_flags, myf my_flags); +extern void free_charsets(void); +extern char *get_charsets_dir(char *buf); +extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); +extern my_bool init_compiled_charsets(myf flags); +extern void add_compiled_collation(CHARSET_INFO *cs); +extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, + char *to, ulong to_length, + const char *from, ulong length); +#ifdef __WIN__ +#define BACKSLASH_MBTAIL +/* File system character set */ +extern CHARSET_INFO *fs_character_set(void); +#endif +extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, + char *to, ulong to_length, + const char *from, ulong length); + +extern void thd_increment_bytes_sent(ulong length); +extern void thd_increment_bytes_received(ulong length); +extern void thd_increment_net_big_packet_count(ulong length); + +#ifdef __WIN__ +extern my_bool have_tcpip; /* Is set if tcpip is used */ + +/* implemented in my_windac.c */ + +int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, + DWORD owner_rights, DWORD everybody_rights); + +void my_security_attr_free(SECURITY_ATTRIBUTES *sa); + +/* implemented in my_conio.c */ +char* my_cgets(char *string, unsigned long clen, unsigned long* plen); + +#endif +#ifdef __NETWARE__ +void netware_reg_user(const char *ip, const char *user, + const char *application); +#endif + +C_MODE_END +#include "raid.h" +#endif /* _my_sys_h */ diff --git a/3rdparty/mysql/include/mysql.h b/3rdparty/mysql/include/mysql.h new file mode 100644 index 000000000..925a45253 --- /dev/null +++ b/3rdparty/mysql/include/mysql.h @@ -0,0 +1,847 @@ +/* Copyright (C) 2000-2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _mysql_h +#define _mysql_h + +#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */ +#undef WIN +#undef _WIN +#undef _WIN32 +#undef _WIN64 +#undef __WIN__ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _global_h /* If not standard header */ +#include +#ifdef __LCC__ +#include /* For windows */ +#endif +typedef char my_bool; +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) +#define __WIN__ +#endif +#if !defined(__WIN__) +#define STDCALL +#else +#define STDCALL __stdcall +#endif +typedef char * gptr; + +#ifndef my_socket_defined +#ifdef __WIN__ +#define my_socket SOCKET +#else +typedef int my_socket; +#endif /* __WIN__ */ +#endif /* my_socket_defined */ +#endif /* _global_h */ + +#include "mysql_com.h" +#include "mysql_time.h" +#include "mysql_version.h" +#include "typelib.h" + +#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */ + +extern unsigned int mysql_port; +extern char *mysql_unix_port; + +#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */ +#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */ + +#ifdef __NETWARE__ +#pragma pack(push, 8) /* 8 byte alignment */ +#endif + +#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) +#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) +#define IS_BLOB(n) ((n) & BLOB_FLAG) +#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL) +#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) +#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR) + + +typedef struct st_mysql_field { + char *name; /* Name of column */ + char *org_name; /* Original column name, if an alias */ + char *table; /* Table of column if column was a field */ + char *org_table; /* Org table name, if table was an alias */ + char *db; /* Database for table */ + char *catalog; /* Catalog for table */ + char *def; /* Default value (set by mysql_list_fields) */ + unsigned long length; /* Width of column (create length) */ + unsigned long max_length; /* Max width for selected set */ + unsigned int name_length; + unsigned int org_name_length; + unsigned int table_length; + unsigned int org_table_length; + unsigned int db_length; + unsigned int catalog_length; + unsigned int def_length; + unsigned int flags; /* Div flags */ + unsigned int decimals; /* Number of decimals in field */ + unsigned int charsetnr; /* Character set */ + enum enum_field_types type; /* Type of field. See mysql_com.h for types */ +} MYSQL_FIELD; + +typedef char **MYSQL_ROW; /* return data as array of strings */ +typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ + +#ifndef _global_h +#if defined(NO_CLIENT_LONG_LONG) +typedef unsigned long my_ulonglong; +#elif defined (__WIN__) +typedef unsigned __int64 my_ulonglong; +#else +typedef unsigned long long my_ulonglong; +#endif +#endif + +#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0) + +/* backward compatibility define - to be removed eventually */ +#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED + +typedef struct st_mysql_rows { + struct st_mysql_rows *next; /* list of rows */ + MYSQL_ROW data; + unsigned long length; +} MYSQL_ROWS; + +typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ + +#include "my_alloc.h" + +typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; +typedef struct st_mysql_data { + my_ulonglong rows; + unsigned int fields; + MYSQL_ROWS *data; + MEM_ROOT alloc; + /* extra info for embedded library */ + struct embedded_query_result *embedded_info; +} MYSQL_DATA; + +enum mysql_option +{ + MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, + MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, + MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, + MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, + MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, + MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, + MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, + MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT +}; + +struct st_mysql_options { + unsigned int connect_timeout, read_timeout, write_timeout; + unsigned int port, protocol; + unsigned long client_flag; + char *host,*user,*password,*unix_socket,*db; + struct st_dynamic_array *init_commands; + char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; + char *ssl_key; /* PEM key file */ + char *ssl_cert; /* PEM cert file */ + char *ssl_ca; /* PEM CA file */ + char *ssl_capath; /* PEM directory of CA-s? */ + char *ssl_cipher; /* cipher to use */ + char *shared_memory_base_name; + unsigned long max_allowed_packet; + my_bool use_ssl; /* if to use SSL or not */ + my_bool compress,named_pipe; + /* + On connect, find out the replication role of the server, and + establish connections to all the peers + */ + my_bool rpl_probe; + /* + Each call to mysql_real_query() will parse it to tell if it is a read + or a write, and direct it to the slave or the master + */ + my_bool rpl_parse; + /* + If set, never read from a master, only from slave, when doing + a read that is replication-aware + */ + my_bool no_master_reads; +#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY) + my_bool separate_thread; +#endif + enum mysql_option methods_to_use; + char *client_ip; + /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */ + my_bool secure_auth; + /* 0 - never report, 1 - always report (default) */ + my_bool report_data_truncation; + + /* function pointers for local infile support */ + int (*local_infile_init)(void **, const char *, void *); + int (*local_infile_read)(void *, char *, unsigned int); + void (*local_infile_end)(void *); + int (*local_infile_error)(void *, char *, unsigned int); + void *local_infile_userdata; +}; + +enum mysql_status +{ + MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT +}; + +enum mysql_protocol_type +{ + MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, + MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY +}; +/* + There are three types of queries - the ones that have to go to + the master, the ones that go to a slave, and the adminstrative + type which must happen on the pivot connectioin +*/ +enum mysql_rpl_type +{ + MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN +}; + +typedef struct character_set +{ + unsigned int number; /* character set number */ + unsigned int state; /* character set state */ + const char *csname; /* collation name */ + const char *name; /* character set name */ + const char *comment; /* comment */ + const char *dir; /* character set directory */ + unsigned int mbminlen; /* min. length for multibyte strings */ + unsigned int mbmaxlen; /* max. length for multibyte strings */ +} MY_CHARSET_INFO; + +struct st_mysql_methods; + +typedef struct st_mysql +{ + NET net; /* Communication parameters */ + gptr connector_fd; /* ConnectorFd for SSL */ + char *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info; + char *db; + struct charset_info_st *charset; + MYSQL_FIELD *fields; + MEM_ROOT field_alloc; + my_ulonglong affected_rows; + my_ulonglong insert_id; /* id if insert on table with NEXTNR */ + my_ulonglong extra_info; /* Not used */ + unsigned long thread_id; /* Id for connection in server */ + unsigned long packet_length; + unsigned int port; + unsigned long client_flag,server_capabilities; + unsigned int protocol_version; + unsigned int field_count; + unsigned int server_status; + unsigned int server_language; + unsigned int warning_count; + struct st_mysql_options options; + enum mysql_status status; + my_bool free_me; /* If free in mysql_close */ + my_bool reconnect; /* set to 1 if automatic reconnect */ + + /* session-wide random string */ + char scramble[SCRAMBLE_LENGTH+1]; + + /* + Set if this is the original connection, not a master or a slave we have + added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() + */ + my_bool rpl_pivot; + /* + Pointers to the master, and the next slave connections, points to + itself if lone connection. + */ + struct st_mysql* master, *next_slave; + + struct st_mysql* last_used_slave; /* needed for round-robin slave pick */ + /* needed for send/read/store/use result to work correctly with replication */ + struct st_mysql* last_used_con; + + LIST *stmts; /* list of all statements */ + const struct st_mysql_methods *methods; + void *thd; + /* + Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag + from mysql_stmt_close if close had to cancel result set of this object. + */ + my_bool *unbuffered_fetch_owner; +#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100 + /* needed for embedded server - no net buffer to store the 'info' */ + char *info_buffer; +#endif +} MYSQL; + +typedef struct st_mysql_res { + my_ulonglong row_count; + MYSQL_FIELD *fields; + MYSQL_DATA *data; + MYSQL_ROWS *data_cursor; + unsigned long *lengths; /* column lengths of current row */ + MYSQL *handle; /* for unbuffered reads */ + MEM_ROOT field_alloc; + unsigned int field_count, current_field; + MYSQL_ROW row; /* If unbuffered read */ + MYSQL_ROW current_row; /* buffer to current row */ + my_bool eof; /* Used by mysql_fetch_row */ + /* mysql_stmt_close() had to cancel this result */ + my_bool unbuffered_fetch_cancelled; + const struct st_mysql_methods *methods; +} MYSQL_RES; + +#define MAX_MYSQL_MANAGER_ERR 256 +#define MAX_MYSQL_MANAGER_MSG 256 + +#define MANAGER_OK 200 +#define MANAGER_INFO 250 +#define MANAGER_ACCESS 401 +#define MANAGER_CLIENT_ERR 450 +#define MANAGER_INTERNAL_ERR 500 + +#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT) +#define MYSQL_CLIENT +#endif + + +typedef struct st_mysql_manager +{ + NET net; + char *host,*user,*passwd; + unsigned int port; + my_bool free_me; + my_bool eof; + int cmd_status; + int last_errno; + char* net_buf,*net_buf_pos,*net_data_end; + int net_buf_size; + char last_error[MAX_MYSQL_MANAGER_ERR]; +} MYSQL_MANAGER; + +typedef struct st_mysql_parameters +{ + unsigned long *p_max_allowed_packet; + unsigned long *p_net_buffer_length; +} MYSQL_PARAMETERS; + +#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) +#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet) +#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) +#endif + +/* + Set up and bring down the server; to ensure that applications will + work when linked against either the standard client library or the + embedded server library, these functions should be called. +*/ +int STDCALL mysql_server_init(int argc, char **argv, char **groups); +void STDCALL mysql_server_end(void); +/* + mysql_server_init/end need to be called when using libmysqld or + libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so + you don't need to call it explicitely; but you need to call + mysql_server_end() to free memory). The names are a bit misleading + (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general + names which suit well whether you're using libmysqld or libmysqlclient. We + intend to promote these aliases over the mysql_server* ones. +*/ +#define mysql_library_init mysql_server_init +#define mysql_library_end mysql_server_end + +MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void); + +/* + Set up and bring down a thread; these function should be called + for each thread in an application which opens at least one MySQL + connection. All uses of the connection(s) should be between these + function calls. +*/ +my_bool STDCALL mysql_thread_init(void); +void STDCALL mysql_thread_end(void); + +/* + Functions to get information from the MYSQL and MYSQL_RES structures + Should definitely be used if one uses shared libraries. +*/ + +my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); +unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); +my_bool STDCALL mysql_eof(MYSQL_RES *res); +MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, + unsigned int fieldnr); +MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res); +MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res); +MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res); + +unsigned int STDCALL mysql_field_count(MYSQL *mysql); +my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); +my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); +unsigned int STDCALL mysql_errno(MYSQL *mysql); +const char * STDCALL mysql_error(MYSQL *mysql); +const char *STDCALL mysql_sqlstate(MYSQL *mysql); +unsigned int STDCALL mysql_warning_count(MYSQL *mysql); +const char * STDCALL mysql_info(MYSQL *mysql); +unsigned long STDCALL mysql_thread_id(MYSQL *mysql); +const char * STDCALL mysql_character_set_name(MYSQL *mysql); +int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname); + +MYSQL * STDCALL mysql_init(MYSQL *mysql); +my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, + const char *cert, const char *ca, + const char *capath, const char *cipher); +my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, + const char *passwd, const char *db); +MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, + const char *user, + const char *passwd, + const char *db, + unsigned int port, + const char *unix_socket, + unsigned long clientflag); +int STDCALL mysql_select_db(MYSQL *mysql, const char *db); +int STDCALL mysql_query(MYSQL *mysql, const char *q); +int STDCALL mysql_send_query(MYSQL *mysql, const char *q, + unsigned long length); +int STDCALL mysql_real_query(MYSQL *mysql, const char *q, + unsigned long length); +MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); + +/* perform query on master */ +my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q, + unsigned long length); +my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, + unsigned long length); +/* perform query on slave */ +my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q, + unsigned long length); +my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, + unsigned long length); +void STDCALL mysql_get_character_set_info(MYSQL *mysql, + MY_CHARSET_INFO *charset); + +/* local infile support */ + +#define LOCAL_INFILE_ERROR_LEN 512 + +void +mysql_set_local_infile_handler(MYSQL *mysql, + int (*local_infile_init)(void **, const char *, + void *), + int (*local_infile_read)(void *, char *, + unsigned int), + void (*local_infile_end)(void *), + int (*local_infile_error)(void *, char*, + unsigned int), + void *); + +void +mysql_set_local_infile_default(MYSQL *mysql); + + +/* + enable/disable parsing of all queries to decide if they go on master or + slave +*/ +void STDCALL mysql_enable_rpl_parse(MYSQL* mysql); +void STDCALL mysql_disable_rpl_parse(MYSQL* mysql); +/* get the value of the parse flag */ +int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql); + +/* enable/disable reads from master */ +void STDCALL mysql_enable_reads_from_master(MYSQL* mysql); +void STDCALL mysql_disable_reads_from_master(MYSQL* mysql); +/* get the value of the master read flag */ +my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql); + +enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len); + +/* discover the master and its slaves */ +my_bool STDCALL mysql_rpl_probe(MYSQL* mysql); + +/* set the master, close/free the old one, if it is not a pivot */ +int STDCALL mysql_set_master(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); +int STDCALL mysql_add_slave(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); + +int STDCALL mysql_shutdown(MYSQL *mysql, + enum mysql_enum_shutdown_level + shutdown_level); +int STDCALL mysql_dump_debug_info(MYSQL *mysql); +int STDCALL mysql_refresh(MYSQL *mysql, + unsigned int refresh_options); +int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); +int STDCALL mysql_set_server_option(MYSQL *mysql, + enum enum_mysql_set_option + option); +int STDCALL mysql_ping(MYSQL *mysql); +const char * STDCALL mysql_stat(MYSQL *mysql); +const char * STDCALL mysql_get_server_info(MYSQL *mysql); +const char * STDCALL mysql_get_client_info(void); +unsigned long STDCALL mysql_get_client_version(void); +const char * STDCALL mysql_get_host_info(MYSQL *mysql); +unsigned long STDCALL mysql_get_server_version(MYSQL *mysql); +unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); +MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); +MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); +int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, + const char *arg); +void STDCALL mysql_free_result(MYSQL_RES *result); +void STDCALL mysql_data_seek(MYSQL_RES *result, + my_ulonglong offset); +MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, + MYSQL_ROW_OFFSET offset); +MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, + MYSQL_FIELD_OFFSET offset); +MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); +unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); +MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); +MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, + const char *wild); +unsigned long STDCALL mysql_escape_string(char *to,const char *from, + unsigned long from_length); +unsigned long STDCALL mysql_hex_string(char *to,const char *from, + unsigned long from_length); +unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, + char *to,const char *from, + unsigned long length); +void STDCALL mysql_debug(const char *debug); +char * STDCALL mysql_odbc_escape_string(MYSQL *mysql, + char *to, + unsigned long to_length, + const char *from, + unsigned long from_length, + void *param, + char * + (*extend_buffer) + (void *, char *to, + unsigned long *length)); +void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name); +unsigned int STDCALL mysql_thread_safe(void); +my_bool STDCALL mysql_embedded(void); +MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con); +MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con, + const char* host, + const char* user, + const char* passwd, + unsigned int port); +void STDCALL mysql_manager_close(MYSQL_MANAGER* con); +int STDCALL mysql_manager_command(MYSQL_MANAGER* con, + const char* cmd, int cmd_len); +int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, + char* res_buf, + int res_buf_size); +my_bool STDCALL mysql_read_query_result(MYSQL *mysql); + + +/* + The following definitions are added for the enhanced + client-server protocol +*/ + +/* statement state */ +enum enum_mysql_stmt_state +{ + MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE, + MYSQL_STMT_FETCH_DONE +}; + + +/* + This structure is used to define bind information, and + internally by the client library. + Public members with their descriptions are listed below + (conventionally `On input' refers to the binds given to + mysql_stmt_bind_param, `On output' refers to the binds given + to mysql_stmt_bind_result): + + buffer_type - One of the MYSQL_* types, used to describe + the host language type of buffer. + On output: if column type is different from + buffer_type, column value is automatically converted + to buffer_type before it is stored in the buffer. + buffer - On input: points to the buffer with input data. + On output: points to the buffer capable to store + output data. + The type of memory pointed by buffer must correspond + to buffer_type. See the correspondence table in + the comment to mysql_stmt_bind_param. + + The two above members are mandatory for any kind of bind. + + buffer_length - the length of the buffer. You don't have to set + it for any fixed length buffer: float, double, + int, etc. It must be set however for variable-length + types, such as BLOBs or STRINGs. + + length - On input: in case when lengths of input values + are different for each execute, you can set this to + point at a variable containining value length. This + way the value length can be different in each execute. + If length is not NULL, buffer_length is not used. + Note, length can even point at buffer_length if + you keep bind structures around while fetching: + this way you can change buffer_length before + each execution, everything will work ok. + On output: if length is set, mysql_stmt_fetch will + write column length into it. + + is_null - On input: points to a boolean variable that should + be set to TRUE for NULL values. + This member is useful only if your data may be + NULL in some but not all cases. + If your data is never NULL, is_null should be set to 0. + If your data is always NULL, set buffer_type + to MYSQL_TYPE_NULL, and is_null will not be used. + + is_unsigned - On input: used to signify that values provided for one + of numeric types are unsigned. + On output describes signedness of the output buffer. + If, taking into account is_unsigned flag, column data + is out of range of the output buffer, data for this column + is regarded truncated. Note that this has no correspondence + to the sign of result set column, if you need to find it out + use mysql_stmt_result_metadata. + error - where to write a truncation error if it is present. + possible error value is: + 0 no truncation + 1 value is out of range or buffer is too small + + Please note that MYSQL_BIND also has internals members. +*/ + +typedef struct st_mysql_bind +{ + unsigned long *length; /* output length pointer */ + my_bool *is_null; /* Pointer to null indicator */ + void *buffer; /* buffer to get/put data */ + /* set this if you want to track data truncations happened during fetch */ + my_bool *error; + enum enum_field_types buffer_type; /* buffer type */ + /* output buffer length, must be set when fetching str/binary */ + unsigned long buffer_length; + unsigned char *row_ptr; /* for the current data position */ + unsigned long offset; /* offset position for char/binary fetch */ + unsigned long length_value; /* Used if length is 0 */ + unsigned int param_number; /* For null count and error messages */ + unsigned int pack_length; /* Internal length for packed data */ + my_bool error_value; /* used if error is 0 */ + my_bool is_unsigned; /* set if integer type is unsigned */ + my_bool long_data_used; /* If used with mysql_send_long_data */ + my_bool is_null_value; /* Used if is_null is 0 */ + void (*store_param_func)(NET *net, struct st_mysql_bind *param); + void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *, + unsigned char **row); + void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, + unsigned char **row); +} MYSQL_BIND; + + +/* statement handler */ +typedef struct st_mysql_stmt +{ + MEM_ROOT mem_root; /* root allocations */ + LIST list; /* list to keep track of all stmts */ + MYSQL *mysql; /* connection handle */ + MYSQL_BIND *params; /* input parameters */ + MYSQL_BIND *bind; /* output parameters */ + MYSQL_FIELD *fields; /* result set metadata */ + MYSQL_DATA result; /* cached result set */ + MYSQL_ROWS *data_cursor; /* current row in cached result */ + /* copy of mysql->affected_rows after statement execution */ + my_ulonglong affected_rows; + my_ulonglong insert_id; /* copy of mysql->insert_id */ + /* + mysql_stmt_fetch() calls this function to fetch one row (it's different + for buffered, unbuffered and cursor fetch). + */ + int (*read_row_func)(struct st_mysql_stmt *stmt, + unsigned char **row); + unsigned long stmt_id; /* Id for prepared statement */ + unsigned long flags; /* i.e. type of cursor to open */ + unsigned long prefetch_rows; /* number of rows per one COM_FETCH */ + /* + Copied from mysql->server_status after execute/fetch to know + server-side cursor status for this statement. + */ + unsigned int server_status; + unsigned int last_errno; /* error code */ + unsigned int param_count; /* input parameter count */ + unsigned int field_count; /* number of columns in result set */ + enum enum_mysql_stmt_state state; /* statement state */ + char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ + char sqlstate[SQLSTATE_LENGTH+1]; + /* Types of input parameters should be sent to server */ + my_bool send_types_to_server; + my_bool bind_param_done; /* input buffers were supplied */ + unsigned char bind_result_done; /* output buffers were supplied */ + /* mysql_stmt_close() had to cancel this result */ + my_bool unbuffered_fetch_cancelled; + /* + Is set to true if we need to calculate field->max_length for + metadata fields when doing mysql_stmt_store_result. + */ + my_bool update_max_length; +} MYSQL_STMT; + +enum enum_stmt_attr_type +{ + /* + When doing mysql_stmt_store_result calculate max_length attribute + of statement metadata. This is to be consistent with the old API, + where this was done automatically. + In the new API we do that only by request because it slows down + mysql_stmt_store_result sufficiently. + */ + STMT_ATTR_UPDATE_MAX_LENGTH, + /* + unsigned long with combination of cursor flags (read only, for update, + etc) + */ + STMT_ATTR_CURSOR_TYPE, + /* + Amount of rows to retrieve from server per one fetch if using cursors. + Accepts unsigned long attribute in the range 1 - ulong_max + */ + STMT_ATTR_PREFETCH_ROWS +}; + + +typedef struct st_mysql_methods +{ + my_bool (*read_query_result)(MYSQL *mysql); + my_bool (*advanced_command)(MYSQL *mysql, + enum enum_server_command command, + const char *header, + unsigned long header_length, + const char *arg, + unsigned long arg_length, + my_bool skip_check); + MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields); + MYSQL_RES * (*use_result)(MYSQL *mysql); + void (*fetch_lengths)(unsigned long *to, + MYSQL_ROW column, unsigned int field_count); + void (*flush_use_result)(MYSQL *mysql); +#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) + MYSQL_FIELD * (*list_fields)(MYSQL *mysql); + my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (*stmt_execute)(MYSQL_STMT *stmt); + int (*read_binary_rows)(MYSQL_STMT *stmt); + int (*unbuffered_fetch)(MYSQL *mysql, char **row); + void (*free_embedded_thd)(MYSQL *mysql); + const char *(*read_statistics)(MYSQL *mysql); + my_bool (*next_result)(MYSQL *mysql); + int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd); + int (*read_rows_from_cursor)(MYSQL_STMT *stmt); +#endif +} MYSQL_METHODS; + + +MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql); +int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, + unsigned long length); +int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, + unsigned int column, + unsigned long offset); +int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); +unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, + enum enum_stmt_attr_type attr_type, + const void *attr); +my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, + enum enum_stmt_attr_type attr_type, + void *attr); +my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt); +my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, + unsigned int param_number, + const char *data, + unsigned long length); +MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt); +MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt); +unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt); +const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt); +const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt); +MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, + MYSQL_ROW_OFFSET offset); +MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); +void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset); +my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt); +my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); +my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt); +unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt); + +my_bool STDCALL mysql_commit(MYSQL * mysql); +my_bool STDCALL mysql_rollback(MYSQL * mysql); +my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode); +my_bool STDCALL mysql_more_results(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); +void STDCALL mysql_close(MYSQL *sock); + + +/* status return codes */ +#define MYSQL_NO_DATA 100 +#define MYSQL_DATA_TRUNCATED 101 + +#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) + +#ifdef USE_OLD_FUNCTIONS +MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, + const char *user, const char *passwd); +int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); +int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); +#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) +#endif +#define HAVE_MYSQL_REAL_CONNECT + +/* + The following functions are mainly exported because of mysqlbinlog; + They are not for general usage +*/ + +#define simple_command(mysql, command, arg, length, skip_check) \ + (*(mysql)->methods->advanced_command)(mysql, command, \ + NullS, 0, arg, length, skip_check) +unsigned long net_safe_read(MYSQL* mysql); + +#ifdef __NETWARE__ +#pragma pack(pop) /* restore alignment */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _mysql_h */ diff --git a/3rdparty/mysql/include/mysql_com.h b/3rdparty/mysql/include/mysql_com.h new file mode 100644 index 000000000..ec1c13379 --- /dev/null +++ b/3rdparty/mysql/include/mysql_com.h @@ -0,0 +1,452 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* +** Common definition between mysql server & client +*/ + +#ifndef _mysql_com_h +#define _mysql_com_h + +#define NAME_LEN 64 /* Field/table name length */ +#define HOSTNAME_LENGTH 60 +#define USERNAME_LENGTH 16 +#define SERVER_VERSION_LENGTH 60 +#define SQLSTATE_LENGTH 5 + +/* + USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain + username and hostname parts of the user identifier with trailing zero in + MySQL standard format: + user_name_part@host_name_part\0 +*/ +#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2 + +#define LOCAL_HOST "localhost" +#define LOCAL_HOST_NAMEDPIPE "." + + +#if defined(__WIN__) && !defined( _CUSTOMCONFIG_) +#define MYSQL_NAMEDPIPE "MySQL" +#define MYSQL_SERVICENAME "MySQL" +#endif /* __WIN__ */ + +/* + You should add new commands to the end of this list, otherwise old + servers won't be able to handle them as 'unsupported'. +*/ + +enum enum_server_command +{ + COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, + COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, + COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, + COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, + COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE, + COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, + COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, + /* don't forget to update const char *command_name[] in sql_parse.cc */ + + /* Must be last */ + COM_END +}; + + +/* + Length of random string sent by server on handshake; this is also length of + obfuscated password, recieved from client +*/ +#define SCRAMBLE_LENGTH 20 +#define SCRAMBLE_LENGTH_323 8 +/* length of password stored in the db: new passwords are preceeded with '*' */ +#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) +#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2) + + +#define NOT_NULL_FLAG 1 /* Field can't be NULL */ +#define PRI_KEY_FLAG 2 /* Field is part of a primary key */ +#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ +#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ +#define BLOB_FLAG 16 /* Field is a blob */ +#define UNSIGNED_FLAG 32 /* Field is unsigned */ +#define ZEROFILL_FLAG 64 /* Field is zerofill */ +#define BINARY_FLAG 128 /* Field is binary */ + +/* The following are only sent to new clients */ +#define ENUM_FLAG 256 /* field is an enum */ +#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ +#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ +#define SET_FLAG 2048 /* field is a set */ +#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ +#define NUM_FLAG 32768 /* Field is num (for clients) */ +#define PART_KEY_FLAG 16384 /* Intern; Part of some key */ +#define GROUP_FLAG 32768 /* Intern: Group field */ +#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ +#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */ + +#define REFRESH_GRANT 1 /* Refresh grant tables */ +#define REFRESH_LOG 2 /* Start on new log file */ +#define REFRESH_TABLES 4 /* close all tables */ +#define REFRESH_HOSTS 8 /* Flush host cache */ +#define REFRESH_STATUS 16 /* Flush status variables */ +#define REFRESH_THREADS 32 /* Flush thread cache */ +#define REFRESH_SLAVE 64 /* Reset master info and restart slave + thread */ +#define REFRESH_MASTER 128 /* Remove all bin logs in the index + and truncate the index */ + +/* The following can't be set with mysql_refresh() */ +#define REFRESH_READ_LOCK 16384 /* Lock tables for read */ +#define REFRESH_FAST 32768 /* Intern flag */ + +/* RESET (remove all queries) from query cache */ +#define REFRESH_QUERY_CACHE 65536 +#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ +#define REFRESH_DES_KEY_FILE 0x40000L +#define REFRESH_USER_RESOURCES 0x80000L + +#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ +#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ +#define CLIENT_LONG_FLAG 4 /* Get all column flags */ +#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ +#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ +#define CLIENT_COMPRESS 32 /* Can use compression protocol */ +#define CLIENT_ODBC 64 /* Odbc client */ +#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ +#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ +#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */ +#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ +#define CLIENT_SSL 2048 /* Switch to SSL after handshake */ +#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ +#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ +#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ +#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ +#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ +#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ +#define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31) + +#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ +#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ +#define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */ +#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ +#define SERVER_QUERY_NO_GOOD_INDEX_USED 16 +#define SERVER_QUERY_NO_INDEX_USED 32 +/* + The server was able to fulfill the clients request and opened a + read-only non-scrollable cursor for a query. This flag comes + in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. +*/ +#define SERVER_STATUS_CURSOR_EXISTS 64 +/* + This flag is sent when a read-only cursor is exhausted, in reply to + COM_STMT_FETCH command. +*/ +#define SERVER_STATUS_LAST_ROW_SENT 128 +#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ +#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 + +#define MYSQL_ERRMSG_SIZE 512 +#define NET_READ_TIMEOUT 30 /* Timeout on read */ +#define NET_WRITE_TIMEOUT 60 /* Timeout on write */ +#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */ + +#define ONLY_KILL_QUERY 1 + +struct st_vio; /* Only C */ +typedef struct st_vio Vio; + +#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */ +#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */ +#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */ +#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */ +#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */ +#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ +#define MAX_BLOB_WIDTH 8192 /* Default width for blob */ + +typedef struct st_net { +#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) + Vio* vio; + unsigned char *buff,*buff_end,*write_pos,*read_pos; + my_socket fd; /* For Perl DBI/dbd */ + unsigned long max_packet,max_packet_size; + unsigned int pkt_nr,compress_pkt_nr; + unsigned int write_timeout, read_timeout, retry_count; + int fcntl; + my_bool compress; + /* + The following variable is set if we are doing several queries in one + command ( as in LOAD TABLE ... FROM MASTER ), + and do not want to confuse the client with OK at the wrong time + */ + unsigned long remain_in_buf,length, buf_length, where_b; + unsigned int *return_status; + unsigned char reading_or_writing; + char save_char; + my_bool no_send_ok; /* For SPs and other things that do multiple stmts */ + my_bool no_send_eof; /* For SPs' first version read-only cursors */ + /* + Set if OK packet is already sent, and we do not need to send error + messages + */ + my_bool no_send_error; + /* + Pointer to query object in query cache, do not equal NULL (0) for + queries in cache that have not stored its results yet + */ +#endif + char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1]; + unsigned int last_errno; + unsigned char error; + gptr query_cache_query; + my_bool report_error; /* We should report error (we have unreported error) */ + my_bool return_errno; +} NET; + +#define packet_error (~(unsigned long) 0) + +enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, + MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, + MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, + MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, + MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, + MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, + MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, + MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, + MYSQL_TYPE_BIT, + MYSQL_TYPE_NEWDECIMAL=246, + MYSQL_TYPE_ENUM=247, + MYSQL_TYPE_SET=248, + MYSQL_TYPE_TINY_BLOB=249, + MYSQL_TYPE_MEDIUM_BLOB=250, + MYSQL_TYPE_LONG_BLOB=251, + MYSQL_TYPE_BLOB=252, + MYSQL_TYPE_VAR_STRING=253, + MYSQL_TYPE_STRING=254, + MYSQL_TYPE_GEOMETRY=255 + +}; + +/* For backward compatibility */ +#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS +#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL +#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL +#define FIELD_TYPE_TINY MYSQL_TYPE_TINY +#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT +#define FIELD_TYPE_LONG MYSQL_TYPE_LONG +#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT +#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE +#define FIELD_TYPE_NULL MYSQL_TYPE_NULL +#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP +#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG +#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 +#define FIELD_TYPE_DATE MYSQL_TYPE_DATE +#define FIELD_TYPE_TIME MYSQL_TYPE_TIME +#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME +#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR +#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE +#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM +#define FIELD_TYPE_SET MYSQL_TYPE_SET +#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB +#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB +#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB +#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB +#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING +#define FIELD_TYPE_STRING MYSQL_TYPE_STRING +#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY +#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM +#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY +#define FIELD_TYPE_BIT MYSQL_TYPE_BIT + + +/* Shutdown/kill enums and constants */ + +/* Bits for THD::killable. */ +#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) +#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) +#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) +#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) + +enum mysql_enum_shutdown_level { + /* + We want levels to be in growing order of hardness (because we use number + comparisons). Note that DEFAULT does not respect the growing property, but + it's ok. + */ + SHUTDOWN_DEFAULT = 0, + /* wait for existing connections to finish */ + SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT, + /* wait for existing trans to finish */ + SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS, + /* wait for existing updates to finish (=> no partial MyISAM update) */ + SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE, + /* flush InnoDB buffers and other storage engines' buffers*/ + SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), + /* don't flush InnoDB buffers, flush other storage engines' buffers*/ + SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, + /* Now the 2 levels of the KILL command */ +#if MYSQL_VERSION_ID >= 50000 + KILL_QUERY= 254, +#endif + KILL_CONNECTION= 255 +}; + + +enum enum_cursor_type +{ + CURSOR_TYPE_NO_CURSOR= 0, + CURSOR_TYPE_READ_ONLY= 1, + CURSOR_TYPE_FOR_UPDATE= 2, + CURSOR_TYPE_SCROLLABLE= 4 +}; + + +/* options for mysql_set_option */ +enum enum_mysql_set_option +{ + MYSQL_OPTION_MULTI_STATEMENTS_ON, + MYSQL_OPTION_MULTI_STATEMENTS_OFF +}; + +#define net_new_transaction(net) ((net)->pkt_nr=0) + +#ifdef __cplusplus +extern "C" { +#endif + +my_bool my_net_init(NET *net, Vio* vio); +void my_net_local_init(NET *net); +void net_end(NET *net); +void net_clear(NET *net); +my_bool net_realloc(NET *net, unsigned long length); +my_bool net_flush(NET *net); +my_bool my_net_write(NET *net,const char *packet,unsigned long len); +my_bool net_write_command(NET *net,unsigned char command, + const char *header, unsigned long head_len, + const char *packet, unsigned long len); +int net_real_write(NET *net,const char *packet,unsigned long len); +unsigned long my_net_read(NET *net); + +/* + The following function is not meant for normal usage + Currently it's used internally by manager.c +*/ +struct sockaddr; +int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, + unsigned int timeout); + +struct rand_struct { + unsigned long seed1,seed2,max_value; + double max_value_dbl; +}; + +#ifdef __cplusplus +} +#endif + + /* The following is for user defined functions */ + +enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, + DECIMAL_RESULT}; + +typedef struct st_udf_args +{ + unsigned int arg_count; /* Number of arguments */ + enum Item_result *arg_type; /* Pointer to item_results */ + char **args; /* Pointer to argument */ + unsigned long *lengths; /* Length of string arguments */ + char *maybe_null; /* Set to 1 for all maybe_null args */ + char **attributes; /* Pointer to attribute name */ + unsigned long *attribute_lengths; /* Length of attribute arguments */ +} UDF_ARGS; + + /* This holds information about the result */ + +typedef struct st_udf_init +{ + my_bool maybe_null; /* 1 if function can return NULL */ + unsigned int decimals; /* for real functions */ + unsigned long max_length; /* For string functions */ + char *ptr; /* free pointer for function data */ + my_bool const_item; /* 0 if result is independent of arguments */ +} UDF_INIT; + + /* Constants when using compression */ +#define NET_HEADER_SIZE 4 /* standard header size */ +#define COMP_HEADER_SIZE 3 /* compression header extra size */ + + /* Prototypes to password functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + These functions are used for authentication by client and server and + implemented in sql/password.c +*/ + +void randominit(struct rand_struct *, unsigned long seed1, + unsigned long seed2); +double my_rnd(struct rand_struct *); +void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st); + +void hash_password(unsigned long *to, const char *password, unsigned int password_len); +void make_scrambled_password_323(char *to, const char *password); +void scramble_323(char *to, const char *message, const char *password); +my_bool check_scramble_323(const char *, const char *message, + unsigned long *salt); +void get_salt_from_password_323(unsigned long *res, const char *password); +void make_password_from_salt_323(char *to, const unsigned long *salt); + +void make_scrambled_password(char *to, const char *password); +void scramble(char *to, const char *message, const char *password); +my_bool check_scramble(const char *reply, const char *message, + const unsigned char *hash_stage2); +void get_salt_from_password(unsigned char *res, const char *password); +void make_password_from_salt(char *to, const unsigned char *hash_stage2); +char *octet2hex(char *to, const char *str, unsigned int len); + +/* end of password.c */ + +char *get_tty_password(char *opt_message); +const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); + +/* Some other useful functions */ + +my_bool my_init(void); +extern int modify_defaults_file(const char *file_location, const char *option, + const char *option_value, + const char *section_name, int remove_option); +int load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); +my_bool my_thread_init(void); +void my_thread_end(void); + +#ifdef _global_h +ulong STDCALL net_field_length(uchar **packet); +my_ulonglong net_field_length_ll(uchar **packet); +char *net_store_length(char *pkg, ulonglong length); +#endif + +#ifdef __cplusplus +} +#endif + +#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ +#define MYSQL_STMT_HEADER 4 +#define MYSQL_LONG_DATA_HEADER 6 + +#endif diff --git a/3rdparty/mysql/include/mysql_time.h b/3rdparty/mysql/include/mysql_time.h new file mode 100644 index 000000000..5f4fc12c0 --- /dev/null +++ b/3rdparty/mysql/include/mysql_time.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _mysql_time_h_ +#define _mysql_time_h_ + +/* + Time declarations shared between the server and client API: + you should not add anything to this header unless it's used + (and hence should be visible) in mysql.h. + If you're looking for a place to add new time-related declaration, + it's most likely my_time.h. See also "C API Handling of Date + and Time Values" chapter in documentation. +*/ + +enum enum_mysql_timestamp_type +{ + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 +}; + + +/* + Structure which is used to represent datetime values inside MySQL. + + We assume that values in this structure are normalized, i.e. year <= 9999, + month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions + in server such as my_system_gmt_sec() or make_time() family of functions + rely on this (actually now usage of make_*() family relies on a bit weaker + restriction). Also functions that produce MYSQL_TIME as result ensure this. + There is one exception to this rule though if this structure holds time + value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold + bigger values. +*/ +typedef struct st_mysql_time +{ + unsigned int year, month, day, hour, minute, second; + unsigned long second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; +} MYSQL_TIME; + +#endif /* _mysql_time_h_ */ diff --git a/3rdparty/mysql/include/mysql_version.h b/3rdparty/mysql/include/mysql_version.h new file mode 100644 index 000000000..473a19987 --- /dev/null +++ b/3rdparty/mysql/include/mysql_version.h @@ -0,0 +1,29 @@ +/* Copyright Abandoned 1996, 1999, 2001 MySQL AB + This file is public domain and comes with NO WARRANTY of any kind */ + +/* Version numbers for protocol & mysqld */ + +#ifndef _mysql_version_h +#define _mysql_version_h +#ifdef _CUSTOMCONFIG_ +#include +#else +#define PROTOCOL_VERSION 10 +#define MYSQL_SERVER_VERSION "5.0.20" +#define MYSQL_BASE_VERSION "mysqld-5.0" +#define MYSQL_SERVER_SUFFIX_DEF "-community-max-nt" +#define FRM_VER 6 +#define MYSQL_VERSION_ID 50020 +#define MYSQL_PORT 3306 +#define MYSQL_UNIX_ADDR "/tmp/mysql.sock" +#define MYSQL_CONFIG_NAME "my" +#define MYSQL_COMPILATION_COMMENT "MySQL Community Edition - Max (GPL)" + +/* mysqld compile time options */ +#endif /* _CUSTOMCONFIG_ */ + +#ifndef LICENSE +#define LICENSE GPL +#endif /* LICENSE */ + +#endif /* _mysql_version_h */ diff --git a/3rdparty/mysql/include/raid.h b/3rdparty/mysql/include/raid.h new file mode 100644 index 000000000..c840afcba --- /dev/null +++ b/3rdparty/mysql/include/raid.h @@ -0,0 +1,159 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* Parser needs these defines always, even if USE_RAID is not defined */ +#define RAID_TYPE_0 1 /* Striping */ +#define RAID_TYPE_x 2 /* Some new modes */ +#define RAID_TYPE_y 3 + +#define RAID_DEFAULT_CHUNKS 4 +#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */ + +C_MODE_START +#define my_raid_type(raid_type) raid_type_string[(int)(raid_type)] +extern const char *raid_type_string[]; +C_MODE_END + +#ifdef DONT_USE_RAID +#undef USE_RAID +#endif +#if defined(USE_RAID) + +#include "my_dir.h" + +/* Trap all occurences of my_...() in source and use our wrapper around this function */ + +#ifdef MAP_TO_USE_RAID +#define my_read(A,B,C,D) my_raid_read(A,B,C,D) +#define my_write(A,B,C,D) my_raid_write(A,B,C,D) +#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E) +#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E) +#define my_chsize(A,B,C,D) my_raid_chsize(A,B,C,D) +#define my_close(A,B) my_raid_close(A,B) +#define my_tell(A,B) my_raid_tell(A,B) +#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D) +#define my_lock(A,B,C,D,E) my_raid_lock(A,B,C,D,E) +#define my_fstat(A,B,C) my_raid_fstat(A,B,C) +#endif /* MAP_TO_USE_RAID */ + +#ifdef __cplusplus +extern "C" { +#endif + + void init_raid(void); + void end_raid(void); + + bool is_raid(File fd); + File my_raid_create(const char *FileName, int CreateFlags, int access_flags, + uint raid_type, uint raid_chunks, ulong raid_chunksize, + myf MyFlags); + File my_raid_open(const char *FileName, int Flags, + uint raid_type, uint raid_chunks, ulong raid_chunksize, + myf MyFlags); + int my_raid_rename(const char *from, const char *to, uint raid_chunks, + myf MyFlags); + int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags); + int my_raid_redel(const char *old_name, const char *new_name, + uint raid_chunks, myf MyFlags); + + my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags); + my_off_t my_raid_tell(File fd, myf MyFlags); + + uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags); + uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags); + + uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, + myf MyFlags); + uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count, + my_off_t offset, myf MyFlags); + + int my_raid_lock(File,int locktype, my_off_t start, my_off_t length, + myf MyFlags); + int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags); + int my_raid_close(File, myf MyFlags); + int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags); + +#ifdef __cplusplus +} + +#ifdef USE_PRAGMA_INTERFACE +#pragma interface /* gcc class implementation */ +#endif + +class RaidName { + public: + RaidName(const char *FileName); + ~RaidName(); + bool IsRaid(); + int Rename(const char * from, const char * to, myf MyFlags); + private: + uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ + uint _raid_chunks; /* 1..n */ + ulong _raid_chunksize; /* 1..n in bytes */ +}; + +class RaidFd { + public: + RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize); + ~RaidFd(); + File Create(const char *FileName, int CreateFlags, int access_flags, + myf MyFlags); + File Open(const char *FileName, int Flags, myf MyFlags); + my_off_t Seek(my_off_t pos,int whence,myf MyFlags); + my_off_t Tell(myf MyFlags); + int Write(const byte *Buffer, uint Count, myf MyFlags); + int Read(const byte *Buffer, uint Count, myf MyFlags); + int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags); + int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags); + int Fstat(int fd, MY_STAT *stat_area, myf MyFlags ); + int Close(myf MyFlags); + static bool IsRaid(File fd); + static DYNAMIC_ARRAY _raid_map; /* Map of RaidFD* */ + private: + + uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ + uint _raid_chunks; /* 1..n */ + ulong _raid_chunksize; /* 1..n in bytes */ + + ulong _total_block; /* We are operating with block no x (can be 0..many). */ + uint _this_block; /* can be 0.._raid_chunks */ + uint _remaining_bytes; /* Maximum bytes that can be written in this block */ + + my_off_t _position; + my_off_t _size; /* Cached file size for faster seek(SEEK_END) */ + File _fd; + File *_fd_vector; /* Array of File */ + off_t *_seek_vector; /* Array of cached seek positions */ + + inline void Calculate() + { + DBUG_ENTER("RaidFd::_Calculate"); + DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu", + (ulong) _position, _raid_chunksize, (ulong) _size)); + + _total_block = (ulong) (_position / _raid_chunksize); + _this_block = _total_block % _raid_chunks; /* can be 0.._raid_chunks */ + _remaining_bytes = (uint) (_raid_chunksize - + (_position - _total_block * _raid_chunksize)); + DBUG_PRINT("info", + ("_total_block: %d this_block: %d _remaining_bytes:%d", + _total_block, _this_block, _remaining_bytes)); + DBUG_VOID_RETURN; + } +}; + +#endif /* __cplusplus */ +#endif /* USE_RAID */ diff --git a/3rdparty/mysql/include/typelib.h b/3rdparty/mysql/include/typelib.h new file mode 100644 index 000000000..4d6a90ad5 --- /dev/null +++ b/3rdparty/mysql/include/typelib.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#ifndef _typelib_h +#define _typelib_h + +typedef struct st_typelib { /* Different types saved here */ + unsigned int count; /* How many types */ + const char *name; /* Name of typelib */ + const char **type_names; + unsigned int *type_lengths; +} TYPELIB; + +extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name); +extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); +extern const char *get_type(TYPELIB *typelib,unsigned int nr); + +extern TYPELIB sql_protocol_typelib; + +#endif /* _typelib_h */ diff --git a/3rdparty/mysql/lib/libmysql.lib b/3rdparty/mysql/lib/libmysql.lib new file mode 100644 index 000000000..aa99dc3b8 Binary files /dev/null and b/3rdparty/mysql/lib/libmysql.lib differ diff --git a/3rdparty/mysql/mysql-5.0.20 b/3rdparty/mysql/mysql-5.0.20 new file mode 100644 index 000000000..e69de29bb diff --git a/3rdparty/pcre/include/pcre.h b/3rdparty/pcre/include/pcre.h new file mode 100644 index 000000000..e973396ba --- /dev/null +++ b/3rdparty/pcre/include/pcre.h @@ -0,0 +1,294 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* This is the public header file for the PCRE library, to be #included by +applications that call the PCRE functions. + + Copyright (c) 1997-2006 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +#ifndef _PCRE_H +#define _PCRE_H + +/* The current PCRE version information. */ + +/* NOTES FOR FUTURE MAINTAINERS: Do not use numbers with leading zeros, because +they may be treated as octal constants. The PCRE_PRERELEASE feature is for +identifying release candidates. It might be defined as -RC2, for example. In +real releases, it should be defined empty. Do not change the alignment of these +statments. The code in ./configure greps out the version numbers by using "cut" +to get values from column 29 onwards. These are substituted into pcre-config +and libpcre.pc. The values are not put into configure.ac and substituted here +(which would simplify this issue) because that makes life harder for those who +cannot run ./configure. As it now stands, this file need not be edited in that +circumstance. */ + +#define PCRE_MAJOR 7 +#define PCRE_MINOR 0 +#define PCRE_PRERELEASE +#define PCRE_DATE 18-Dec-2006 + +/* Win32 uses DLL by default; it needs special stuff for exported functions +when building PCRE. */ + +#ifdef _WIN32 +# ifdef PCRE_DEFINITION +# ifdef DLL_EXPORT +# define PCRE_DATA_SCOPE __declspec(dllexport) +# endif +# else +# ifndef PCRE_STATIC +# define PCRE_DATA_SCOPE extern __declspec(dllimport) +# endif +# endif +#endif + +/* Otherwise, we use the standard "extern". */ + +#ifndef PCRE_DATA_SCOPE +# ifdef __cplusplus +# define PCRE_DATA_SCOPE extern "C" +# else +# define PCRE_DATA_SCOPE extern +# endif +#endif + +/* Have to include stdlib.h in order to ensure that size_t is defined; +it is needed here for malloc. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options */ + +#define PCRE_CASELESS 0x00000001 +#define PCRE_MULTILINE 0x00000002 +#define PCRE_DOTALL 0x00000004 +#define PCRE_EXTENDED 0x00000008 +#define PCRE_ANCHORED 0x00000010 +#define PCRE_DOLLAR_ENDONLY 0x00000020 +#define PCRE_EXTRA 0x00000040 +#define PCRE_NOTBOL 0x00000080 +#define PCRE_NOTEOL 0x00000100 +#define PCRE_UNGREEDY 0x00000200 +#define PCRE_NOTEMPTY 0x00000400 +#define PCRE_UTF8 0x00000800 +#define PCRE_NO_AUTO_CAPTURE 0x00001000 +#define PCRE_NO_UTF8_CHECK 0x00002000 +#define PCRE_AUTO_CALLOUT 0x00004000 +#define PCRE_PARTIAL 0x00008000 +#define PCRE_DFA_SHORTEST 0x00010000 +#define PCRE_DFA_RESTART 0x00020000 +#define PCRE_FIRSTLINE 0x00040000 +#define PCRE_DUPNAMES 0x00080000 +#define PCRE_NEWLINE_CR 0x00100000 +#define PCRE_NEWLINE_LF 0x00200000 +#define PCRE_NEWLINE_CRLF 0x00300000 +#define PCRE_NEWLINE_ANY 0x00400000 + +/* Exec-time and get/set-time error codes */ + +#define PCRE_ERROR_NOMATCH (-1) +#define PCRE_ERROR_NULL (-2) +#define PCRE_ERROR_BADOPTION (-3) +#define PCRE_ERROR_BADMAGIC (-4) +#define PCRE_ERROR_UNKNOWN_OPCODE (-5) +#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */ +#define PCRE_ERROR_NOMEMORY (-6) +#define PCRE_ERROR_NOSUBSTRING (-7) +#define PCRE_ERROR_MATCHLIMIT (-8) +#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */ +#define PCRE_ERROR_BADUTF8 (-10) +#define PCRE_ERROR_BADUTF8_OFFSET (-11) +#define PCRE_ERROR_PARTIAL (-12) +#define PCRE_ERROR_BADPARTIAL (-13) +#define PCRE_ERROR_INTERNAL (-14) +#define PCRE_ERROR_BADCOUNT (-15) +#define PCRE_ERROR_DFA_UITEM (-16) +#define PCRE_ERROR_DFA_UCOND (-17) +#define PCRE_ERROR_DFA_UMLIMIT (-18) +#define PCRE_ERROR_DFA_WSSIZE (-19) +#define PCRE_ERROR_DFA_RECURSE (-20) +#define PCRE_ERROR_RECURSIONLIMIT (-21) +#define PCRE_ERROR_NULLWSLIMIT (-22) +#define PCRE_ERROR_BADNEWLINE (-23) + +/* Request types for pcre_fullinfo() */ + +#define PCRE_INFO_OPTIONS 0 +#define PCRE_INFO_SIZE 1 +#define PCRE_INFO_CAPTURECOUNT 2 +#define PCRE_INFO_BACKREFMAX 3 +#define PCRE_INFO_FIRSTBYTE 4 +#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */ +#define PCRE_INFO_FIRSTTABLE 5 +#define PCRE_INFO_LASTLITERAL 6 +#define PCRE_INFO_NAMEENTRYSIZE 7 +#define PCRE_INFO_NAMECOUNT 8 +#define PCRE_INFO_NAMETABLE 9 +#define PCRE_INFO_STUDYSIZE 10 +#define PCRE_INFO_DEFAULT_TABLES 11 + +/* Request types for pcre_config(). Do not re-arrange, in order to remain +compatible. */ + +#define PCRE_CONFIG_UTF8 0 +#define PCRE_CONFIG_NEWLINE 1 +#define PCRE_CONFIG_LINK_SIZE 2 +#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3 +#define PCRE_CONFIG_MATCH_LIMIT 4 +#define PCRE_CONFIG_STACKRECURSE 5 +#define PCRE_CONFIG_UNICODE_PROPERTIES 6 +#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 + +/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine +these bits, just add new ones on the end, in order to remain compatible. */ + +#define PCRE_EXTRA_STUDY_DATA 0x0001 +#define PCRE_EXTRA_MATCH_LIMIT 0x0002 +#define PCRE_EXTRA_CALLOUT_DATA 0x0004 +#define PCRE_EXTRA_TABLES 0x0008 +#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010 + +/* Types */ + +struct real_pcre; /* declaration; the definition is private */ +typedef struct real_pcre pcre; + +/* When PCRE is compiled as a C++ library, the subject pointer type can be +replaced with a custom type. For conventional use, the public interface is a +const char *. */ + +#ifndef PCRE_SPTR +#define PCRE_SPTR const char * +#endif + +/* The structure for passing additional data to pcre_exec(). This is defined in +such as way as to be extensible. Always add new fields at the end, in order to +remain compatible. */ + +typedef struct pcre_extra { + unsigned long int flags; /* Bits for which fields are set */ + void *study_data; /* Opaque data from pcre_study() */ + unsigned long int match_limit; /* Maximum number of calls to match() */ + void *callout_data; /* Data passed back in callouts */ + const unsigned char *tables; /* Pointer to character tables */ + unsigned long int match_limit_recursion; /* Max recursive calls to match() */ +} pcre_extra; + +/* The structure for passing out data via the pcre_callout_function. We use a +structure so that new fields can be added on the end in future versions, +without changing the API of the function, thereby allowing old clients to work +without modification. */ + +typedef struct pcre_callout_block { + int version; /* Identifies version of block */ + /* ------------------------ Version 0 ------------------------------- */ + int callout_number; /* Number compiled into pattern */ + int *offset_vector; /* The offset vector */ + PCRE_SPTR subject; /* The subject being matched */ + int subject_length; /* The length of the subject */ + int start_match; /* Offset to start of this match attempt */ + int current_position; /* Where we currently are in the subject */ + int capture_top; /* Max current capture */ + int capture_last; /* Most recently closed capture */ + void *callout_data; /* Data passed in with the call */ + /* ------------------- Added for Version 1 -------------------------- */ + int pattern_position; /* Offset to next item in the pattern */ + int next_item_length; /* Length of next item in the pattern */ + /* ------------------------------------------------------------------ */ +} pcre_callout_block; + +/* Indirection for store get and free functions. These can be set to +alternative malloc/free functions if required. Special ones are used in the +non-recursive case for "frames". There is also an optional callout function +that is triggered by the (?) regex item. For Virtual Pascal, these definitions +have to take another form. */ + +#ifndef VPCOMPAT +PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t); +PCRE_DATA_SCOPE void (*pcre_free)(void *); +PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t); +PCRE_DATA_SCOPE void (*pcre_stack_free)(void *); +PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *); +#else /* VPCOMPAT */ +PCRE_DATA_SCOPE void *pcre_malloc(size_t); +PCRE_DATA_SCOPE void pcre_free(void *); +PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t); +PCRE_DATA_SCOPE void pcre_stack_free(void *); +PCRE_DATA_SCOPE int pcre_callout(pcre_callout_block *); +#endif /* VPCOMPAT */ + +/* Exported PCRE functions */ + +PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *, + const unsigned char *); +PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **, + int *, const unsigned char *); +PCRE_DATA_SCOPE int pcre_config(int, void *); +PCRE_DATA_SCOPE int pcre_copy_named_substring(const pcre *, const char *, + int *, int, const char *, char *, int); +PCRE_DATA_SCOPE int pcre_copy_substring(const char *, int *, int, int, char *, + int); +PCRE_DATA_SCOPE int pcre_dfa_exec(const pcre *, const pcre_extra *, + const char *, int, int, int, int *, int , int *, int); +PCRE_DATA_SCOPE int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, + int, int, int, int *, int); +PCRE_DATA_SCOPE void pcre_free_substring(const char *); +PCRE_DATA_SCOPE void pcre_free_substring_list(const char **); +PCRE_DATA_SCOPE int pcre_fullinfo(const pcre *, const pcre_extra *, int, + void *); +PCRE_DATA_SCOPE int pcre_get_named_substring(const pcre *, const char *, + int *, int, const char *, const char **); +PCRE_DATA_SCOPE int pcre_get_stringnumber(const pcre *, const char *); +PCRE_DATA_SCOPE int pcre_get_stringtable_entries(const pcre *, const char *, + char **, char **); +PCRE_DATA_SCOPE int pcre_get_substring(const char *, int *, int, int, + const char **); +PCRE_DATA_SCOPE int pcre_get_substring_list(const char *, int *, int, + const char ***); +PCRE_DATA_SCOPE int pcre_info(const pcre *, int *, int *); +PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void); +PCRE_DATA_SCOPE int pcre_refcount(pcre *, int); +PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **); +PCRE_DATA_SCOPE const char *pcre_version(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* End of pcre.h */ diff --git a/3rdparty/pcre/lib/pcre.lib b/3rdparty/pcre/lib/pcre.lib new file mode 100644 index 000000000..37b4084ef Binary files /dev/null and b/3rdparty/pcre/lib/pcre.lib differ diff --git a/3rdparty/pcre/pcre-7.0 b/3rdparty/pcre/pcre-7.0 new file mode 100644 index 000000000..e69de29bb diff --git a/3rdparty/zlib/include/zconf.h b/3rdparty/zlib/include/zconf.h new file mode 100644 index 000000000..03a9431c8 --- /dev/null +++ b/3rdparty/zlib/include/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/3rdparty/zlib/include/zlib.h b/3rdparty/zlib/include/zlib.h new file mode 100644 index 000000000..022817927 --- /dev/null +++ b/3rdparty/zlib/include/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/3rdparty/zlib/lib/zdll.lib b/3rdparty/zlib/lib/zdll.lib new file mode 100644 index 000000000..01f4e10e6 Binary files /dev/null and b/3rdparty/zlib/lib/zdll.lib differ diff --git a/3rdparty/zlib/zlib-1.2.3 b/3rdparty/zlib/zlib-1.2.3 new file mode 100644 index 000000000..e69de29bb diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index bf2623489..54e73ea51 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,33 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2008/07/27 + * Changed the way GM levels are handled + - removed conf/gm_account.txt + - added the gm level column to the txt savefile (after 'email' column) + - gm level information is now transferred along with account data + * Merged the /loginmerge branch [ultramage] + - the login server storage, ipban and logging systems have been abstracted + and now provide a common interface; the rest has been merged into a + single login server core (no more login/login_sql duplicity) + - storage systems are now added via compiler options (WITH_SQL / WITH_TXT) + - multiple storage engines can be compiled in at the same time, + and the config option account.engine defines which one will be used. + - due to MySQL autoincrement limitations, accounts with id '0' will not + be supported; account IDs from this point on should start from '1'. + - login_log() functions now again record IP addresses in dotted format, + not as 4-byte integers (undo from r6868). + - removed config options that defined column names in the login table + - removed `memo` and `error message` columns from login db/savefile + - moved `loginlog` table to the logs database + - added sql files upgrade_svn12975.sql and upgrade_svn12975_log.sql + - due to changes to the login table layout, I added an !optional! sql + file (upgrade_svn12975_view.sql) that will provide a certain degree + of backwards compatibility with existing software; + read the instructions inside carefully! + - moved third-party includes/libs to a separate directory + - updated project files / makefiles + 2008/07/20 * Simplified the search in pop_timer_heap and added more debug info to help determine the source condition of timer errors. (bugreport:1860) diff --git a/Makefile.in b/Makefile.in index aa47001a1..2afeda0f5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -43,10 +43,10 @@ common_sql: $(COMMON_SQL_DEPENDS) @$(MAKE) -C src/common sql login: common - @$(MAKE) -C src/login + @$(MAKE) -C src/login txt login_sql: $(LOGIN_SQL_DEPENDS) - @$(MAKE) -C src/login_sql + @$(MAKE) -C src/login sql char: common @$(MAKE) -C src/char @@ -93,7 +93,6 @@ save: clean: @$(MAKE) -C src/common $@ @$(MAKE) -C src/login $@ - @$(MAKE) -C src/login_sql $@ @$(MAKE) -C src/char $@ @$(MAKE) -C src/char_sql $@ @$(MAKE) -C src/map $@ diff --git a/conf/Changelog.txt b/conf/Changelog.txt index 3e9fd15d4..d5371167f 100644 --- a/conf/Changelog.txt +++ b/conf/Changelog.txt @@ -1,5 +1,13 @@ Date Added +2008/07/27 + * Conf file adjustments for the loginmerge branch + - added new login and ipban db config options to login_athena.conf + - login database options are no longer in inter_athena.conf! + - moved setting 'lowest_gm_level' from inter_athena.conf to battle/gm.conf + - removed setting 'gm_read_method' + - removed options for setting `login` table column names + - deleted file GM_account.txt, now the savefile is used for this 2008/07/23 * Increased max. hairstyle number, 23 -> 25 (bugreport:1773) [ultramage] 2008/07/22 diff --git a/conf/GM_account.txt b/conf/GM_account.txt deleted file mode 100644 index e49f9df16..000000000 --- a/conf/GM_account.txt +++ /dev/null @@ -1,10 +0,0 @@ -// eAthena's GM Accounts File (for TXT servers only) -// Edited by MC Cameri to enable account id ranges -// Changing this file while login server is running -// Usage #1(Standard): -// Usage #2(Range): -// Examples: -// 2000002 99 -// 2000003-2000005 99 -// 2000003~2000005 99 -// 2000001 30 diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index 1bfc4a372..ff0b1126a 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -30,6 +30,11 @@ atcommand_slave_clone_limit: 25 // current map server. partial_name_scan: yes +// The level at which a player with access is considered a GM. +// An account with an access level lower than this is not effected +// by gm_can_drop_lv (battle_athena.conf). +lowest_gm_level: 1 + // [GM] Can use all skills? (No or mimimum GM level) gm_all_skill: no diff --git a/conf/inter_athena.conf b/conf/inter_athena.conf index c5dcd351d..ddb7c5e1b 100644 --- a/conf/inter_athena.conf +++ b/conf/inter_athena.conf @@ -1,5 +1,17 @@ // Athena InterServer configuration. +// Options for both versions + +// Log Inter Connections, etc.? +log_inter: 1 + +// Inter Log Filename +inter_log_filename: log/inter.log + +// Level range for sharing within a party +party_share_level: 10 + + // TXT version options only // Storage flatfile database, used for Karfa storage. @@ -26,32 +38,14 @@ castle_txt: save/castle.txt // Status change flatfile database, for status changes that are saved between sessions. scdata_txt: save/scdata.txt -// Options for both versions - -// Log Inter Connections, etc.? -log_inter: 1 - -// Inter Log Filename -inter_log_filename: log/inter.log - -// Level range for sharing within a party -party_share_level: 10 // SQL version options only -// GM Reading Method -// 1 to have Char read GMs, 0 to have Login-controlled GMs -gm_read_method: 0 - -// The level at which a player with access is considered a GM. -// An account with an access level lower than this is not effected -// by gm_can_drop_lv (battle_athena.conf). -lowest_gm_level: 1 - // You can specify the codepage to use in your mySQL tables here. // (Note that this feature requires MySQL 4.1+) //default_codepage: + // For IPs, ideally under linux, you want to use localhost instead of 127.0.0.1 // Under windows, you want to use 127.0.0.1. If you see a message like // "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" @@ -96,16 +90,9 @@ db_server_logindb: ragnarok // this is meant for people who KNOW their stuff, and for some reason want to change their // database layout. [CLOWNISIUS] -//Column names for the login table. -login_db_account_id: account_id -login_db_userid: userid -login_db_user_pass: user_pass -login_db_level: level - // ALL MySQL Database Table names // Login Database Tables -login_db: login loginlog_db: loginlog // Char Database Tables diff --git a/conf/ladmin_athena.conf b/conf/ladmin_athena.conf index b091b47ff..5c4257af7 100644 --- a/conf/ladmin_athena.conf +++ b/conf/ladmin_athena.conf @@ -15,11 +15,6 @@ admin_pass: admin // 2: password+key passenc: 2 -// Language of ladmin -// F: Français -// E: English (default) -defaultlanguage: E - // Log Filename. All operations done by the software are logged in this file. ladmin_log_filename: log/ladmin.log diff --git a/conf/login_athena.conf b/conf/login_athena.conf index c5a9fb242..28f022c42 100644 --- a/conf/login_athena.conf +++ b/conf/login_athena.conf @@ -38,13 +38,12 @@ console_silent: 0 // Whether remote administration is enabled or disabled admin_state: no -// Administrative password, used by ladmin (perl software) to connect remotely to server. -// NOTICE: If you enable remote administration, you should change its value for security -// NOTE: ladmin only works on TXT login servers. +// Administrative password, used by ladmin to connect remotely to server. +// NOTICE: you should change this value for security if you use ladmin. admin_pass: admin // Indicate the IP/host that the server accepts for remote administration. -admin_allowed_ip: 127.0.0.1 +admin_allowed_host: 127.0.0.1 // Console Commands // Allow for console commands to be used on/off @@ -62,15 +61,8 @@ new_account: yes allowed_regs: 1 time_allowed: 10 -// Account flatfile database, stores account information. -account_filename: save/account.txt - -// What account AIDs have GM privs, and what level? -gm_account_filename: conf/GM_account.txt - -// Timer to check if GM_account file has been changed and reload GM account automaticaly -// (in seconds; default: 15; value: 0 (disabled), or 2 or more) -gm_account_filename_check_timer: 15 +// Log Filename. All operations received by the server are logged in this file. +login_log_filename: log/login.log // To log the login server? // NOTE: The login-sql server needs the login logs to enable dynamic pass failure bans. @@ -110,11 +102,18 @@ client_version_to_connect: 20 use_MD5_passwords: no // Ipban features (SQL only) -ipban: yes -dynamic_pass_failure_ban: yes -dynamic_pass_failure_ban_interval: 5 -dynamic_pass_failure_ban_limit: 7 -dynamic_pass_failure_ban_duration: 5 +ipban.enable: yes +ipban.sql.db_hostname: 127.0.0.1 +ipban.sql.db_port: 3306 +ipban.sql.db_username: ragnarok +ipban.sql.db_password: ragnarok +ipban.sql.db_database: ragnarok +ipban.sql.ipban_table: ipbanlist +// Dynamic password failure ipban system +ipban.dynamic_pass_failure_ban: yes +ipban.dynamic_pass_failure_ban_interval: 5 +ipban.dynamic_pass_failure_ban_limit: 7 +ipban.dynamic_pass_failure_ban_duration: 5 // Interval (in minutes) to execute a DNS/IP update. Disabled by default. // Enable it if your server uses a dynamic IP which changes with time. @@ -126,4 +125,24 @@ dynamic_pass_failure_ban_duration: 5 use_dnsbl: no dnsbl_servers: dnsbl.deltaanime.net +// Which account engine to use. +// 'auto' selects the first engine available (txt, sql, then others) +// (defaults to auto) +account.engine: auto + +// Account data storage configuration +// TXT +account.txt.account_db: save/account.txt +account.txt.case_sensitive: no +// SQL +account.sql.db_hostname: 127.0.0.1 +account.sql.db_port: 3306 +account.sql.db_username: ragnarok +account.sql.db_password: ragnarok +account.sql.db_database: ragnarok +account.sql.codepage: +account.sql.case_sensitive: no +account.sql.account_db: login +account.sql.accreg_db: global_reg_value + import: conf/import/login_conf.txt diff --git a/configure b/configure index 39e0ecdcd..290958782 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 12803 . +# From configure.in Revision: 12731 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -663,6 +663,7 @@ OBJEXT CPP GREP EGREP +HAVE_OPENRJ_TXT MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION @@ -1259,7 +1260,9 @@ Optional Features: --enable-mapregsql Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (disabled by default) - --enable-debug Compiles in debug mode. (disabled by default) + --enable-debug Compiles extra debug code. (disabled by default) + --disable-openrj-txt Disables the openrj-based account engine in the TXT + login-server (enabled by default) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1718,7 +1721,7 @@ ac_config_files="$ac_config_files Makefile src/common/Makefile" ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" -ac_config_files="$ac_config_files src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile" +ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" @@ -1807,6 +1810,28 @@ fi +# +# OpenRJ account engine in the txt login server +# +# Check whether --enable-openrj-txt was given. +if test "${enable_openrj_txt+set}" = set; then + enableval=$enable_openrj_txt; + HAVE_OPENRJ_TXT="$enableval" + case $enableval in + no);; + yes);; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-openrj-txt=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-openrj-txt=$enableval... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + HAVE_OPENRJ_TXT="yes" + +fi + + + # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # @@ -4530,6 +4555,12 @@ if test "$enable_debug" = "yes" ; then fi +# +# OpenRJ account engine in the txt login server +# + + + # # zlib library (required) # @@ -6002,7 +6033,6 @@ do "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; "src/ladmin/Makefile") CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; "src/char_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; - "src/login_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/login_sql/Makefile" ;; "src/txt-converter/Makefile") CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; @@ -6115,6 +6145,7 @@ OBJEXT!$OBJEXT$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim +HAVE_OPENRJ_TXT!$HAVE_OPENRJ_TXT$ac_delim MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim HAVE_MYSQL!$HAVE_MYSQL$ac_delim MYSQL_VERSION!$MYSQL_VERSION$ac_delim @@ -6128,7 +6159,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 60; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index d9deb8710..5ebbe1561 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile src/ladmin/Makefile]) -AC_CONFIG_FILES([src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile]) +AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) @@ -78,7 +78,7 @@ AC_ARG_ENABLE( [debug], AC_HELP_STRING( [--enable-debug], - [Compiles in debug mode. (disabled by default)] + [Compiles extra debug code. (disabled by default)] ), [ enable_debug="$enableval" diff --git a/lib/libmysql.lib b/lib/libmysql.lib deleted file mode 100644 index aa99dc3b8..000000000 Binary files a/lib/libmysql.lib and /dev/null differ diff --git a/lib/mysql-5.0.20 b/lib/mysql-5.0.20 deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/pcre-7.0 b/lib/pcre-7.0 deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/pcre.lib b/lib/pcre.lib deleted file mode 100644 index 37b4084ef..000000000 Binary files a/lib/pcre.lib and /dev/null differ diff --git a/lib/zdll.lib b/lib/zdll.lib deleted file mode 100644 index 01f4e10e6..000000000 Binary files a/lib/zdll.lib and /dev/null differ diff --git a/lib/zlib-1.2.3 b/lib/zlib-1.2.3 deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/account.txt b/save-tmpl/account.txt index b326f67f7..43299d089 100644 --- a/save-tmpl/account.txt +++ b/save-tmpl/account.txt @@ -1,19 +1,16 @@ +20080409 // Accounts file: here are saved all information about the accounts. -// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value) -// Some explanations: -// account name : between 4 to 23 char for a normal account (standard client can't send less than 4 char). -// account password: between 4 to 23 char +// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, repeated(register key, register value) +// where: // sex : M or F for normal accounts, S for server accounts +// level : this account's gm level // state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1 -// email : between 3 to 39 char (a@a.com is like no email) -// error message : text for the state 7: 'Your are Prohibited to login until '. Max 19 char -// valitidy time : 0: unlimited account, : date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970) -// memo field : max 254 char -// ban time : 0: no ban, : banned until the date: date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970) -0 s1 p1 2004-10-25 01:12:04.147 S 2 0 a@a.com - 0 127.0.0.1 - 0 -1 s2 p2 - S 0 0 a@a.com - 0 - - 0 -2 s3 p3 - S 0 0 a@a.com - 0 - - 0 -3 s4 p4 - S 0 0 a@a.com - 0 - - 0 -4 s5 p5 - S 0 0 a@a.com - 0 - - 0 -2000001 Test Test - M 0 0 a@a.com - 0 - - 0 +// unban time : 0: no ban, : banned until the date (unix timestamp) +// expiration time : 0: unlimited account, : account expires on the date (unix timestamp) +1 s1 p1 S a@a.com 0 0 0 0 0 - - +2 s2 p2 S a@a.com 0 0 0 0 0 - - +3 s3 p3 S a@a.com 0 0 0 0 0 - - +4 s4 p4 S a@a.com 0 0 0 0 0 - - +5 s5 p5 S a@a.com 0 0 0 0 0 - - +2000001 Test Test M a@a.com 0 0 0 0 0 - - 2000002 %newid% diff --git a/save-tmpl/castle.txt b/save-tmpl/castle.txt index 72df05921..5270d976b 100644 --- a/save-tmpl/castle.txt +++ b/save-tmpl/castle.txt @@ -1,34 +1,34 @@ -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/sql-files/logs.sql b/sql-files/logs.sql index 09895263b..b46b34355 100644 --- a/sql-files/logs.sql +++ b/sql-files/logs.sql @@ -113,3 +113,15 @@ CREATE TABLE `chatlog` ( INDEX (`src_accountid`), INDEX (`src_charid`) ) ENGINE=MyISAM AUTO_INCREMENT=1 ; + +#Database: log +#Table: loginlog +CREATE TABLE `loginlog` ( + `time` datetime NOT NULL default '0000-00-00 00:00:00', + `ip` varchar(15) NOT NULL default '', + `user` varchar(23) NOT NULL default '', + `rcode` tinyint(4) NOT NULL default '0', + `log` varchar(255) NOT NULL default '', + INDEX (`ip`) +) ENGINE=MyISAM ; + diff --git a/sql-files/main.sql b/sql-files/main.sql index 1dd36bbc1..5b9f1a313 100644 --- a/sql-files/main.sql +++ b/sql-files/main.sql @@ -421,17 +421,15 @@ CREATE TABLE `login` ( `account_id` int(11) unsigned NOT NULL auto_increment, `userid` varchar(23) NOT NULL default '', `user_pass` varchar(32) NOT NULL default '', - `lastlogin` datetime NOT NULL default '0000-00-00 00:00:00', `sex` enum('M','F','S') NOT NULL default 'M', - `logincount` mediumint(9) unsigned NOT NULL default '0', `email` varchar(39) NOT NULL default '', `level` tinyint(3) NOT NULL default '0', - `error_message` smallint(11) unsigned NOT NULL default '0', - `connect_until` int(11) unsigned NOT NULL default '0', - `last_ip` varchar(100) NOT NULL default '', - `memo` smallint(11) unsigned NOT NULL default '0', - `ban_until` int(11) unsigned NOT NULL default '0', `state` int(11) unsigned NOT NULL default '0', + `unban_time` int(11) unsigned NOT NULL default '0', + `expiration_time` int(11) unsigned NOT NULL default '0', + `logincount` mediumint(9) unsigned NOT NULL default '0', + `lastlogin` datetime NOT NULL default '0000-00-00 00:00:00', + `last_ip` varchar(100) NOT NULL default '', PRIMARY KEY (`account_id`), KEY `name` (`userid`) ) ENGINE=MyISAM AUTO_INCREMENT=2000000; @@ -472,20 +470,6 @@ CREATE TABLE `sc_data` ( KEY (`char_id`) ) ENGINE=MyISAM; --- --- Table structure for table `loginlog` --- - -DROP TABLE IF EXISTS `loginlog`; -CREATE TABLE `loginlog` ( - `time` datetime NOT NULL default '0000-00-00 00:00:00', - `ip` int(10) unsigned NOT NULL default '0', - `user` varchar(23) NOT NULL default '', - `rcode` tinyint(4) NOT NULL default '0', - `log` varchar(255) NOT NULL default '', - INDEX (`ip`) -) ENGINE=MyISAM; - -- -- Table structure for table `mail` -- diff --git a/sql-files/upgrade_svn12975.sql b/sql-files/upgrade_svn12975.sql new file mode 100644 index 000000000..a8f5e3818 --- /dev/null +++ b/sql-files/upgrade_svn12975.sql @@ -0,0 +1,24 @@ +START TRANSACTION; + +-- delete columns +ALTER TABLE `login` DROP `error_message`; +ALTER TABLE `login` DROP `memo`; + +-- rename columns +ALTER TABLE `login` CHANGE `connect_until` `expiration_time` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'; +ALTER TABLE `login` CHANGE `ban_until` `unban_time` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'; + +-- reorder columns +ALTER TABLE `login` MODIFY `sex` enum('M','F','S') NOT NULL default 'M' AFTER `user_pass`; +ALTER TABLE `login` MODIFY `email` varchar(39) NOT NULL default '' AFTER `sex`; +ALTER TABLE `login` MODIFY `level` tinyint(3) NOT NULL default '0' AFTER `email`; +ALTER TABLE `login` MODIFY `state` int(11) unsigned NOT NULL default '0' AFTER `level`; +ALTER TABLE `login` MODIFY `unban_time` int(11) unsigned NOT NULL default '0' AFTER `state`; +ALTER TABLE `login` MODIFY `expiration_time` int(11) unsigned NOT NULL default '0' AFTER `unban_time`; +ALTER TABLE `login` MODIFY `logincount` mediumint(9) unsigned NOT NULL default '0' AFTER `expiration_time`; + +-- change ip format +ALTER TABLE `loginlog` CHANGE `ip` `ip` VARCHAR( 15 ) NOT NULL default ''; +UPDATE `loginlog` SET `ip` = inet_ntoa(`ip`); + +COMMIT; diff --git a/sql-files/upgrade_svn12975_log.sql b/sql-files/upgrade_svn12975_log.sql new file mode 100644 index 000000000..c6900e606 --- /dev/null +++ b/sql-files/upgrade_svn12975_log.sql @@ -0,0 +1,20 @@ +-- NOTE: change `ragnarok` and `log` to whatever your database names are. + +START TRANSACTION; + +CREATE TABLE `log`.`loginlog` ( + `time` datetime NOT NULL default '0000-00-00 00:00:00', + `ip` varchar( 15 ) NOT NULL , + `user` varchar( 23 ) NOT NULL default '', + `rcode` tinyint( 4 ) NOT NULL default '0', + `log` varchar( 255 ) NOT NULL default '', + KEY `ip` ( `ip` ) +) ENGINE = MYISAM; + +INSERT INTO `log`.`loginlog` + SELECT * + FROM `ragnarok`.`loginlog` ; + +DROP TABLE `ragnarok`.`loginlog` ; + +COMMIT; diff --git a/sql-files/upgrade_svn12975_view.sql b/sql-files/upgrade_svn12975_view.sql new file mode 100644 index 000000000..8d5d5906b --- /dev/null +++ b/sql-files/upgrade_svn12975_view.sql @@ -0,0 +1,17 @@ +-- The statements below will create a 'view' (virtual table) that mimics +-- the previous `login` table layout. You can use this hack to make your db +-- compatible with older eathena servers or control panels. +-- Note: also adjust the account.sql.account_db setting in login_athena.conf. +-- Note: if your CP does not have a config setting for the `login` table name +-- you'll have to either modify its code or do some table renaming. + +START TRANSACTION; + +-- create dummy columns, needed to make the view insertable +ALTER TABLE `login` ADD `error_message` SMALLINT UNSIGNED NOT NULL; +ALTER TABLE `login` ADD `memo` SMALLINT UNSIGNED NOT NULL; + +-- create the view +CREATE VIEW `login_view` ( `account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`, `error_message`, `connect_until`, `last_ip`, `memo`, `ban_until`, `state` ) AS SELECT `account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`, `error_message`, `expiration_time`, `last_ip`, `memo`, `unban_time`, `state` FROM `login`; + +COMMIT; diff --git a/src/char/char.c b/src/char/char.c index 071e21472..cedf7caa2 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -109,6 +109,7 @@ struct char_session_data { int found_char[MAX_CHARS]; // ids of chars on this account char email[40]; // e-mail (default: a@a.com) by [Yor] time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + int gmlevel; }; int char_id_count = START_CHAR_NUM; @@ -136,9 +137,6 @@ struct fame_list taekwon_fame_list[MAX_FAME_LIST]; // Initial position (it's possible to set it in conf file) struct point start_point = { 0, 53, 111 }; -struct gm_account *gm_account = NULL; -int GM_num = 0; - // online players by [Yor] char online_txt_filename[1024] = "online.txt"; char online_html_filename[1024] = "online.html"; @@ -162,6 +160,7 @@ struct auth_node { uint32 ip; int sex; time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + int gmlevel; }; static DBMap* auth_db; // int account_id -> struct auth_node* @@ -344,20 +343,6 @@ int char_log(char *fmt, ...) return 0; } -//---------------------------------------------------------------------- -// Determine if an account (id) is a GM account -// and returns its level (or 0 if it isn't a GM account or if not found) -//---------------------------------------------------------------------- -int isGM(int account_id) -{ - int i; - - for(i = 0; i < GM_num; i++) - if (gm_account[i].account_id == account_id) - return gm_account[i].level; - return 0; -} - //Search character data from the aid/cid givem struct mmo_charstatus* search_character(int aid, int cid) { @@ -1556,7 +1541,8 @@ void create_online_files(void) // displaying the character name if ((online_display_option & 1) || (online_display_option & 64)) { // without/with 'GM' display strcpy(temp, char_dat[j].status.name); - l = isGM(char_dat[j].status.account_id); + //l = isGM(char_dat[j].status.account_id); + l = 0; //FIXME: how to get the gm level? if (online_display_option & 64) { if (l >= online_gm_display_min_level) fprintf(fp, "%-24s (GM) ", temp); @@ -1892,7 +1878,7 @@ static int char_delete(struct mmo_charstatus *cs) static void char_auth_ok(int fd, struct char_session_data *sd) { struct online_char_data* character; - if (max_connect_user && count_users() >= max_connect_user && isGM(sd->account_id) < gm_allow_level) + if (max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level) { // refuse connection (over populated) WFIFOW(fd,0) = 0x6c; @@ -1999,7 +1985,7 @@ int parse_fromlogin(int fd) // acknowledgement of account authentication request case 0x2713: - if (RFIFOREST(fd) < 59) + if (RFIFOREST(fd) < 60) return 0; { int account_id = RFIFOL(fd,2); @@ -2008,6 +1994,7 @@ int parse_fromlogin(int fd) bool result = RFIFOB(fd,14); const char* email = (const char*)RFIFOP(fd,15); time_t expiration_time = (time_t)RFIFOL(fd,55); + int gmlevel = RFIFOB(fd,59); // find the session with this account id ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && @@ -2021,32 +2008,29 @@ int parse_fromlogin(int fd) WFIFOSET(i,3); } else { // success memcpy(sd->email, email, 40); - if (e_mail_check(sd->email) == 0) - strncpy(sd->email, "a@a.com", 40); // default e-mail sd->expiration_time = expiration_time; + sd->gmlevel = gmlevel; char_auth_ok(i, sd); } } } - RFIFOSKIP(fd,59); + RFIFOSKIP(fd,60); break; // Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor] case 0x2717: - if (RFIFOREST(fd) < 50) + if (RFIFOREST(fd) < 51) return 0; - for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { - if (sd->account_id == RFIFOL(fd,2)) { - memcpy(sd->email, RFIFOP(fd,6), 40); - if (e_mail_check(sd->email) == 0) - strncpy(sd->email, "a@a.com", 40); // default e-mail - sd->expiration_time = (time_t)RFIFOL(fd,46); - break; - } - } + + // find the session with this account id + ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2) ); + if( i < fd_max ) + { + memcpy(sd->email, RFIFOP(fd,6), 40); + sd->expiration_time = (time_t)RFIFOL(fd,46); + sd->gmlevel = RFIFOB(fd,50); } - RFIFOSKIP(fd,50); + RFIFOSKIP(fd,51); break; // login-server alive packet @@ -2209,7 +2193,7 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { //Receive account_reg2 registry, forward to map servers. - unsigned char buf[ACCOUNT_REG2_NUM*(256+32+2)+16]; + unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)]; memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2)); // WBUFW(buf,0) = 0x2b11; WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex] @@ -2284,33 +2268,6 @@ int parse_fromlogin(int fd) RFIFOSKIP(fd,11); break; - // Receiving GM acounts info from login-server (by [Yor]) - case 0x2732: - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { - unsigned char buf[32000]; //FIXME: this will crash - if (gm_account != NULL) - aFree(gm_account); - CREATE(gm_account, struct gm_account, (RFIFOW(fd,2) - 4)/5); - GM_num = 0; - for (i = 4; i < RFIFOW(fd,2); i = i + 5) { - gm_account[GM_num].account_id = RFIFOL(fd,i); - gm_account[GM_num].level = (int)RFIFOB(fd,i+4); - //printf("GM account: %d -> level %d\n", gm_account[GM_num].account_id, gm_account[GM_num].level); - GM_num++; - } - ShowStatus("From login-server: receiving information of %d GM accounts.\n", GM_num); - char_log("From login-server: receiving information of %d GM accounts.\n", GM_num); - // send new gm acccounts level to map-servers - memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2)); - WBUFW(buf,0) = 0x2b15; - mapif_sendall(buf, RFIFOW(fd,2)); - - RFIFOSKIP(fd,RFIFOW(fd,2)); - } - break; - // Login server request to kick a character out. [Skotlex] case 0x2734: if (RFIFOREST(fd) < 6) @@ -2634,15 +2591,6 @@ int parse_frommap(int fd) switch(RFIFOW(fd,0)) { - case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x2709; - WFIFOSET(login_fd,2); - } - RFIFOSKIP(fd,2); - break; - case 0x2afa: // Receiving map names list from the map-server if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; @@ -2844,8 +2792,9 @@ int parse_frommap(int fd) char_dat[i].status.char_id == RFIFOL(fd,14)) break; } + char_data = i < char_num ? &char_dat[i].status : NULL; - //Tell the new map server about this player using Kevin's new auth packet. [Skotlex] + if (map_fd >= 0 && session[map_fd] && char_data) { //Send the map server the auth of this player. struct auth_node* node; @@ -2856,19 +2805,6 @@ int parse_frommap(int fd) char_data->last_point.y = RFIFOW(fd,22); char_data->sex = RFIFOB(fd,30); -#if 0 - // the map-server must request it [FlavioJS] - WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus)); - WFIFOW(map_fd,0) = 0x2afd; - WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus); - WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID - WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1 - WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2 - WFIFOL(map_fd,12) = (unsigned long)0; //TODO: expiration_time, how do I figure it out right now? - memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus)); - WFIFOSET(map_fd, WFIFOW(map_fd,2)); -#endif - // create temporary auth entry CREATE(node, struct auth_node, 1); node->account_id = RFIFOL(fd,2); @@ -2959,9 +2895,9 @@ int parse_frommap(int fd) if( login_fd <= 0 ) result = 3; // 3-login-server offline - else - if( acc != -1 && isGM(acc) < isGM(account_id) ) - result = 2; // 2-gm level too low +// else +// if( acc != -1 && isGM(acc) < isGM(account_id) ) +// result = 2; // 2-gm level too low else switch( type ) { case 1: // block @@ -3168,14 +3104,15 @@ int parse_frommap(int fd) {// auth ok cd->sex = sex; - WFIFOHEAD(fd,20 + sizeof(struct mmo_charstatus)); + WFIFOHEAD(fd,24 + sizeof(struct mmo_charstatus)); WFIFOW(fd,0) = 0x2afd; - WFIFOW(fd,2) = 20 + sizeof(struct mmo_charstatus); + WFIFOW(fd,2) = 24 + sizeof(struct mmo_charstatus); WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = login_id1; - WFIFOL(fd,12) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" - WFIFOL(fd,16) = node->login_id2; - memcpy(WFIFOP(fd,20), cd, sizeof(struct mmo_charstatus)); + WFIFOL(fd,8) = node->login_id1; + WFIFOL(fd,12) = node->login_id2; + WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" + WFIFOL(fd,20) = node->gmlevel; + memcpy(WFIFOP(fd,24), cd, sizeof(struct mmo_charstatus)); WFIFOSET(fd, WFIFOW(fd,2)); // only use the auth once and mark user online @@ -3309,7 +3246,6 @@ int parse_char(int fd) return 0; { struct auth_node* node; - int GM_value; int account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); @@ -3325,16 +3261,9 @@ int parse_char(int fd) //TODO: and perhaps send back a reply? break; } - - if( (GM_value = isGM(account_id)) != 0 ) - ShowInfo("Account Logged On; Account ID: %d (GM level %d).\n", account_id, GM_value); - else - ShowInfo("Account Logged On; Account ID: %d.\n", account_id); CREATE(session[fd]->session_data, struct char_session_data, 1); sd = (struct char_session_data*)session[fd]->session_data; - strncpy(sd->email, "no mail", 40); // put here a mail without '@' to refuse deletion if we don't receive the e-mail - sd->expiration_time = 0; // unknown or unlimited (not displaying on map-server) sd->account_id = account_id; sd->login_id1 = login_id1; sd->login_id2 = login_id2; @@ -3454,7 +3383,6 @@ int parse_char(int fd) cd->last_point.map = j; } - //Send NEW auth packet [Kevin] //FIXME: is this case even possible? [ultramage] if ((map_fd = server[i].fd) < 1 || session[map_fd] == NULL) { @@ -3474,29 +3402,13 @@ int parse_char(int fd) WFIFOW(fd,0) = 0x71; WFIFOL(fd,2) = cd->char_id; mapindex_getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6)); - - // Advanced subnet check [LuzZza] - subnet_map_ip = lan_subnetcheck(ipl); + subnet_map_ip = lan_subnetcheck(ipl); // Advanced subnet check [LuzZza] WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] WFIFOSET(fd,28); ShowInfo("Character selection '%s' (account: %d, slot: %d).\n", cd->name, sd->account_id, ch); -#if 0 - // The server must request it [FlavioJS] - //Send auth ok to map server - WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus)); - WFIFOW(map_fd,0) = 0x2afd; - WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus); - WFIFOL(map_fd,4) = sd->account_id; - WFIFOL(map_fd,8) = sd->login_id1; - WFIFOL(map_fd,16) = sd->login_id2; - WFIFOL(map_fd,12) = (unsigned long)sd->expiration_time; - memcpy(WFIFOP(map_fd,20), cd, sizeof(struct mmo_charstatus)); - WFIFOSET(map_fd, WFIFOW(map_fd,2)); -#endif - // create temporary auth entry CREATE(node, struct auth_node, 1); node->account_id = sd->account_id; @@ -3505,6 +3417,7 @@ int parse_char(int fd) node->login_id2 = sd->login_id2; node->sex = sd->sex; node->expiration_time = sd->expiration_time; + node->gmlevel = sd->gmlevel; node->ip = ipl; idb_put(auth_db, sd->account_id, node); } @@ -3706,15 +3619,6 @@ int parse_char(int fd) session[fd]->flag.server = 1; realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); char_mapif_init(fd); - // send gm acccounts level to map-servers - WFIFOHEAD(fd,4+5*GM_num); - WFIFOW(fd,0) = 0x2b15; - for(i = 0; i < GM_num; i++) { - WFIFOL(fd,4+5*i) = gm_account[i].account_id; - WFIFOB(fd,4+5*i+4) = (unsigned char)gm_account[i].level; - } - WFIFOW(fd,2) = 4+5*GM_num; - WFIFOSET(fd,WFIFOW(fd,2)); } RFIFOSKIP(fd,60); @@ -4245,7 +4149,6 @@ void do_final(void) online_char_db->destroy(online_char_db, NULL); //dispose the db... auth_db->destroy(auth_db, NULL); - if(gm_account) aFree(gm_account); if(char_dat) aFree(char_dat); if (login_fd > 0) diff --git a/src/char/char.h b/src/char/char.h index 72077ac09..8c8d7c554 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -6,7 +6,6 @@ #include "../common/mmo.h" -#define START_CHAR_NUM 150000 #define MAX_MAP_SERVERS 30 #define DEFAULT_AUTOSAVE_INTERVAL 300*1000 diff --git a/src/char/inter.c b/src/char/inter.c index 463d2dd4d..6f6f92bf0 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -650,6 +650,25 @@ int mapif_parse_NameChangeRequest(int fd) //-------------------------------------------------------- +/// Returns the length of the next complete packet to process, +/// or 0 if no complete packet exists in the queue. +/// +/// @param length The minimum allowed length, or -1 for dynamic lookup +int inter_check_length(int fd, int length) +{ + if( length == -1 ) + {// variable-length packet + if( RFIFOREST(fd) < 4 ) + return 0; + length = RFIFOW(fd,2); + } + + if( (int)RFIFOREST(fd) < length ) + return 0; + + return length; +} + // map server ‚©‚ç‚Ì’ÊMi‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æj // ƒGƒ‰[‚È‚ç0(false)Aˆ—‚Å‚«‚½‚È‚ç1A // ƒpƒPƒbƒg’·‚ª‘«‚è‚È‚¯‚ê‚Î2‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ @@ -695,19 +714,4 @@ int inter_parse_frommap(int fd) { return 1; } -// RFIFO‚̃pƒPƒbƒg’·Šm”F -// •K—vƒpƒPƒbƒg’·‚ª‚ ‚ê‚΃pƒPƒbƒg’·A‚Ü‚¾‘«‚è‚È‚¯‚ê‚Î0 -int inter_check_length(int fd, int length) { - if (length == -1) { // ‰Â•σpƒPƒbƒg’· - RFIFOHEAD(fd); - if (RFIFOREST(fd) < 4) // ƒpƒPƒbƒg’·‚ª–¢’… - return 0; - length = RFIFOW(fd,2); - } - - if ((int)RFIFOREST(fd) < length) // ƒpƒPƒbƒg‚ª–¢’… - return 0; - - return length; -} #endif //TXT_SQL_CONVERT diff --git a/src/char/inter.h b/src/char/inter.h index 4752f600c..cf3eb4b2e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -13,14 +13,11 @@ int inter_parse_frommap(int fd); int inter_mapif_init(int fd); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); -int inter_check_length(int fd,int length); - int inter_log(char *fmt,...); #define inter_cfgName "conf/inter_athena.conf" extern unsigned int party_share_level; -extern char inter_log_filename[1024]; extern char main_chat_nick[16]; //For TXT->SQL conversion diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 0ce2aecf6..f11fb7896 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -69,12 +69,6 @@ char db_path[1024] = "db"; int db_use_sqldbs; -char login_db[256] = "login"; -char login_db_account_id[32] = "account_id"; -char login_db_level[32] = "level"; - -int lowest_gm_level = 1; - struct mmo_map_server { int fd; uint32 ip; @@ -135,6 +129,7 @@ struct char_session_data { int found_char[MAX_CHARS]; // ids of chars on this account char email[40]; // e-mail (default: a@a.com) by [Yor] time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + int gmlevel; }; int char_num, char_max; @@ -164,10 +159,6 @@ unsigned int save_flag = 0; // Initial position (it's possible to set it in conf file) struct point start_point = { 0, 53, 111 }; -bool char_gm_read = false; -struct gm_account *gm_account = NULL; -int GM_num = 0; - int console = 0; //----------------------------------------------------- @@ -183,6 +174,7 @@ struct auth_node { uint32 ip; int sex; time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + int gmlevel; }; static DBMap* auth_db; // int account_id -> struct auth_node* @@ -394,53 +386,6 @@ void set_all_offline_sql(void) Sql_ShowDebug(sql_handle); } -//---------------------------------------------------------------------- -// Determine if an account (id) is a GM account -// and returns its level (or 0 if it isn't a GM account or if not found) -//---------------------------------------------------------------------- -int isGM(int account_id) -{ - int i; - - for(i = 0; i < GM_num; i++) - if (gm_account[i].account_id == account_id) - return gm_account[i].level; - return 0; -} - -void read_gm_account(void) -{ - if(!char_gm_read) - return; - - if (gm_account != NULL) - aFree(gm_account); - GM_num = 0; - - if( SQL_ERROR == Sql_Query(lsql_handle, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'", login_db_account_id, login_db_level, login_db, login_db_level, lowest_gm_level) ) - Sql_ShowDebug(lsql_handle); - - if( Sql_NumRows(lsql_handle) > 0 ) - { - char* data; - - CREATE(gm_account, struct gm_account, (size_t)Sql_NumRows(lsql_handle)); - while( SQL_SUCCESS == Sql_NextRow(lsql_handle) ) - { - // account_id - Sql_GetData(lsql_handle, 0, &data, NULL); - gm_account[GM_num].account_id = atoi(data); - // account_id - Sql_GetData(lsql_handle, 1, &data, NULL); - gm_account[GM_num].level = atoi(data); - ++GM_num; - } - } - Sql_FreeResult(lsql_handle); - - mapif_send_gmaccounts(); -} - static void* create_charstatus(DBKey key, va_list args) { struct mmo_charstatus *cp; @@ -1636,7 +1581,7 @@ int char_family(int pl1, int pl2, int pl3) static void char_auth_ok(int fd, struct char_session_data *sd) { struct online_char_data* character; - if (max_connect_user && count_users() >= max_connect_user && isGM(sd->account_id) < gm_allow_level) + if (max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level) { // refuse connection (over populated) WFIFOW(fd,0) = 0x6c; @@ -1742,7 +1687,7 @@ int parse_fromlogin(int fd) // acknowledgement of account authentication request case 0x2713: - if (RFIFOREST(fd) < 59) + if (RFIFOREST(fd) < 60) return 0; { int account_id = RFIFOL(fd,2); @@ -1751,6 +1696,7 @@ int parse_fromlogin(int fd) bool result = RFIFOB(fd,14); const char* email = (const char*)RFIFOP(fd,15); time_t expiration_time = (time_t)RFIFOL(fd,55); + int gmlevel = RFIFOB(fd,59); // find the session with this account id ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && @@ -1765,16 +1711,17 @@ int parse_fromlogin(int fd) } else { // success memcpy(sd->email, email, 40); sd->expiration_time = expiration_time; + sd->gmlevel = gmlevel; char_auth_ok(i, sd); } } } - RFIFOSKIP(fd,59); + RFIFOSKIP(fd,60); break; // acknowledgement of e-mail/limited time request case 0x2717: - if (RFIFOREST(fd) < 50) + if (RFIFOREST(fd) < 51) return 0; // find the session with this account id @@ -1783,8 +1730,9 @@ int parse_fromlogin(int fd) { memcpy(sd->email, RFIFOP(fd,6), 40); sd->expiration_time = (time_t)RFIFOL(fd,46); + sd->gmlevel = RFIFOB(fd,50); } - RFIFOSKIP(fd,50); + RFIFOSKIP(fd,51); break; // login-server alive packet @@ -1881,7 +1829,7 @@ int parse_fromlogin(int fd) return 0; { //Receive account_reg2 registry, forward to map servers. - unsigned char buf[ACCOUNT_REG2_NUM*(256+32+2)+16]; + unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)]; memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2)); WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex] mapif_sendall(buf, WBUFW(buf,2)); @@ -1910,33 +1858,6 @@ int parse_fromlogin(int fd) RFIFOSKIP(fd,11); break; - // gm account information from login server - case 0x2732: - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - - if(!char_gm_read) { - unsigned char buf[32000]; //FIXME: this will crash - if (gm_account != NULL) - aFree(gm_account); - gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); - GM_num = 0; - for (i = 4; i < RFIFOW(fd,2); i = i + 5) { - gm_account[GM_num].account_id = RFIFOL(fd,i); - gm_account[GM_num].level = (int)RFIFOB(fd,i+4); - //printf("GM account: %d -> level %d\n", gm_account[GM_num].account_id, gm_account[GM_num].level); - GM_num++; - } - ShowStatus("From login-server: receiving information of %d GM accounts.\n", GM_num); - // send new gm acccounts level to map-servers - memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2)); - WBUFW(buf,0) = 0x2b15; - mapif_sendall(buf, RFIFOW(fd,2)); - } - - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - // Login server request to kick a character out. [Skotlex] case 0x2734: if (RFIFOREST(fd) < 6) @@ -2214,18 +2135,6 @@ int parse_frommap(int fd) switch(RFIFOW(fd, 0)) { - case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server - if(char_gm_read) //Re-read gm accounts. - read_gm_account(); - //Send to login request to reload gm accounts. - else if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x2709; - WFIFOSET(login_fd,2); - } - RFIFOSKIP(fd,2); - break; - case 0x2afa: // Receiving map names list from the map-server if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; @@ -2434,7 +2343,8 @@ int parse_frommap(int fd) node->login_id2 = login_id2; //node->sex = 0; node->ip = ntohl(ip); - node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server) + //node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server) + //node->gmlevel = 0; idb_put(auth_db, account_id, node); //Set char to "@ char select" in online db [Kevin] @@ -2467,7 +2377,7 @@ int parse_frommap(int fd) mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true); char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); } - //Tell the new map server about this player using Kevin's new auth packet. [Skotlex] + if (map_fd >= 0 && session[map_fd] && char_data) { //Send the map server the auth of this player. struct auth_node* node; @@ -2478,19 +2388,6 @@ int parse_frommap(int fd) char_data->last_point.y = RFIFOW(fd,22); char_data->sex = RFIFOB(fd,30); -#if 0 - // the map-server must request it [FlavioJS] - WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus)); - WFIFOW(map_fd,0) = 0x2afd; - WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus); - WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID - WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1 - WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2 - WFIFOL(map_fd,12) = (unsigned long)0; //TODO: expiration_time, how do I figure it out right now? - memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus)); - WFIFOSET(map_fd, WFIFOW(map_fd,2)); -#endif - // create temporary auth entry CREATE(node, struct auth_node, 1); node->account_id = RFIFOL(fd,2); @@ -2588,9 +2485,10 @@ int parse_frommap(int fd) if( login_fd <= 0 ) result = 3; // 3-login-server offline - else - if( acc != -1 && isGM(acc) < isGM(account_id) ) - result = 2; // 2-gm level too low + //FIXME: need to move this check to login server [ultramage] +// else +// if( acc != -1 && isGM(acc) < isGM(account_id) ) +// result = 2; // 2-gm level too low else switch( type ) { case 1: // block @@ -2838,14 +2736,15 @@ int parse_frommap(int fd) {// auth ok cd->sex = sex; - WFIFOHEAD(fd,20 + sizeof(struct mmo_charstatus)); + WFIFOHEAD(fd,24 + sizeof(struct mmo_charstatus)); WFIFOW(fd,0) = 0x2afd; - WFIFOW(fd,2) = 20 + sizeof(struct mmo_charstatus); + WFIFOW(fd,2) = 24 + sizeof(struct mmo_charstatus); WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = login_id1; - WFIFOL(fd,12) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" - WFIFOL(fd,16) = node->login_id2; - memcpy(WFIFOP(fd,20), cd, sizeof(struct mmo_charstatus)); + WFIFOL(fd,8) = node->login_id1; + WFIFOL(fd,12) = node->login_id2; + WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" + WFIFOL(fd,20) = node->gmlevel; + memcpy(WFIFOP(fd,24), cd, sizeof(struct mmo_charstatus)); WFIFOSET(fd, WFIFOW(fd,2)); // only use the auth once and mark user online @@ -2996,7 +2895,6 @@ int parse_char(int fd) CREATE(session[fd]->session_data, struct char_session_data, 1); sd = (struct char_session_data*)session[fd]->session_data; - sd->expiration_time = 0; // unknown or unlimited (not displaying on map-server) sd->account_id = account_id; sd->login_id1 = login_id1; sd->login_id2 = login_id2; @@ -3149,8 +3047,6 @@ int parse_char(int fd) WFIFOW(fd,0) = 0x71; WFIFOL(fd,2) = cp->char_id; mapindex_getmapname_ext(mapindex_id2name(cp->last_point.map), (char*)WFIFOP(fd,6)); - - // Advanced subnet check [LuzZza] subnet_map_ip = lan_subnetcheck(ipl); WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] @@ -3164,6 +3060,7 @@ int parse_char(int fd) node->login_id2 = sd->login_id2; node->sex = sd->sex; node->expiration_time = sd->expiration_time; + node->gmlevel = sd->gmlevel; node->ip = ipl; idb_put(auth_db, sd->account_id, node); @@ -3324,15 +3221,6 @@ int parse_char(int fd) session[fd]->flag.server = 1; realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); char_mapif_init(fd); - // send gm acccounts level to map-servers - WFIFOHEAD(fd,4+5*GM_num); - WFIFOW(fd,0) = 0x2b15; - for(i = 0; i < GM_num; i++) { - WFIFOL(fd,4+5*i) = gm_account[i].account_id; - WFIFOB(fd,4+5*i+4) = (unsigned char)gm_account[i].level; - } - WFIFOW(fd,2) = 4+5*GM_num; - WFIFOSET(fd,WFIFOW(fd,2)); } RFIFOSKIP(fd,60); @@ -3669,21 +3557,6 @@ void sql_config_read(const char* cfgName) if(!strcmpi(w1,"char_db")) strcpy(char_db,w2); -#ifndef TXT_SQL_CONVERT - else if(!strcmpi(w1,"gm_read_method")) - char_gm_read = config_switch(w2); - //custom columns for login database - else if(!strcmpi(w1,"login_db")) - strcpy(login_db,w2); - else if(!strcmpi(w1,"login_db_level")) - strcpy(login_db_level,w2); - else if(!strcmpi(w1,"login_db_account_id")) - strcpy(login_db_account_id,w2); - else if(!strcmpi(w1,"lowest_gm_level")) { - lowest_gm_level = atoi(w2); - ShowStatus("set lowest_gm_level : %s\n", w2); - } -#endif else if(!strcmpi(w1,"scdata_db")) strcpy(scdata_db,w2); else if(!strcmpi(w1,"cart_db")) @@ -3920,11 +3793,6 @@ void do_final(void) if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo") ) Sql_ShowDebug(sql_handle); - if(gm_account) { - aFree(gm_account); - gm_account = 0; - } - if (login_fd > 0) do_close(login_fd); if (char_fd > 0) @@ -3934,8 +3802,6 @@ void do_final(void) auth_db->destroy(auth_db, NULL); Sql_Free(sql_handle); - if( lsql_handle ) - Sql_Free(lsql_handle); ShowInfo("ok! all done...\n"); } @@ -3986,8 +3852,6 @@ int do_init(int argc, char **argv) online_char_db = idb_alloc(DB_OPT_RELEASE_DATA); mmo_char_sql_init(); char_read_fame_list(); //Read fame lists. - if(char_gm_read) - read_gm_account(); ShowInfo("char server initialized.\n"); set_defaultparse(parse_char); diff --git a/src/char_sql/char.h b/src/char_sql/char.h index 19c6fcba5..33c4544b2 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -6,7 +6,6 @@ struct mmo_charstatus; -#define START_CHAR_NUM 150000 #define MAX_MAP_SERVERS 30 #define DEFAULT_AUTOSAVE_INTERVAL 300*1000 @@ -64,13 +63,6 @@ extern char quest_obj_db[256]; extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] -extern char login_db_level[32]; -extern char login_db_account_id[32]; - -extern int lowest_gm_level; -extern int GM_num; -extern struct gm_account *gm_account; - extern int guild_exp_rate; extern int log_inter; diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 261ed9b0d..58215d5da 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -28,7 +28,6 @@ Sql* sql_handle = NULL; -Sql* lsql_handle = NULL; int char_server_port = 3306; char char_server_ip[32] = "127.0.0.1"; @@ -37,12 +36,6 @@ char char_server_pw[32] = "ragnarok"; char char_server_db[32] = "ragnarok"; char default_codepage[32] = ""; //Feature by irmin. -int login_server_port = 3306; -char login_server_ip[32] = "127.0.0.1"; -char login_server_id[32] = "ragnarok"; -char login_server_pw[32] = "ragnarok"; -char login_server_db[32] = "ragnarok"; - #ifndef TXT_SQL_CONVERT static struct accreg *accreg_pt; @@ -71,8 +64,6 @@ struct WisData { static DBMap* wis_db = NULL; // int wis_id -> struct WisData* static int wis_dellist[WISDELLIST_MAX], wis_delnum; -int inter_sql_test (void); - #endif //TXT_SQL_CONVERT //-------------------------------------------------------- // Save registry to sql @@ -237,29 +228,6 @@ static int inter_config_read(const char* cfgName) strcpy(default_codepage,w2); ShowStatus ("set default_codepage : %s\n", w2); } - //Logins information to be read from the inter_athena.conf - //for character deletion (checks email in the loginDB) - else - if(!strcmpi(w1,"login_server_ip")) { - strcpy(login_server_ip, w2); - ShowStatus ("set login_server_ip : %s\n", w2); - } else - if(!strcmpi(w1,"login_server_port")) { - login_server_port = atoi(w2); - ShowStatus ("set login_server_port : %s\n", w2); - } else - if(!strcmpi(w1,"login_server_id")) { - strcpy(login_server_id, w2); - ShowStatus ("set login_server_id : %s\n", w2); - } else - if(!strcmpi(w1,"login_server_pw")) { - strcpy(login_server_pw, w2); - ShowStatus ("set login_server_pw : %s\n", w2); - } else - if(!strcmpi(w1,"login_server_db")) { - strcpy(login_server_db, w2); - ShowStatus ("set login_server_db : %s\n", w2); - } #ifndef TXT_SQL_CONVERT else if(!strcmpi(w1,"party_share_level")) party_share_level = atoi(w2); @@ -297,38 +265,6 @@ int inter_log(char* fmt, ...) return 0; } -/*============================================= - * Does a mysql_ping to all connection handles - *---------------------------------------------*/ -int inter_sql_ping(int tid, unsigned int tick, int id, intptr data) -{ - ShowInfo("Pinging SQL server to keep connection alive...\n"); - Sql_Ping(sql_handle); - if( char_gm_read ) - Sql_Ping(lsql_handle); - return 0; -} - - -int sql_ping_init(void) -{ - uint32 connection_timeout, connection_ping_interval; - - // set a default value first - connection_timeout = 28800; // 8 hours - - // ask the mysql server for the timeout value - if( SQL_SUCCESS == Sql_GetTimeout(sql_handle, &connection_timeout) && connection_timeout < 60 ) - connection_timeout = 60; - - // establish keepalive - connection_ping_interval = connection_timeout - 30; // 30-second reserve - add_timer_func_list(inter_sql_ping, "inter_sql_ping"); - add_timer_interval(gettick() + connection_ping_interval*1000, inter_sql_ping, 0, 0, connection_ping_interval*1000); - - return 0; -} - #endif //TXT_SQL_CONVERT // initialize @@ -348,34 +284,10 @@ int inter_init_sql(const char *file) Sql_Free(sql_handle); exit(EXIT_FAILURE); } -#ifndef TXT_SQL_CONVERT - else if (inter_sql_test()) { - ShowStatus("Connect Success! (Character Server)\n"); - } - if(char_gm_read) { - lsql_handle = Sql_Malloc(); - ShowInfo("Connect Character DB server.... (login server)\n"); - if( SQL_ERROR == Sql_Connect(lsql_handle, login_server_id, login_server_pw, login_server_ip, (uint16)login_server_port, login_server_db) ) - { - Sql_ShowDebug(lsql_handle); - Sql_Free(lsql_handle); - Sql_Free(sql_handle); - exit(EXIT_FAILURE); - } - else - { - ShowStatus ("Connect Success! (Login Server)\n"); - } - } -#endif //TXT_SQL_CONVERT if( *default_codepage ) { if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) Sql_ShowDebug(sql_handle); -#ifndef TXT_SQL_CONVERT - if( char_gm_read && SQL_ERROR == Sql_SetEncoding(lsql_handle, default_codepage) ) - Sql_ShowDebug(lsql_handle); -#endif //TXT_SQL_CONVERT } #ifndef TXT_SQL_CONVERT @@ -389,46 +301,11 @@ int inter_init_sql(const char *file) inter_mail_sql_init(); inter_auction_sql_init(); - sql_ping_init(); #endif //TXT_SQL_CONVERT return 0; } #ifndef TXT_SQL_CONVERT -int inter_sql_test (void) -{ - const char fields[][24] = { - "father", // version 1363 - "fame", // version 1491 - }; - char buf[1024] = ""; - char* p; - size_t len; - int i; - - if( SQL_ERROR == Sql_GetColumnNames(sql_handle, char_db, buf, sizeof(buf), '\n') ) - Sql_ShowDebug(sql_handle); - - // check DB strings - for( i = 0; i < ARRAYLENGTH(fields); ++i ) - { - len = strlen(fields[i]); - p = strstr(buf, fields[i]); - while( p != NULL && p[len] != '\n' ) - p = strstr(p, fields[i]); - if( p == NULL ) - { - ShowSQL ("Field `%s` not be found in `%s`. Consider updating your database!\n", fields[i], char_db); - if( lsql_handle ) - Sql_Free(lsql_handle); - Sql_Free(sql_handle); - exit(EXIT_FAILURE); - } - } - - return 1; -} - // finalize void inter_final(void) { @@ -533,26 +410,6 @@ int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) return 0; } -int mapif_send_gmaccounts() -{ - int i, len = 4; - unsigned char buf[32000]; - - // forward the gm accounts to the map server - len = 4; - WBUFW(buf,0) = 0x2b15; - - for(i = 0; i < GM_num; i++) { - WBUFL(buf,len) = gm_account[i].account_id; - WBUFB(buf,len+4) = (uint8)gm_account[i].level; - len += 5; - } - WBUFW(buf,2) = len; - mapif_sendall(buf, len); - - return 0; -} - //Request to kick char from a certain map server. [Skotlex] int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) { @@ -815,6 +672,26 @@ int mapif_parse_NameChangeRequest(int fd) } //-------------------------------------------------------- + +/// Returns the length of the next complete packet to process, +/// or 0 if no complete packet exists in the queue. +/// +/// @param length The minimum allowed length, or -1 for dynamic lookup +int inter_check_length(int fd, int length) +{ + if( length == -1 ) + {// variable-length packet + if( RFIFOREST(fd) < 4 ) + return 0; + length = RFIFOW(fd,2); + } + + if( (int)RFIFOREST(fd) < length ) + return 0; + + return length; +} + int inter_parse_frommap(int fd) { int cmd; @@ -855,18 +732,4 @@ int inter_parse_frommap(int fd) return 1; } -// RFIFO check -int inter_check_length(int fd, int length) -{ - if(length == -1) { // v-len packet - if(RFIFOREST(fd) < 4) // packet not yet - return 0; - length = RFIFOW(fd, 2); - } - - if((int)RFIFOREST(fd) < length) // packet not yet - return 0; - - return length; -} #endif //TXT_SQL_CONVERT diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index a44ce77e1..ac2e1785f 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -14,30 +14,15 @@ int inter_mapif_init(int fd); int mapif_send_gmaccounts(void); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); -int inter_check_length(int fd,int length); - int inter_log(char *fmt,...); #define inter_cfgName "conf/inter_athena.conf" extern unsigned int party_share_level; -extern char inter_log_filename[1024]; extern Sql* sql_handle; extern Sql* lsql_handle; -extern int char_server_port; -extern char char_server_ip[32]; -extern char char_server_id[32]; -extern char char_server_pw[32]; -extern char char_server_db[32]; - -extern int login_db_server_port; -extern char login_db_server_ip[32]; -extern char login_db_server_id[32]; -extern char login_db_server_pw[32]; -extern char login_db_server_db[32]; - extern char main_chat_nick[16]; int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); diff --git a/src/common/mmo.h b/src/common/mmo.h index 2e96e8910..9e419c65b 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -90,6 +90,7 @@ //Limits to avoid ID collision with other game objects #define START_ACCOUNT_NUM 2000000 #define END_ACCOUNT_NUM 100000000 +#define START_CHAR_NUM 150000 //Base Homun skill. #define HM_SKILLBASE 8001 @@ -344,11 +345,6 @@ struct registry { struct global_reg account2[ACCOUNT_REG2_NUM]; }; -struct gm_account { - int account_id; - int level; -}; - struct party_member { int account_id; int char_id; diff --git a/src/common/plugins.c b/src/common/plugins.c index 01a6194cd..c6c362de5 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -287,7 +287,7 @@ char *DLL_ERROR(void) { static char dllbuf[80]; DWORD dw = GetLastError(); - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, 0, dllbuf, 80, NULL); + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, 0, dllbuf, 80, NULL); return dllbuf; } #endif diff --git a/src/common/plugins.h b/src/common/plugins.h index 9d93bcaa6..e71a4e8c5 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -16,7 +16,7 @@ #define WIN32_LEAN_AND_MEAN #include - #define DLL_OPEN(x) LoadLibrary(x) + #define DLL_OPEN(x) LoadLibraryA(x) #define DLL_SYM(x,y) GetProcAddress(x,y) #define DLL_CLOSE(x) FreeLibrary(x) char *DLL_ERROR(void); diff --git a/src/common/sql.c b/src/common/sql.c index 567fbb703..47ff320ea 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -5,6 +5,7 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" +#include "../common/timer.h" #include "sql.h" #ifdef WIN32 @@ -24,6 +25,7 @@ struct Sql MYSQL_RES* result; MYSQL_ROW row; unsigned long* lengths; + int keepalive; }; @@ -73,6 +75,8 @@ Sql* Sql_Malloc(void) +static int Sql_P_Keepalive(Sql* self); + /// Establishes a connection. int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db) { @@ -85,6 +89,14 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos ShowSQL("%s\n", mysql_error(&self->handle)); return SQL_ERROR; } + + self->keepalive = Sql_P_Keepalive(self); + if( self->keepalive == INVALID_TIMER ) + { + ShowSQL("Failed to establish keepalive for DB connection!\n"); + return SQL_ERROR; + } + return SQL_SUCCESS; } @@ -162,6 +174,44 @@ int Sql_Ping(Sql* self) +/// Wrapper function for Sql_Ping. +/// +/// @private +static int Sql_P_KeepaliveTimer(int tid, unsigned int tick, int id, intptr data) +{ + Sql* self = (Sql*)data; + ShowInfo("Pinging SQL server to keep connection alive...\n"); + Sql_Ping(self); + return 0; +} + + + +/// Establishes keepalive (periodic ping) on the connection. +/// +/// @return the keepalive timer id, or INVALID_TIMER +/// @private +static int Sql_P_Keepalive(Sql* self) +{ + uint32 timeout, ping_interval; + + // set a default value first + timeout = 28800; // 8 hours + + // request the timeout value from the mysql server + Sql_GetTimeout(self, &timeout); + + if( timeout < 60 ) + timeout = 60; + + // establish keepalive + ping_interval = timeout - 30; // 30-second reserve + //add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer"); + return add_timer_interval(gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (int)self, ping_interval*1000); +} + + + /// Escapes a string. size_t Sql_EscapeString(Sql* self, char *out_to, const char *from) { @@ -356,6 +406,7 @@ void Sql_Free(Sql* self) { Sql_FreeResult(self); StringBuf_Destroy(&self->buf); + delete_timer(self->keepalive, Sql_P_KeepaliveTimer); aFree(self); } } diff --git a/src/common/utils.c b/src/common/utils.c index ce9ea56f2..c1128edb4 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -77,7 +77,7 @@ static char* checkpath(char *path, const char *srcpath) void findfile(const char *p, const char *pat, void (func)(const char*)) { - WIN32_FIND_DATA FindFileData; + WIN32_FIND_DATAA FindFileData; HANDLE hFind; char tmppath[MAX_PATH+1]; @@ -90,7 +90,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) else strcat(tmppath, "*"); - hFind = FindFirstFile(tmppath, &FindFileData); + hFind = FindFirstFileA(tmppath, &FindFileData); if (hFind != INVALID_HANDLE_VALUE) { do @@ -111,7 +111,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) { findfile(tmppath, pat, func); } - }while (FindNextFile(hFind, &FindFileData) != 0); + }while (FindNextFileA(hFind, &FindFileData) != 0); FindClose(hFind); } return; diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index b798ef385..56e08bde5 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -3,8 +3,6 @@ /////////////////////////////////////////////////////////////////////////// // EAthena login-server remote administration tool -// Ladamin in C by [Yor] -// if you modify this software, modify ladmin in tool too. /////////////////////////////////////////////////////////////////////////// #include "../common/cbasetypes.h" @@ -20,27 +18,6 @@ #include #include -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -void Gettimeofday(struct timeval *timenow) -{ - time_t t; - t = clock(); - timenow->tv_usec = t; - timenow->tv_sec = t / CLK_TCK; - return; -} -#define gettimeofday(timenow, dummy) Gettimeofday(timenow) -#else -#include -#include -#include // gettimeofday -#include -#include // close -#include // inet_addr -#include // gethostbyname -#endif #include #include #include @@ -54,7 +31,6 @@ void Gettimeofday(struct timeval *timenow) // IP of the login server. // Port where the login-server listens incoming packets. // Password of administration (same of config_athena.conf). -// Displayed language of the sofware (if not correct, english is used). // IMPORTANT: // Be sure that you authorize remote administration in login-server // (see login_athena.conf, 'admin_state' parameter) @@ -63,10 +39,9 @@ char loginserverip[16] = "127.0.0.1"; // IP of login-server int loginserverport = 6900; // Port of login-server char loginserveradminpassword[24] = "admin"; // Administration password int passenc = 0; // Encoding type of the password -char defaultlanguage = 'E'; // Default language (F: Français/E: English) - // (if it's not 'F', default is English) char ladmin_log_filename[1024] = "log/ladmin.log"; char date_format[32] = "%Y-%m-%d %H:%M:%S"; + //------------------------------------------------------------------------- // LIST of COMMANDs that you can type at the prompt: // To use these commands you can only type only the first letters. @@ -154,9 +129,6 @@ char date_format[32] = "%Y-%m-%d %H:%M:%S"; // kamib // Sends a broadcast message on all map-server (in blue). // -// language -// Change the language of displaying. -// // list/ls [start_id [end_id]] // Display a list of accounts. // 'start_id', 'end_id': indicate end and start identifiers. @@ -250,6 +222,7 @@ char date_format[32] = "%Y-%m-%d %H:%M:%S"; // Displays complete information of an account. // //------------------------------------------------------------------------- + int login_fd; int login_ip; int bytes_to_read = 0; // flag to know if we waiting bytes from login-server @@ -265,7 +238,7 @@ int ladmin_log(char *fmt, ...) { FILE *logfp; va_list ap; - struct timeval tv; + time_t t; char tmpstr[2048]; va_start(ap, fmt); @@ -275,9 +248,9 @@ int ladmin_log(char *fmt, ...) if (fmt[0] == '\0') // jump a line if no message fprintf(logfp, "\n"); else { - gettimeofday(&tv, NULL); - strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec))); - sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt); + t = time(NULL); + strftime(tmpstr, 24, date_format, localtime(&t)); + sprintf(tmpstr + strlen(tmpstr), ": %s", fmt); vfprintf(logfp, tmpstr, ap); } fclose(logfp); @@ -292,24 +265,15 @@ int ladmin_log(char *fmt, ...) //--------------------------------------------- char* makeordinal(int number) { - if (defaultlanguage == 'F') { - if (number == 0) - return ""; - else if (number == 1) - return "er"; + if ((number % 10) < 4 && (number % 10) != 0 && (number < 10 || number > 20)) { + if ((number % 10) == 1) + return "st"; + else if ((number % 10) == 2) + return "nd"; else - return "ème"; + return "rd"; } else { - if ((number % 10) < 4 && (number % 10) != 0 && (number < 10 || number > 20)) { - if ((number % 10) == 1) - return "st"; - else if ((number % 10) == 2) - return "nd"; - else - return "rd"; - } else { - return "th"; - } + return "th"; } return ""; } @@ -323,36 +287,21 @@ int verify_accountname(char* account_name) for(i = 0; account_name[i]; i++) { if (account_name[i] < 32) { - if (defaultlanguage == 'F') { - ShowMessage("Caractère interdit trouvé dans le nom du compte (%d%s caractère).\n", i+1, makeordinal(i+1)); - ladmin_log("Caractère interdit trouvé dans le nom du compte (%d%s caractère).\n", i+1, makeordinal(i+1)); - } else { - ShowMessage("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); - ladmin_log("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); - } + ShowMessage("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); + ladmin_log("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); return 0; } } if (strlen(account_name) < 4) { - if (defaultlanguage == 'F') { - ShowMessage("Nom du compte trop court. Entrez un nom de compte de 4-23 caractères.\n"); - ladmin_log("Nom du compte trop court. Entrez un nom de compte de 4-23 caractères.\n"); - } else { - ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); - } + ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); + ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); return 0; } if (strlen(account_name) > 23) { - if (defaultlanguage == 'F') { - ShowMessage("Nom du compte trop long. Entrez un nom de compte de 4-23 caractères.\n"); - ladmin_log("Nom du compte trop long. Entrez un nom de compte de 4-23 caractères.\n"); - } else { - ShowMessage("Account name is too long. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too long. Please input an account name of 4-23 bytes.\n"); - } + ShowMessage("Account name is too long. Please input an account name of 4-23 bytes.\n"); + ladmin_log("Account name is too long. Please input an account name of 4-23 bytes.\n"); return 0; } @@ -368,50 +317,34 @@ int typepasswd(char * password) int letter; int i; - if (defaultlanguage == 'F') { - ladmin_log("Aucun mot de passe n'a été donné. Demande d'un mot de passe.\n"); - } else { - ladmin_log("No password was given. Request to obtain a password.\n"); - } + ladmin_log("No password was given. Request to obtain a password.\n"); memset(password1, '\0', sizeof(password1)); memset(password2, '\0', sizeof(password2)); - if (defaultlanguage == 'F') - ShowMessage("\033[1;36m Entrez le mot de passe > \033[0;32;42m"); - else - ShowMessage("\033[1;36m Type the password > \033[0;32;42m"); - i = 0; - while ((letter = getchar()) != '\n') - password1[i++] = letter; - if (defaultlanguage == 'F') - ShowMessage("\033[0m\033[1;36m Ré-entrez le mot de passe > \033[0;32;42m"); - else - ShowMessage("\033[0m\033[1;36m Verify the password > \033[0;32;42m"); - i = 0; - while ((letter = getchar()) != '\n') - password2[i++] = letter; + + ShowMessage("\033[1;36m Type the password > \033[0;32;42m"); + + i = 0; + while ((letter = getchar()) != '\n') + password1[i++] = letter; + + ShowMessage("\033[0m\033[1;36m Verify the password > \033[0;32;42m"); + + i = 0; + while ((letter = getchar()) != '\n') + password2[i++] = letter; ShowMessage("\033[0m"); fflush(stdout); fflush(stdin); if (strcmp(password1, password2) != 0) { - if (defaultlanguage == 'F') { - ShowMessage("Erreur de vérification du mot de passe: Saisissez le même mot de passe svp.\n"); - ladmin_log("Erreur de vérification du mot de passe: Saisissez le même mot de passe svp.\n"); - ladmin_log(" Premier mot de passe: %s, second mot de passe: %s.\n", password1, password2); - } else { - ShowMessage("Password verification failed. Please input same password.\n"); - ladmin_log("Password verification failed. Please input same password.\n"); - ladmin_log(" First password: %s, second password: %s.\n", password1, password2); - } + ShowMessage("Password verification failed. Please input same password.\n"); + ladmin_log("Password verification failed. Please input same password.\n"); + ladmin_log(" First password: %s, second password: %s.\n", password1, password2); return 0; } - if (defaultlanguage == 'F') { - ladmin_log("Mot de passe saisi: %s.\n", password1); - } else { - ladmin_log("Typed password: %s.\n", password1); - } + ladmin_log("Typed password: %s.\n", password1); strcpy(password, password1); return 1; } @@ -425,36 +358,21 @@ int verify_password(char * password) for(i = 0; password[i]; i++) { if (password[i] < 32) { - if (defaultlanguage == 'F') { - ShowMessage("Caractère interdit trouvé dans le mot de passe (%d%s caractère).\n", i+1, makeordinal(i+1)); - ladmin_log("Caractère interdit trouvé dans le nom du compte (%d%s caractère).\n", i+1, makeordinal(i+1)); - } else { - ShowMessage("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); - ladmin_log("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); - } + ShowMessage("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); + ladmin_log("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); return 0; } } if (strlen(password) < 4) { - if (defaultlanguage == 'F') { - ShowMessage("Nom du compte trop court. Entrez un nom de compte de 4-23 caractères.\n"); - ladmin_log("Nom du compte trop court. Entrez un nom de compte de 4-23 caractères.\n"); - } else { - ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); - } + ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); + ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); return 0; } if (strlen(password) > 23) { - if (defaultlanguage == 'F') { - ShowMessage("Mot de passe trop long. Entrez un mot de passe de 4-23 caractères.\n"); - ladmin_log("Mot de passe trop long. Entrez un mot de passe de 4-23 caractères.\n"); - } else { - ShowMessage("Password is too long. Please input a password of 4-23 bytes.\n"); - ladmin_log("Password is too long. Please input a password of 4-23 bytes.\n"); - } + ShowMessage("Password is too long. Please input a password of 4-23 bytes.\n"); + ladmin_log("Password is too long. Please input a password of 4-23 bytes.\n"); return 0; } @@ -467,9 +385,7 @@ int verify_password(char * password) int check_command(char * command) { // help - if (strncmp(command, "aide", 2) == 0 && strncmp(command, "aide", strlen(command)) == 0) // not 1 letter command: 'aide' or 'add'? - strcpy(command, "aide"); - else if (strncmp(command, "help", 1) == 0 && strncmp(command, "help", strlen(command)) == 0) + if (strncmp(command, "help", 1) == 0 && strncmp(command, "help", strlen(command)) == 0) strcpy(command, "help"); // general commands else if (strncmp(command, "add", 2) == 0 && strncmp(command, "add", strlen(command)) == 0) // not 1 letter command: 'aide' or 'add'? @@ -506,9 +422,7 @@ int check_command(char * command) // strcpy(command, "kami"); // else if (strncmp(command, "kamib", 5) == 0 && strncmp(command, "kamib", strlen(command)) == 0) // only all letters command: 'kami' or 'kamib'? // strcpy(command, "kamib"); - else if ((strncmp(command, "language", 2) == 0 && strncmp(command, "language", strlen(command)) == 0)) // not 1 letter command: 'language' or 'list'? - strcpy(command, "language"); - else if ((strncmp(command, "list", 2) == 0 && strncmp(command, "list", strlen(command)) == 0) || // 'list' is default list command // not 1 letter command: 'language' or 'list'? + else if ((strncmp(command, "list", 2) == 0 && strncmp(command, "list", strlen(command)) == 0) || // 'list' is default list command // not 1 letter command: 'list'? strcmp(command, "ls") == 0) strcpy(command, "list"); else if ((strncmp(command, "listban", 5) == 0 && strncmp(command, "listban", strlen(command)) == 0) || @@ -567,7 +481,7 @@ int check_command(char * command) //----------------------------------------- // Sub-function: Display commands of ladmin //----------------------------------------- -void display_help(char* param, int language) +void display_help(char* param) { char command[1023]; int i; @@ -577,12 +491,8 @@ void display_help(char* param, int language) if (sscanf(param, "%s ", command) < 1 || strlen(command) == 0) strcpy(command, ""); // any value that is not a command - if (command[0] == '?') { - if (defaultlanguage == 'F') - strcpy(command, "aide"); - else - strcpy(command, "help"); - } + if (command[0] == '?') + strcpy(command, "help"); // lowercase for command for (i = 0; command[i]; i++) @@ -591,503 +501,242 @@ void display_help(char* param, int language) // Analyse of the command check_command(command); // give complete name to the command - if (defaultlanguage == 'F') { - ladmin_log("Affichage des commandes ou d'une commande.\n"); - } else { - ladmin_log("Displaying of the commands or a command.\n"); - } + ladmin_log("Displaying of the commands or a command.\n"); - if (language == 1) { - if (strcmp(command, "aide") == 0) { - ShowMessage("aide/help/?\n"); - ShowMessage(" Affiche la description des commandes\n"); - ShowMessage("aide/help/? [commande]\n"); - ShowMessage(" Affiche la description de la commande specifiée\n"); - } else if (strcmp(command, "help") == 0 ) { - ShowMessage("aide/help/?\n"); - ShowMessage(" Display the description of the commands\n"); - ShowMessage("aide/help/? [command]\n"); - ShowMessage(" Display the description of the specified command\n"); + if (strcmp(command, "help") == 0 ) { + ShowMessage("aide/help/?\n"); + ShowMessage(" Display the description of the commands\n"); + ShowMessage("aide/help/? [command]\n"); + ShowMessage(" Display the description of the specified command\n"); // general commands - } else if (strcmp(command, "add") == 0) { - ShowMessage("add \n"); - ShowMessage(" Crée un compte avec l'email par défaut (a@a.com).\n"); - ShowMessage(" Concernant le sexe, seule la première lettre compte (F ou M).\n"); - ShowMessage(" L'e-mail est a@a.com (e-mail par défaut). C'est comme n'avoir aucun e-mail.\n"); - ShowMessage(" Lorsque motdepasse est omis, la saisie se fait sans que la frappe se voit.\n"); - ShowMessage(" add testname Male testpass\n"); - } else if (strcmp(command, "ban") == 0) { - ShowMessage("ban/banish aaaa/mm/jj hh:mm:ss \n"); - ShowMessage(" Change la date de fin de bannissement d'un compte.\n"); - ShowMessage(" Comme banset, mais est à la fin.\n"); - } else if (strcmp(command, "banadd") == 0) { - ShowMessage("banadd \n"); - ShowMessage(" Ajoute ou soustrait du temps à la date de banissement d'un compte.\n"); - ShowMessage(" Les modificateurs sont construits comme suit:\n"); - ShowMessage(" Valeur d'ajustement (-1, 1, +1, etc...)\n"); - ShowMessage(" Elément modifié:\n"); - ShowMessage(" a ou y: année\n"); - ShowMessage(" m: mois\n"); - ShowMessage(" j ou d: jour\n"); - ShowMessage(" h: heure\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: seconde\n"); - ShowMessage(" banadd testname +1m-2mn1s-6a\n"); - ShowMessage(" Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ShowMessage("NOTE: Si vous modifez la date de banissement d'un compte non bani,\n"); - ShowMessage(" vous indiquez comme date (le moment actuel +- les ajustements)\n"); - } else if (strcmp(command, "banset") == 0) { - ShowMessage("banset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" Change la date de fin de bannissement d'un compte.\n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("banset 0\n"); - ShowMessage(" Débanni un compte (0 = de-banni).\n"); - } else if (strcmp(command, "block") == 0) { - ShowMessage("block \n"); - ShowMessage(" Place le status d'un compte à 5 (You have been blocked by the GM Team).\n"); - ShowMessage(" La commande est l'équivalent de state 5.\n"); - } else if (strcmp(command, "check") == 0) { - ShowMessage("check \n"); - ShowMessage(" Vérifie la validité d'un mot de passe pour un compte\n"); - ShowMessage(" NOTE: Le serveur n'enverra jamais un mot de passe.\n"); - ShowMessage(" C'est la seule méthode que vous possédez pour savoir\n"); - ShowMessage(" si un mot de passe est le bon. L'autre méthode est\n"); - ShowMessage(" d'avoir un accès ('physique') au fichier des comptes.\n"); - } else if (strcmp(command, "create") == 0) { - ShowMessage("create \n"); - ShowMessage(" Comme la commande add, mais avec l'e-mail en plus.\n"); - ShowMessage(" create testname Male mon@mail.com testpass\n"); - } else if (strcmp(command, "delete") == 0) { - ShowMessage("del \n"); - ShowMessage(" Supprime un compte.\n"); - ShowMessage(" La commande demande confirmation. Après confirmation, le compte est détruit.\n"); - } else if (strcmp(command, "email") == 0) { - ShowMessage("email \n"); - ShowMessage(" Modifie l'e-mail d'un compte.\n"); - } else if (strcmp(command, "getcount") == 0) { - ShowMessage("getcount\n"); - ShowMessage(" Donne le nombre de joueurs en ligne par serveur de char.\n"); - } else if (strcmp(command, "gm") == 0) { - ShowMessage("gm [Niveau_GM]\n"); - ShowMessage(" Modifie le niveau de GM d'un compte.\n"); - ShowMessage(" Valeur par défaut: 0 (suppression du niveau de GM).\n"); - ShowMessage(" gm nomtest 80\n"); - } else if (strcmp(command, "id") == 0) { - ShowMessage("id \n"); - ShowMessage(" Donne l'id d'un compte.\n"); - } else if (strcmp(command, "info") == 0) { - ShowMessage("info \n"); - ShowMessage(" Affiche les informations sur un compte.\n"); - } else if (strcmp(command, "kami") == 0) { - ShowMessage("kami \n"); - ShowMessage(" Envoi un message général sur tous les serveurs de map (en jaune).\n"); - } else if (strcmp(command, "kamib") == 0) { - ShowMessage("kamib \n"); - ShowMessage(" Envoi un message général sur tous les serveurs de map (en bleu).\n"); - } else if (strcmp(command, "language") == 0) { - ShowMessage("language \n"); - ShowMessage(" Change la langue d'affichage.\n"); - ShowMessage(" Langues possibles: 'Français' ou 'English'.\n"); - } else if (strcmp(command, "list") == 0) { - ShowMessage("list/ls [Premier_id [Dernier_id]]\n"); - ShowMessage(" Affiche une liste de comptes.\n"); - ShowMessage(" 'Premier_id', 'Dernier_id': indique les identifiants de départ et de fin.\n"); - ShowMessage(" La recherche par nom n'est pas possible avec cette commande.\n"); - ShowMessage(" list 10 9999999\n"); - } else if (strcmp(command, "listban") == 0) { - ShowMessage("listBan/lsBan [Premier_id [Dernier_id]]\n"); - ShowMessage(" Comme list/ls, mais seulement pour les comptes avec statut ou bannis.\n"); - } else if (strcmp(command, "listgm") == 0) { - ShowMessage("listGM/lsGM [Premier_id [Dernier_id]]\n"); - ShowMessage(" Comme list/ls, mais seulement pour les comptes GM.\n"); - } else if (strcmp(command, "listok") == 0) { - ShowMessage("listOK/lsOK [Premier_id [Dernier_id]]\n"); - ShowMessage(" Comme list/ls, mais seulement pour les comptes sans statut et non bannis.\n"); - } else if (strcmp(command, "memo") == 0) { - ShowMessage("memo \n"); - ShowMessage(" Modifie le mémo d'un compte.\n"); - ShowMessage(" 'memo': Il peut avoir jusqu'à 253 caractères (avec des espaces ou non).\n"); - } else if (strcmp(command, "name") == 0) { - ShowMessage("name \n"); - ShowMessage(" Donne le nom d'un compte.\n"); - } else if (strcmp(command, "password") == 0) { - ShowMessage("passwd \n"); - ShowMessage(" Change le mot de passe d'un compte.\n"); - ShowMessage(" Lorsque nouveaumotdepasse est omis,\n"); - ShowMessage(" la saisie se fait sans que la frappe ne se voit.\n"); - } else if (strcmp(command, "reloadgm") == 0) { - ShowMessage("reloadGM\n"); - ShowMessage(" Reload GM configuration file\n"); - } else if (strcmp(command, "search") == 0) { - ShowMessage("search \n"); - ShowMessage(" Cherche des comptes.\n"); - ShowMessage(" Affiche les comptes dont les noms correspondent.\n"); -// ShowMessage("search -r/-e/--expr/--regex \n"); -// ShowMessage(" Cherche des comptes par expression regulière.\n"); -// ShowMessage(" Affiche les comptes dont les noms correspondent.\n"); - } else if (strcmp(command, "sex") == 0) { - ShowMessage("sex \n"); - ShowMessage(" Modifie le sexe d'un compte.\n"); - ShowMessage(" sex testname Male\n"); - } else if (strcmp(command, "state") == 0) { - ShowMessage("state \n"); - ShowMessage(" Change le statut d'un compte.\n"); - ShowMessage(" 'nouveaustatut': Le statut est le même que celui du packet 0x006a + 1.\n"); - ShowMessage(" les possibilités sont:\n"); - ShowMessage(" 0 = Compte ok\n"); - ShowMessage(" 1 = Unregistered ID\n"); - ShowMessage(" 2 = Incorrect Password\n"); - ShowMessage(" 3 = This ID is expired\n"); - ShowMessage(" 4 = Rejected from Server\n"); - ShowMessage(" 5 = You have been blocked by the GM Team\n"); - ShowMessage(" 6 = Your Game's EXE file is not the latest version\n"); - ShowMessage(" 7 = You are Prohibited to log in until...\n"); - ShowMessage(" 8 = Server is jammed due to over populated\n"); - ShowMessage(" 9 = No MSG\n"); - ShowMessage(" 100 = This ID has been totally erased\n"); - ShowMessage(" all other values are 'No MSG', then use state 9 please.\n"); - ShowMessage(" 'message_erreur_7': message du code erreur 6 =\n"); - ShowMessage(" = Your are Prohibited to log in until... (packet 0x006a)\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeadd \n"); - ShowMessage(" Ajoute/soustrait du temps à la limite de validité d'un compte.\n"); - ShowMessage(" Le modificateur est composé comme suit:\n"); - ShowMessage(" Valeur modificatrice (-1, 1, +1, etc...)\n"); - ShowMessage(" Elément modifié:\n"); - ShowMessage(" a ou y: année\n"); - ShowMessage(" m: mois\n"); - ShowMessage(" j ou d: jour\n"); - ShowMessage(" h: heure\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: seconde\n"); - ShowMessage(" timeadd testname +1m-2mn1s-6a\n"); - ShowMessage(" Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ShowMessage("NOTE: Vous ne pouvez pas modifier une limite de validité illimitée. Si vous\n"); - ShowMessage(" désirez le faire, c'est que vous voulez probablement créer un limite de\n"); - ShowMessage(" validité limitée. Donc, en premier, fixé une limite de valitidé.\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" Change la limite de validité d'un compte.\n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("timeset 0\n"); - ShowMessage(" Donne une limite de validité illimitée (0 = illimitée).\n"); - } else if (strcmp(command, "unban") == 0) { - ShowMessage("unban/unbanish \n"); - ShowMessage(" Ote le banissement d'un compte.\n"); - ShowMessage(" La commande est l'équivalent de banset 0.\n"); - } else if (strcmp(command, "unblock") == 0) { - ShowMessage("unblock \n"); - ShowMessage(" Place le status d'un compte à 0 (Compte ok).\n"); - ShowMessage(" La commande est l'équivalent de state 0.\n"); - } else if (strcmp(command, "version") == 0) { - ShowMessage("version\n"); - ShowMessage(" Affiche la version du login-serveur.\n"); - } else if (strcmp(command, "who") == 0) { - ShowMessage("who \n"); - ShowMessage(" Affiche les informations sur un compte.\n"); -// quit - } else if (strcmp(command, "quit") == 0 || - strcmp(command, "exit") == 0 || - strcmp(command, "end") == 0) { - ShowMessage("quit/end/exit\n"); - ShowMessage(" Fin du programme d'administration.\n"); -// unknown command - } else { - if (strlen(command) > 0) - ShowMessage("Commande inconnue [%s] pour l'aide. Affichage de toutes les commandes.\n", command); - ShowMessage(" aide/help/? -- Affiche cet aide\n"); - ShowMessage(" aide/help/? [commande] -- Affiche l'aide de la commande\n"); - ShowMessage(" add -- Crée un compte (sans email)\n"); - ShowMessage(" ban/banish aaaa/mm/jj hh:mm:ss -- Fixe la date finale de banismnt\n"); - ShowMessage(" banadd/ba -- Ajout/soustrait du temps à la\n"); - ShowMessage(" exemple: ba moncompte +1m-2mn1s-2y date finale de banissement\n"); - ShowMessage(" banset/bs aaaa/mm/jj [hh:mm:ss] -- Change la date fin de banisemnt\n"); - ShowMessage(" banset/bs 0 -- Dé-banis un compte.\n"); - ShowMessage(" block -- Mets le status d'un compte à 5 (blocked by the GM Team)\n"); - ShowMessage(" check -- Vérifie un mot de passe d'un compte\n"); - ShowMessage(" create -- Crée un compte (avec email)\n"); - ShowMessage(" del -- Supprime un compte\n"); - ShowMessage(" email -- Modifie l'e-mail d'un compte\n"); - ShowMessage(" getcount -- Donne le nb de joueurs en ligne\n"); - ShowMessage(" gm [Niveau_GM] -- Modifie le niveau de GM d'un compte\n"); - ShowMessage(" id -- Donne l'id d'un compte\n"); - ShowMessage(" info -- Affiche les infos sur un compte\n"); - ShowMessage(" kami -- Envoi un message général (en jaune)\n"); - ShowMessage(" kamib -- Envoi un message général (en bleu)\n"); - ShowMessage(" language -- Change la langue d'affichage.\n"); - ShowMessage(" list/ls [Premier_id [Dernier_id] ] -- Affiche une liste de comptes\n"); - ShowMessage(" listBan/lsBan [Premier_id [Dernier_id] ] -- Affiche une liste de comptes\n"); - ShowMessage(" avec un statut ou bannis\n"); - ShowMessage(" listGM/lsGM [Premier_id [Dernier_id] ] -- Affiche une liste de comptes GM\n"); - ShowMessage(" listOK/lsOK [Premier_id [Dernier_id] ] -- Affiche une liste de comptes\n"); - ShowMessage(" sans status et non bannis\n"); - ShowMessage(" memo -- Modifie le memo d'un compte\n"); - ShowMessage(" name -- Donne le nom d'un compte\n"); - ShowMessage(" passwd -- Change le mot de passe d'un compte\n"); - ShowMessage(" quit/end/exit -- Fin du programme d'administation\n"); - ShowMessage(" reloadGM -- Recharger le fichier de config des GM\n"); - ShowMessage(" search -- Cherche des comptes\n"); -// ShowMessage(" search -e/-r/--expr/--regex -- Cherche des comptes par REGEX\n"); - ShowMessage(" sex -- Modifie le sexe d'un compte\n"); - ShowMessage(" state -- Change le statut d'1 compte\n"); - ShowMessage(" timeadd/ta -- Ajout/soustrait du temps à la\n"); - ShowMessage(" exemple: ta moncompte +1m-2mn1s-2y limite de validité\n"); - ShowMessage(" timeset/ts aaaa/mm/jj [hh:mm:ss] -- Change la limite de validité\n"); - ShowMessage(" timeset/ts 0 -- limite de validité = illimitée\n"); - ShowMessage(" unban/unbanish -- Ote le banissement d'un compte\n"); - ShowMessage(" unblock -- Mets le status d'un compte à 0 (Compte ok)\n"); - ShowMessage(" version -- Donne la version du login-serveur\n"); - ShowMessage(" who -- Affiche les infos sur un compte\n"); - ShowMessage(" Note: Pour les noms de compte avec des espaces, tapez \"\" (ou ').\n"); - } - } else { - if (strcmp(command, "aide") == 0) { - ShowMessage("aide/help/?\n"); - ShowMessage(" Display the description of the commands\n"); - ShowMessage("aide/help/? [command]\n"); - ShowMessage(" Display the description of the specified command\n"); - } else if (strcmp(command, "help") == 0 ) { - ShowMessage("aide/help/?\n"); - ShowMessage(" Display the description of the commands\n"); - ShowMessage("aide/help/? [command]\n"); - ShowMessage(" Display the description of the specified command\n"); -// general commands - } else if (strcmp(command, "add") == 0) { - ShowMessage("add \n"); - ShowMessage(" Create an account with the default email (a@a.com).\n"); - ShowMessage(" Concerning the sex, only the first letter is used (F or M).\n"); - ShowMessage(" The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.\n"); - ShowMessage(" When the password is omitted,\n"); - ShowMessage(" the input is done without displaying of the pressed keys.\n"); - ShowMessage(" add testname Male testpass\n"); - } else if (strcmp(command, "ban") == 0) { - ShowMessage("ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" Changes the final date of a banishment of an account.\n"); - ShowMessage(" Like banset, but is at end.\n"); - } else if (strcmp(command, "banadd") == 0) { - ShowMessage("banadd \n"); - ShowMessage(" Adds or substracts time from the final date of a banishment of an account.\n"); - ShowMessage(" Modifier is done as follows:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ShowMessage("NOTE: If you modify the final date of a non-banished account,\n"); - ShowMessage(" you fix the final date to (actual time +- adjustments)\n"); - } else if (strcmp(command, "banset") == 0) { - ShowMessage("banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" Changes the final date of a banishment of an account.\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("banset 0\n"); - ShowMessage(" Set a non-banished account (0 = unbanished).\n"); - } else if (strcmp(command, "block") == 0) { - ShowMessage("block \n"); - ShowMessage(" Set state 5 (You have been blocked by the GM Team) to an account.\n"); - ShowMessage(" This command works like state 5.\n"); - } else if (strcmp(command, "check") == 0) { - ShowMessage("check \n"); - ShowMessage(" Check the validity of a password for an account.\n"); - ShowMessage(" NOTE: Server will never send back a password.\n"); - ShowMessage(" It's the only method you have to know if a password is correct.\n"); - ShowMessage(" The other method is to have a ('physical') access to the accounts file.\n"); - } else if (strcmp(command, "create") == 0) { - ShowMessage("create \n"); - ShowMessage(" Like the 'add' command, but with e-mail moreover.\n"); - ShowMessage(" create testname Male my@mail.com testpass\n"); - } else if (strcmp(command, "delete") == 0) { - ShowMessage("del \n"); - ShowMessage(" Remove an account.\n"); - ShowMessage(" This order requires confirmation. After confirmation, the account is deleted.\n"); - } else if (strcmp(command, "email") == 0) { - ShowMessage("email \n"); - ShowMessage(" Modify the e-mail of an account.\n"); - } else if (strcmp(command, "getcount") == 0) { - ShowMessage("getcount\n"); - ShowMessage(" Give the number of players online on all char-servers.\n"); - } else if (strcmp(command, "gm") == 0) { - ShowMessage("gm [GM_level]\n"); - ShowMessage(" Modify the GM level of an account.\n"); - ShowMessage(" Default value remove GM level (GM level = 0).\n"); - ShowMessage(" gm testname 80\n"); - } else if (strcmp(command, "id") == 0) { - ShowMessage("id \n"); - ShowMessage(" Give the id of an account.\n"); - } else if (strcmp(command, "info") == 0) { - ShowMessage("info \n"); - ShowMessage(" Display complete information of an account.\n"); - } else if (strcmp(command, "kami") == 0) { - ShowMessage("kami \n"); - ShowMessage(" Sends a broadcast message on all map-server (in yellow).\n"); - } else if (strcmp(command, "kamib") == 0) { - ShowMessage("kamib \n"); - ShowMessage(" Sends a broadcast message on all map-server (in blue).\n"); - } else if (strcmp(command, "language") == 0) { - ShowMessage("language \n"); - ShowMessage(" Change the language of displaying.\n"); - ShowMessage(" Possible languages: Français or English.\n"); - } else if (strcmp(command, "list") == 0) { - ShowMessage("list/ls [start_id [end_id]]\n"); - ShowMessage(" Display a list of accounts.\n"); - ShowMessage(" 'start_id', 'end_id': indicate end and start identifiers.\n"); - ShowMessage(" Research by name is not possible with this command.\n"); - ShowMessage(" list 10 9999999\n"); - } else if (strcmp(command, "listban") == 0) { - ShowMessage("listBan/lsBan [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for accounts with state or banished.\n"); - } else if (strcmp(command, "listgm") == 0) { - ShowMessage("listGM/lsGM [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for GM accounts.\n"); - } else if (strcmp(command, "listok") == 0) { - ShowMessage("listOK/lsOK [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for accounts without state and not banished.\n"); - } else if (strcmp(command, "memo") == 0) { - ShowMessage("memo \n"); - ShowMessage(" Modify the memo of an account.\n"); - ShowMessage(" 'memo': it can have until 253 characters (with spaces or not).\n"); - } else if (strcmp(command, "name") == 0) { - ShowMessage("name \n"); - ShowMessage(" Give the name of an account.\n"); - } else if (strcmp(command, "password") == 0) { - ShowMessage("passwd \n"); - ShowMessage(" Change the password of an account.\n"); - ShowMessage(" When new password is omitted,\n"); - ShowMessage(" the input is done without displaying of the pressed keys.\n"); - } else if (strcmp(command, "reloadgm") == 0) { - ShowMessage("reloadGM\n"); - ShowMessage(" Reload GM configuration file\n"); - } else if (strcmp(command, "search") == 0) { - ShowMessage("search \n"); - ShowMessage(" Seek accounts.\n"); - ShowMessage(" Displays the accounts whose names correspond.\n"); + } else if (strcmp(command, "add") == 0) { + ShowMessage("add \n"); + ShowMessage(" Create an account with the default email (a@a.com).\n"); + ShowMessage(" Concerning the sex, only the first letter is used (F or M).\n"); + ShowMessage(" The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.\n"); + ShowMessage(" When the password is omitted,\n"); + ShowMessage(" the input is done without displaying of the pressed keys.\n"); + ShowMessage(" add testname Male testpass\n"); + } else if (strcmp(command, "ban") == 0) { + ShowMessage("ban/banish yyyy/mm/dd hh:mm:ss \n"); + ShowMessage(" Changes the final date of a banishment of an account.\n"); + ShowMessage(" Like banset, but is at end.\n"); + } else if (strcmp(command, "banadd") == 0) { + ShowMessage("banadd \n"); + ShowMessage(" Adds or substracts time from the final date of a banishment of an account.\n"); + ShowMessage(" Modifier is done as follows:\n"); + ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); + ShowMessage(" Modified element:\n"); + ShowMessage(" a or y: year\n"); + ShowMessage(" m: month\n"); + ShowMessage(" j or d: day\n"); + ShowMessage(" h: hour\n"); + ShowMessage(" mn: minute\n"); + ShowMessage(" s: second\n"); + ShowMessage(" banadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ShowMessage("NOTE: If you modify the final date of a non-banished account,\n"); + ShowMessage(" you fix the final date to (actual time +- adjustments)\n"); + } else if (strcmp(command, "banset") == 0) { + ShowMessage("banset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" Changes the final date of a banishment of an account.\n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ShowMessage("banset 0\n"); + ShowMessage(" Set a non-banished account (0 = unbanished).\n"); + } else if (strcmp(command, "block") == 0) { + ShowMessage("block \n"); + ShowMessage(" Set state 5 (You have been blocked by the GM Team) to an account.\n"); + ShowMessage(" This command works like state 5.\n"); + } else if (strcmp(command, "check") == 0) { + ShowMessage("check \n"); + ShowMessage(" Check the validity of a password for an account.\n"); + ShowMessage(" NOTE: Server will never send back a password.\n"); + ShowMessage(" It's the only method you have to know if a password is correct.\n"); + ShowMessage(" The other method is to have a ('physical') access to the accounts file.\n"); + } else if (strcmp(command, "create") == 0) { + ShowMessage("create \n"); + ShowMessage(" Like the 'add' command, but with e-mail moreover.\n"); + ShowMessage(" create testname Male my@mail.com testpass\n"); + } else if (strcmp(command, "delete") == 0) { + ShowMessage("del \n"); + ShowMessage(" Remove an account.\n"); + ShowMessage(" This order requires confirmation. After confirmation, the account is deleted.\n"); + } else if (strcmp(command, "email") == 0) { + ShowMessage("email \n"); + ShowMessage(" Modify the e-mail of an account.\n"); + } else if (strcmp(command, "getcount") == 0) { + ShowMessage("getcount\n"); + ShowMessage(" Give the number of players online on all char-servers.\n"); + } else if (strcmp(command, "gm") == 0) { + ShowMessage("gm [GM_level]\n"); + ShowMessage(" Modify the GM level of an account.\n"); + ShowMessage(" Default value remove GM level (GM level = 0).\n"); + ShowMessage(" gm testname 80\n"); + } else if (strcmp(command, "id") == 0) { + ShowMessage("id \n"); + ShowMessage(" Give the id of an account.\n"); + } else if (strcmp(command, "info") == 0) { + ShowMessage("info \n"); + ShowMessage(" Display complete information of an account.\n"); + } else if (strcmp(command, "kami") == 0) { + ShowMessage("kami \n"); + ShowMessage(" Sends a broadcast message on all map-server (in yellow).\n"); + } else if (strcmp(command, "kamib") == 0) { + ShowMessage("kamib \n"); + ShowMessage(" Sends a broadcast message on all map-server (in blue).\n"); + } else if (strcmp(command, "list") == 0) { + ShowMessage("list/ls [start_id [end_id]]\n"); + ShowMessage(" Display a list of accounts.\n"); + ShowMessage(" 'start_id', 'end_id': indicate end and start identifiers.\n"); + ShowMessage(" Research by name is not possible with this command.\n"); + ShowMessage(" list 10 9999999\n"); + } else if (strcmp(command, "listban") == 0) { + ShowMessage("listBan/lsBan [start_id [end_id]]\n"); + ShowMessage(" Like list/ls, but only for accounts with state or banished.\n"); + } else if (strcmp(command, "listgm") == 0) { + ShowMessage("listGM/lsGM [start_id [end_id]]\n"); + ShowMessage(" Like list/ls, but only for GM accounts.\n"); + } else if (strcmp(command, "listok") == 0) { + ShowMessage("listOK/lsOK [start_id [end_id]]\n"); + ShowMessage(" Like list/ls, but only for accounts without state and not banished.\n"); + } else if (strcmp(command, "memo") == 0) { + ShowMessage("memo \n"); + ShowMessage(" Modify the memo of an account.\n"); + ShowMessage(" 'memo': it can have until 253 characters (with spaces or not).\n"); + } else if (strcmp(command, "name") == 0) { + ShowMessage("name \n"); + ShowMessage(" Give the name of an account.\n"); + } else if (strcmp(command, "password") == 0) { + ShowMessage("passwd \n"); + ShowMessage(" Change the password of an account.\n"); + ShowMessage(" When new password is omitted,\n"); + ShowMessage(" the input is done without displaying of the pressed keys.\n"); + } else if (strcmp(command, "reloadgm") == 0) { + ShowMessage("reloadGM\n"); + ShowMessage(" Reload GM configuration file\n"); + } else if (strcmp(command, "search") == 0) { + ShowMessage("search \n"); + ShowMessage(" Seek accounts.\n"); + ShowMessage(" Displays the accounts whose names correspond.\n"); // ShowMessage("search -r/-e/--expr/--regex \n"); // ShowMessage(" Seek accounts by regular expression.\n"); // ShowMessage(" Displays the accounts whose names correspond.\n"); - } else if (strcmp(command, "sex") == 0) { - ShowMessage("sex \n"); - ShowMessage(" Modify the sex of an account.\n"); - ShowMessage(" sex testname Male\n"); - } else if (strcmp(command, "state") == 0) { - ShowMessage("state \n"); - ShowMessage(" Change the state of an account.\n"); - ShowMessage(" 'new_state': state is the state of the packet 0x006a + 1.\n"); - ShowMessage(" The possibilities are:\n"); - ShowMessage(" 0 = Account ok\n"); - ShowMessage(" 1 = Unregistered ID\n"); - ShowMessage(" 2 = Incorrect Password\n"); - ShowMessage(" 3 = This ID is expired\n"); - ShowMessage(" 4 = Rejected from Server\n"); - ShowMessage(" 5 = You have been blocked by the GM Team\n"); - ShowMessage(" 6 = Your Game's EXE file is not the latest version\n"); - ShowMessage(" 7 = You are Prohibited to log in until...\n"); - ShowMessage(" 8 = Server is jammed due to over populated\n"); - ShowMessage(" 9 = No MSG\n"); - ShowMessage(" 100 = This ID has been totally erased\n"); - ShowMessage(" all other values are 'No MSG', then use state 9 please.\n"); - ShowMessage(" 'error_message_#7': message of the code error 6\n"); - ShowMessage(" = Your are Prohibited to log in until... (packet 0x006a)\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeadd \n"); - ShowMessage(" Adds or substracts time from the validity limit of an account.\n"); - ShowMessage(" Modifier is done as follows:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ShowMessage("NOTE: You can not modify a unlimited validity limit.\n"); - ShowMessage(" If you want modify it, you want probably create a limited validity limit.\n"); - ShowMessage(" So, at first, you must set the validity limit to a date/time.\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" Changes the validity limit of an account.\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("timeset 0\n"); - ShowMessage(" Gives an unlimited validity limit (0 = unlimited).\n"); - } else if (strcmp(command, "unban") == 0) { - ShowMessage("unban/unbanish \n"); - ShowMessage(" Remove the banishment of an account.\n"); - ShowMessage(" This command works like banset 0.\n"); - } else if (strcmp(command, "unblock") == 0) { - ShowMessage("unblock \n"); - ShowMessage(" Set state 0 (Account ok) to an account.\n"); - ShowMessage(" This command works like state 0.\n"); - } else if (strcmp(command, "version") == 0) { - ShowMessage("version\n"); - ShowMessage(" Display the version of the login-server.\n"); - } else if (strcmp(command, "who") == 0) { - ShowMessage("who \n"); - ShowMessage(" Displays complete information of an account.\n"); + } else if (strcmp(command, "sex") == 0) { + ShowMessage("sex \n"); + ShowMessage(" Modify the sex of an account.\n"); + ShowMessage(" sex testname Male\n"); + } else if (strcmp(command, "state") == 0) { + ShowMessage("state \n"); + ShowMessage(" Change the state of an account.\n"); + ShowMessage(" 'new_state': state is the state of the packet 0x006a + 1.\n"); + ShowMessage(" The possibilities are:\n"); + ShowMessage(" 0 = Account ok\n"); + ShowMessage(" 1 = Unregistered ID\n"); + ShowMessage(" 2 = Incorrect Password\n"); + ShowMessage(" 3 = This ID is expired\n"); + ShowMessage(" 4 = Rejected from Server\n"); + ShowMessage(" 5 = You have been blocked by the GM Team\n"); + ShowMessage(" 6 = Your Game's EXE file is not the latest version\n"); + ShowMessage(" 7 = You are Prohibited to log in until...\n"); + ShowMessage(" 8 = Server is jammed due to over populated\n"); + ShowMessage(" 9 = No MSG\n"); + ShowMessage(" 100 = This ID has been totally erased\n"); + ShowMessage(" all other values are 'No MSG', then use state 9 please.\n"); + ShowMessage(" 'error_message_#7': message of the code error 6\n"); + ShowMessage(" = Your are Prohibited to log in until... (packet 0x006a)\n"); + } else if (strcmp(command, "timeadd") == 0) { + ShowMessage("timeadd \n"); + ShowMessage(" Adds or substracts time from the validity limit of an account.\n"); + ShowMessage(" Modifier is done as follows:\n"); + ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); + ShowMessage(" Modified element:\n"); + ShowMessage(" a or y: year\n"); + ShowMessage(" m: month\n"); + ShowMessage(" j or d: day\n"); + ShowMessage(" h: hour\n"); + ShowMessage(" mn: minute\n"); + ShowMessage(" s: second\n"); + ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ShowMessage("NOTE: You can not modify a unlimited validity limit.\n"); + ShowMessage(" If you want modify it, you want probably create a limited validity limit.\n"); + ShowMessage(" So, at first, you must set the validity limit to a date/time.\n"); + } else if (strcmp(command, "timeadd") == 0) { + ShowMessage("timeset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" Changes the validity limit of an account.\n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ShowMessage("timeset 0\n"); + ShowMessage(" Gives an unlimited validity limit (0 = unlimited).\n"); + } else if (strcmp(command, "unban") == 0) { + ShowMessage("unban/unbanish \n"); + ShowMessage(" Remove the banishment of an account.\n"); + ShowMessage(" This command works like banset 0.\n"); + } else if (strcmp(command, "unblock") == 0) { + ShowMessage("unblock \n"); + ShowMessage(" Set state 0 (Account ok) to an account.\n"); + ShowMessage(" This command works like state 0.\n"); + } else if (strcmp(command, "version") == 0) { + ShowMessage("version\n"); + ShowMessage(" Display the version of the login-server.\n"); + } else if (strcmp(command, "who") == 0) { + ShowMessage("who \n"); + ShowMessage(" Displays complete information of an account.\n"); // quit - } else if (strcmp(command, "quit") == 0 || - strcmp(command, "exit") == 0 || - strcmp(command, "end") == 0) { - ShowMessage("quit/end/exit\n"); - ShowMessage(" End of the program of administration.\n"); + } else if (strcmp(command, "quit") == 0 || + strcmp(command, "exit") == 0 || + strcmp(command, "end") == 0) { + ShowMessage("quit/end/exit\n"); + ShowMessage(" End of the program of administration.\n"); // unknown command - } else { - if (strlen(command) > 0) - ShowMessage("Unknown command [%s] for help. Displaying of all commands.\n", command); - ShowMessage(" aide/help/? -- Display this help\n"); - ShowMessage(" aide/help/? [command] -- Display the help of the command\n"); - ShowMessage(" add -- Create an account with default email\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss -- Change final date of a ban\n"); - ShowMessage(" banadd/ba -- Add or substract time from the final\n"); - ShowMessage(" example: ba apple +1m-2mn1s-2y date of a banishment of an account\n"); - ShowMessage(" banset/bs yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban\n"); - ShowMessage(" banset/bs 0 -- Un-banish an account\n"); - ShowMessage(" block -- Set state 5 (blocked by the GM Team) to an account\n"); - ShowMessage(" check -- Check the validity of a password\n"); - ShowMessage(" create -- Create an account with email\n"); - ShowMessage(" del -- Remove an account\n"); - ShowMessage(" email -- Modify an email of an account\n"); - ShowMessage(" getcount -- Give the number of players online\n"); - ShowMessage(" gm [GM_level] -- Modify the GM level of an account\n"); - ShowMessage(" id -- Give the id of an account\n"); - ShowMessage(" info -- Display all information of an account\n"); - ShowMessage(" kami -- Sends a broadcast message (in yellow)\n"); - ShowMessage(" kamib -- Sends a broadcast message (in blue)\n"); - ShowMessage(" language -- Change the language of displaying.\n"); - ShowMessage(" list/ls [First_id [Last_id]] -- Display a list of accounts\n"); - ShowMessage(" listBan/lsBan [First_id [Last_id] ] -- Display a list of accounts\n"); - ShowMessage(" with state or banished\n"); - ShowMessage(" listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts\n"); - ShowMessage(" listOK/lsOK [First_id [Last_id] ] -- Display a list of accounts\n"); - ShowMessage(" without state and not banished\n"); - ShowMessage(" memo -- Modify the memo of an account\n"); - ShowMessage(" name -- Give the name of an account\n"); - ShowMessage(" passwd -- Change the password of an account\n"); - ShowMessage(" quit/end/exit -- End of the program of administation\n"); - ShowMessage(" reloadGM -- Reload GM configuration file\n"); - ShowMessage(" search -- Seek accounts\n"); + } else { + if (strlen(command) > 0) + ShowMessage("Unknown command [%s] for help. Displaying of all commands.\n", command); + ShowMessage(" aide/help/? -- Display this help\n"); + ShowMessage(" aide/help/? [command] -- Display the help of the command\n"); + ShowMessage(" add -- Create an account with default email\n"); + ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss -- Change final date of a ban\n"); + ShowMessage(" banadd/ba -- Add or substract time from the final\n"); + ShowMessage(" example: ba apple +1m-2mn1s-2y date of a banishment of an account\n"); + ShowMessage(" banset/bs yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban\n"); + ShowMessage(" banset/bs 0 -- Un-banish an account\n"); + ShowMessage(" block -- Set state 5 (blocked by the GM Team) to an account\n"); + ShowMessage(" check -- Check the validity of a password\n"); + ShowMessage(" create -- Create an account with email\n"); + ShowMessage(" del -- Remove an account\n"); + ShowMessage(" email -- Modify an email of an account\n"); + ShowMessage(" getcount -- Give the number of players online\n"); + ShowMessage(" gm [GM_level] -- Modify the GM level of an account\n"); + ShowMessage(" id -- Give the id of an account\n"); + ShowMessage(" info -- Display all information of an account\n"); + ShowMessage(" kami -- Sends a broadcast message (in yellow)\n"); + ShowMessage(" kamib -- Sends a broadcast message (in blue)\n"); + ShowMessage(" list/ls [First_id [Last_id]] -- Display a list of accounts\n"); + ShowMessage(" listBan/lsBan [First_id [Last_id] ] -- Display a list of accounts\n"); + ShowMessage(" with state or banished\n"); + ShowMessage(" listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts\n"); + ShowMessage(" listOK/lsOK [First_id [Last_id] ] -- Display a list of accounts\n"); + ShowMessage(" without state and not banished\n"); + ShowMessage(" memo -- Modify the memo of an account\n"); + ShowMessage(" name -- Give the name of an account\n"); + ShowMessage(" passwd -- Change the password of an account\n"); + ShowMessage(" quit/end/exit -- End of the program of administation\n"); + ShowMessage(" reloadGM -- Reload GM configuration file\n"); + ShowMessage(" search -- Seek accounts\n"); // ShowMessage(" search -e/-r/--expr/--regex -- Seek accounts by regular-expression\n"); - ShowMessage(" sex -- Modify the sex of an account\n"); - ShowMessage(" state -- Change the state\n"); - ShowMessage(" timeadd/ta -- Add or substract time from the\n"); - ShowMessage(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"); - ShowMessage(" timeset/ts yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"); - ShowMessage(" timeset/ts 0 -- Give a unlimited validity limit\n"); - ShowMessage(" unban/unbanish -- Remove the banishment of an account\n"); - ShowMessage(" unblock -- Set state 0 (Account ok) to an account\n"); - ShowMessage(" version -- Gives the version of the login-server\n"); - ShowMessage(" who -- Display all information of an account\n"); - ShowMessage(" who -- Display all information of an account\n"); - ShowMessage(" Note: To use spaces in an account name, type \"\" (or ').\n"); - } + ShowMessage(" sex -- Modify the sex of an account\n"); + ShowMessage(" state -- Change the state\n"); + ShowMessage(" timeadd/ta -- Add or substract time from the\n"); + ShowMessage(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"); + ShowMessage(" timeset/ts yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"); + ShowMessage(" timeset/ts 0 -- Give a unlimited validity limit\n"); + ShowMessage(" unban/unbanish -- Remove the banishment of an account\n"); + ShowMessage(" unblock -- Set state 0 (Account ok) to an account\n"); + ShowMessage(" version -- Gives the version of the login-server\n"); + ShowMessage(" who -- Display all information of an account\n"); + ShowMessage(" who -- Display all information of an account\n"); + ShowMessage(" Note: To use spaces in an account name, type \"\" (or ').\n"); } } @@ -1109,15 +758,9 @@ int addaccount(char* param, int emailflag) if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, sex, password) < 2 && // password can be void sscanf(param, "'%[^']' %s %[^\r\n]", name, sex, password) < 2 && // password can be void sscanf(param, "%s %s %[^\r\n]", name, sex, password) < 2) { // password can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte, un sexe et un mot de passe svp.\n"); - ShowMessage(" add nomtest Male motdepassetest\n"); - ladmin_log("Nombre incorrect de paramètres pour créer un compte (commande 'add').\n"); - } else { - ShowMessage("Please input an account name, a sex and a password.\n"); - ShowMessage(" add testname Male testpass\n"); - ladmin_log("Incomplete parameters to create an account ('add' command).\n"); - } + ShowMessage("Please input an account name, a sex and a password.\n"); + ShowMessage(" add testname Male testpass\n"); + ladmin_log("Incomplete parameters to create an account ('add' command).\n"); return 136; } strcpy(email, "a@a.com"); // default email @@ -1125,15 +768,9 @@ int addaccount(char* param, int emailflag) if (sscanf(param, "\"%[^\"]\" %s %s %[^\r\n]", name, sex, email, password) < 3 && // password can be void sscanf(param, "'%[^']' %s %s %[^\r\n]", name, sex, email, password) < 3 && // password can be void sscanf(param, "%s %s %s %[^\r\n]", name, sex, email, password) < 3) { // password can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte, un sexe et un mot de passe svp.\n"); - ShowMessage(" create nomtest Male mo@mail.com motdepassetest\n"); - ladmin_log("Nombre incorrect de paramètres pour créer un compte (commande 'create').\n"); - } else { - ShowMessage("Please input an account name, a sex and a password.\n"); - ShowMessage(" create testname Male my@mail.com testpass\n"); - ladmin_log("Incomplete parameters to create an account ('create' command).\n"); - } + ShowMessage("Please input an account name, a sex and a password.\n"); + ShowMessage(" create testname Male my@mail.com testpass\n"); + ladmin_log("Incomplete parameters to create an account ('create' command).\n"); return 136; } } @@ -1143,44 +780,24 @@ int addaccount(char* param, int emailflag) sex[0] = TOUPPER(sex[0]); if (strchr("MF", sex[0]) == NULL) { - if (defaultlanguage == 'F') { - ShowMessage("Sexe incorrect [%s]. Entrez M ou F svp.\n", sex); - ladmin_log("Sexe incorrect [%s]. Entrez M ou F svp.\n", sex); - } else { - ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); - ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); - } + ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); + ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); return 103; } if (strlen(email) < 3) { - if (defaultlanguage == 'F') { - ShowMessage("Email trop courte [%s]. Entrez une e-mail valide svp.\n", email); - ladmin_log("Email trop courte [%s]. Entrez une e-mail valide svp.\n", email); - } else { - ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); - } + ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); + ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); return 109; } if (strlen(email) > 39) { - if (defaultlanguage == 'F') { - ShowMessage("Email trop longue [%s]. Entrez une e-mail de 39 caractères maximum svp.\n", email); - ladmin_log("Email trop longue [%s]. Entrez une e-mail de 39 caractères maximum svp.\n", email); - } else { - ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - } + ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); + ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); return 109; } if (e_mail_check(email) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Email incorrecte [%s]. Entrez une e-mail valide svp.\n", email); - ladmin_log("Email incorrecte [%s]. Entrez une e-mail valide svp.\n", email); - } else { - ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); - } + ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); + ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); return 109; } @@ -1191,11 +808,7 @@ int addaccount(char* param, int emailflag) if (verify_password(password) == 0) return 104; - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour créer un compte.\n"); - } else { - ladmin_log("Request to login-server to create an account.\n"); - } + ladmin_log("Request to login-server to create an account.\n"); WFIFOW(login_fd,0) = 0x7930; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1226,19 +839,11 @@ int banaddaccount(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, modif) < 2 && sscanf(param, "'%[^']' %[^\r\n]", name, modif) < 2 && sscanf(param, "%s %[^\r\n]", name, modif) < 2) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un modificateur svp.\n"); - ShowMessage(" banadd nomtest +1m-2mn1s-6y\n"); - ShowMessage(" Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ladmin_log("Nombre incorrect de paramètres pour modifier la fin de ban d'un compte (commande 'banadd').\n"); - } else { - ShowMessage("Please input an account name and a modifier.\n"); - ShowMessage(" : banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("Incomplete parameters to modify the ban date/time of an account ('banadd' command).\n"); - } + ShowMessage("Please input an account name and a modifier.\n"); + ShowMessage(" : banadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ladmin_log("Incomplete parameters to modify the ban date/time of an account ('banadd' command).\n"); return 136; } if (verify_accountname(name) == 0) { @@ -1283,120 +888,61 @@ int banaddaccount(char* param) } } - if (defaultlanguage == 'F') { - ShowMessage(" année: %d\n", year); - ShowMessage(" mois: %d\n", month); - ShowMessage(" jour: %d\n", day); - ShowMessage(" heure: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" seconde: %d\n", second); - } else { - ShowMessage(" year: %d\n", year); - ShowMessage(" month: %d\n", month); - ShowMessage(" day: %d\n", day); - ShowMessage(" hour: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" second: %d\n", second); - } + ShowMessage(" year: %d\n", year); + ShowMessage(" month: %d\n", month); + ShowMessage(" day: %d\n", day); + ShowMessage(" hour: %d\n", hour); + ShowMessage(" minute: %d\n", minute); + ShowMessage(" second: %d\n", second); if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Vous devez entrer un ajustement avec cette commande, svp:\n"); - ShowMessage(" Valeur d'ajustement (-1, 1, +1, etc...)\n"); - ShowMessage(" Element modifié:\n"); - ShowMessage(" a ou y: année\n"); - ShowMessage(" m: mois\n"); - ShowMessage(" j ou d: jour\n"); - ShowMessage(" h: heure\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: seconde\n"); - ShowMessage(" banadd nomtest +1m-2mn1s-6y\n"); - ShowMessage(" Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ladmin_log("Aucun ajustement n'est pas un ajustement (commande 'banadd').\n"); - } else { - ShowMessage("Please give an adjustment with this command:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("No adjustment isn't an adjustment ('banadd' command).\n"); - } + ShowMessage("Please give an adjustment with this command:\n"); + ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); + ShowMessage(" Modified element:\n"); + ShowMessage(" a or y: year\n"); + ShowMessage(" m: month\n"); + ShowMessage(" j or d: day\n"); + ShowMessage(" h: hour\n"); + ShowMessage(" mn: minute\n"); + ShowMessage(" s: second\n"); + ShowMessage(" banadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ladmin_log("No adjustment isn't an adjustment ('banadd' command).\n"); return 137; } if (year > 127 || year < -127) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement d'années correct (de -127 à 127), svp.\n"); - ladmin_log("Ajustement de l'année hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); - ladmin_log("Abnormal adjustment for the year ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); + ladmin_log("Abnormal adjustment for the year ('banadd' command).\n"); return 137; } if (month > 255 || month < -255) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de mois correct (de -255 à 255), svp.\n"); - ladmin_log("Ajustement du mois hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); - ladmin_log("Abnormal adjustment for the month ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); + ladmin_log("Abnormal adjustment for the month ('banadd' command).\n"); return 137; } if (day > 32767 || day < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de jours correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des jours hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the days ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the days ('banadd' command).\n"); return 137; } if (hour > 32767 || hour < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement d'heures correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des heures hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the hours ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the hours ('banadd' command).\n"); return 137; } if (minute > 32767 || minute < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de minutes correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des minutes hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the minutes ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the minutes ('banadd' command).\n"); return 137; } if (second > 32767 || second < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de secondes correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des secondes hors norme (commande 'banadd').\n"); - } else { - ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the seconds ('banadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the seconds ('banadd' command).\n"); return 137; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour modifier la date d'un bannissement.\n"); - } else { - ladmin_log("Request to login-server to modify a ban date/time.\n"); - } + ladmin_log("Request to login-server to modify a ban date/time.\n"); WFIFOW(login_fd,0) = 0x794c; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1435,16 +981,11 @@ int bansetaccountsub(char* name, char* date, char* time) ((sscanf(date, "%d/%d/%d", &year, &month, &day) < 3 && sscanf(date, "%d-%d-%d", &year, &month, &day) < 3 && sscanf(date, "%d.%d.%d", &year, &month, &day) < 3) || - sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez une date et une heure svp (format: aaaa/mm/jj hh:mm:ss).\n"); - ShowMessage("Vous pouvez aussi mettre 0 à la place si vous utilisez la commande 'banset'.\n"); - ladmin_log("Format incorrect pour la date/heure (commande'banset' ou 'ban').\n"); - } else { - ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); - ladmin_log("Invalid format for the date/time ('banset' or 'ban' command).\n"); - } + sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) + { + ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); + ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); + ladmin_log("Invalid format for the date/time ('banset' or 'ban' command).\n"); return 102; } @@ -1458,65 +999,35 @@ int bansetaccountsub(char* name, char* date, char* time) year = year - 1900; } if (month < 1 || month > 12) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un mois correct svp (entre 1 et 12).\n"); - ladmin_log("Mois incorrect pour la date (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); - ladmin_log("Invalid month for the date ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); + ladmin_log("Invalid month for the date ('banset' or 'ban' command).\n"); return 102; } month = month - 1; if (day < 1 || day > 31) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un jour correct svp (entre 1 et 31).\n"); - ladmin_log("Jour incorrect pour la date (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); - ladmin_log("Invalid day for the date ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); + ladmin_log("Invalid day for the date ('banset' or 'ban' command).\n"); return 102; } if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) || (month == 1 && day > 29)) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un jour correct en fonction du mois (%d) svp.\n", month); - ladmin_log("Jour incorrect pour ce mois correspondant (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for a day of this month (%d).\n", month); - ladmin_log("Invalid day for this month ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for a day of this month (%d).\n", month); + ladmin_log("Invalid day for this month ('banset' or 'ban' command).\n"); return 102; } if (hour < 0 || hour > 23) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez une heure correcte svp (entre 0 et 23).\n"); - ladmin_log("Heure incorrecte pour l'heure (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); - ladmin_log("Invalid hour for the time ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); + ladmin_log("Invalid hour for the time ('banset' or 'ban' command).\n"); return 102; } if (minute < 0 || minute > 59) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez des minutes correctes svp (entre 0 et 59).\n"); - ladmin_log("Minute incorrecte pour l'heure (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); - ladmin_log("Invalid minute for the time ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); + ladmin_log("Invalid minute for the time ('banset' or 'ban' command).\n"); return 102; } if (second < 0 || second > 59) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez des secondes correctes svp (entre 0 et 59).\n"); - ladmin_log("Seconde incorrecte pour l'heure (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); - ladmin_log("Invalid second for the time ('banset' or 'ban' command).\n"); - } + ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); + ladmin_log("Invalid second for the time ('banset' or 'ban' command).\n"); return 102; } tmtime->tm_year = year; @@ -1528,26 +1039,15 @@ int bansetaccountsub(char* name, char* date, char* time) tmtime->tm_isdst = -1; // -1: no winter/summer time modification unban_time = mktime(tmtime); if (unban_time == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Date incorrecte.\n"); - ShowMessage("Entrez une date et une heure svp (format: aaaa/mm/jj hh:mm:ss).\n"); - ShowMessage("Vous pouvez aussi mettre 0 à la place si vous utilisez la commande 'banset'.\n"); - ladmin_log("Date incorrecte. (command 'banset' ou 'ban').\n"); - } else { - ShowMessage("Invalid date.\n"); - ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); - ladmin_log("Invalid date. ('banset' or 'ban' command).\n"); - } + ShowMessage("Invalid date.\n"); + ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); + ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); + ladmin_log("Invalid date. ('banset' or 'ban' command).\n"); return 102; } } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour fixer un ban.\n"); - } else { - ladmin_log("Request to login-server to set a ban.\n"); - } + ladmin_log("Request to login-server to set a ban.\n"); WFIFOW(login_fd,0) = 0x794a; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1572,23 +1072,13 @@ int banaccount(char* param) if (sscanf(param, "%s %s \"%[^\"]\"", date, time, name) < 3 && sscanf(param, "%s %s '%[^']'", date, time, name) < 3 && sscanf(param, "%s %s %[^\r\n]", date, time, name) < 3) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte, une date et une heure svp.\n"); - ShowMessage(": banset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = dé-bani)\n"); - ShowMessage(" ban/banish aaaa/mm/jj hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Nombre incorrect de paramètres pour fixer un ban (commande 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); - } + ShowMessage("Please input an account name, a date and a hour.\n"); + ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" banset 0 (0 = un-banished)\n"); + ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); + ShowMessage(" unban/unbanish \n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); return 136; } @@ -1609,23 +1099,13 @@ int bansetaccount(char* param) if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void sscanf(param, "'%[^']' %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void sscanf(param, "%s %s %[^\r\n]", name, date, time) < 2) { // if date = 0, time can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte, une date et une heure svp.\n"); - ShowMessage(": banset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = dé-bani)\n"); - ShowMessage(" ban/banish aaaa/mm/jj hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Nombre incorrect de paramètres pour fixer un ban (commande 'banset' ou 'ban').\n"); - } else { - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); - } + ShowMessage("Please input an account name, a date and a hour.\n"); + ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" banset 0 (0 = un-banished)\n"); + ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); + ShowMessage(" unban/unbanish \n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); return 136; } @@ -1648,24 +1128,15 @@ int unbanaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(": banset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = dé-bani)\n"); - ShowMessage(" ban/banish aaaa/mm/jj hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Nombre incorrect de paramètres pour fixer un ban (commande 'unban').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('unban' command).\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" banset 0 (0 = un-banished)\n"); + ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); + ShowMessage(" unban/unbanish \n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ladmin_log("Incomplete parameters to set a ban ('unban' command).\n"); return 136; } @@ -1687,15 +1158,9 @@ int checkaccount(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, password) < 1 && // password can be void sscanf(param, "'%[^']' %[^\r\n]", name, password) < 1 && // password can be void sscanf(param, "%s %[^\r\n]", name, password) < 1) { // password can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" check testname motdepasse\n"); - ladmin_log("Nombre incorrect de paramètres pour tester le mot d'un passe d'un compte (commande 'check').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" check testname password\n"); - ladmin_log("Incomplete parameters to check the password of an account ('check' command).\n"); - } + ShowMessage("Please input an account name.\n"); + ShowMessage(" check testname password\n"); + ladmin_log("Incomplete parameters to check the password of an account ('check' command).\n"); return 136; } @@ -1710,11 +1175,7 @@ int checkaccount(char* param) if (verify_password(password) == 0) return 131; - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour test un mot de passe.\n"); - } else { - ladmin_log("Request to login-server to check a password.\n"); - } + ladmin_log("Request to login-server to check a password.\n"); WFIFOW(login_fd,0) = 0x793a; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1742,16 +1203,11 @@ int delaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" del nomtestasupprimer\n"); - ladmin_log("Aucun nom donné pour supprimer un compte (commande 'delete').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" del testnametodelete\n"); - ladmin_log("No name given to delete an account ('delete' command).\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(" del testnametodelete\n"); + ladmin_log("No name given to delete an account ('delete' command).\n"); return 136; } @@ -1760,11 +1216,9 @@ int delaccount(char* param) } memset(confirm, '\0', sizeof(confirm)); - while ((confirm[0] != 'o' || defaultlanguage != 'F') && confirm[0] != 'n' && (confirm[0] != 'y' || defaultlanguage == 'F')) { - if (defaultlanguage == 'F') - ShowMessage("\033[1;36m ** Etes-vous vraiment sûr de vouloir SUPPRIMER le compte [$userid]? (o/n) > \033[0m"); - else - ShowMessage("\033[1;36m ** Are you really sure to DELETE account [$userid]? (y/n) > \033[0m"); + while (confirm[0] != 'n' && confirm[0] != 'y') + { + ShowMessage("\033[1;36m ** Are you really sure to DELETE account [$userid]? (y/n) > \033[0m"); fflush(stdout); memset(confirm, '\0', sizeof(confirm)); i = 0; @@ -1773,21 +1227,12 @@ int delaccount(char* param) } if (confirm[0] == 'n') { - if (defaultlanguage == 'F') { - ShowMessage("Suppression annulée.\n"); - ladmin_log("Suppression annulée par l'utilisateur (commande 'delete').\n"); - } else { - ShowMessage("Deletion canceled.\n"); - ladmin_log("Deletion canceled by user ('delete' command).\n"); - } + ShowMessage("Deletion canceled.\n"); + ladmin_log("Deletion canceled by user ('delete' command).\n"); return 121; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour détruire un compte.\n"); - } else { - ladmin_log("Request to login-server to delete an acount.\n"); - } + ladmin_log("Request to login-server to delete an acount.\n"); WFIFOW(login_fd,0) = 0x7932; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1811,15 +1256,9 @@ int changeemail(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, email) < 2 && sscanf(param, "'%[^']' %[^\r\n]", name, email) < 2 && sscanf(param, "%s %[^\r\n]", name, email) < 2) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et une email svp.\n"); - ShowMessage(" email testname nouveauemail\n"); - ladmin_log("Nombre incorrect de paramètres pour changer l'email d'un compte (commande 'email').\n"); - } else { - ShowMessage("Please input an account name and an email.\n"); - ShowMessage(" email testname newemail\n"); - ladmin_log("Incomplete parameters to change the email of an account ('email' command).\n"); - } + ShowMessage("Please input an account name and an email.\n"); + ShowMessage(" email testname newemail\n"); + ladmin_log("Incomplete parameters to change the email of an account ('email' command).\n"); return 136; } @@ -1828,41 +1267,22 @@ int changeemail(char* param) } if (strlen(email) < 3) { - if (defaultlanguage == 'F') { - ShowMessage("Email trop courte [%s]. Entrez une e-mail valide svp.\n", email); - ladmin_log("Email trop courte [%s]. Entrez une e-mail valide svp.\n", email); - } else { - ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); - } + ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); + ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); return 109; } if (strlen(email) > 39) { - if (defaultlanguage == 'F') { - ShowMessage("Email trop longue [%s]. Entrez une e-mail de 39 caractères maximum svp.\n", email); - ladmin_log("Email trop longue [%s]. Entrez une e-mail de 39 caractères maximum svp.\n", email); - } else { - ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - } + ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); + ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); return 109; } if (e_mail_check(email) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Email incorrecte [%s]. Entrez une e-mail valide svp.\n", email); - ladmin_log("Email incorrecte [%s]. Entrez une e-mail valide svp.\n", email); - } else { - ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); - } + ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); + ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); return 109; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer une email.\n"); - } else { - ladmin_log("Request to login-server to change an email.\n"); - } + ladmin_log("Request to login-server to change an email.\n"); WFIFOW(login_fd,0) = 0x7940; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1879,11 +1299,7 @@ int changeemail(char* param) int getlogincount(void) { WFIFOHEAD(login_fd,2); - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir le nombre de joueurs en jeu.\n"); - } else { - ladmin_log("Request to login-server to obtain the # of online players.\n"); - } + ladmin_log("Request to login-server to obtain the # of online players.\n"); WFIFOW(login_fd,0) = 0x7938; WFIFOSET(login_fd,2); @@ -1907,15 +1323,9 @@ int changegmlevel(char* param) if (sscanf(param, "\"%[^\"]\" %d", name, &GM_level) < 1 && sscanf(param, "'%[^']' %d", name, &GM_level) < 1 && sscanf(param, "%s %d", name, &GM_level) < 1) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un niveau de GM svp.\n"); - ShowMessage(" gm nomtest 80\n"); - ladmin_log("Nombre incorrect de paramètres pour changer le Niveau de GM d'un compte (commande 'gm').\n"); - } else { - ShowMessage("Please input an account name and a GM level.\n"); - ShowMessage(" gm testname 80\n"); - ladmin_log("Incomplete parameters to change the GM level of an account ('gm' command).\n"); - } + ShowMessage("Please input an account name and a GM level.\n"); + ShowMessage(" gm testname 80\n"); + ladmin_log("Incomplete parameters to change the GM level of an account ('gm' command).\n"); return 136; } @@ -1924,21 +1334,12 @@ int changegmlevel(char* param) } if (GM_level < 0 || GM_level > 99) { - if (defaultlanguage == 'F') { - ShowMessage("Niveau de GM incorrect [%d]. Entrez une valeur de 0 à 99 svp.\n", GM_level); - ladmin_log("Niveau de GM incorrect [%d]. La valeur peut être de 0 à 99.\n", GM_level); - } else { - ShowMessage("Illegal GM level [%d]. Please input a value from 0 to 99.\n", GM_level); - ladmin_log("Illegal GM level [%d]. The value can be from 0 to 99.\n", GM_level); - } + ShowMessage("Illegal GM level [%d]. Please input a value from 0 to 99.\n", GM_level); + ladmin_log("Illegal GM level [%d]. The value can be from 0 to 99.\n", GM_level); return 103; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer un niveau de GM.\n"); - } else { - ladmin_log("Request to login-server to change a GM level.\n"); - } + ladmin_log("Request to login-server to change a GM level.\n"); WFIFOW(login_fd,0) = 0x793e; memcpy(WFIFOP(login_fd,2), name, 24); @@ -1963,16 +1364,11 @@ int idaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" id nomtest\n"); - ladmin_log("Aucun nom donné pour rechecher l'id d'un compte (commande 'id').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" id testname\n"); - ladmin_log("No name given to search an account id ('id' command).\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(" id testname\n"); + ladmin_log("No name given to search an account id ('id' command).\n"); return 136; } @@ -1980,11 +1376,7 @@ int idaccount(char* param) return 102; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour connaître l'id d'un compte.\n"); - } else { - ladmin_log("Request to login-server to know an account id.\n"); - } + ladmin_log("Request to login-server to know an account id.\n"); WFIFOW(login_fd,0) = 0x7944; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2001,21 +1393,12 @@ int infoaccount(int account_id) { WFIFOHEAD(login_fd,6); if (account_id < 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un id ayant une valeur positive svp.\n"); - ladmin_log("Une valeur négative a été donné pour trouver le compte.\n"); - } else { - ShowMessage("Please input a positive value for the id.\n"); - ladmin_log("Negative value was given to found the account.\n"); - } + ShowMessage("Please input a positive value for the id.\n"); + ladmin_log("Negative value was given to found the account.\n"); return 136; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir le information d'un compte (par l'id).\n"); - } else { - ladmin_log("Request to login-server to obtain information about an account (by its id).\n"); - } + ladmin_log("Request to login-server to obtain information about an account (by its id).\n"); WFIFOW(login_fd,0) = 0x7954; WFIFOL(login_fd,2) = account_id; @@ -2033,23 +1416,13 @@ int sendbroadcast(short type, char* message) int len = strlen(message); WFIFOHEAD(login_fd,9+len); if (len == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un message svp.\n"); - if (type == 0) { - ShowMessage(" kami un message\n"); - } else { - ShowMessage(" kamib un message\n"); - } - ladmin_log("Le message est vide (commande 'kami(b)').\n"); + ShowMessage("Please input a message.\n"); + if (type == 0) { + ShowMessage(" kami a message\n"); } else { - ShowMessage("Please input a message.\n"); - if (type == 0) { - ShowMessage(" kami a message\n"); - } else { - ShowMessage(" kamib a message\n"); - } - ladmin_log("The message is void ('kami(b)' command).\n"); + ShowMessage(" kamib a message\n"); } + ladmin_log("The message is void ('kami(b)' command).\n"); return 136; } len++; //+'\0' @@ -2063,49 +1436,6 @@ int sendbroadcast(short type, char* message) return 0; } -//-------------------------------------------- -// Sub-function: Change language of displaying -//-------------------------------------------- -int changelanguage(char* language) -{ - if (strlen(language) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez une langue svp.\n"); - ShowMessage(" language english\n"); - ShowMessage(" language français\n"); - ladmin_log("La langue est vide (commande 'language').\n"); - } else { - ShowMessage("Please input a language.\n"); - ShowMessage(" language english\n"); - ShowMessage(" language français\n"); - ladmin_log("The language is void ('language' command).\n"); - } - return 136; - } - - language[0] = TOUPPER(language[0]); - if (language[0] == 'F' || language[0] == 'E') { - defaultlanguage = language[0]; - if (defaultlanguage == 'F') { - ShowMessage("Changement de la langue d'affichage en Français.\n"); - ladmin_log("Changement de la langue d'affichage en Français.\n"); - } else { - ShowMessage("Displaying language changed to English.\n"); - ladmin_log("Displaying language changed to English.\n"); - } - } else { - if (defaultlanguage == 'F') { - ShowMessage("Langue non paramétrée (langues possibles: 'Français' ou 'English').\n"); - ladmin_log("Langue non paramétrée (Français ou English nécessaire).\n"); - } else { - ShowMessage("Undefined language (possible languages: Français or English).\n"); - ladmin_log("Undefined language (must be Français or English).\n"); - } - } - - return 0; -} - //-------------------------------------------------------- // Sub-function: Asking to Displaying of the accounts list //-------------------------------------------------------- @@ -2148,11 +1478,7 @@ int listaccount(char* param, int type) } } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir la liste des comptes de %d à %d.\n", list_first, list_last); - } else { - ladmin_log("Request to login-server to obtain the list of accounts from %d to %d.\n", list_first, list_last); - } + ladmin_log("Request to login-server to obtain the list of accounts from %d to %d.\n", list_first, list_last); WFIFOW(login_fd,0) = 0x7920; WFIFOL(login_fd,2) = list_first; @@ -2161,11 +1487,7 @@ int listaccount(char* param, int type) bytes_to_read = 1; // 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 - if (defaultlanguage == 'F') { - ShowMessage(" id_compte GM nom_utilisateur sexe count statut\n"); - } else { - ShowMessage("account_id GM user_name sex count state\n"); - } + ShowMessage("account_id GM user_name sex count state\n"); ShowMessage("-------------------------------------------------------------------------------\n"); list_count = 0; @@ -2186,15 +1508,9 @@ int changememo(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, memo) < 1 && // memo can be void sscanf(param, "'%[^']' %[^\r\n]", name, memo) < 1 && // memo can be void sscanf(param, "%s %[^\r\n]", name, memo) < 1) { // memo can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un mémo svp.\n"); - ShowMessage(" memo nomtest nouveau memo\n"); - ladmin_log("Nombre incorrect de paramètres pour changer le mémo d'un compte (commande 'email').\n"); - } else { - ShowMessage("Please input an account name and a memo.\n"); - ShowMessage(" memo testname new memo\n"); - ladmin_log("Incomplete parameters to change the memo of an account ('email' command).\n"); - } + ShowMessage("Please input an account name and a memo.\n"); + ShowMessage(" memo testname new memo\n"); + ladmin_log("Incomplete parameters to change the memo of an account ('email' command).\n"); return 136; } @@ -2203,23 +1519,13 @@ int changememo(char* param) } if (strlen(memo) > 254) { - if (defaultlanguage == 'F') { - ShowMessage("Mémo trop long (%lu caractères).\n", (unsigned long)strlen(memo)); - ShowMessage("Entrez un mémo de 254 caractères maximum svp.\n"); - ladmin_log("Mémo trop long (%d caractères). Entrez un mémo de 254 caractères maximum svp.\n", strlen(memo)); - } else { - ShowMessage("Memo is too long (%lu characters).\n", (unsigned long)strlen(memo)); - ShowMessage("Please input a memo of 254 bytes at the maximum.\n"); - ladmin_log("Email is too long (%d characters). Please input a memo of 254 bytes at the maximum.\n", strlen(memo)); - } + ShowMessage("Memo is too long (%lu characters).\n", (unsigned long)strlen(memo)); + ShowMessage("Please input a memo of 254 bytes at the maximum.\n"); + ladmin_log("Email is too long (%d characters). Please input a memo of 254 bytes at the maximum.\n", strlen(memo)); return 102; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer un mémo.\n"); - } else { - ladmin_log("Request to login-server to change a memo.\n"); - } + ladmin_log("Request to login-server to change a memo.\n"); WFIFOW(login_fd,0) = 0x7942; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2239,20 +1545,12 @@ int nameaccount(int id) { WFIFOHEAD(login_fd,6); if (id < 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un id ayant une valeur positive svp.\n"); - ladmin_log("Id négatif donné pour rechecher le nom d'un compte (commande 'name').\n"); - } else { - ShowMessage("Please input a positive value for the id.\n"); - ladmin_log("Negativ id given to search an account name ('name' command).\n"); - } + ShowMessage("Please input a positive value for the id.\n"); + ladmin_log("Negativ id given to search an account name ('name' command).\n"); return 136; } - if (defaultlanguage == 'F') - ladmin_log("Envoi d'un requête au serveur de logins pour connaître le nom d'un compte.\n"); - else - ladmin_log("Request to login-server to know an account name.\n"); + ladmin_log("Request to login-server to know an account name.\n"); WFIFOW(login_fd,0) = 0x7946; WFIFOL(login_fd,2) = id; @@ -2277,15 +1575,9 @@ int changepasswd(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, password) < 1 && sscanf(param, "'%[^']' %[^\r\n]", name, password) < 1 && sscanf(param, "%s %[^\r\n]", name, password) < 1) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" passwd nomtest nouveaumotdepasse\n"); - ladmin_log("Nombre incorrect de paramètres pour changer le mot d'un passe d'un compte (commande 'password').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" passwd testname newpassword\n"); - ladmin_log("Incomplete parameters to change the password of an account ('password' command).\n"); - } + ShowMessage("Please input an account name.\n"); + ShowMessage(" passwd testname newpassword\n"); + ladmin_log("Incomplete parameters to change the password of an account ('password' command).\n"); return 136; } @@ -2300,11 +1592,7 @@ int changepasswd(char* param) if (verify_password(password) == 0) return 131; - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer un mot de passe.\n"); - } else { - ladmin_log("Request to login-server to change a password.\n"); - } + ladmin_log("Request to login-server to change a password.\n"); WFIFOW(login_fd,0) = 0x7934; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2326,15 +1614,9 @@ int reloadGM(void) WFIFOSET(login_fd,2); bytes_to_read = 0; - if (defaultlanguage == 'F') { - ladmin_log("Demande de recharger le fichier de configuration des GM envoyée.\n"); - ShowMessage("Demande de recharger le fichier de configuration des GM envoyée.\n"); - ShowMessage("Vérifiez les comptes GM actuels (après rechargement):\n"); - } else { - ladmin_log("Request to reload the GM configuration file sended.\n"); - ShowMessage("Request to reload the GM configuration file sended.\n"); - ShowMessage("Check the actual GM accounts (after reloading):\n"); - } + ladmin_log("Request to reload the GM configuration file sended.\n"); + ShowMessage("Request to reload the GM configuration file sended.\n"); + ShowMessage("Check the actual GM accounts (after reloading):\n"); listaccount(parameters, 1); // 1: to list only GM return 180; @@ -2354,15 +1636,9 @@ int changesex(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, sex) < 2 && sscanf(param, "'%[^']' %[^\r\n]", name, sex) < 2 && sscanf(param, "%s %[^\r\n]", name, sex) < 2) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un sexe svp.\n"); - ShowMessage(" sex nomtest Male\n"); - ladmin_log("Nombre incorrect de paramètres pour changer le sexe d'un compte (commande 'sex').\n"); - } else { - ShowMessage("Please input an account name and a sex.\n"); - ShowMessage(" sex testname Male\n"); - ladmin_log("Incomplete parameters to change the sex of an account ('sex' command).\n"); - } + ShowMessage("Please input an account name and a sex.\n"); + ShowMessage(" sex testname Male\n"); + ladmin_log("Incomplete parameters to change the sex of an account ('sex' command).\n"); return 136; } @@ -2372,21 +1648,12 @@ int changesex(char* param) sex[0] = TOUPPER(sex[0]); if (strchr("MF", sex[0]) == NULL) { - if (defaultlanguage == 'F') { - ShowMessage("Sexe incorrect [%s]. Entrez M ou F svp.\n", sex); - ladmin_log("Sexe incorrect [%s]. Entrez M ou F svp.\n", sex); - } else { - ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); - ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); - } + ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); + ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); return 103; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer un sexe.\n"); - } else { - ladmin_log("Request to login-server to change a sex.\n"); - } + ladmin_log("Request to login-server to change a sex.\n"); WFIFOW(login_fd,0) = 0x793c; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2410,31 +1677,18 @@ int changestatesub(char* name, int state, char* error_message7) strncpy(error_message, error_message7, sizeof(error_message)-1); if ((state < 0 || state > 9) && state != 100) { // Valid values: 0: ok, or value of the 0x006a packet + 1 - if (defaultlanguage == 'F') { - ShowMessage("Entrez une des statuts suivantes svp:\n"); - ShowMessage(" 0 = Compte ok 6 = Your Game's EXE file is not the latest version\n"); - } else { - ShowMessage("Please input one of these states:\n"); - ShowMessage(" 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"); - } + ShowMessage("Please input one of these states:\n"); + ShowMessage(" 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"); ShowMessage(" 1 = Unregistered ID 7 = You are Prohibited to log in until + message\n"); ShowMessage(" 2 = Incorrect Password 8 = Server is jammed due to over populated\n"); ShowMessage(" 3 = This ID is expired 9 = No MSG\n"); ShowMessage(" 4 = Rejected from Server 100 = This ID has been totally erased\n"); ShowMessage(" 5 = You have been blocked by the GM Team\n"); - if (defaultlanguage == 'F') { - ShowMessage(" state nomtest 5\n"); - ShowMessage(" state nomtest 7 fin de votre ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Valeur incorrecte pour le statut d'un compte (commande 'state', 'block' ou 'unblock').\n"); - } else { - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Invalid value for the state of an account ('state', 'block' or 'unblock' command).\n"); - } + ShowMessage(" state testname 5\n"); + ShowMessage(" state testname 7 end of your ban\n"); + ShowMessage(" block \n"); + ShowMessage(" unblock \n"); + ladmin_log("Invalid value for the state of an account ('state', 'block' or 'unblock' command).\n"); return 151; } @@ -2446,32 +1700,18 @@ int changestatesub(char* name, int state, char* error_message7) strcpy(error_message, "-"); } else { if (strlen(error_message) < 1) { - if (defaultlanguage == 'F') { - ShowMessage("Message d'erreur trop court. Entrez un message de 1-19 caractères.\n"); - ladmin_log("Message d'erreur trop court. Entrez un message de 1-19 caractères.\n"); - } else { - ShowMessage("Error message is too short. Please input a message of 1-19 bytes.\n"); - ladmin_log("Error message is too short. Please input a message of 1-19 bytes.\n"); - } + ShowMessage("Error message is too short. Please input a message of 1-19 bytes.\n"); + ladmin_log("Error message is too short. Please input a message of 1-19 bytes.\n"); return 102; } if (strlen(error_message) > 19) { - if (defaultlanguage == 'F') { - ShowMessage("Message d'erreur trop long. Entrez un message de 1-19 caractères.\n"); - ladmin_log("Message d'erreur trop long. Entrez un message de 1-19 caractères.\n"); - } else { - ShowMessage("Error message is too long. Please input a message of 1-19 bytes.\n"); - ladmin_log("Error message is too long. Please input a message of 1-19 bytes.\n"); - } + ShowMessage("Error message is too long. Please input a message of 1-19 bytes.\n"); + ladmin_log("Error message is too long. Please input a message of 1-19 bytes.\n"); return 102; } } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour changer un statut.\n"); - } else { - ladmin_log("Request to login-server to change a state.\n"); - } + ladmin_log("Request to login-server to change a state.\n"); WFIFOW(login_fd,0) = 0x7936; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2497,21 +1737,12 @@ int changestate(char* param) if (sscanf(param, "\"%[^\"]\" %d %[^\r\n]", name, &state, error_message) < 2 && sscanf(param, "'%[^']' %d %[^\r\n]", name, &state, error_message) < 2 && sscanf(param, "%s %d %[^\r\n]", name, &state, error_message) < 2) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un statut svp.\n"); - ShowMessage(" state nomtest 5\n"); - ShowMessage(" state nomtest 7 fin de votre ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Nombre incorrect de paramètres pour changer le statut d'un compte (commande 'state').\n"); - } else { - ShowMessage("Please input an account name and a state.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('state' command).\n"); - } + ShowMessage("Please input an account name and a state.\n"); + ShowMessage(" state testname 5\n"); + ShowMessage(" state testname 7 end of your ban\n"); + ShowMessage(" block \n"); + ShowMessage(" unblock \n"); + ladmin_log("Incomplete parameters to change the state of an account ('state' command).\n"); return 136; } @@ -2531,22 +1762,14 @@ int unblockaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" state nomtest 5\n"); - ShowMessage(" state nomtest 7 fin de votre ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Nombre incorrect de paramètres pour changer le statut d'un compte (commande 'unblock').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('unblock' command).\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(" state testname 5\n"); + ShowMessage(" state testname 7 end of your ban\n"); + ShowMessage(" block \n"); + ShowMessage(" unblock \n"); + ladmin_log("Incomplete parameters to change the state of an account ('unblock' command).\n"); return 136; } @@ -2566,22 +1789,14 @@ int blockaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" state nomtest 5\n"); - ShowMessage(" state nomtest 7 fin de votre ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Nombre incorrect de paramètres pour changer le statut d'un compte (commande 'block').\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('block' command).\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(" state testname 5\n"); + ShowMessage(" state testname 7 end of your ban\n"); + ShowMessage(" block \n"); + ShowMessage(" unblock \n"); + ladmin_log("Incomplete parameters to change the state of an account ('block' command).\n"); return 136; } @@ -2605,20 +1820,13 @@ int timeaddaccount(char* param) if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, modif) < 2 && sscanf(param, "'%[^']' %[^\r\n]", name, modif) < 2 && - sscanf(param, "%s %[^\r\n]", name, modif) < 2) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte et un modificateur svp.\n"); - ShowMessage(" timeadd nomtest +1m-2mn1s-6y\n"); - ShowMessage(" Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ladmin_log("Nombre incorrect de paramètres pour modifier une date limite d'utilisation (commande 'timeadd').\n"); - } else { - ShowMessage("Please input an account name and a modifier.\n"); - ShowMessage(" : timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("Incomplete parameters to modify a limit time ('timeadd' command).\n"); - } + sscanf(param, "%s %[^\r\n]", name, modif) < 2) + { + ShowMessage("Please input an account name and a modifier.\n"); + ShowMessage(" : timeadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ladmin_log("Incomplete parameters to modify a limit time ('timeadd' command).\n"); return 136; } if (verify_accountname(name) == 0) { @@ -2663,120 +1871,61 @@ int timeaddaccount(char* param) } } - if (defaultlanguage == 'F') { - ShowMessage(" année: %d\n", year); - ShowMessage(" mois: %d\n", month); - ShowMessage(" jour: %d\n", day); - ShowMessage(" heure: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" seconde: %d\n", second); - } else { - ShowMessage(" year: %d\n", year); - ShowMessage(" month: %d\n", month); - ShowMessage(" day: %d\n", day); - ShowMessage(" hour: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" second: %d\n", second); - } + ShowMessage(" year: %d\n", year); + ShowMessage(" month: %d\n", month); + ShowMessage(" day: %d\n", day); + ShowMessage(" hour: %d\n", hour); + ShowMessage(" minute: %d\n", minute); + ShowMessage(" second: %d\n", second); if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Vous devez entrer un ajustement avec cette commande, svp:\n"); - ShowMessage(" Valeur d'ajustement (-1, 1, +1, etc...)\n"); - ShowMessage(" Elément modifié:\n"); - ShowMessage(" a ou y: année\n"); - ShowMessage(" m: mois\n"); - ShowMessage(" j ou d: jour\n"); - ShowMessage(" h: heure\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: seconde\n"); - ShowMessage(" timeadd nomtest +1m-2mn1s-6y\n"); - ShowMessage(" Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"); - ShowMessage(" et 6 ans dans le même temps.\n"); - ladmin_log("Aucun ajustement n'est pas un ajustement (commande 'timeadd').\n"); - } else { - ShowMessage("Please give an adjustment with this command:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("No adjustment isn't an adjustment ('timeadd' command).\n"); - } + ShowMessage("Please give an adjustment with this command:\n"); + ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); + ShowMessage(" Modified element:\n"); + ShowMessage(" a or y: year\n"); + ShowMessage(" m: month\n"); + ShowMessage(" j or d: day\n"); + ShowMessage(" h: hour\n"); + ShowMessage(" mn: minute\n"); + ShowMessage(" s: second\n"); + ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); + ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); + ShowMessage(" and 6 years at the same time.\n"); + ladmin_log("No adjustment isn't an adjustment ('timeadd' command).\n"); return 137; } if (year > 127 || year < -127) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement d'années correct (de -127 à 127), svp.\n"); - ladmin_log("Ajustement de l'année hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); - ladmin_log("Abnormal adjustment for the year ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); + ladmin_log("Abnormal adjustment for the year ('timeadd' command).\n"); return 137; } if (month > 255 || month < -255) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de mois correct (de -255 à 255), svp.\n"); - ladmin_log("Ajustement du mois hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); - ladmin_log("Abnormal adjustment for the month ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); + ladmin_log("Abnormal adjustment for the month ('timeadd' command).\n"); return 137; } if (day > 32767 || day < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de jours correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des jours hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the days ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the days ('timeadd' command).\n"); return 137; } if (hour > 32767 || hour < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement d'heures correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des heures hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the hours ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the hours ('timeadd' command).\n"); return 137; } if (minute > 32767 || minute < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de minutes correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des minutes hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the minutes ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the minutes ('timeadd' command).\n"); return 137; } if (second > 32767 || second < -32767) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un ajustement de secondes correct (de -32767 à 32767), svp.\n"); - ladmin_log("Ajustement des secondes hors norme ('timeadd' command).\n"); - } else { - ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the seconds ('timeadd' command).\n"); - } + ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); + ladmin_log("Abnormal adjustment for the seconds ('timeadd' command).\n"); return 137; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour modifier une date limite d'utilisation.\n"); - } else { - ladmin_log("Request to login-server to modify a time limit.\n"); - } + ladmin_log("Request to login-server to modify a time limit.\n"); WFIFOW(login_fd,0) = 0x7950; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2813,19 +1962,11 @@ int timesetaccount(char* param) if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void sscanf(param, "'%[^']' %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void sscanf(param, "%s %s %[^\r\n]", name, date, time) < 2) { // if date = 0, time can be void - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte, une date et une heure svp.\n"); - ShowMessage(": timeset aaaa/mm/jj [hh:mm:ss]\n"); - ShowMessage(" timeset 0 (0 = illimité)\n"); - ShowMessage(" Heure par défaut [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Nombre incorrect de paramètres pour fixer une date limite d'utilisation (commande 'timeset').\n"); - } else { - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": timeset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" timeset 0 (0 = unlimited)\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a limit time ('timeset' command).\n"); - } + ShowMessage("Please input an account name, a date and a hour.\n"); + ShowMessage(": timeset yyyy/mm/dd [hh:mm:ss]\n"); + ShowMessage(" timeset 0 (0 = unlimited)\n"); + ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); + ladmin_log("Incomplete parameters to set a limit time ('timeset' command).\n"); return 136; } if (verify_accountname(name) == 0) { @@ -2840,14 +1981,10 @@ int timesetaccount(char* param) sscanf(date, "%d-%d-%d", &year, &month, &day) < 3 && sscanf(date, "%d.%d.%d", &year, &month, &day) < 3 && sscanf(date, "%d'%d'%d", &year, &month, &day) < 3) || - sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"); - ladmin_log("Format incorrect pour la date/heure ('timeset' command).\n"); - } else { - ShowMessage("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - ladmin_log("Invalid format for the date/time ('timeset' command).\n"); - } + sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) + { + ShowMessage("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); + ladmin_log("Invalid format for the date/time ('timeset' command).\n"); return 102; } @@ -2861,65 +1998,35 @@ int timesetaccount(char* param) year = year - 1900; } if (month < 1 || month > 12) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un mois correct svp (entre 1 et 12).\n"); - ladmin_log("Mois incorrect pour la date ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); - ladmin_log("Invalid month for the date ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); + ladmin_log("Invalid month for the date ('timeset' command).\n"); return 102; } month = month - 1; if (day < 1 || day > 31) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un jour correct svp (entre 1 et 31).\n"); - ladmin_log("Jour incorrect pour la date ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); - ladmin_log("Invalid day for the date ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); + ladmin_log("Invalid day for the date ('timeset' command).\n"); return 102; } if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) || (month == 1 && day > 29)) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un jour correct en fonction du mois (%d) svp.\n", month); - ladmin_log("Jour incorrect pour ce mois correspondant ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for a day of this month (%d).\n", month); - ladmin_log("Invalid day for this month ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for a day of this month (%d).\n", month); + ladmin_log("Invalid day for this month ('timeset' command).\n"); return 102; } if (hour < 0 || hour > 23) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez une heure correcte svp (entre 0 et 23).\n"); - ladmin_log("Heure incorrecte pour l'heure ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); - ladmin_log("Invalid hour for the time ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); + ladmin_log("Invalid hour for the time ('timeset' command).\n"); return 102; } if (minute < 0 || minute > 59) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez des minutes correctes svp (entre 0 et 59).\n"); - ladmin_log("Minute incorrecte pour l'heure ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); - ladmin_log("Invalid minute for the time ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); + ladmin_log("Invalid minute for the time ('timeset' command).\n"); return 102; } if (second < 0 || second > 59) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez des secondes correctes svp (entre 0 et 59).\n"); - ladmin_log("Seconde incorrecte pour l'heure ('timeset' command).\n"); - } else { - ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); - ladmin_log("Invalid second for the time ('timeset' command).\n"); - } + ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); + ladmin_log("Invalid second for the time ('timeset' command).\n"); return 102; } tmtime->tm_year = year; @@ -2931,24 +2038,14 @@ int timesetaccount(char* param) tmtime->tm_isdst = -1; // -1: no winter/summer time modification expiration_time = mktime(tmtime); if (expiration_time == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Date incorrecte.\n"); - ShowMessage("Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"); - ladmin_log("Date incorrecte. ('timeset' command).\n"); - } else { - ShowMessage("Invalid date.\n"); - ShowMessage("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - ladmin_log("Invalid date. ('timeset' command).\n"); - } + ShowMessage("Invalid date.\n"); + ShowMessage("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); + ladmin_log("Invalid date. ('timeset' command).\n"); return 102; } } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour fixer une date limite d'utilisation.\n"); - } else { - ladmin_log("Request to login-server to set a time limit.\n"); - } + ladmin_log("Request to login-server to set a time limit.\n"); WFIFOW(login_fd,0) = 0x7948; memcpy(WFIFOP(login_fd,2), name, 24); @@ -2973,27 +2070,18 @@ int whoaccount(char* param) (sscanf(param, "\"%[^\"]\"", name) < 1 && sscanf(param, "'%[^']'", name) < 1 && sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Entrez un nom de compte svp.\n"); - ShowMessage(" who nomtest\n"); - ladmin_log("Aucun nom n'a été donné pour trouver le compte.\n"); - } else { - ShowMessage("Please input an account name.\n"); - ShowMessage(" who testname\n"); - ladmin_log("No name was given to found the account.\n"); - } + strlen(name) == 0) + { + ShowMessage("Please input an account name.\n"); + ShowMessage(" who testname\n"); + ladmin_log("No name was given to found the account.\n"); return 136; } if (verify_accountname(name) == 0) { return 102; } - if (defaultlanguage == 'F') { - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir le information d'un compte (par le nom).\n"); - } else { - ladmin_log("Request to login-server to obtain information about an account (by its name).\n"); - } + ladmin_log("Request to login-server to obtain information about an account (by its name).\n"); WFIFOW(login_fd,0) = 0x7952; memcpy(WFIFOP(login_fd,2), name, 24); @@ -3009,10 +2097,7 @@ int whoaccount(char* param) int checkloginversion(void) { WFIFOHEAD(login_fd,2); - if (defaultlanguage == 'F') - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir sa version.\n"); - else - ladmin_log("Request to login-server to obtain its version.\n"); + ladmin_log("Request to login-server to obtain its version.\n"); WFIFOW(login_fd,0) = 0x7530; WFIFOSET(login_fd,2); @@ -3042,10 +2127,7 @@ int prompt(void) // \033[0m : reset color parameter // \033[1m : use bold for font ShowMessage("\n"); - if (defaultlanguage == 'F') - ShowMessage("\033[32mPour afficher les commandes, tapez 'Entrée'.\033[0m\n"); - else - ShowMessage("\033[32mTo list the commands, type 'enter'.\033[0m\n"); + ShowMessage("\033[32mTo list the commands, type 'enter'.\033[0m\n"); ShowMessage("\033[0;36mLadmin-> \033[0m"); ShowMessage("\033[1m"); fflush(stdout); @@ -3107,38 +2189,23 @@ int prompt(void) command[i] = TOLOWER(command[i]); if (command[0] == '?' || strlen(command) == 0) { - if (defaultlanguage == 'F') { - strcpy(buf, "aide"); - strcpy(command, "aide"); - } else { - strcpy(buf, "help"); - strcpy(command, "help"); - } + strcpy(buf, "help"); + strcpy(command, "help"); } // Analyse of the command check_command(command); // give complete name to the command if (strlen(parameters) == 0) { - if (defaultlanguage == 'F') { - ladmin_log("Commande: '%s' (sans paramètre)\n", command, parameters); - } else { - ladmin_log("Command: '%s' (without parameters)\n", command, parameters); - } + ladmin_log("Command: '%s' (without parameters)\n", command, parameters); } else { - if (defaultlanguage == 'F') { - ladmin_log("Commande: '%s', paramètres: '%s'\n", command, parameters); - } else { - ladmin_log("Command: '%s', parameters: '%s'\n", command, parameters); - } + ladmin_log("Command: '%s', parameters: '%s'\n", command, parameters); } // Analyse of the command // help - if (strcmp(command, "aide") == 0) { - display_help(parameters, 1); // 1: french - } else if (strcmp(command, "help") == 0 ) { - display_help(parameters, 0); // 0: english + if (strcmp(command, "help") == 0 ) { + display_help(parameters); // general commands } else if (strcmp(command, "add") == 0) { addaccount(parameters, 0); // 0: no email @@ -3170,8 +2237,6 @@ int prompt(void) sendbroadcast(0, parameters); // flag for normal } else if (strcmp(command, "kamib") == 0) { sendbroadcast(0x10, parameters); // flag for blue - } else if (strcmp(command, "language") == 0) { - changelanguage(parameters); } else if (strcmp(command, "list") == 0) { listaccount(parameters, 0); // 0: to list all } else if (strcmp(command, "listban") == 0) { @@ -3210,21 +2275,12 @@ int prompt(void) } else if (strcmp(command, "quit") == 0 || strcmp(command, "exit") == 0 || strcmp(command, "end") == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Au revoir.\n"); - } else { - ShowMessage("Bye.\n"); - } + ShowMessage("Bye.\n"); exit(EXIT_SUCCESS); // unknown command } else { - if (defaultlanguage == 'F') { - ShowMessage("Commande inconnue [%s].\n", buf); - ladmin_log("Commande inconnue [%s].\n", buf); - } else { - ShowMessage("Unknown command [%s].\n", buf); - ladmin_log("Unknown command [%s].\n", buf); - } + ShowMessage("Unknown command [%s].\n", buf); + ladmin_log("Unknown command [%s].\n", buf); } } @@ -3240,13 +2296,8 @@ int parse_fromlogin(int fd) int id; RFIFOHEAD(fd); if (session[fd]->flag.eof) { - if (defaultlanguage == 'F') { - ShowMessage("Impossible de se connecter au serveur de login [%s:%d] !\n", loginserverip, loginserverport); - ladmin_log("Impossible de se connecter au serveur de login [%s:%d] !\n", loginserverip, loginserverport); - } else { - ShowMessage("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); - ladmin_log("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); - } + ShowMessage("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); + ladmin_log("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); do_close(fd); exit(EXIT_FAILURE); } @@ -3260,34 +2311,19 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 3) return 0; if (RFIFOB(fd,2) != 0) { - if (defaultlanguage == 'F') { - ShowMessage("Erreur de login:\n"); - ShowMessage(" - mot de passe incorrect,\n"); - ShowMessage(" - système d'administration non activé, ou\n"); - ShowMessage(" - IP non autorisée.\n"); - ladmin_log("Erreur de login: mot de passe incorrect, système d'administration non activé, ou IP non autorisée.\n"); - } else { - ShowMessage("Error at login:\n"); - ShowMessage(" - incorrect password,\n"); - ShowMessage(" - administration system not activated, or\n"); - ShowMessage(" - unauthorised IP.\n"); - ladmin_log("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n"); - } + ShowMessage("Error at login:\n"); + ShowMessage(" - incorrect password,\n"); + ShowMessage(" - administration system not activated, or\n"); + ShowMessage(" - unauthorised IP.\n"); + ladmin_log("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n"); set_eof(fd); //bytes_to_read = 1; // not stop at prompt return 0; } else { - if (defaultlanguage == 'F') { - ShowMessage("Connexion établie.\n"); - ladmin_log("Connexion établie.\n"); - ShowMessage("Lecture de la version du serveur de login...\n"); - ladmin_log("Lecture de la version du serveur de login...\n"); - } else { - ShowMessage("Established connection.\n"); - ladmin_log("Established connection.\n"); - ShowMessage("Reading of the version of the login-server...\n"); - ladmin_log("Reading of the version of the login-server...\n"); - } + ShowMessage("Established connection.\n"); + ladmin_log("Established connection.\n"); + ShowMessage("Reading of the version of the login-server...\n"); + ladmin_log("Reading of the version of the login-server...\n"); //bytes_to_read = 1; // unchanged checkloginversion(); } @@ -3312,17 +2348,10 @@ int parse_fromlogin(int fd) WFIFOW(login_fd,2) = passenc; // Encrypted type memcpy(WFIFOP(login_fd,4), md5bin, 16); WFIFOSET(login_fd,20); - if (defaultlanguage == 'F') { - ShowMessage("Réception de la clef MD5.\n"); - ladmin_log("Réception de la clef MD5.\n"); - ShowMessage("Envoi du mot de passe crypté...\n"); - ladmin_log("Envoi du mot de passe crypté...\n"); - } else { - ShowMessage("Receiving of the MD5 key.\n"); - ladmin_log("Receiving of the MD5 key.\n"); - ShowMessage("Sending of the encrypted password...\n"); - ladmin_log("Sending of the encrypted password...\n"); - } + ShowMessage("Receiving of the MD5 key.\n"); + ladmin_log("Receiving of the MD5 key.\n"); + ShowMessage("Sending of the encrypted password...\n"); + ladmin_log("Sending of the encrypted password...\n"); } bytes_to_read = 1; RFIFOSKIP(fd,RFIFOW(fd,2)); @@ -3351,31 +2380,18 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; if (RFIFOW(fd,2) < 5) { - if (defaultlanguage == 'F') { - ladmin_log(" Réception d'une liste des comptes vide.\n"); - if (list_count == 0) - ShowMessage("Aucun compte trouvé.\n"); - else if (list_count == 1) - ShowMessage("1 compte trouvé.\n"); - else - ShowMessage("%d comptes trouvés.\n", list_count); - } else { - ladmin_log(" Receiving of a void accounts list.\n"); - if (list_count == 0) - ShowMessage("No account found.\n"); - else if (list_count == 1) - ShowMessage("1 account found.\n"); - else - ShowMessage("%d accounts found.\n", list_count); - } + ladmin_log(" Receiving of a void accounts list.\n"); + if (list_count == 0) + ShowMessage("No account found.\n"); + else if (list_count == 1) + ShowMessage("1 account found.\n"); + else + ShowMessage("%d accounts found.\n", list_count); bytes_to_read = 0; } else { int i; WFIFOHEAD(login_fd,10); - if (defaultlanguage == 'F') - ladmin_log(" Réception d'une liste des comptes.\n"); - else - ladmin_log(" Receiving of a accounts list.\n"); + ladmin_log(" Receiving of a accounts list.\n"); for(i = 4; i < RFIFOW(fd,2); i += 38) { int j; char userid[24]; @@ -3398,28 +2414,16 @@ int parse_fromlogin(int fd) else ShowMessage("%2d ", (int)RFIFOB(fd,i+4)); ShowMessage("%-24s", userid); - if (defaultlanguage == 'F') { - if (RFIFOB(fd,i+29) == 0) - ShowMessage("%-5s ", "Femme"); - else if (RFIFOB(fd,i+29) == 1) - ShowMessage("%-5s ", "Male"); - else - ShowMessage("%-5s ", "Servr"); - } else { - if (RFIFOB(fd,i+29) == 0) - ShowMessage("%-5s ", "Femal"); - else if (RFIFOB(fd,i+29) == 1) - ShowMessage("%-5s ", "Male"); - else - ShowMessage("%-5s ", "Servr"); - } + if (RFIFOB(fd,i+29) == 0) + ShowMessage("%-5s ", "Femal"); + else if (RFIFOB(fd,i+29) == 1) + ShowMessage("%-5s ", "Male"); + else + ShowMessage("%-5s ", "Servr"); ShowMessage("%6d ", (int)RFIFOL(fd,i+30)); switch(RFIFOL(fd,i+34)) { case 0: - if (defaultlanguage == 'F') - ShowMessage("%-27s\n", "Compte Ok"); - else - ShowMessage("%-27s\n", "Account OK"); + ShowMessage("%-27s\n", "Account OK"); break; case 1: ShowMessage("%-27s\n", "Unregistered ID"); @@ -3457,10 +2461,7 @@ int parse_fromlogin(int fd) } } // asking of the following acounts - if (defaultlanguage == 'F') - ladmin_log("Envoi d'un requête au serveur de logins pour obtenir la liste des comptes de %d à %d (complément).\n", list_first, list_last); - else - ladmin_log("Request to login-server to obtain the list of accounts from %d to %d (complement).\n", list_first, list_last); + ladmin_log("Request to login-server to obtain the list of accounts from %d to %d (complement).\n", list_first, list_last); WFIFOW(login_fd,0) = 0x7920; WFIFOL(login_fd,2) = list_first; WFIFOL(login_fd,6) = list_last; @@ -3473,23 +2474,13 @@ int parse_fromlogin(int fd) case 0x7931: // Answer of login-server about an account creation if (RFIFOREST(fd) < 30) return 0; - id=RFIFOL(fd,2); - if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec à la création du compte [%s]. Un compte identique existe déjà.\n", RFIFOP(fd,6)); - ladmin_log("Echec à la création du compte [%s]. Un compte identique existe déjà.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] creation failed. Same account already exists.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] creation failed. Same account already exists.\n", RFIFOP(fd,6)); - } + id = RFIFOL(fd,2); + if (id != -1) { + ShowMessage("Account [%s] creation failed. Return code %d.\n", RFIFOP(fd,6), id); + ladmin_log("Account [%s] creation failed. Return code %d.\n", RFIFOP(fd,6), id); } else { - if (defaultlanguage == 'F') { - ShowMessage("Compte [%s] créé avec succès [id: %d].\n", RFIFOP(fd,6), id); - ladmin_log("Compte [%s] créé avec succès [id: %d].\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s] is successfully created [id: %d].\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s] is successfully created [id: %d].\n", RFIFOP(fd,6), id); - } + ShowMessage("Account [%s] is successfully created.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] is successfully created.\n", RFIFOP(fd,6)); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3499,21 +2490,11 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 30) return 0; if (RFIFOL(fd,2) == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de la suppression du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec de la suppression du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Compte [%s][id: %d] SUPPRIME avec succès.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Compte [%s][id: %d] SUPPRIME avec succès.\n", RFIFOP(fd,6), RFIFOL(fd,2)); - } else { - ShowMessage("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), RFIFOL(fd,2)); - } + ShowMessage("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); + ladmin_log("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), RFIFOL(fd,2)); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3523,23 +2504,12 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 30) return 0; if (RFIFOL(fd,2) == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de la modification du mot de passe du compte [%s].\n", RFIFOP(fd,6)); - ShowMessage("Le compte [%s] n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec de la modification du mot de passe du compte. Le compte [%s] n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] password changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account password changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] password changing failed.\n", RFIFOP(fd,6)); + ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account password changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Modification du mot de passe du compte [%s][id: %d] réussie.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Modification du mot de passe du compte [%s][id: %d] réussie.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - } else { - ShowMessage("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - } + ShowMessage("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); + ladmin_log("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3549,27 +2519,14 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 34) return 0; if (RFIFOL(fd,2) == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement du statut du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement du statut du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { char tmpstr[256]; - if (defaultlanguage == 'F') { - sprintf(tmpstr, "Statut du compte [%s] changé avec succès en [", RFIFOP(fd,6)); - } else { - sprintf(tmpstr, "Account [%s] state successfully changed in [", RFIFOP(fd,6)); - } + sprintf(tmpstr, "Account [%s] state successfully changed in [", RFIFOP(fd,6)); switch(RFIFOL(fd,30)) { case 0: - if (defaultlanguage == 'F') - strcat(tmpstr, "0: Compte Ok"); - else - strcat(tmpstr, "0: Account OK"); - break; + strcat(tmpstr, "0: Account OK"); case 1: strcat(tmpstr, "1: Unregistered ID"); break; @@ -3616,24 +2573,12 @@ int parse_fromlogin(int fd) // Get length of the received packet int i; char name[20]; - if (defaultlanguage == 'F') { - ladmin_log(" Réception du nombre de joueurs en ligne.\n"); - } else { - ladmin_log(" Receiving of the number of online players.\n"); - } + ladmin_log(" Receiving of the number of online players.\n"); // Read information of the servers if (RFIFOW(fd,2) < 5) { - if (defaultlanguage == 'F') { - ShowMessage(" Aucun serveur n'est connecté au login serveur.\n"); - } else { - ShowMessage(" No server is connected to the login-server.\n"); - } + ShowMessage(" No server is connected to the login-server.\n"); } else { - if (defaultlanguage == 'F') { - ShowMessage(" Nombre de joueurs en ligne (serveur: nb):\n"); - } else { - ShowMessage(" Number of online players (server: number).\n"); - } + ShowMessage(" Number of online players (server: number).\n"); // Displaying of result for(i = 4; i < RFIFOW(fd,2); i += 32) { memcpy(name, RFIFOP(fd,i+6), sizeof(name)); @@ -3651,21 +2596,11 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Le compte [%s] n'existe pas ou le mot de passe est incorrect.\n", RFIFOP(fd,6)); - ladmin_log("Le compte [%s] n'existe pas ou le mot de passe est incorrect.\n", RFIFOP(fd,6)); - } else { - ShowMessage("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); - ladmin_log("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); - } + ShowMessage("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); + ladmin_log("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Le mot de passe donné correspond bien au compte [%s][id: %d].\n", RFIFOP(fd,6), id); - ladmin_log("Le mot de passe donné correspond bien au compte [%s][id: %d].\n", RFIFOP(fd,6), id); - } else { - ShowMessage("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); - ladmin_log("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); - } + ShowMessage("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); + ladmin_log("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3676,23 +2611,12 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de la modification du sexe du compte [%s].\n", RFIFOP(fd,6)); - ShowMessage("Le compte [%s] n'existe pas ou le sexe est déjà celui demandé.\n", RFIFOP(fd,6)); - ladmin_log("Echec de la modification du sexe du compte. Le compte [%s] n'existe pas ou le sexe est déjà celui demandé.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] sex changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); - ladmin_log("Account sex changing failed. The compte [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] sex changing failed.\n", RFIFOP(fd,6)); + ShowMessage("Account [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); + ladmin_log("Account sex changing failed. The compte [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Sexe du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - ladmin_log("Sexe du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); - } + ShowMessage("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); + ladmin_log("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3703,25 +2627,13 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de la modification du niveau de GM du compte [%s].\n", RFIFOP(fd,6)); - ShowMessage("Le compte [%s] n'existe pas, le niveau de GM est déjà celui demandé\n", RFIFOP(fd,6)); - ShowMessage("ou il est impossible de modifier le fichier des comptes GM.\n"); - ladmin_log("Echec de la modification du niveau de GM du compte. Le compte [%s] n'existe pas, le niveau de GM est déjà celui demandé ou il est impossible de modifier le fichier des comptes GM.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] GM level changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist, the GM level is already the good GM level\n", RFIFOP(fd,6)); - ShowMessage("or it's impossible to modify the GM accounts file.\n"); - ladmin_log("Account GM level changing failed. The compte [%s] doesn't exist, the GM level is already the good sex or it's impossible to modify the GM accounts file.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] GM level changing failed.\n", RFIFOP(fd,6)); + ShowMessage("Account [%s] doesn't exist, the GM level is already the good GM level\n", RFIFOP(fd,6)); + ShowMessage("or it's impossible to modify the GM accounts file.\n"); + ladmin_log("Account GM level changing failed. The compte [%s] doesn't exist, the GM level is already the good sex or it's impossible to modify the GM accounts file.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Niveau de GM du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - ladmin_log("Niveau de GM du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); - } + ShowMessage("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); + ladmin_log("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3732,23 +2644,12 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de la modification de l'e-mail du compte [%s].\n", RFIFOP(fd,6)); - ShowMessage("Le compte [%s] n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec de la modification de l'e-mail du compte. Le compte [%s] n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] e-mail changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account e-mail changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] e-mail changing failed.\n", RFIFOP(fd,6)); + ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account e-mail changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Modification de l'e-mail du compte [%s][id: %d] réussie.\n", RFIFOP(fd,6), id); - ladmin_log("Modification de l'e-mail du compte [%s][id: %d] réussie.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); - } + ShowMessage("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); + ladmin_log("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3759,21 +2660,11 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement du mémo du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement du mémo du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Mémo du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - ladmin_log("Mémo du compte [%s][id: %d] changé avec succès.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); - } + ShowMessage("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); + ladmin_log("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3784,21 +2675,11 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Impossible de trouver l'id du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Impossible de trouver l'id du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); } else { - if (defaultlanguage == 'F') { - ShowMessage("Le compte [%s] a pour id: %d.\n", RFIFOP(fd,6), id); - ladmin_log("Le compte [%s] a pour id: %d.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); - ladmin_log("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); - } + ShowMessage("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); + ladmin_log("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3809,21 +2690,11 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (strcmp((const char*)RFIFOP(fd,6), "") == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas.\n", id); - ladmin_log("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas.\n", id); - } else { - ShowMessage("Unable to find the account [%d] name. Account doesn't exist.\n", id); - ladmin_log("Unable to find the account [%d] name. Account doesn't exist.\n", id); - } + ShowMessage("Unable to find the account [%d] name. Account doesn't exist.\n", id); + ladmin_log("Unable to find the account [%d] name. Account doesn't exist.\n", id); } else { - if (defaultlanguage == 'F') { - ShowMessage("Le compte [id: %d] a pour nom: %s.\n", id, RFIFOP(fd,6)); - ladmin_log("Le compte [id: %d] a pour nom: %s.\n", id, RFIFOP(fd,6)); - } else { - ShowMessage("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); - ladmin_log("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); - } + ShowMessage("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); + ladmin_log("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); } bytes_to_read = 0; RFIFOSKIP(fd,30); @@ -3834,33 +2705,18 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement de la validité du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement de la validité du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { time_t timestamp = RFIFOL(fd,30); if (timestamp == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Limite de validité du compte [%s][id: %d] changée avec succès en [illimité].\n", RFIFOP(fd,6), id); - ladmin_log("Limite de validité du compte [%s][id: %d] changée avec succès en [illimité].\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); - ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); - } + ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); + ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); } else { char tmpstr[128]; strftime(tmpstr, 24, date_format, localtime(×tamp)); - if (defaultlanguage == 'F') { - ShowMessage("Limite de validité du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Limite de validité du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - } else { - ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } + ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); + ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); } } bytes_to_read = 0; @@ -3872,33 +2728,18 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement de la date finale de banissement du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement de la date finale de banissement du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { time_t timestamp = RFIFOL(fd,30); if (timestamp == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Date finale de banissement du compte [%s][id: %d] changée avec succès en [dé-bannie].\n", RFIFOP(fd,6), id); - ladmin_log("Date finale de banissement du compte [%s][id: %d] changée avec succès en [dé-bannie].\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - } + ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); + ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); } else { char tmpstr[128]; strftime(tmpstr, 24, date_format, localtime(×tamp)); - if (defaultlanguage == 'F') { - ShowMessage("Date finale de banissement du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Date finale de banissement du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - } else { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } + ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); + ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); } } bytes_to_read = 0; @@ -3910,33 +2751,18 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement de la date finale de banissement du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement de la date finale de banissement du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { time_t timestamp = RFIFOL(fd,30); if (timestamp == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Date finale de banissement du compte [%s][id: %d] changée avec succès en [dé-bannie].\n", RFIFOP(fd,6), id); - ladmin_log("Date finale de banissement du compte [%s][id: %d] changée avec succès en [dé-bannie].\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - } + ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); + ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); } else { char tmpstr[128]; strftime(tmpstr, 24, date_format, localtime(×tamp)); - if (defaultlanguage == 'F') { - ShowMessage("Date finale de banissement du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Date finale de banissement du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - } else { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } + ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); + ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); } } bytes_to_read = 0; @@ -3947,21 +2773,11 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 4) return 0; if (RFIFOW(fd,2) == (unsigned short)-1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec de l'envoi du message. Aucun server de char en ligne.\n"); - ladmin_log("Echec de l'envoi du message. Aucun server de char en ligne.\n"); - } else { - ShowMessage("Message sending failed. No online char-server.\n"); - ladmin_log("Message sending failed. No online char-server.\n"); - } + ShowMessage("Message sending failed. No online char-server.\n"); + ladmin_log("Message sending failed. No online char-server.\n"); } else { - if (defaultlanguage == 'F') { - ShowMessage("Message transmis au server de logins avec succès.\n"); - ladmin_log("Message transmis au server de logins avec succès.\n"); - } else { - ShowMessage("Message successfully sended to login-server.\n"); - ladmin_log("Message successfully sended to login-server.\n"); - } + ShowMessage("Message successfully sended to login-server.\n"); + ladmin_log("Message successfully sended to login-server.\n"); } bytes_to_read = 0; RFIFOSKIP(fd,4); @@ -3972,37 +2788,20 @@ int parse_fromlogin(int fd) return 0; id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Echec du changement de la validité du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - ladmin_log("Echec du changement de la validité du compte [%s]. Le compte n'existe pas.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } + ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); + ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); } else { time_t timestamp = RFIFOL(fd,30); if (timestamp == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Limite de validité du compte [%s][id: %d] inchangée.\n", RFIFOP(fd,6), id); - ShowMessage("Le compte a une validité illimitée ou\n"); - ShowMessage("la modification est impossible avec les ajustements demandés.\n"); - ladmin_log("Limite de validité du compte [%s][id: %d] inchangée. Le compte a une validité illimitée ou la modification est impossible avec les ajustements demandés.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Validity limit of the account [%s][id: %d] unchanged.\n", RFIFOP(fd,6), id); - ShowMessage("The account have an unlimited validity limit or\n"); - ShowMessage("the changing is impossible with the proposed adjustments.\n"); - ladmin_log("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n", RFIFOP(fd,6), id); - } + ShowMessage("Validity limit of the account [%s][id: %d] unchanged.\n", RFIFOP(fd,6), id); + ShowMessage("The account have an unlimited validity limit or\n"); + ShowMessage("the changing is impossible with the proposed adjustments.\n"); + ladmin_log("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n", RFIFOP(fd,6), id); } else { char tmpstr[128]; strftime(tmpstr, 24, date_format, localtime(×tamp)); - if (defaultlanguage == 'F') { - ShowMessage("Limite de validité du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Limite de validité du compte [%s][id: %d] changée avec succès pour être jusqu'au %s.\n", RFIFOP(fd,6), id, tmpstr); - } else { - ShowMessage("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } + ShowMessage("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); + ladmin_log("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); } } bytes_to_read = 0; @@ -4012,154 +2811,75 @@ int parse_fromlogin(int fd) case 0x7953: // answer of a request about informations of an account (by account name/id) if (RFIFOREST(fd) < 150 || RFIFOREST(fd) < (size_t)(150 + RFIFOW(fd,148))) return 0; - { + { char userid[24], error_message[20], lastlogin[24], last_ip[16], email[40], memo[255]; time_t unban_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - memcpy(userid, RFIFOP(fd,7), sizeof(userid)); - userid[sizeof(userid)-1] = '\0'; - memcpy(error_message, RFIFOP(fd,40), sizeof(error_message)); - error_message[sizeof(error_message)-1] = '\0'; - memcpy(lastlogin, RFIFOP(fd,60), sizeof(lastlogin)); - lastlogin[sizeof(lastlogin)-1] = '\0'; - memcpy(last_ip, RFIFOP(fd,84), sizeof(last_ip)); - last_ip[sizeof(last_ip)-1] = '\0'; - memcpy(email, RFIFOP(fd,100), sizeof(email)); - email[sizeof(email)-1] = '\0'; + safestrncpy(userid, (char*)RFIFOP(fd,7), sizeof(userid)); + safestrncpy(error_message, (char*)RFIFOP(fd,40), sizeof(error_message)); + safestrncpy(lastlogin, (char*)RFIFOP(fd,60), sizeof(lastlogin)); + safestrncpy(last_ip, (char*)RFIFOP(fd,84), sizeof(last_ip)); + safestrncpy(email, (char*)RFIFOP(fd,100), sizeof(email)); expiration_time = (time_t)RFIFOL(fd,140); unban_time = (time_t)RFIFOL(fd,144); memset(memo, '\0', sizeof(memo)); - strncpy(memo, (const char*)RFIFOP(fd,150), RFIFOW(fd,148)); + safestrncpy(memo, (const char*)RFIFOP(fd,150), RFIFOW(fd,148)); id = RFIFOL(fd,2); if (id == -1) { - if (defaultlanguage == 'F') { - ShowMessage("Impossible de trouver le compte [%s]. Le compte n'existe pas.\n", parameters); - ladmin_log("Impossible de trouver le compte [%s]. Le compte n'existe pas.\n", parameters); - } else { - ShowMessage("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); - ladmin_log("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); - } + ShowMessage("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); + ladmin_log("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); } else if (strlen(userid) == 0) { - if (defaultlanguage == 'F') { - ShowMessage("Impossible de trouver le compte [id: %s]. Le compte n'existe pas.\n", parameters); - ladmin_log("Impossible de trouver le compte [id: %s]. Le compte n'existe pas.\n", parameters); - } else { - ShowMessage("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); - ladmin_log("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); - } + ShowMessage("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); + ladmin_log("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); } else { - if (defaultlanguage == 'F') { - ladmin_log("Réception d'information concernant un compte.\n"); - ShowMessage("Le compte a les caractéristiques suivantes:\n"); - } else { - ladmin_log("Receiving information about an account.\n"); - ShowMessage("The account is set with:\n"); - } + ladmin_log("Receiving information about an account.\n"); + ShowMessage("The account is set with:\n"); if (RFIFOB(fd,6) == 0) { ShowMessage(" Id: %d (non-GM)\n", id); } else { - if (defaultlanguage == 'F') { - ShowMessage(" Id: %d (GM niveau %d)\n", id, (int)RFIFOB(fd,6)); - } else { - ShowMessage(" Id: %d (GM level %d)\n", id, (int)RFIFOB(fd,6)); - } - } - if (defaultlanguage == 'F') { - ShowMessage(" Nom: '%s'\n", userid); - if (RFIFOB(fd,31) == 0) - ShowMessage(" Sexe: Femme\n"); - else if (RFIFOB(fd,31) == 1) - ShowMessage(" Sexe: Male\n"); - else - ShowMessage(" Sexe: Serveur\n"); - } else { - ShowMessage(" Name: '%s'\n", userid); - if (RFIFOB(fd,31) == 0) - ShowMessage(" Sex: Female\n"); - else if (RFIFOB(fd,31) == 1) - ShowMessage(" Sex: Male\n"); - else - ShowMessage(" Sex: Server\n"); + ShowMessage(" Id: %d (GM level %d)\n", id, (int)RFIFOB(fd,6)); } + ShowMessage(" Name: '%s'\n", userid); + if (RFIFOB(fd,31) == 0) + ShowMessage(" Sex: Female\n"); + else if (RFIFOB(fd,31) == 1) + ShowMessage(" Sex: Male\n"); + else + ShowMessage(" Sex: Server\n"); ShowMessage(" E-mail: %s\n", email); switch(RFIFOL(fd,36)) { - case 0: - if (defaultlanguage == 'F') - ShowMessage(" Statut: 0 [Compte Ok]\n"); - else - ShowMessage(" State: 0 [Account OK]\n"); - break; - case 1: - ShowMessage(" Statut: 1 [Unregistered ID]\n"); - break; - case 2: - ShowMessage(" State: 2 [Incorrect Password]\n"); - break; - case 3: - ShowMessage(" Statut: 3 [This ID is expired]\n"); - break; - case 4: - ShowMessage(" State: 4 [Rejected from Server]\n"); - break; - case 5: - ShowMessage(" Statut: 5 [You have been blocked by the GM Team]\n"); - break; - case 6: - ShowMessage(" State: 6 [Your Game's EXE file is not the latest version]\n"); - break; - case 7: - ShowMessage(" Statut: 7 [You are Prohibited to log in until %s]\n", error_message); - break; - case 8: - ShowMessage(" State: 8 [Server is jammed due to over populated]\n"); - break; - case 9: - ShowMessage(" Statut: 9 [No MSG]\n"); - break; + case 0: ShowMessage(" State: 0 [Account OK]\n"); break; + case 1: ShowMessage(" State: 1 [Unregistered ID]\n"); break; + case 2: ShowMessage(" State: 2 [Incorrect Password]\n"); break; + case 3: ShowMessage(" State: 3 [This ID is expired]\n"); break; + case 4: ShowMessage(" State: 4 [Rejected from Server]\n"); break; + case 5: ShowMessage(" State: 5 [You have been blocked by the GM Team]\n"); break; + case 6: ShowMessage(" State: 6 [Your Game's EXE file is not the latest version]\n"); break; + case 7: ShowMessage(" State: 7 [You are Prohibited to log in until %s]\n", error_message); break; + case 8: ShowMessage(" State: 8 [Server is jammed due to over populated]\n"); break; + case 9: ShowMessage(" State: 9 [No MSG]\n"); break; default: // 100 ShowMessage(" State: %d [This ID is totally erased]\n", (int)RFIFOL(fd,36)); break; } - if (defaultlanguage == 'F') { - if (unban_time == 0) { - ShowMessage(" Banissement: non banni.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&unban_time)); - ShowMessage(" Banissement: jusqu'au %s.\n", tmpstr); - } - if (RFIFOL(fd,32) > 1) - ShowMessage(" Compteur: %d connexions.\n", (int)RFIFOL(fd,32)); - else - ShowMessage(" Compteur: %d connexion.\n", (int)RFIFOL(fd,32)); - ShowMessage(" Dernière connexion le: %s (ip: %s)\n", lastlogin, last_ip); - if (expiration_time == 0) { - ShowMessage(" Limite de validité: illimité.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&expiration_time)); - ShowMessage(" Limite de validité: jusqu'au %s.\n", tmpstr); - } + if (unban_time == 0) { + ShowMessage(" Banishment: not banished.\n"); } else { - if (unban_time == 0) { - ShowMessage(" Banishment: not banished.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&unban_time)); - ShowMessage(" Banishment: until %s.\n", tmpstr); - } - if (RFIFOL(fd,32) > 1) - ShowMessage(" Count: %d connections.\n", (int)RFIFOL(fd,32)); - else - ShowMessage(" Count: %d connection.\n", (int)RFIFOL(fd,32)); - ShowMessage(" Last connection at: %s (ip: %s)\n", lastlogin, last_ip); - if (expiration_time == 0) { - ShowMessage(" Validity limit: unlimited.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&expiration_time)); - ShowMessage(" Validity limit: until %s.\n", tmpstr); - } + char tmpstr[128]; + strftime(tmpstr, 24, date_format, localtime(&unban_time)); + ShowMessage(" Banishment: until %s.\n", tmpstr); + } + if (RFIFOL(fd,32) > 1) + ShowMessage(" Count: %d connections.\n", (int)RFIFOL(fd,32)); + else + ShowMessage(" Count: %d connection.\n", (int)RFIFOL(fd,32)); + ShowMessage(" Last connection at: %s (ip: %s)\n", lastlogin, last_ip); + if (expiration_time == 0) { + ShowMessage(" Validity limit: unlimited.\n"); + } else { + char tmpstr[128]; + strftime(tmpstr, 24, date_format, localtime(&expiration_time)); + ShowMessage(" Validity limit: until %s.\n", tmpstr); } ShowMessage(" Memo: '%s'\n", memo); } @@ -4187,13 +2907,8 @@ int parse_fromlogin(int fd) //------------------------------------ int Connect_login_server(void) { - if (defaultlanguage == 'F') { - ShowMessage("Essai de connection au server de logins...\n"); - ladmin_log("Essai de connection au server de logins...\n"); - } else { - ShowMessage("Attempt to connect to login-server...\n"); - ladmin_log("Attempt to connect to login-server...\n"); - } + ShowMessage("Attempt to connect to login-server...\n"); + ladmin_log("Attempt to connect to login-server...\n"); login_fd = make_connection(login_ip, loginserverport); if (login_fd == -1) @@ -4209,25 +2924,15 @@ int Connect_login_server(void) memcpy(WFIFOP(login_fd,4), loginserveradminpassword, 24); WFIFOSET(login_fd,28); bytes_to_read = 1; - if (defaultlanguage == 'F') { - ShowMessage("Envoi du mot de passe...\n"); - ladmin_log("Envoi du mot de passe...\n"); - } else { - ShowMessage("Sending of the password...\n"); - ladmin_log("Sending of the password...\n"); - } + ShowMessage("Sending of the password...\n"); + ladmin_log("Sending of the password...\n"); } else { WFIFOHEAD(login_fd,2); WFIFOW(login_fd,0) = 0x791a; // Sending request about the coding key WFIFOSET(login_fd,2); bytes_to_read = 1; - if (defaultlanguage == 'F') { - ShowMessage("Demande de la clef MD5...\n"); - ladmin_log("Demande de la clef MD5...\n"); - } else { - ShowMessage("Request about the MD5 key...\n"); - ladmin_log("Request about the MD5 key...\n"); - } + ShowMessage("Request about the MD5 key...\n"); + ladmin_log("Request about the MD5 key...\n"); } return 0; @@ -4255,19 +2960,11 @@ int ladmin_config_read(const char *cfgName) fp = fopen(cfgName, "r"); if (fp == NULL) { - if (defaultlanguage == 'F') { - ShowMessage("\033[0mFichier de configuration (%s) non trouvé.\n", cfgName); - } else { - ShowMessage("\033[0mConfiguration file (%s) not found.\n", cfgName); - } + ShowMessage("\033[0mConfiguration file (%s) not found.\n", cfgName); return 1; } - if (defaultlanguage == 'F') { - ShowMessage("\033[0m---Début de lecture du fichier de configuration Ladmin (%s)\n", cfgName); - } else { - ShowMessage("\033[0m---Start reading of Ladmin configuration file (%s)\n", cfgName); - } + ShowMessage("\033[0m---Start reading of Ladmin configuration file (%s)\n", cfgName); while(fgets(line, sizeof(line), fp)) { if (line[0] == '/' && line[1] == '/') @@ -4281,11 +2978,7 @@ int ladmin_config_read(const char *cfgName) uint32 ipl = host2ip(w2); if (ipl != 0) { ip2str(ipl, loginserverip); - if (defaultlanguage == 'F') { - ShowMessage("Adresse du serveur de logins: %s -> %s\n", w2, loginserverip); - } else { - ShowMessage("Login server IP address: %s -> %s\n", w2, loginserverip); - } + ShowMessage("Login server IP address: %s -> %s\n", w2, loginserverip); } else memcpy(loginserverip, w2, 16); } else if (strcmpi(w1, "login_port") == 0) { @@ -4297,9 +2990,6 @@ int ladmin_config_read(const char *cfgName) passenc = atoi(w2); if (passenc < 0 || passenc > 2) passenc = 0; - } else if (strcmpi(w1, "defaultlanguage") == 0) { - if (w2[0] == 'F' || w2[0] == 'E') - defaultlanguage = w2[0]; } else if (strcmpi(w1, "ladmin_log_filename") == 0) { strncpy(ladmin_log_filename, w2, sizeof(ladmin_log_filename)); ladmin_log_filename[sizeof(ladmin_log_filename)-1] = '\0'; @@ -4316,11 +3006,7 @@ int ladmin_config_read(const char *cfgName) login_ip = str2ip(loginserverip); - if (defaultlanguage == 'F') { - ShowMessage("---Lecture du fichier de configuration Ladmin terminée.\n"); - } else { - ShowMessage("---End reading of Ladmin configuration file.\n"); - } + ShowMessage("---End reading of Ladmin configuration file.\n"); return 0; } @@ -4340,13 +3026,8 @@ void do_final(void) { if (already_exit_function == 0) { - if (defaultlanguage == 'F') { - ShowMessage("\033[0m----Fin de Ladmin (fin normale avec fermeture de tous les fichiers).\n"); - ladmin_log("----Fin de Ladmin (fin normale avec fermeture de tous les fichiers).\n"); - } else { - ShowMessage("\033[0m----End of Ladmin (normal end with closing of all files).\n"); - ladmin_log("----End of Ladmin (normal end with closing of all files).\n"); - } + ShowMessage("\033[0m----End of Ladmin (normal end with closing of all files).\n"); + ladmin_log("----End of Ladmin (normal end with closing of all files).\n"); already_exit_function = 1; do_close(login_fd); @@ -4365,31 +3046,17 @@ int do_init(int argc, char **argv) ladmin_config_read((argc > 1) ? argv[1] : LADMIN_CONF_NAME); ladmin_log(""); - if (defaultlanguage == 'F') { - ladmin_log("Fichier de configuration lu.\n"); - } else { - ladmin_log("Configuration file readed.\n"); - } + ladmin_log("Configuration file readed.\n"); srand(time(NULL)); set_defaultparse(parse_fromlogin); - if (defaultlanguage == 'F') { - ShowMessage("Outil d'administration à distance de eAthena.\n"); - ShowMessage("(pour eAthena version %d.%d.%d.)\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION); - } else { - ShowMessage("EAthena login-server administration tool.\n"); - ShowMessage("(for eAthena version %d.%d.%d.)\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION); - } + ShowMessage("EAthena login-server administration tool.\n"); + ShowMessage("(for eAthena version %d.%d.%d.)\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION); - if (defaultlanguage == 'F') { - ladmin_log("Ladmin est prêt.\n"); - ShowMessage("Ladmin est \033[1;32mprêt\033[0m.\n\n"); - } else { - ladmin_log("Ladmin is ready.\n"); - ShowMessage("Ladmin is \033[1;32mready\033[0m.\n\n"); - } + ladmin_log("Ladmin is ready.\n"); + ShowMessage("Ladmin is \033[1;32mready\033[0m.\n\n"); Connect_login_server(); diff --git a/src/login/Makefile.in b/src/login/Makefile.in index aeb41b667..1f6080746 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -10,36 +10,71 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/grfio.h ../common/mapindex.h \ ../common/ers.h ../common/md5calc.h -LOGIN_OBJ = obj_txt/login.o obj_txt/admin.o -LOGIN_H = login.h +COMMON_SQL_OBJ = ../common/obj_sql/sql.o +COMMON_SQL_H = ../common/sql.h + +LOGIN_OBJ = login.o admin.o +LOGIN_TXT_OBJ = $(LOGIN_OBJ:%=obj_txt/%) \ + obj_txt/account_txt.o obj_txt/ipban_txt.o obj_txt/loginlog_txt.o +LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \ + obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o +LOGIN_H = login.h account.h ipban.h loginlog.h + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) +else + LOGIN_SERVER_SQL_DEPENDS=needs_mysql +endif @SET_MAKE@ ##################################################################### -.PHONY : all login-server clean help +.PHONY :all txt sql clean help -all: login-server +all: txt sql -login-server: obj_txt $(LOGIN_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ +txt: obj_txt login-server + +sql: obj_sql login-server_sql clean: - rm -rf *.o obj_txt ../../login-server@EXEEXT@ + rm -rf *.o obj_txt obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ help: - @echo "possible targets are 'login-server' 'all' 'clean' 'help'" - @echo "'login-server' - login server (TXT version)" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" + @echo "possible targets are 'sql' 'txt' 'all' 'clean' 'help'" + @echo "'sql' - login server (SQL version)" + @echo "'txt' - login server (TXT version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" ##################################################################### +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 + +# object directories obj_txt: - -mkdir obj_txt + test -d obj_txt || mkdir obj_txt +obj_sql: + test -d obj_sql || mkdir obj_sql + +#executables +login-server: $(LOGIN_TXT_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_TXT_OBJ) $(COMMON_OBJ) @LIBS@ + +login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) + @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @MYSQL_LIBS@ + +# login object files obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) - @CC@ @CFLAGS@ $(CUSTOM_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @CC@ @CFLAGS@ $(CUSTOM_CFLAGS) -DWITH_TXT @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) + @CC@ @CFLAGS@ $(CUSTOM_CFLAGS) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: diff --git a/src/login/account.h b/src/login/account.h new file mode 100644 index 000000000..4cc9b353b --- /dev/null +++ b/src/login/account.h @@ -0,0 +1,159 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef __ACCOUNT_H_INCLUDED__ +#define __ACCOUNT_H_INCLUDED__ + +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // ACCOUNT_REG2_NUM + +typedef struct AccountDB AccountDB; +typedef struct AccountDBIterator AccountDBIterator; + + +// standard engines +#ifdef WITH_TXT +AccountDB* account_db_txt(void); +#endif +#ifdef WITH_SQL +AccountDB* account_db_sql(void); +#endif +// extra engines (will probably use the other txt functions) +#define ACCOUNTDB_CONSTRUCTOR_(engine) account_db_##engine +#define ACCOUNTDB_CONSTRUCTOR(engine) ACCOUNTDB_CONSTRUCTOR_(engine) +#ifdef ACCOUNTDB_ENGINE_0 +AccountDB* ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_0)(void); +#endif +#ifdef ACCOUNTDB_ENGINE_1 +AccountDB* ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_1)(void); +#endif +#ifdef ACCOUNTDB_ENGINE_2 +AccountDB* ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_2)(void); +#endif +#ifdef ACCOUNTDB_ENGINE_3 +AccountDB* ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_3)(void); +#endif +#ifdef ACCOUNTDB_ENGINE_4 +AccountDB* ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_4)(void); +#endif + + +struct mmo_account +{ + int account_id; + char userid[24]; + char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords + char sex; // gender (M/F/S) + char email[40]; // e-mail (by default: a@a.com) + int level; // GM level + unsigned int state; // packet 0x006a value + 1 (0: compte OK) + time_t unban_time; // (timestamp): ban time limit of the account (0 = no ban) + time_t expiration_time; // (timestamp): validity limit of the account (0 = unlimited) + unsigned int logincount;// number of successful auth attempts + char lastlogin[24]; // date+time of last successful login + char last_ip[16]; // save of last IP of connection + int account_reg2_num; + struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server) +}; + + +struct AccountDBIterator +{ + /// Destroys this iterator, releasing all allocated memory (including itself). + /// + /// @param self Iterator + void (*destroy)(AccountDBIterator* self); + + /// Fetches the next account in the database. + /// Fills acc with the account data. + /// @param self Iterator + /// @param acc Account data + /// @return true if successful + bool (*next)(AccountDBIterator* self, struct mmo_account* acc); +}; + + +struct AccountDB +{ + /// Initializes this database, making it ready for use. + /// Call this after setting the properties. + /// + /// @param self Database + /// @return true if successful + bool (*init)(AccountDB* self); + + /// Destroys this database, releasing all allocated memory (including itself). + /// + /// @param self Database + void (*destroy)(AccountDB* self); + + /// Gets a property from this database. + /// These read-only properties must be implemented: + /// "engine.name" -> "txt", "sql", ... + /// "engine.version" -> internal version + /// "engine.comment" -> anything (suggestion: description or specs of the engine) + /// + /// @param self Database + /// @param key Property name + /// @param buf Buffer for the value + /// @param buflen Buffer length + /// @return true if successful + bool (*get_property)(AccountDB* self, const char* key, char* buf, size_t buflen); + + /// Sets a property in this database. + /// + /// @param self Database + /// @param key Property name + /// @param value Property value + /// @return true if successful + bool (*set_property)(AccountDB* self, const char* key, const char* value); + + /// Creates a new account in this database. + /// If acc->account_id is not -1, the provided value will be used. + /// Otherwise the account_id will be auto-generated and written to acc->account_id. + /// + /// @param self Database + /// @param acc Account data + /// @return true if successful + bool (*create)(AccountDB* self, struct mmo_account* acc); + + /// Removes an account from this database. + /// + /// @param self Database + /// @param account_id Account id + /// @return true if successful + bool (*remove)(AccountDB* self, const int account_id); + + /// Modifies the data of an existing account. + /// Uses acc->account_id to identify the account. + /// + /// @param self Database + /// @param acc Account data + /// @return true if successful + bool (*save)(AccountDB* self, const struct mmo_account* acc); + + /// Finds an account with account_id and copies it to acc. + /// + /// @param self Database + /// @param acc Pointer that receives the account data + /// @param account_id Target account id + /// @return true if successful + bool (*load_num)(AccountDB* self, struct mmo_account* acc, const int account_id); + + /// Finds an account with userid and copies it to acc. + /// + /// @param self Database + /// @param acc Pointer that receives the account data + /// @param userid Target username + /// @return true if successful + bool (*load_str)(AccountDB* self, struct mmo_account* acc, const char* userid); + + /// Returns a new forward iterator. + /// + /// @param self Database + /// @return Iterator + AccountDBIterator* (*iterator)(AccountDB* self); +}; + + +#endif // __ACCOUNT_H_INCLUDED__ diff --git a/src/login/account_sql.c b/src/login/account_sql.c new file mode 100644 index 000000000..b510949fa --- /dev/null +++ b/src/login/account_sql.c @@ -0,0 +1,578 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "account.h" +#include +#include + +/// global defines +#define ACCOUNT_SQL_DB_VERSION 20080417 + +/// internal structure +typedef struct AccountDB_SQL +{ + AccountDB vtable; // public interface + + Sql* accounts; // SQL accounts storage + + char db_hostname[32]; + uint16 db_port; + char db_username[32]; + char db_password[32]; + char db_database[32]; + char codepage[32]; + bool case_sensitive; + char account_db[32]; + char accreg_db[32]; + +} AccountDB_SQL; + +/// internal structure +typedef struct AccountDBIterator_SQL +{ + AccountDBIterator vtable; // public interface + + AccountDB_SQL* db; + int last_account_id; +} AccountDBIterator_SQL; + +/// internal functions +static bool account_db_sql_init(AccountDB* self); +static void account_db_sql_destroy(AccountDB* self); +static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen); +static bool account_db_sql_set_property(AccountDB* self, const char* option, const char* value); +static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc); +static bool account_db_sql_remove(AccountDB* self, const int account_id); +static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc); +static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id); +static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid); +static AccountDBIterator* account_db_sql_iterator(AccountDB* self); +static void account_db_sql_iter_destroy(AccountDBIterator* self); +static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc); + +static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id); +static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new); + +/// public constructor +AccountDB* account_db_sql(void) +{ + AccountDB_SQL* db = (AccountDB_SQL*)aCalloc(1, sizeof(AccountDB_SQL)); + + // set up the vtable + db->vtable.init = &account_db_sql_init; + db->vtable.destroy = &account_db_sql_destroy; + db->vtable.get_property = &account_db_sql_get_property; + db->vtable.set_property = &account_db_sql_set_property; + db->vtable.save = &account_db_sql_save; + db->vtable.create = &account_db_sql_create; + db->vtable.remove = &account_db_sql_remove; + db->vtable.load_num = &account_db_sql_load_num; + db->vtable.load_str = &account_db_sql_load_str; + db->vtable.iterator = &account_db_sql_iterator; + + // initialize to default values + db->accounts = NULL; + safestrncpy(db->db_hostname, "127.0.0.1", sizeof(db->db_hostname)); + db->db_port = 3306; + safestrncpy(db->db_username, "ragnarok", sizeof(db->db_username)); + safestrncpy(db->db_password, "ragnarok", sizeof(db->db_password)); + safestrncpy(db->db_database, "ragnarok", sizeof(db->db_database)); + safestrncpy(db->codepage, "", sizeof(db->codepage)); + db->case_sensitive = false; + safestrncpy(db->account_db, "login", sizeof(db->account_db)); + safestrncpy(db->accreg_db, "global_reg_value", sizeof(db->accreg_db)); + + return &db->vtable; +} + + +/* ------------------------------------------------------------------------- */ + + +/// establishes database connection +static bool account_db_sql_init(AccountDB* self) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + Sql* sql_handle; + + db->accounts = Sql_Malloc(); + sql_handle = db->accounts; + + if( SQL_ERROR == Sql_Connect(sql_handle, db->db_username, db->db_password, db->db_hostname, db->db_port, db->db_database) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(db->accounts); + db->accounts = NULL; + return false; + } + + if( db->codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, db->codepage) ) + Sql_ShowDebug(sql_handle); + + return true; +} + +/// disconnects from database +static void account_db_sql_destroy(AccountDB* self) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + + Sql_Free(db->accounts); + db->accounts = NULL; +} + +/// Gets a property from this database. +static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + const char* signature = "account.sql."; + + if( strcmp(key, "engine.name") == 0 ) + { + safesnprintf(buf, buflen, "sql"); + return true; + } + if( strcmp(key, "engine.version") == 0 ) + { + safesnprintf(buf, buflen, "%d", ACCOUNT_SQL_DB_VERSION); + return true; + } + if( strcmp(key, "engine.comment") == 0 ) + { + safesnprintf(buf, buflen, "SQL Account Database"); + return true; + } + + if( strncmp(key, signature, strlen(signature)) != 0 ) + return false; + + key += strlen(signature); + + if( strcmpi(key, "db_hostname") == 0 ) + safesnprintf(buf, buflen, "%s", db->db_hostname); + else + if( strcmpi(key, "db_port") == 0 ) + safesnprintf(buf, buflen, "%d", db->db_port); + else + if( strcmpi(key, "db_username") == 0 ) + safesnprintf(buf, buflen, "%s", db->db_username); + else + if( strcmpi(key, "db_password") == 0 ) + safesnprintf(buf, buflen, "%s", db->db_password); + else + if( strcmpi(key, "db_database") == 0 ) + safesnprintf(buf, buflen, "%s", db->db_database); + else + if( strcmpi(key, "codepage") == 0 ) + safesnprintf(buf, buflen, "%s", db->codepage); + else + if( strcmpi(key, "case_sensitive") == 0 ) + safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0)); + else + if( strcmpi(key, "account_db") == 0 ) + safesnprintf(buf, buflen, "%s", db->account_db); + else + if( strcmpi(key, "accreg_db") == 0 ) + safesnprintf(buf, buflen, "%s", db->accreg_db); + else + return false;// not found + + return true; +} + +/// if the option is supported, adjusts the internal state +static bool account_db_sql_set_property(AccountDB* self, const char* key, const char* value) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + const char* signature = "account.sql."; + + if( strncmp(key, signature, strlen(signature)) != 0 ) + return false; + + key += strlen(signature); + + if( strcmpi(key, "db_hostname") == 0 ) + safestrncpy(db->db_hostname, value, sizeof(db->db_hostname)); + else + if( strcmpi(key, "db_port") == 0 ) + db->db_port = (uint16)strtoul(value, NULL, 10); + else + if( strcmpi(key, "db_username") == 0 ) + safestrncpy(db->db_username, value, sizeof(db->db_username)); + else + if( strcmpi(key, "db_password") == 0 ) + safestrncpy(db->db_password, value, sizeof(db->db_password)); + else + if( strcmpi(key, "db_database") == 0 ) + safestrncpy(db->db_database, value, sizeof(db->db_database)); + else + if( strcmpi(key, "codepage") == 0 ) + safestrncpy(db->codepage, value, sizeof(db->codepage)); + else + if( strcmpi(key, "case_sensitive") == 0 ) + db->case_sensitive = config_switch(value); + else + if( strcmpi(key, "account_db") == 0 ) + safestrncpy(db->account_db, value, sizeof(db->account_db)); + else + if( strcmpi(key, "accreg_db") == 0 ) + safestrncpy(db->accreg_db, value, sizeof(db->accreg_db)); + else // no match + return false; + + return true; +} + +/// create a new account entry +/// If acc->account_id is -1, the account id will be auto-generated, +/// and its value will be written to acc->account_id if everything succeeds. +static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + Sql* sql_handle = db->accounts; + + // decide on the account id to assign + int account_id; + if( acc->account_id != -1 ) + {// caller specifies it manually + account_id = acc->account_id; + } + else + {// ask the database + char* data; + size_t len; + + if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT MAX(`account_id`)+1 FROM `%s`", db->account_db) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_ShowDebug(sql_handle); + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, &len); + account_id = ( data != NULL ) ? atoi(data) : 0; + Sql_FreeResult(sql_handle); + + if( account_id < START_ACCOUNT_NUM ) + account_id = START_ACCOUNT_NUM; + + } + + // zero value is prohibited + if( account_id == 0 ) + return false; + + // absolute maximum + if( account_id > END_ACCOUNT_NUM ) + return false; + + // insert the data into the database + acc->account_id = account_id; + return mmo_auth_tosql(db, acc, true); +} + +/// delete an existing account entry + its regs +static bool account_db_sql_remove(AccountDB* self, const int account_id) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + Sql* sql_handle = db->accounts; + bool result = false; + + if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION") + || SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->account_db, account_id) + || SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->accreg_db, account_id) ) + Sql_ShowDebug(sql_handle); + else + result = true; + + result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ); + + return result; +} + +/// update an existing account with the provided new data (both account and regs) +static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + return mmo_auth_tosql(db, acc, false); +} + +/// retrieve data from db and store it in the provided data structure +static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + return mmo_auth_fromsql(db, acc, account_id); +} + +/// retrieve data from db and store it in the provided data structure +static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + Sql* sql_handle = db->accounts; + char esc_userid[2*NAME_LENGTH+1]; + int account_id; + char* data; + + Sql_EscapeString(sql_handle, esc_userid, userid); + + // get the list of account IDs for this user ID + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `userid`= %s '%s'", + db->account_db, (db->case_sensitive ? "BINARY" : ""), esc_userid) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + if( Sql_NumRows(sql_handle) > 1 ) + {// serious problem - duplicit account + ShowError("account_db_sql_load_str: multiple accounts found when retrieving data for account '%s'!\n", userid); + Sql_FreeResult(sql_handle); + return false; + } + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + {// no such entry + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, NULL); + account_id = atoi(data); + + return account_db_sql_load_num(self, acc, account_id); +} + + +/// Returns a new forward iterator. +static AccountDBIterator* account_db_sql_iterator(AccountDB* self) +{ + AccountDB_SQL* db = (AccountDB_SQL*)self; + AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)aCalloc(1, sizeof(AccountDBIterator_SQL)); + + // set up the vtable + iter->vtable.destroy = &account_db_sql_iter_destroy; + iter->vtable.next = &account_db_sql_iter_next; + + // fill data + iter->db = db; + iter->last_account_id = -1; + + return &iter->vtable; +} + + +/// Destroys this iterator, releasing all allocated memory (including itself). +static void account_db_sql_iter_destroy(AccountDBIterator* self) +{ + AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; + aFree(iter); +} + + +/// Fetches the next account in the database. +static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc) +{ + AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; + AccountDB_SQL* db = (AccountDB_SQL*)iter->db; + Sql* sql_handle = db->accounts; + int account_id; + char* data; + + // get next account ID + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1", + db->account_db, iter->last_account_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + if( SQL_SUCCESS == Sql_NextRow(sql_handle) && + SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, NULL) && + data != NULL ) + {// get account data + account_id = atoi(data); + if( mmo_auth_fromsql(db, acc, account_id) ) + { + iter->last_account_id = account_id; + Sql_FreeResult(sql_handle); + return true; + } + } + Sql_FreeResult(sql_handle); + return false; +} + + +static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id) +{ + Sql* sql_handle = db->accounts; + char* data; + int i = 0; + + // retrieve login entry for the specified account + if( SQL_ERROR == Sql_Query(sql_handle, + "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`level`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip` FROM `%s` WHERE `account_id` = %d", + db->account_db, account_id ) + ) { + Sql_ShowDebug(sql_handle); + return false; + } + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + {// no such entry + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, NULL); acc->account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(acc->userid, data, sizeof(acc->userid)); + Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(acc->pass, data, sizeof(acc->pass)); + Sql_GetData(sql_handle, 3, &data, NULL); acc->sex = data[0]; + Sql_GetData(sql_handle, 4, &data, NULL); safestrncpy(acc->email, data, sizeof(acc->email)); + Sql_GetData(sql_handle, 5, &data, NULL); acc->level = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); acc->state = strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 7, &data, NULL); acc->unban_time = atol(data); + Sql_GetData(sql_handle, 8, &data, NULL); acc->expiration_time = atol(data); + Sql_GetData(sql_handle, 9, &data, NULL); acc->logincount = strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data, sizeof(acc->lastlogin)); + Sql_GetData(sql_handle, 11, &data, NULL); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip)); + + Sql_FreeResult(sql_handle); + + + // retrieve account regs for the specified user + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'", db->accreg_db, acc->account_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + acc->account_reg2_num = (int)Sql_NumRows(sql_handle); + + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + Sql_GetData(sql_handle, 0, &data, NULL); safestrncpy(acc->account_reg2[i].str, data, sizeof(acc->account_reg2[i].str)); + Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(acc->account_reg2[i].value, data, sizeof(acc->account_reg2[i].value)); + ++i; + } + Sql_FreeResult(sql_handle); + + if( i != acc->account_reg2_num ) + return false; + + return true; +} + +static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new) +{ + Sql* sql_handle = db->accounts; + SqlStmt* stmt = SqlStmt_Malloc(sql_handle); + bool result = false; + int i; + + // try + do + { + + if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION") ) + { + Sql_ShowDebug(sql_handle); + break; + } + + if( is_new ) + {// insert into account table + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, + "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `level`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + db->account_db) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->level, sizeof(acc->level)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) + ) { + SqlStmt_ShowDebug(stmt); + break; + } + } + else + {// update account table + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`level`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->level, sizeof(acc->level)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) + ) { + SqlStmt_ShowDebug(stmt); + break; + } + } + + // remove old account regs + if( SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`='1' AND `account_id`='%d'", db->accreg_db, acc->account_id) ) + { + Sql_ShowDebug(sql_handle); + break; + } + // insert new account regs + if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ? );", db->accreg_db, acc->account_id) ) + { + SqlStmt_ShowDebug(stmt); + break; + } + for( i = 0; i < acc->account_reg2_num; ++i ) + { + if( SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->account_reg2[i].str, strlen(acc->account_reg2[i].str)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->account_reg2[i].value, strlen(acc->account_reg2[i].value)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) + ) { + SqlStmt_ShowDebug(stmt); + break; + } + } + if( i < acc->account_reg2_num ) + { + result = false; + break; + } + + // if we got this far, everything was successful + result = true; + + } while(0); + // finally + + result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ); + SqlStmt_Free(stmt); + + return result; +} diff --git a/src/login/account_txt.c b/src/login/account_txt.c new file mode 100644 index 000000000..cfcb6fb8f --- /dev/null +++ b/src/login/account_txt.c @@ -0,0 +1,622 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/db.h" +#include "../common/lock.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "account.h" +#include +#include +#include + +/// global defines +#define ACCOUNT_TXT_DB_VERSION 20080409 +#define AUTHS_BEFORE_SAVE 10 // flush every 10 saves +#define AUTH_SAVING_INTERVAL 60000 // flush every 10 minutes + +/// internal structure +typedef struct AccountDB_TXT +{ + AccountDB vtable; // public interface + + DBMap* accounts; // in-memory accounts storage + int next_account_id; // auto_increment + int auths_before_save; // prevents writing to disk too often + int save_timer; // save timer id + + char account_db[1024]; // account data storage file + bool case_sensitive; // how to look up usernames + +} AccountDB_TXT; + +/// internal structure +typedef struct AccountDBIterator_TXT +{ + AccountDBIterator vtable; // public interface + + DBIterator* iter; +} AccountDBIterator_TXT; + +/// internal functions +static bool account_db_txt_init(AccountDB* self); +static void account_db_txt_destroy(AccountDB* self); +static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen); +static bool account_db_txt_set_property(AccountDB* self, const char* option, const char* value); +static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc); +static bool account_db_txt_remove(AccountDB* self, const int account_id); +static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc); +static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id); +static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid); +static AccountDBIterator* account_db_txt_iterator(AccountDB* self); +static void account_db_txt_iter_destroy(AccountDBIterator* self); +static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc); + +static bool mmo_auth_fromstr(struct mmo_account* acc, char* str, unsigned int version); +static bool mmo_auth_tostr(const struct mmo_account* acc, char* str); +static void mmo_auth_sync(AccountDB_TXT* self); +static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr data); + +/// public constructor +AccountDB* account_db_txt(void) +{ + AccountDB_TXT* db = (AccountDB_TXT*)aCalloc(1, sizeof(AccountDB_TXT)); + + // set up the vtable + db->vtable.init = &account_db_txt_init; + db->vtable.destroy = &account_db_txt_destroy; + db->vtable.get_property = &account_db_txt_get_property; + db->vtable.set_property = &account_db_txt_set_property; + db->vtable.save = &account_db_txt_save; + db->vtable.create = &account_db_txt_create; + db->vtable.remove = &account_db_txt_remove; + db->vtable.load_num = &account_db_txt_load_num; + db->vtable.load_str = &account_db_txt_load_str; + db->vtable.iterator = &account_db_txt_iterator; + + // initialize to default values + db->accounts = NULL; + db->next_account_id = START_ACCOUNT_NUM; + db->auths_before_save = AUTHS_BEFORE_SAVE; + db->save_timer = INVALID_TIMER; + safestrncpy(db->account_db, "save/account.txt", sizeof(db->account_db)); + db->case_sensitive = false; + + return &db->vtable; +} + + +/* ------------------------------------------------------------------------- */ + + +/// opens accounts file, loads it, and starts a periodic saving timer +static bool account_db_txt_init(AccountDB* self) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts; + FILE* fp; + char line[2048]; + unsigned int version = 0; + + // create accounts database + db->accounts = idb_alloc(DB_OPT_RELEASE_DATA); + accounts = db->accounts; + + // open data file + fp = fopen(db->account_db, "r"); + if( fp == NULL ) + { + // no account file -> no account -> no login, including char-server (ERROR) + ShowError(CL_RED"account_db_txt_init: Accounts file [%s] not found."CL_RESET"\n", db->account_db); + return false; + } + + // load data file + while( fgets(line, sizeof(line), fp) != NULL ) + { + int account_id, n; + unsigned int v; + struct mmo_account acc; + struct mmo_account* tmp; + struct DBIterator* iter; + int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp; + + if( line[0] == '/' && line[1] == '/' ) + continue; + + if( sscanf(line, "%d%n", &v, &n) == 1 && line[n] == '\n' ) + {// format version definition + version = v; + continue; + } + + if( sscanf(line, "%d\t%%newid%%%n", &account_id, &n) == 1 && line[n] == '\n' ) + {// auto-increment + if( account_id > db->next_account_id ) + db->next_account_id = account_id; + continue; + } + + if( !mmo_auth_fromstr(&acc, line, version) ) + { + ShowError("account_db_txt_init: skipping invalid data: %s", line); + continue; + } + + // apply constraints & checks here + if( acc.sex != 'S' && (acc.account_id < START_ACCOUNT_NUM || acc.account_id > END_ACCOUNT_NUM) ) + ShowWarning("account_db_txt_init: account %d:'%s' has ID outside of the defined range for accounts (min:%d max:%d)!\n", acc.account_id, acc.userid, START_ACCOUNT_NUM, END_ACCOUNT_NUM); + + iter = accounts->iterator(accounts); + for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) ) + if( compare(acc.userid, tmp->userid) == 0 ) + break; + iter->destroy(iter); + + if( tmp != NULL ) + {// entry with identical username + ShowWarning("account_db_txt_init: account %d:'%s' has same username as account %d. The account will be inaccessible!\n", acc.account_id, acc.userid, tmp->account_id); + } + + if( idb_get(accounts, acc.account_id) != NULL ) + {// account id already occupied + ShowError("account_db_txt_init: ID collision for account id %d! Discarding data for account '%s'...\n", acc.account_id, acc.userid); + continue; + } + + // record entry in db + tmp = (struct mmo_account*)aMalloc(sizeof(struct mmo_account)); + memcpy(tmp, &acc, sizeof(struct mmo_account)); + idb_put(accounts, acc.account_id, tmp); + + if( db->next_account_id < acc.account_id) + db->next_account_id = acc.account_id + 1; + } + + // close data file + fclose(fp); + + // initialize data saving timer + add_timer_func_list(mmo_auth_sync_timer, "mmo_auth_sync_timer"); + db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (int)db, AUTH_SAVING_INTERVAL); + + return true; +} + +/// flush accounts db, close savefile and deallocate structures +static void account_db_txt_destroy(AccountDB* self) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + + // stop saving timer + delete_timer(db->save_timer, mmo_auth_sync_timer); + + // write data + mmo_auth_sync(db); + + // delete accounts database + accounts->destroy(accounts, NULL); + db->accounts = NULL; + + // delete entire structure + aFree(db); +} + +/// Gets a property from this database. +static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + const char* signature = "account.txt."; + + if( strcmp(key, "engine.name") == 0 ) + { + safesnprintf(buf, buflen, "txt"); + return true; + } + if( strcmp(key, "engine.version") == 0 ) + { + safesnprintf(buf, buflen, "%d", ACCOUNT_TXT_DB_VERSION); + return true; + } + if( strcmp(key, "engine.comment") == 0 ) + { + safesnprintf(buf, buflen, "TXT Account Database %d", ACCOUNT_TXT_DB_VERSION); + return true; + } + + if( strncmp(key, signature, strlen(signature)) != 0 ) + return false; + + key += strlen(signature); + + if( strcmpi(key, "account_db") == 0 ) + safesnprintf(buf, buflen, "%s", db->account_db); + else if( strcmpi(key, "case_sensitive") == 0 ) + safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0)); + else + return false;// not found + + return true; +} + +/// Sets a property in this database. +static bool account_db_txt_set_property(AccountDB* self, const char* key, const char* value) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + const char* signature = "account.txt."; + + if( strncmp(key, signature, strlen(signature)) != 0 ) + return false; + + key += strlen(signature); + + if( strcmpi(key, "account_db") == 0 ) + safestrncpy(db->account_db, value, sizeof(db->account_db)); + else if( strcmpi(key, "case_sensitive") == 0 ) + db->case_sensitive = config_switch(value); + else // no match + return false; + + return true; +} + +/// Add a new entry for this account to the account db and save it. +/// If acc->account_id is -1, the account id will be auto-generated, +/// and its value will be written to acc->account_id if everything succeeds. +static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + struct mmo_account* tmp; + + // decide on the account id to assign + int account_id = ( acc->account_id != -1 ) ? acc->account_id : db->next_account_id; + + // absolute maximum + if( account_id > END_ACCOUNT_NUM ) + return false; + + // check if the account_id is free + tmp = idb_get(accounts, account_id); + if( tmp != NULL ) + {// error condition - entry already present + ShowError("account_db_txt_create: cannot create account %d:'%s', this id is already occupied by %d:'%s'!\n", account_id, acc->userid, account_id, tmp->userid); + return false; + } + + // copy the data and store it in the db + CREATE(tmp, struct mmo_account, 1); + memcpy(tmp, acc, sizeof(struct mmo_account)); + tmp->account_id = account_id; + idb_put(accounts, account_id, tmp); + + // increment the auto_increment value + if( account_id >= db->next_account_id ) + db->next_account_id = account_id + 1; + + // flush data + mmo_auth_sync(db); + + // write output + acc->account_id = account_id; + + return true; +} + +/// find an existing entry for this account id and delete it +static bool account_db_txt_remove(AccountDB* self, const int account_id) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + + //TODO: find out if this really works + struct mmo_account* tmp = idb_remove(accounts, account_id); + if( tmp == NULL ) + {// error condition - entry not present + ShowError("account_db_txt_remove: no such account with id %d\n", account_id); + return false; + } + + // flush data + mmo_auth_sync(db); + + return true; +} + +/// rewrite the data stored in the account_db with the one provided +static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + int account_id = acc->account_id; + + // retrieve previous data + struct mmo_acount* tmp = idb_get(accounts, account_id); + if( tmp == NULL ) + {// error condition - entry not found + return false; + } + + // overwrite with new data + memcpy(tmp, acc, sizeof(struct mmo_account)); + + // modify save counter and save if needed + if( --db->auths_before_save == 0 ) + mmo_auth_sync(db); + + return true; +} + +/// retrieve data from db and store it in the provided data structure +static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + + // retrieve data + struct mmo_account* tmp = idb_get(accounts, account_id); + if( tmp == NULL ) + {// entry not found + return false; + } + + // store it + memcpy(acc, tmp, sizeof(struct mmo_account)); + + return true; +} + +/// retrieve data from db and store it in the provided data structure +static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + + // retrieve data + struct DBIterator* iter = accounts->iterator(accounts); + struct mmo_account* tmp; + int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp; + + for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) ) + if( compare(userid, tmp->userid) == 0 ) + break; + iter->destroy(iter); + + if( tmp == NULL ) + {// entry not found + return false; + } + + // store it + memcpy(acc, tmp, sizeof(struct mmo_account)); + + return true; +} + + +/// Returns a new forward iterator. +static AccountDBIterator* account_db_txt_iterator(AccountDB* self) +{ + AccountDB_TXT* db = (AccountDB_TXT*)self; + DBMap* accounts = db->accounts; + AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)aCalloc(1, sizeof(AccountDBIterator_TXT)); + + // set up the vtable + iter->vtable.destroy = &account_db_txt_iter_destroy; + iter->vtable.next = &account_db_txt_iter_next; + + // fill data + iter->iter = db_iterator(accounts); + + return &iter->vtable; +} + + +/// Destroys this iterator, releasing all allocated memory (including itself). +static void account_db_txt_iter_destroy(AccountDBIterator* self) +{ + AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self; + dbi_destroy(iter->iter); + aFree(iter); +} + + +/// Fetches the next account in the database. +static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc) +{ + AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self; + struct mmo_account* tmp = (struct mmo_account*)dbi_next(iter->iter); + if( dbi_exists(iter->iter) ) + { + memcpy(acc, tmp, sizeof(struct mmo_account)); + return true; + } + return false; +} + + +/// parse input string into the provided account data structure +static bool mmo_auth_fromstr(struct mmo_account* a, char* str, unsigned int version) +{ + char* fields[32]; + int count; + char* regs; + int i, n; + + // zero out the destination first + memset(a, 0x00, sizeof(struct mmo_account)); + + // extract tab-separated columns from line + count = sv_split(str, strlen(str), 0, '\t', fields, ARRAYLENGTH(fields), SV_NOESCAPE_NOTERMINATE); + + if( version == ACCOUNT_TXT_DB_VERSION && count == 13 ) + { + a->account_id = strtol(fields[1], NULL, 10); + safestrncpy(a->userid, fields[2], sizeof(a->userid)); + safestrncpy(a->pass, fields[3], sizeof(a->pass)); + a->sex = fields[4][0]; + safestrncpy(a->email, fields[5], sizeof(a->email)); + a->level = strtoul(fields[6], NULL, 10); + a->state = strtoul(fields[7], NULL, 10); + a->unban_time = strtol(fields[8], NULL, 10); + a->expiration_time = strtol(fields[9], NULL, 10); + a->logincount = strtoul(fields[10], NULL, 10); + safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin)); + safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip)); + regs = fields[13]; + } + else + if( version == 0 && count == 14 ) + { + a->account_id = strtol(fields[1], NULL, 10); + safestrncpy(a->userid, fields[2], sizeof(a->userid)); + safestrncpy(a->pass, fields[3], sizeof(a->pass)); + safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); + a->sex = fields[5][0]; + a->logincount = strtoul(fields[6], NULL, 10); + a->state = strtoul(fields[7], NULL, 10); + safestrncpy(a->email, fields[8], sizeof(a->email)); + //safestrncpy(a->error_message, fields[9], sizeof(a->error_message)); + a->expiration_time = strtol(fields[10], NULL, 10); + safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip)); + //safestrncpy(a->memo, fields[12], sizeof(a->memo)); + a->unban_time = strtol(fields[13], NULL, 10); + regs = fields[14]; + } + else + if( version == 0 && count == 13 ) + { + a->account_id = strtol(fields[1], NULL, 10); + safestrncpy(a->userid, fields[2], sizeof(a->userid)); + safestrncpy(a->pass, fields[3], sizeof(a->pass)); + safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); + a->sex = fields[5][0]; + a->logincount = strtoul(fields[6], NULL, 10); + a->state = strtoul(fields[7], NULL, 10); + safestrncpy(a->email, fields[8], sizeof(a->email)); + //safestrncpy(a->error_message, fields[9], sizeof(a->error_message)); + a->expiration_time = strtol(fields[10], NULL, 10); + safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip)); + //safestrncpy(a->memo, fields[12], sizeof(a->memo)); + regs = fields[13]; + } + else + if( version == 0 && count == 8 ) + { + a->account_id = strtol(fields[1], NULL, 10); + safestrncpy(a->userid, fields[2], sizeof(a->userid)); + safestrncpy(a->pass, fields[3], sizeof(a->pass)); + safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); + a->sex = fields[5][0]; + a->logincount = strtoul(fields[6], NULL, 10); + a->state = strtoul(fields[7], NULL, 10); + regs = fields[8]; + } + else + {// unmatched row + return false; + } + + // extract account regs + // {reg namereg value}* + n = 0; + for( i = 0; i < ACCOUNT_REG2_NUM; ++i ) + { + char key[32]; + char value[256]; + + regs += n; + + if (sscanf(regs, "%31[^\t,],%255[^\t ] %n", key, value, &n) != 2) + { + // We must check if a str is void. If it's, we can continue to read other REG2. + // Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good) + if (regs[0] == ',' && sscanf(regs, ",%[^\t ] %n", value, &n) == 1) { + i--; + continue; + } else + break; + } + + safestrncpy(a->account_reg2[i].str, key, 32); + safestrncpy(a->account_reg2[i].value, value, 256); + } + a->account_reg2_num = i; + + return true; +} + +/// dump the contents of the account data structure into the provided string buffer +static bool mmo_auth_tostr(const struct mmo_account* a, char* str) +{ + int i; + char* str_p = str; + + str_p += sprintf(str_p, "%d\t%s\t%s\t%c\t%s\t%u\t%u\t%ld\t%ld\t%u\t%s\t%s\t", + a->account_id, a->userid, a->pass, a->sex, a->email, a->level, + a->state, (long)a->unban_time, (long)a->expiration_time, + a->logincount, a->lastlogin, a->last_ip); + + for( i = 0; i < a->account_reg2_num; ++i ) + if( a->account_reg2[i].str[0] ) + str_p += sprintf(str_p, "%s,%s ", a->account_reg2[i].str, a->account_reg2[i].value); + + return true; +} + +/// dump the entire account db to disk +static void mmo_auth_sync(AccountDB_TXT* db) +{ + int lock; + FILE *fp; + struct DBIterator* iter; + struct mmo_account* acc; + + fp = lock_fopen(db->account_db, &lock); + if( fp == NULL ) + { + return; + } + + fprintf(fp, "%d\n", ACCOUNT_TXT_DB_VERSION); // savefile version + + fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n"); + fprintf(fp, "// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, repeated(register key, register value)\n"); + fprintf(fp, "// where:\n"); + fprintf(fp, "// sex : M or F for normal accounts, S for server accounts\n"); + fprintf(fp, "// level : this account's gm level\n"); + fprintf(fp, "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n"); + fprintf(fp, "// unban time : 0: no ban, : banned until the date (unix timestamp)\n"); + fprintf(fp, "// expiration time : 0: unlimited account, : account expires on the date (unix timestamp)\n"); + + //TODO: sort? + + iter = db->accounts->iterator(db->accounts); + for( acc = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); acc = (struct mmo_account*)iter->next(iter,NULL) ) + { + char buf[2048]; // ought to be big enough ^^ + mmo_auth_tostr(acc, buf); + fprintf(fp, "%s\n", buf); + } + fprintf(fp, "%d\t%%newid%%\n", db->next_account_id); + iter->destroy(iter); + + lock_fclose(fp, db->account_db, &lock); + + // reset save counter + db->auths_before_save = AUTHS_BEFORE_SAVE; +} + +static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr data) +{ + AccountDB_TXT* db = (AccountDB_TXT*)data; + + if( db->auths_before_save < AUTHS_BEFORE_SAVE ) + mmo_auth_sync(db); // db was modified, flush it + + return 0; +} diff --git a/src/login/admin.c b/src/login/admin.c index 9bce1a02f..c4116f16d 100644 --- a/src/login/admin.c +++ b/src/login/admin.c @@ -1,3 +1,6 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/core.h" @@ -10,6 +13,7 @@ #include "../common/version.h" #include "../common/md5calc.h" #include "../common/lock.h" +#include "account.h" #include "login.h" #include @@ -17,31 +21,72 @@ #include #include // for stat/lstat/fstat -extern struct Login_Config login_config; - #define MAX_SERVERS 30 extern struct mmo_char_server server[MAX_SERVERS]; -extern struct mmo_account* auth_dat; -extern uint32 auth_num; -extern int account_id_count; -extern char GM_account_filename[1024]; +extern AccountDB* accounts; int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len); -int search_account_index(char* account_name); -int mmo_auth_new(struct mmo_account* account); -void mmo_auth_sync(void); -int mmo_auth_tostr(char* str, struct mmo_account* p); -int read_gm_account(void); -void send_GM_accounts(int fd); -int isGM(int account_id); +bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass); +int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip); +int parse_admin(int fd); + + +bool ladmin_auth(struct login_session_data* sd, const char* ip) +{ + bool result = false; + + if( str2ip(ip) != host2ip(login_config.admin_allowed_host) ) + ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - IP isn't authorised (ip: %s).\n", ip); + else + if( !login_config.admin_state ) + ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (ip: %s)\n", ip); + else + if( !check_password(sd->md5key, sd->passwdenc, sd->passwd, login_config.admin_pass) ) + ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - invalid password (ip: %s)\n", ip); + else + { + ShowNotice("'ladmin'-login: Connection in administration mode accepted (ip: %s)\n", ip); + session[sd->fd]->func_parse = parse_admin; + result = true; + } + + return result; +} //--------------------------------------- // Packet parsing for administation login +// +// List of supported operations: +// 0x7530 - request server version (response: 0x7531) +// 0x7938 - request server list (response: 0x7939) +// 0x7920 - request entire list of accounts (response: 0x7921) +// 0x794e - request message broadcast (response: 0x794f + 0x2726) + +// 0x7930 - request account creation (response: 0x7931) +// 0x7932 - request account deletion (response: 0x7933 + 0x2730) + +// 0x7934 - request account password modification (response: 0x7935) +// 0x7936 - request account state modification (response: 0x7937 + 0x2731) +// 0x793a - request password check (response: 0x793b) +// 0x793c - request account sex modification (response: 0x793d + 0x2723) +// 0x793e - request account gm-level modification (response: 0x793f) +// 0x7940 - request account email modification (response: 0x7941) +// 0x7942 - request account memo modification (response: 0x7943) +// 0x7948 - request account expiration-time modification - absolute (response: 0x7949) +// 0x7950 - request account expiration-time modification - relative (response: 0x7951) +// 0x794a - request account unban-time modification - absolute (response: 0x794b + 0x2731) +// 0x794c - request account unban-time modification - relative (response: 0x794d + 0x2731) + +// 0x7944 - request account id lookup by name (response: 0x7945) +// 0x7946 - request account name lookup by id (response: 0x7947) +// 0x7952 - request account information lookup by name (response: 0x7953) +// 0x7954 - request account information lookup by id (response: 0x7953) //--------------------------------------- int parse_admin(int fd) { unsigned int i, j; char* account_name; + struct mmo_account acc; uint32 ipl = session[fd]->client_addr; char ip[16]; @@ -75,7 +120,7 @@ int parse_admin(int fd) WFIFOSET(fd,10); RFIFOSKIP(fd,2); break; - +/* case 0x7920: // Request of an accounts list if (RFIFOREST(fd) < 10) return 0; @@ -130,158 +175,145 @@ int parse_admin(int fd) DELETE_BUFFER(id); } break; - +*/ case 0x7930: // Request for an account creation if (RFIFOREST(fd) < 91) return 0; - { - struct mmo_account ma; - safestrncpy(ma.userid, (char*)RFIFOP(fd, 2), NAME_LENGTH); - safestrncpy(ma.pass, (char*)RFIFOP(fd,26), NAME_LENGTH); - safestrncpy(ma.email, (char*)RFIFOP(fd,51), 40); - memcpy(ma.lastlogin, "-", 2); - ma.sex = RFIFOB(fd,50); - RFIFOSKIP(fd,91); - - WFIFOW(fd,0) = 0x7931; - WFIFOL(fd,2) = 0xffffffff; // invalid account id - safestrncpy((char*)WFIFOP(fd,6), ma.userid, 24); - if (strlen(ma.userid) < 4 || strlen(ma.pass) < 4) { - ShowNotice("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n", ip); - } else if (ma.sex != 'F' && ma.sex != 'M') { - ShowNotice("'ladmin': Attempt to create an invalid account (account: %s, received pass: %s, invalid sex, ip: %s)\n", ma.userid, ma.pass, ip); - } else if (account_id_count > END_ACCOUNT_NUM) { - ShowNotice("'ladmin': Attempt to create an account, but there is no more available id number (account: %s, pass: %s, sex: %c, ip: %s)\n", ma.userid, ma.pass, ma.sex, ip); - } else { - remove_control_chars(ma.userid); - remove_control_chars(ma.pass); - remove_control_chars(ma.email); - ARR_FIND( 0, auth_num, i, strncmp(auth_dat[i].userid, ma.userid, 24) == 0 ); - if( i < auth_num ) - ShowNotice("'ladmin': Attempt to create an already existing account (account: %s, pass: %s, received pass: %s, ip: %s)\n", auth_dat[i].userid, auth_dat[i].pass, ma.pass, ip); - else - { - int new_id; - new_id = mmo_auth_new(&ma); - ShowNotice("'ladmin': Account creation (account: %s (id: %d), pass: %s, sex: %c, email: %s, ip: %s)\n", ma.userid, new_id, ma.pass, ma.sex, auth_dat[i].email, ip); - WFIFOL(fd,2) = new_id; - mmo_auth_sync(); - } - } - WFIFOSET(fd,30); - } + { + struct mmo_account ma; + safestrncpy(ma.userid, (char*)RFIFOP(fd, 2), sizeof(ma.userid)); + safestrncpy(ma.pass, (char*)RFIFOP(fd,26), sizeof(ma.pass)); + ma.sex = RFIFOB(fd,50); + safestrncpy(ma.email, (char*)RFIFOP(fd,51), sizeof(ma.email)); + safestrncpy(ma.lastlogin, "-", sizeof(ma.lastlogin)); + + ShowNotice("'ladmin': Account creation request (account: %s pass: %s, sex: %c, email: %s, ip: %s)\n", ma.userid, ma.pass, ma.sex, ma.email, ip); + + WFIFOW(fd,0) = 0x7931; + WFIFOL(fd,2) = mmo_auth_new(ma.userid, ma.pass, ma.sex, ip); + safestrncpy((char*)WFIFOP(fd,6), ma.userid, 24); + WFIFOSET(fd,30); + } + RFIFOSKIP(fd,91); break; - +/* case 0x7932: // Request for an account deletion if (RFIFOREST(fd) < 26) return 0; - WFIFOW(fd,0) = 0x7933; - WFIFOL(fd,2) = 0xFFFFFFFF; - account_name = (char*)RFIFOP(fd,2); + { + struct mmo_account acc; + + char* account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { + + WFIFOW(fd,0) = 0x7933; + + if( accounts->load_str(accounts, &acc, account_name) ) + { // Char-server is notified of deletion (for characters deletion). unsigned char buf[65535]; WBUFW(buf,0) = 0x2730; - WBUFL(buf,2) = auth_dat[i].account_id; + WBUFL(buf,2) = acc.account_id; charif_sendallwos(-1, buf, 6); + // send answer - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - WFIFOL(fd,2) = auth_dat[i].account_id; - // save deleted account in log file - ShowNotice("'ladmin': Account deletion (account: %s, id: %d, ip: %s) - saved in next line:\n", auth_dat[i].userid, auth_dat[i].account_id, ip); - mmo_auth_tostr((char*)buf, &auth_dat[i]); - ShowNotice("%s\n", buf); + memcpy(WFIFOP(fd,6), acc.userid, 24); + WFIFOL(fd,2) = acc.account_id; + // delete account - memset(auth_dat[i].userid, '\0', sizeof(auth_dat[i].userid)); + memset(acc.userid, '\0', sizeof(acc.userid)); auth_dat[i].account_id = -1; mmo_auth_sync(); } else { + WFIFOL(fd,2) = -1; memcpy(WFIFOP(fd,6), account_name, 24); ShowNotice("'ladmin': Attempt to delete an unknown account (account: %s, ip: %s)\n", account_name, ip); } WFIFOSET(fd,30); + } RFIFOSKIP(fd,26); break; - +*/ case 0x7934: // Request to change a password if (RFIFOREST(fd) < 50) return 0; - WFIFOW(fd,0) = 0x7935; - WFIFOL(fd,2) = 0xFFFFFFFF; /// WTF??? an unsigned being set to a -1 - account_name = (char*)RFIFOP(fd,2); + { + struct mmo_account acc; + + char* account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - memcpy(auth_dat[i].pass, RFIFOP(fd,26), 24); - auth_dat[i].pass[23] = '\0'; - remove_control_chars(auth_dat[i].pass); - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n", auth_dat[i].userid, auth_dat[i].pass, ip); - mmo_auth_sync(); - } else { - memcpy(WFIFOP(fd,6), account_name, 24); + + WFIFOW(fd,0) = 0x7935; + + if( accounts->load_str(accounts, &acc, account_name) ) + { + WFIFOL(fd,2) = acc.account_id; + safestrncpy((char*)WFIFOP(fd,6), acc.userid, 24); + safestrncpy(acc.pass, (char*)RFIFOP(fd,26), 24); + ShowNotice("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n", acc.userid, acc.pass, ip); + + accounts->save(accounts, &acc); + } + else + { + WFIFOL(fd,2) = -1; + safestrncpy((char*)WFIFOP(fd,6), account_name, 24); ShowNotice("'ladmin': Attempt to modify the password of an unknown account (account: %s, ip: %s)\n", account_name, ip); } + WFIFOSET(fd,30); + } RFIFOSKIP(fd,50); break; case 0x7936: // Request to modify a state if (RFIFOREST(fd) < 50) return 0; + { + struct mmo_account acc; + + char* account_name = (char*)RFIFOP(fd,2); + uint32 state = RFIFOL(fd,26); + account_name[23] = '\0'; + + WFIFOW(fd,0) = 0x7937; + + if( accounts->load_str(accounts, &acc, account_name) ) { - char error_message[20]; - uint32 statut; - WFIFOW(fd,0) = 0x7937; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - statut = RFIFOL(fd,26); - memcpy(error_message, RFIFOP(fd,30), 20); - error_message[19] = '\0'; - remove_control_chars(error_message); - if (statut != 7 || error_message[0] == '\0') { // 7: // 6 = Your are Prohibited to log in until %s - strcpy(error_message, "-"); - } - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - WFIFOL(fd,2) = auth_dat[i].account_id; - if (auth_dat[i].state == statut && strcmp(auth_dat[i].error_message, error_message) == 0) - ShowNotice("'ladmin': Modification of a state, but the state of the account is already the good state (account: %s, received state: %d, ip: %s)\n", account_name, statut, ip); - else { - if (statut == 7) - ShowNotice("'ladmin': Modification of a state (account: %s, new state: %d - prohibited to login until '%s', ip: %s)\n", auth_dat[i].userid, statut, error_message, ip); - else - ShowNotice("'ladmin': Modification of a state (account: %s, new state: %d, ip: %s)\n", auth_dat[i].userid, statut, ip); - if (auth_dat[i].state == 0) { - unsigned char buf[16]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = auth_dat[i].account_id; - WBUFB(buf,6) = 0; // 0: change of statut, 1: ban - WBUFL(buf,7) = statut; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - auth_dat[i].state = statut; - memcpy(auth_dat[i].error_message, error_message, 20); - mmo_auth_sync(); + memcpy(WFIFOP(fd,6), acc.userid, 24); + WFIFOL(fd,2) = acc.account_id; + + if (acc.state == state) + ShowNotice("'ladmin': Modification of a state, but the state of the account already has this value (account: %s, received state: %d, ip: %s)\n", account_name, state, ip); + else + { + ShowNotice("'ladmin': Modification of a state (account: %s, new state: %d, ip: %s)\n", acc.userid, state, ip); + + if (acc.state == 0) { + unsigned char buf[16]; + WBUFW(buf,0) = 0x2731; + WBUFL(buf,2) = acc.account_id; + WBUFB(buf,6) = 0; // 0: change of statut, 1: ban + WBUFL(buf,7) = state; // status or final date of a banishment + charif_sendallwos(-1, buf, 11); } - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n", account_name, statut, ip); + acc.state = state; + accounts->save(accounts, &acc); } - WFIFOL(fd,30) = statut; } + else + { + ShowNotice("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n", account_name, state, ip); + WFIFOL(fd,2) = -1; + memcpy(WFIFOP(fd,6), account_name, 24); + } + + WFIFOL(fd,30) = state; WFIFOSET(fd,34); + } RFIFOSKIP(fd,50); break; - +/* case 0x7938: // Request for servers list and # of online players { uint8 server_num = 0; @@ -312,18 +344,18 @@ int parse_admin(int fd) account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { + if( accounts->load_str(accounts, &acc, account_name) ) + { char pass[25]; memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); memcpy(pass, RFIFOP(fd,26), 24); pass[24] = '\0'; remove_control_chars(pass); - if (strcmp(auth_dat[i].pass, pass) == 0) { - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n", auth_dat[i].userid, auth_dat[i].pass, ip); + if (strcmp(acc.pass, pass) == 0) { + WFIFOL(fd,2) = acc.account_id; + ShowNotice("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n", acc.userid, acc.pass, ip); } else { - ShowNotice("'ladmin': Failure of password check (account: %s, proposed pass: %s, ip: %s)\n", auth_dat[i].userid, pass, ip); + ShowNotice("'ladmin': Failure of password check (account: %s, proposed pass: %s, ip: %s)\n", acc.userid, pass, ip); } } else { memcpy(WFIFOP(fd,6), account_name, 24); @@ -337,7 +369,7 @@ int parse_admin(int fd) if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793d; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // -1 account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); @@ -351,22 +383,25 @@ int parse_admin(int fd) else ShowNotice("'ladmin': Attempt to give an invalid sex (account: %s, received sex: 'control char', ip: %s)\n", account_name, ip); } else { - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - if (auth_dat[i].sex != ((sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm'))) { + if( accounts->load_str(accounts, &acc, account_name) ) + { + memcpy(WFIFOP(fd,6), acc.userid, 24); + if (acc.sex != sex) + { unsigned char buf[16]; - WFIFOL(fd,2) = auth_dat[i].account_id; - auth_dat[i].sex = (sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm'); - ShowNotice("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n", auth_dat[i].userid, sex, ip); - mmo_auth_sync(); + ShowNotice("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n", acc.userid, sex, ip); + + WFIFOL(fd,2) = acc.account_id; + acc.sex = sex; + accounts->save(accounts, &acc); + // send to all char-server the change WBUFW(buf,0) = 0x2723; - WBUFL(buf,2) = auth_dat[i].account_id; - WBUFB(buf,6) = auth_dat[i].sex; + WBUFL(buf,2) = acc.account_id; + WBUFB(buf,6) = acc.sex; charif_sendallwos(-1, buf, 7); } else { - ShowNotice("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n", auth_dat[i].userid, sex, ip); + ShowNotice("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n", acc.userid, sex, ip); } } else { ShowNotice("'ladmin': Attempt to modify the sex of an unknown account (account: %s, received sex: %c, ip: %s)\n", account_name, sex, ip); @@ -381,82 +416,31 @@ int parse_admin(int fd) if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793f; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // -1 account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); + { + char new_gm_level; + new_gm_level = RFIFOB(fd,26); + if( new_gm_level < 0 || new_gm_level > 99 ) + ShowNotice("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); + else + if( !accounts->load_str(accounts, &acc, account_name) ) + ShowNotice("'ladmin': Attempt to modify the GM level of an unknown account (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); + else { - char new_gm_level; - new_gm_level = RFIFOB(fd,26); - if (new_gm_level < 0 || new_gm_level > 99) { - ShowNotice("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); - } else { - i = search_account_index(account_name); - if (i != -1) { - int acc = auth_dat[i].account_id; - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - if (isGM(acc) != new_gm_level) { - // modification of the file - FILE *fp, *fp2; - int lock; - char line[512]; - int GM_account, GM_level; - int modify_flag; - char tmpstr[24]; - time_t raw_time; - if ((fp2 = lock_fopen(GM_account_filename, &lock)) != NULL) { - if ((fp = fopen(GM_account_filename, "r")) != NULL) { - time(&raw_time); - strftime(tmpstr, 23, login_config.date_format, localtime(&raw_time)); - modify_flag = 0; - // read/write GM file - while(fgets(line, sizeof(line), fp)) - { - while(line[0] != '\0' && (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r')) - line[strlen(line)-1] = '\0'; // TODO: remove this - if ((line[0] == '/' && line[1] == '/') || line[0] == '\0') - fprintf(fp2, "%s\n", line); - else { - if (sscanf(line, "%d %d", &GM_account, &GM_level) != 2 && sscanf(line, "%d: %d", &GM_account, &GM_level) != 2) - fprintf(fp2, "%s\n", line); - else if (GM_account != acc) - fprintf(fp2, "%s\n", line); - else if (new_gm_level < 1) { - fprintf(fp2, "// %s: 'ladmin' GM level removed on account %d '%s' (previous level: %d)\n//%d %d\n", tmpstr, acc, auth_dat[i].userid, GM_level, acc, new_gm_level); - modify_flag = 1; - } else { - fprintf(fp2, "// %s: 'ladmin' GM level on account %d '%s' (previous level: %d)\n%d %d\n", tmpstr, acc, auth_dat[i].userid, GM_level, acc, new_gm_level); - modify_flag = 1; - } - } - } - if (modify_flag == 0) - fprintf(fp2, "// %s: 'ladmin' GM level on account %d '%s' (previous level: 0)\n%d %d\n", tmpstr, acc, auth_dat[i].userid, acc, new_gm_level); - fclose(fp); - } else { - ShowNotice("'ladmin': Attempt to modify of a GM level - impossible to read GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n", auth_dat[i].userid, acc, (int)new_gm_level, ip); - } - if (lock_fclose(fp2, GM_account_filename, &lock) == 0) { - WFIFOL(fd,2) = acc; - ShowNotice("'ladmin': Modification of a GM level (account: %s (%d), new GM level: %d, ip: %s)\n", auth_dat[i].userid, acc, (int)new_gm_level, ip); - // read and send new GM informations - read_gm_account(); - send_GM_accounts(-1); - } else { - ShowNotice("'ladmin': Attempt to modify of a GM level - impossible to write GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n", auth_dat[i].userid, acc, (int)new_gm_level, ip); - } - } else { - ShowNotice("'ladmin': Attempt to modify of a GM level - impossible to write GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n", auth_dat[i].userid, acc, (int)new_gm_level, ip); - } - } else { - ShowNotice("'ladmin': Attempt to modify of a GM level, but the GM level is already the good GM level (account: %s (%d), GM level: %d, ip: %s)\n", auth_dat[i].userid, acc, (int)new_gm_level, ip); - } - } else { - ShowNotice("'ladmin': Attempt to modify the GM level of an unknown account (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); - } + memcpy(WFIFOP(fd,6), acc.userid, 24); + + if (isGM(acc.account_id) == new_gm_level) + ShowNotice("'ladmin': Attempt to modify of a GM level, but the GM level is already the good GM level (account: %s (%d), GM level: %d, ip: %s)\n", acc.userid, acc.account_id, (int)new_gm_level, ip); + else + { + //TODO: change level } } + } WFIFOSET(fd,30); RFIFOSKIP(fd,27); break; @@ -739,133 +723,131 @@ int parse_admin(int fd) case 0x7950: // Request to change the validity limite (timestamp) (relative change) if (RFIFOREST(fd) < 38) return 0; - { - time_t timestamp; - struct tm *tmtime; - char tmpstr[2048]; - char tmpstr2[2048]; - WFIFOW(fd,0) = 0x7951; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - WFIFOL(fd,2) = auth_dat[i].account_id; - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - timestamp = auth_dat[i].expiration_time; - if (timestamp == 0 || timestamp < time(NULL)) - timestamp = time(NULL); - tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26); - tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28); - tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30); - tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,32); - tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,34); - tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,36); - timestamp = mktime(tmtime); - if (timestamp != -1) { - strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); - strftime(tmpstr2, 24, login_config.date_format, localtime(×tamp)); - ShowNotice("'ladmin': Adjustment of a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "unlimited" : tmpstr2), ip); - auth_dat[i].expiration_time = timestamp; - mmo_auth_sync(); - WFIFOL(fd,30) = (unsigned long)auth_dat[i].expiration_time; - } else { - strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); - ShowNotice("'ladmin': Impossible to adjust a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip); - WFIFOL(fd,30) = 0; - } + { + time_t timestamp; + struct tm *tmtime; + char tmpstr[2048]; + char tmpstr2[2048]; + WFIFOW(fd,0) = 0x7951; + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? + account_name = (char*)RFIFOP(fd,2); + account_name[23] = '\0'; + remove_control_chars(account_name); + i = search_account_index(account_name); + if (i != -1) { + WFIFOL(fd,2) = auth_dat[i].account_id; + memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); + timestamp = auth_dat[i].expiration_time; + if (timestamp == 0 || timestamp < time(NULL)) + timestamp = time(NULL); + tmtime = localtime(×tamp); + tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26); + tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28); + tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30); + tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,32); + tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,34); + tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,36); + timestamp = mktime(tmtime); + if (timestamp != -1) { + strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); + strftime(tmpstr2, 24, login_config.date_format, localtime(×tamp)); + ShowNotice("'ladmin': Adjustment of a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "unlimited" : tmpstr2), ip); + auth_dat[i].expiration_time = timestamp; + mmo_auth_sync(); + WFIFOL(fd,30) = (unsigned long)auth_dat[i].expiration_time; } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n", account_name, ip); + strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); + ShowNotice("'ladmin': Impossible to adjust a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip); WFIFOL(fd,30) = 0; } + } else { + memcpy(WFIFOP(fd,6), account_name, 24); + ShowNotice("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n", account_name, ip); + WFIFOL(fd,30) = 0; } + WFIFOSET(fd,34); + } RFIFOSKIP(fd,38); break; - +*/ case 0x7952: // Request about informations of an account (by account name) if (RFIFOREST(fd) < 26) return 0; + { + struct mmo_account acc; + WFIFOW(fd,0) = 0x7953; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - WFIFOL(fd,2) = auth_dat[i].account_id; - WFIFOB(fd,6) = (unsigned char)isGM(auth_dat[i].account_id); - memcpy(WFIFOP(fd,7), auth_dat[i].userid, 24); - WFIFOB(fd,31) = auth_dat[i].sex; - WFIFOL(fd,32) = auth_dat[i].logincount; - WFIFOL(fd,36) = auth_dat[i].state; - memcpy(WFIFOP(fd,40), auth_dat[i].error_message, 20); - memcpy(WFIFOP(fd,60), auth_dat[i].lastlogin, 24); - memcpy(WFIFOP(fd,84), auth_dat[i].last_ip, 16); - memcpy(WFIFOP(fd,100), auth_dat[i].email, 40); - WFIFOL(fd,140) = (unsigned long)auth_dat[i].expiration_time; - WFIFOL(fd,144) = (unsigned long)auth_dat[i].unban_time; - WFIFOW(fd,148) = (uint16)strlen(auth_dat[i].memo); - if (auth_dat[i].memo[0]) { - memcpy(WFIFOP(fd,150), auth_dat[i].memo, strlen(auth_dat[i].memo)); - } - ShowNotice("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n", auth_dat[i].userid, auth_dat[i].account_id, ip); - WFIFOSET(fd,150+strlen(auth_dat[i].memo)); - } else { - memcpy(WFIFOP(fd,7), account_name, 24); - WFIFOW(fd,148) = 0; + + if( accounts->load_str(accounts, &acc, account_name) ) + { + ShowNotice("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n", acc.userid, acc.account_id, ip); + WFIFOL(fd,2) = acc.account_id; + WFIFOB(fd,6) = acc.level; + safestrncpy((char*)WFIFOP(fd,7), acc.userid, 24); + WFIFOB(fd,31) = acc.sex; + WFIFOL(fd,32) = acc.logincount; + WFIFOL(fd,36) = acc.state; + safestrncpy((char*)WFIFOP(fd,40), "-", 20); // error message (removed) + safestrncpy((char*)WFIFOP(fd,60), acc.lastlogin, 24); + safestrncpy((char*)WFIFOP(fd,84), acc.last_ip, 16); + safestrncpy((char*)WFIFOP(fd,100), acc.email, 40); + WFIFOL(fd,140) = (unsigned long)acc.expiration_time; + WFIFOL(fd,144) = (unsigned long)acc.unban_time; + WFIFOW(fd,148) = 0; // previously, this was strlen(memo), and memo went afterwards + } + else + { ShowNotice("'ladmin': Attempt to obtain information (by the name) of an unknown account (account: %s, ip: %s)\n", account_name, ip); - WFIFOSET(fd,150); + WFIFOL(fd,2) = -1; + safestrncpy((char*)WFIFOP(fd,7), account_name, 24); // not found } + + WFIFOSET(fd,150); + } RFIFOSKIP(fd,26); break; case 0x7954: // Request about information of an account (by account id) if (RFIFOREST(fd) < 6) return 0; + { + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + + WFIFOHEAD(fd,150); WFIFOW(fd,0) = 0x7953; - WFIFOL(fd,2) = RFIFOL(fd,2); - memset(WFIFOP(fd,7), '\0', 24); - for(i = 0; i < auth_num; i++) { - if (auth_dat[i].account_id == (int)RFIFOL(fd,2)) { - ShowNotice("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n", auth_dat[i].userid, RFIFOL(fd,2), ip); - WFIFOB(fd,6) = (unsigned char)isGM(auth_dat[i].account_id); - memcpy(WFIFOP(fd,7), auth_dat[i].userid, 24); - WFIFOB(fd,31) = auth_dat[i].sex; - WFIFOL(fd,32) = auth_dat[i].logincount; - WFIFOL(fd,36) = auth_dat[i].state; - memcpy(WFIFOP(fd,40), auth_dat[i].error_message, 20); - memcpy(WFIFOP(fd,60), auth_dat[i].lastlogin, 24); - memcpy(WFIFOP(fd,84), auth_dat[i].last_ip, 16); - memcpy(WFIFOP(fd,100), auth_dat[i].email, 40); - WFIFOL(fd,140) = (unsigned long)auth_dat[i].expiration_time; - WFIFOL(fd,144) = (unsigned long)auth_dat[i].unban_time; - WFIFOW(fd,148) = (uint16)strlen(auth_dat[i].memo); - if (auth_dat[i].memo[0]) { - memcpy(WFIFOP(fd,150), auth_dat[i].memo, strlen(auth_dat[i].memo)); - } - WFIFOSET(fd,150+strlen(auth_dat[i].memo)); - break; - } + WFIFOL(fd,2) = account_id; + + if( accounts->load_num(accounts, &acc, account_id) ) + { + ShowNotice("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n", acc.userid, account_id, ip); + WFIFOB(fd,6) = acc.level; + safestrncpy((char*)WFIFOP(fd,7), acc.userid, 24); + WFIFOB(fd,31) = acc.sex; + WFIFOL(fd,32) = acc.logincount; + WFIFOL(fd,36) = acc.state; + safestrncpy((char*)WFIFOP(fd,40), "-", 20); // error message (removed) + safestrncpy((char*)WFIFOP(fd,60), acc.lastlogin, 24); + safestrncpy((char*)WFIFOP(fd,84), acc.last_ip, 16); + safestrncpy((char*)WFIFOP(fd,100), acc.email, 40); + WFIFOL(fd,140) = (unsigned long)acc.expiration_time; + WFIFOL(fd,144) = (unsigned long)acc.unban_time; + WFIFOW(fd,148) = 0; // previously, this was strlen(memo), and memo went afterwards } - if (i == auth_num) { - ShowNotice("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n", RFIFOL(fd,2), ip); - strncpy((char*)WFIFOP(fd,7), "", 24); - WFIFOW(fd,148) = 0; - WFIFOSET(fd,150); + else + { + ShowNotice("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n", account_id, ip); + safestrncpy((char*)WFIFOP(fd,7), "", 24); // not found } - RFIFOSKIP(fd,6); - break; - case 0x7955: // Request to reload GM file (no answer) - ShowStatus("'ladmin': Request to re-load GM configuration file (ip: %s).\n", ip); - read_gm_account(); - // send GM accounts to all char-servers - send_GM_accounts(-1); - RFIFOSKIP(fd,2); + WFIFOSET(fd,150); + } + RFIFOSKIP(fd,6); break; default: diff --git a/src/login/ipban.h b/src/login/ipban.h new file mode 100644 index 000000000..b2a1a7d9e --- /dev/null +++ b/src/login/ipban.h @@ -0,0 +1,25 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef __IPBAN_H_INCLUDED__ +#define __IPBAN_H_INCLUDED__ + +#include "../common/cbasetypes.h" + +// initialize +void ipban_init(void); + +// finalize +void ipban_final(void); + +// check ip against ban list +bool ipban_check(uint32 ip); + +// increases failure count for the specified IP +void ipban_log(uint32 ip); + +// parses configuration option +bool ipban_config_read(const char* key, const char* value); + + +#endif // __IPBAN_H_INCLUDED__ diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c new file mode 100644 index 000000000..911ae23db --- /dev/null +++ b/src/login/ipban_sql.c @@ -0,0 +1,209 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/sql.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "login.h" +#include "ipban.h" +#include +#include + +// database options +static char ipban_db_hostname[32] = "127.0.0.1"; +static uint16 ipban_db_port = 3306; +static char ipban_db_username[32] = "ragnarok"; +static char ipban_db_password[32] = "ragnarok"; +static char ipban_db_database[32] = "ragnarok"; +static char ipban_table[32] = "ipbanlist"; + +static char log_db_hostname[32] = "127.0.0.1"; +static uint16 log_db_port = 3306; +static char log_db_username[32] = "ragnarok"; +static char log_db_password[32] = "ragnarok"; +static char log_db_database[32] = "ragnarok"; +static char loginlog_table[32] = "loginlog"; + +static char default_codepage[32] = ""; + +// globals +static Sql* sql_handle; +static Sql* logsql_handle; +static int cleanup_timer_id = INVALID_TIMER; + +int ipban_cleanup(int tid, unsigned int tick, int id, intptr data); + + +// initialize +void ipban_init(void) +{ + // establish connections + sql_handle = Sql_Malloc(); + if( SQL_ERROR == Sql_Connect(sql_handle, ipban_db_username, ipban_db_password, ipban_db_hostname, ipban_db_port, ipban_db_database) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(sql_handle); + exit(EXIT_FAILURE); + } + if( default_codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) + Sql_ShowDebug(sql_handle); + + logsql_handle = Sql_Malloc(); + if( SQL_ERROR == Sql_Connect(logsql_handle, log_db_username, log_db_password, log_db_hostname, log_db_port, log_db_database) ) + { + Sql_ShowDebug(logsql_handle); + Sql_Free(logsql_handle); + exit(EXIT_FAILURE); + } + if( default_codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(logsql_handle, default_codepage) ) + Sql_ShowDebug(logsql_handle); + + // set up periodic cleanup of connection history and active bans + add_timer_func_list(ipban_cleanup, "ipban_cleanup"); + cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, 60*1000); +} + +// finalize +void ipban_final(void) +{ + // release data + delete_timer(cleanup_timer_id, ipban_cleanup); + + // close connections + Sql_Free(sql_handle); + sql_handle = NULL; + Sql_Free(logsql_handle); + logsql_handle = NULL; +} + +// load configuration options +bool ipban_config_read(const char* key, const char* value) +{ + // login server settings + if( strcmpi(key, "ipban.enable") == 0 ) + login_config.ipban = (bool)config_switch(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban") == 0 ) + login_config.dynamic_pass_failure_ban = (bool)config_switch(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_interval") == 0 ) + login_config.dynamic_pass_failure_ban_interval = atoi(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_limit") == 0 ) + login_config.dynamic_pass_failure_ban_limit = atoi(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_duration") == 0 ) + login_config.dynamic_pass_failure_ban_duration = atoi(value); + else + + // ipban table settings + if( strcmpi(key, "ipban.sql.db_hostname") == 0 ) + safestrncpy(ipban_db_hostname, value, sizeof(ipban_db_hostname)); + else + if( strcmpi(key, "ipban.sql.db_port") == 0 ) + ipban_db_port = (uint16)strtoul(value, NULL, 10); + else + if( strcmpi(key, "ipban.sql.db_username") == 0 ) + safestrncpy(ipban_db_username, value, sizeof(ipban_db_username)); + else + if( strcmpi(key, "ipban.sql.db_password") == 0 ) + safestrncpy(ipban_db_password, value, sizeof(ipban_db_password)); + else + if( strcmpi(key, "ipban.sql.db_database") == 0 ) + safestrncpy(ipban_db_database, value, sizeof(ipban_db_database)); + else + if( strcmpi(key, "ipban.sql.ipban_table") == 0 ) + safestrncpy(ipban_table, value, sizeof(ipban_table)); + else + + // interserver settings + if( strcmpi(key, "log_db_ip") == 0 ) + safestrncpy(log_db_hostname, value, sizeof(log_db_hostname)); + else + if( strcmpi(key, "log_db_port") == 0 ) + log_db_port = (uint16)strtoul(value, NULL, 10); + else + if( strcmpi(key, "log_db_id") == 0 ) + safestrncpy(log_db_username, value, sizeof(log_db_username)); + else + if( strcmpi(key, "log_db_pw") == 0 ) + safestrncpy(log_db_password, value, sizeof(log_db_password)); + else + if( strcmpi(key, "log_db") == 0 ) + safestrncpy(log_db_database, value, sizeof(log_db_database)); + else + if( strcmpi(key, "loginlog_db") == 0 ) + safestrncpy(loginlog_table, value, sizeof(loginlog_table)); + else + if( strcmpi(key, "default_codepage") == 0 ) + safestrncpy(default_codepage, value, sizeof(default_codepage)); + else + return false; + + return true; +} + +// check ip against active bans list +bool ipban_check(uint32 ip) +{ + uint8* p = (uint8*)&ip; + char* data = NULL; + int matches; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u'", + ipban_table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) + { + Sql_ShowDebug(sql_handle); + // close connection because we can't verify their connectivity. + return true; + } + + if( SQL_ERROR == Sql_NextRow(sql_handle) ) + return true;// Shouldn't happen, but just in case... + + Sql_GetData(sql_handle, 0, &data, NULL); + matches = atoi(data); + Sql_FreeResult(sql_handle); + + return( matches > 0 ); +} + +// log failed attempt +void ipban_log(uint32 ip) +{ + unsigned long failures = 0; + if( SQL_ERROR == Sql_Query(logsql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%s' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", + loginlog_table, ip2str(ip,NULL), login_config.dynamic_pass_failure_ban_interval) )// how many times failed account? in one ip. + Sql_ShowDebug(sql_handle); + + //check query result + if( SQL_SUCCESS == Sql_NextRow(logsql_handle) ) + { + char* data; + Sql_GetData(logsql_handle, 0, &data, NULL); + failures = strtoul(data, NULL, 10); + Sql_FreeResult(logsql_handle); + } + + // if over the limit, add a temporary ban entry + if( failures >= login_config.dynamic_pass_failure_ban_limit ) + { + uint8* p = (uint8*)&ip; + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')", + ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration) ) + Sql_ShowDebug(sql_handle); + } +} + +// remove expired bans +int ipban_cleanup(int tid, unsigned int tick, int id, intptr data) +{ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") ) + Sql_ShowDebug(sql_handle); + + return 0; +} diff --git a/src/login/ipban_txt.c b/src/login/ipban_txt.c new file mode 100644 index 000000000..6fee15c28 --- /dev/null +++ b/src/login/ipban_txt.c @@ -0,0 +1,50 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/strlib.h" +#include "login.h" +#include "ipban.h" +#include +#include + +void ipban_init(void) +{ +} + +void ipban_final(void) +{ +} + +bool ipban_check(uint32 ip) +{ + return false; +} + +void ipban_log(uint32 ip) +{ +} + +bool ipban_config_read(const char* key, const char* value) +{ + // login server settings + if( strcmpi(key, "ipban.enable") == 0 ) + login_config.ipban = (bool)config_switch(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban") == 0 ) + login_config.dynamic_pass_failure_ban = (bool)config_switch(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_interval") == 0 ) + login_config.dynamic_pass_failure_ban_interval = atoi(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_limit") == 0 ) + login_config.dynamic_pass_failure_ban_limit = atoi(value); + else + if( strcmpi(key, "ipban.dynamic_pass_failure_ban_duration") == 0 ) + login_config.dynamic_pass_failure_ban_duration = atoi(value); + else + return false; + + return true; +} + diff --git a/src/login/login.c b/src/login/login.c index b26256570..2db051807 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1,25 +1,25 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/mmo.h" #include "../common/core.h" -#include "../common/socket.h" #include "../common/db.h" -#include "../common/timer.h" #include "../common/malloc.h" -#include "../common/strlib.h" +#include "../common/md5calc.h" #include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" #include "../common/version.h" -#include "../common/md5calc.h" -#include "../common/lock.h" +#include "account.h" +#include "ipban.h" #include "login.h" +#include "loginlog.h" #include #include #include -#include // for stat/lstat/fstat +bool ladmin_auth(struct login_session_data* sd, const char* ip); struct Login_Config login_config; int login_fd; // login server socket @@ -29,6 +29,42 @@ struct mmo_char_server server[MAX_SERVERS]; // char server data #define sex_num2str(num) ( (num == 0 ) ? 'F' : (num == 1 ) ? 'M' : 'S' ) #define sex_str2num(str) ( (str == 'F' ) ? 0 : (str == 'M' ) ? 1 : 2 ) +// Account engines available +static struct{ + AccountDB* (*constructor)(void); + AccountDB* db; +} account_engines[] = { +#ifdef WITH_TXT + {account_db_txt, NULL}, +#endif +#ifdef WITH_SQL + {account_db_sql, NULL}, +#endif +#ifdef ACCOUNTDB_ENGINE_0 + {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_0), NULL}, +#endif +#ifdef ACCOUNTDB_ENGINE_1 + {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_1), NULL}, +#endif +#ifdef ACCOUNTDB_ENGINE_2 + {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_2), NULL}, +#endif +#ifdef ACCOUNTDB_ENGINE_3 + {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_3), NULL}, +#endif +#ifdef ACCOUNTDB_ENGINE_4 + {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_4), NULL}, +#endif + // end of structure + {NULL, NULL} +}; +// account database +AccountDB* accounts = NULL; + +//Account registration flood protection [Kevin] +int allowed_regs = 1; +int time_allowed = 10; //in seconds + // Advanced subnet check [LuzZza] struct s_subnet { uint32 mask; @@ -38,45 +74,6 @@ struct s_subnet { int subnet_count = 0; -// GM account management -struct gm_account* gm_account_db = NULL; -unsigned int GM_num = 0; // number of gm accounts -char GM_account_filename[1024] = "conf/GM_account.txt"; -long creation_time_GM_account_file; // tracks the last-changed timestamp of the gm accounts file -int gm_account_filename_check_timer = 15; // Timer to check if GM_account file has been changed and reload GM account automaticaly (in seconds; default: 15) - -//Account registration flood protection [Kevin] -int allowed_regs = 1; -int time_allowed = 10; //in seconds -unsigned int new_reg_tick = 0; - - -// data handling (TXT) -char account_filename[1024] = "save/account.txt"; - -// account database -struct mmo_account* auth_dat = NULL; -unsigned int auth_num = 0, auth_max = 0; - -int account_id_count = START_ACCOUNT_NUM; - -// define the number of times that some players must authentify them before to save account file. -// it's just about normal authentication. If an account is created or modified, save is immediatly done. -// An authentication just change last connected IP and date. It already save in log file. -// set minimum auth change before save: -#define AUTH_BEFORE_SAVE_FILE 10 -// set divider of auth_num to found number of change before save -#define AUTH_SAVE_FILE_DIVIDER 50 -int auth_before_save_file = 0; // Counter. First save when 1st char-server do connection. - - -// ladmin configuration -bool admin_state = false; -char admin_pass[24] = ""; -uint32 admin_allowed_ip = 0; - -int parse_admin(int fd); - //----------------------------------------------------- // Auth database @@ -84,6 +81,7 @@ int parse_admin(int fd); #define AUTH_TIMEOUT 30000 struct auth_node { + int account_id; uint32 login_id1; uint32 login_id2; @@ -93,11 +91,12 @@ struct auth_node { static DBMap* auth_db; // int account_id -> struct auth_node* + //----------------------------------------------------- // Online User Database [Wizputer] //----------------------------------------------------- - struct online_login_data { + int account_id; int waiting_disconnect; int char_server; @@ -157,582 +156,61 @@ static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr d return 0; } -//-------------------------------------------------------------------- -// Packet send to all char-servers, except one (wos: without our self) -//-------------------------------------------------------------------- -int charif_sendallwos(int sfd, uint8* buf, size_t len) +static int online_db_setoffline(DBKey key, void* data, va_list ap) { - int i, c; - - for( i = 0, c = 0; i < MAX_SERVERS; ++i ) + struct online_login_data* p = (struct online_login_data*)data; + int server = va_arg(ap, int); + if( server == -1 ) { - int fd = server[i].fd; - if( session_isValid(fd) && fd != sfd ) + p->char_server = -1; + if( p->waiting_disconnect != -1 ) { - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - ++c; - } - } - - return c; -} - -//---------------------------------------------------------------------- -// Determine if an account (id) is a GM account -// and returns its level (or 0 if it isn't a GM account or if not found) -//---------------------------------------------------------------------- -int isGM(int account_id) -{ - unsigned int i; - ARR_FIND( 0, GM_num, i, gm_account_db[i].account_id == account_id ); - return ( i < GM_num ) ? gm_account_db[i].level : 0; -} - -//---------------------------------------------------------------------- -// Adds a new GM using acc id and level -//---------------------------------------------------------------------- -void addGM(int account_id, int level) -{ - static unsigned int GM_max = 0; - unsigned int i; - - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) - return; // no such account - - ARR_FIND( 0, GM_num, i, gm_account_db[i].account_id == account_id ); - if( i < GM_num ) - { - if (gm_account_db[i].level == level) - ShowWarning("addGM: GM account %d defined twice (same level: %d).\n", account_id, level); - else { - ShowWarning("addGM: GM account %d defined twice (levels: %d and %d).\n", account_id, gm_account_db[i].level, level); - gm_account_db[i].level = level; - } - return; // entry already present - } - - // new account - if (GM_num >= GM_max) { - GM_max += 256; - RECREATE(gm_account_db, struct gm_account, GM_max); - } - gm_account_db[GM_num].account_id = account_id; - gm_account_db[GM_num].level = level; - GM_num++; - if (GM_num >= 4000) - ShowWarning("4000 GM accounts found. Next GM accounts are not read.\n"); -} - -//------------------------------------------------------- -// Reading function of GM accounts file (and their level) -//------------------------------------------------------- -int read_gm_account(void) -{ - char line[512]; - FILE *fp; - int account_id, level; - int line_counter; - struct stat file_stat; - int start_range = 0, end_range = 0, is_range = 0, current_id = 0; - - if(gm_account_db) aFree(gm_account_db); - CREATE(gm_account_db, struct gm_account, 1); - GM_num = 0; - - // get last modify time/date - if (stat(GM_account_filename, &file_stat)) - creation_time_GM_account_file = 0; // error - else - creation_time_GM_account_file = (long)file_stat.st_mtime; - - if ((fp = fopen(GM_account_filename, "r")) == NULL) { - ShowError("read_gm_account: GM accounts file [%s] not found.\n", GM_account_filename); - return 1; - } - - line_counter = 0; - // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???) - // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows) - while(fgets(line, sizeof(line), fp) && GM_num < 4000) - { - line_counter++; - if ((line[0] == '/' && line[1] == '/') || line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - is_range = (sscanf(line, "%d%*[-~]%d %d",&start_range,&end_range,&level)==3); // ID Range [MC Cameri] - if (!is_range && sscanf(line, "%d %d", &account_id, &level) != 2 && sscanf(line, "%d: %d", &account_id, &level) != 2) - ShowError("read_gm_account: file [%s], invalid 'acount_id|range level' format (line #%d).\n", GM_account_filename, line_counter); - else if (level <= 0) - ShowError("read_gm_account: file [%s] %dth account (line #%d) (invalid level [0 or negative]: %d).\n", GM_account_filename, GM_num+1, line_counter, level); - else { - if (level > 99) { - ShowNotice("read_gm_account: file [%s] %dth account (invalid level, but corrected: %d->99).\n", GM_account_filename, GM_num+1, level); - level = 99; - } - if (is_range) { - if (start_range==end_range) - ShowError("read_gm_account: file [%s] invalid range, beginning of range is equal to end of range (line #%d).\n", GM_account_filename, line_counter); - else if (start_range>end_range) - ShowError("read_gm_account: file [%s] invalid range, beginning of range must be lower than end of range (line #%d).\n", GM_account_filename, line_counter); - else - for (current_id = start_range;current_id<=end_range;current_id++) - addGM(current_id,level); - } else { - addGM(account_id,level); - } + delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + p->waiting_disconnect = -1; } } - fclose(fp); - - ShowStatus("read_gm_account: file '%s' read (%d GM accounts found).\n", GM_account_filename, GM_num); - + else if( p->char_server == server ) + p->char_server = -2; //Char server disconnected. return 0; } - -//----------------------------------------------- -// Search an account id -// (return account index or -1 (if not found)) -// If exact account name is not found, -// the function checks without case sensitive -// and returns index if only 1 account is found -// and similar to the searched name. -//----------------------------------------------- -int search_account_index(char* account_name) +static int online_data_cleanup_sub(DBKey key, void *data, va_list ap) { - unsigned int i, quantity; - int index; - - quantity = 0; - index = -1; - - for(i = 0; i < auth_num; i++) { - // Without case sensitive check (increase the number of similar account names found) - if (stricmp(auth_dat[i].userid, account_name) == 0) { - // Strict comparison (if found, we finish the function immediatly with correct value) - if (strcmp(auth_dat[i].userid, account_name) == 0) - return i; - quantity++; - index = i; - } - } - // Here, the exact account name is not found - // We return the found index of a similar account ONLY if there is 1 similar account - if (quantity == 1) - return index; - - // Exact account name is not found and 0 or more than 1 similar accounts have been found ==> we say not found - return -1; + struct online_login_data *character= (struct online_login_data*)data; + if (character->char_server == -2) //Unknown server.. set them offline + remove_online_user(character->account_id); + return 0; } -//-------------------------------------------------------- -// Create a string to save the account in the account file -//-------------------------------------------------------- -int mmo_auth_tostr(char* str, struct mmo_account* p) +static int online_data_cleanup(int tid, unsigned int tick, int id, intptr data) { - int i; - char *str_p = str; - - str_p += sprintf(str_p, "%d\t%s\t%s\t%s\t%c\t%d\t%u\t%s\t%s\t%ld\t%s\t%s\t%ld\t", - p->account_id, p->userid, p->pass, p->lastlogin, p->sex, - p->logincount, p->state, p->email, p->error_message, - (long)p->expiration_time, p->last_ip, p->memo, (long)p->unban_time); - - for(i = 0; i < p->account_reg2_num; i++) - if (p->account_reg2[i].str[0]) - str_p += sprintf(str_p, "%s,%s ", p->account_reg2[i].str, p->account_reg2[i].value); - + online_db->foreach(online_db, online_data_cleanup_sub); return 0; -} +} + -//--------------------------------- -// Reading of the accounts database -//--------------------------------- -int mmo_auth_init(void) +//-------------------------------------------------------------------- +// Packet send to all char-servers, except one (wos: without our self) +//-------------------------------------------------------------------- +int charif_sendallwos(int sfd, uint8* buf, size_t len) { - FILE *fp; - int account_id; - uint32 state; - int logincount, n; - uint32 i, j; - char line[2048], *p, userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048]; - long unban_time; - long expiration_time; - char str[2048]; - char v[2048]; - int GM_count = 0; - int server_count = 0; - - auth_max = 256; - CREATE(auth_dat, struct mmo_account, auth_max); - - if ((fp = fopen(account_filename, "r")) == NULL) { - // no account file -> no account -> no login, including char-server (ERROR) - ShowError(CL_RED"mmmo_auth_init: Accounts file [%s] not found."CL_RESET"\n", account_filename); - return 0; - } + int i, c; - while(fgets(line, sizeof(line), fp) != NULL) + for( i = 0, c = 0; i < MAX_SERVERS; ++i ) { - if (line[0] == '/' && line[1] == '/') - continue; - - p = line; - - memset(userid, 0, sizeof(userid)); - memset(pass, 0, sizeof(pass)); - memset(lastlogin, 0, sizeof(lastlogin)); - memset(email, 0, sizeof(email)); - memset(error_message, 0, sizeof(error_message)); - memset(last_ip, 0, sizeof(last_ip)); - memset(memo, 0, sizeof(memo)); - - // database version reading (v2) - if (((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t" - "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n", - &account_id, userid, pass, lastlogin, &sex, &logincount, &state, - email, error_message, &expiration_time, last_ip, memo, &unban_time, &n)) == 13 && line[n] == '\t') || - ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t" - "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]%n", - &account_id, userid, pass, lastlogin, &sex, &logincount, &state, - email, error_message, &expiration_time, last_ip, memo, &n)) == 12 && line[n] == '\t')) { - n = n + 1; - - // Some checks - if (account_id > END_ACCOUNT_NUM) { - ShowError(CL_RED"mmmo_auth_init: an account has an id higher than %d\n", END_ACCOUNT_NUM); - ShowError(" account id #%d -> account not read (data is lost!)."CL_RESET"\n", account_id); - continue; - } - userid[23] = '\0'; - remove_control_chars(userid); - for(j = 0; j < auth_num; j++) { - if (auth_dat[j].account_id == account_id) { - ShowError(CL_RED"mmmo_auth_init: an account has an identical id to another.\n"); - ShowError(" account id #%d -> new account not read (data is lost!)."CL_RED"\n", account_id); - break; - } else if (strcmp(auth_dat[j].userid, userid) == 0) { - ShowError(CL_RED"mmmo_auth_init: account name already exists.\n"); - ShowError(" account name '%s' -> new account not read (data is lost!)."CL_RESET"\n", userid); // 2 lines, account name can be long. - break; - } - } - if (j != auth_num) - continue; - - if (auth_num >= auth_max) { - auth_max += 256; - auth_dat = (struct mmo_account*)aRealloc(auth_dat, sizeof(struct mmo_account) * auth_max); - } - - memset(&auth_dat[auth_num], '\0', sizeof(struct mmo_account)); - - auth_dat[auth_num].account_id = account_id; - - strncpy(auth_dat[auth_num].userid, userid, 24); - - pass[32] = '\0'; - remove_control_chars(pass); - strncpy(auth_dat[auth_num].pass, pass, 32); - - lastlogin[23] = '\0'; - remove_control_chars(lastlogin); - strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24); - - auth_dat[auth_num].sex = sex; - - if (logincount >= 0) - auth_dat[auth_num].logincount = logincount; - else - auth_dat[auth_num].logincount = 0; - - if (state > 255) - auth_dat[auth_num].state = 100; - else - auth_dat[auth_num].state = state; - - if (e_mail_check(email) == 0) { - ShowNotice("Account %s (%d): invalid e-mail (replaced par a@a.com).\n", auth_dat[auth_num].userid, auth_dat[auth_num].account_id); - strncpy(auth_dat[auth_num].email, "a@a.com", 40); - } else { - remove_control_chars(email); - strncpy(auth_dat[auth_num].email, email, 40); - } - - error_message[19] = '\0'; - remove_control_chars(error_message); - if (error_message[0] == '\0' || state != 7) { // 7, because state is packet 0x006a value + 1 - strncpy(auth_dat[auth_num].error_message, "-", 20); - } else { - strncpy(auth_dat[auth_num].error_message, error_message, 20); - } - - if (i == 13) - auth_dat[auth_num].unban_time = (time_t)unban_time; - else - auth_dat[auth_num].unban_time = 0; - - auth_dat[auth_num].expiration_time = (time_t)expiration_time; - - last_ip[15] = '\0'; - remove_control_chars(last_ip); - strncpy(auth_dat[auth_num].last_ip, last_ip, 16); - - memo[254] = '\0'; - remove_control_chars(memo); - strncpy(auth_dat[auth_num].memo, memo, 255); - - for(j = 0; j < ACCOUNT_REG2_NUM; j++) { - p += n; - if (sscanf(p, "%[^\t,],%[^\t ] %n", str, v, &n) != 2) { - // We must check if a str is void. If it's, we can continue to read other REG2. - // Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good) - if (p[0] == ',' && sscanf(p, ",%[^\t ] %n", v, &n) == 1) { - j--; - continue; - } else - break; - } - str[31] = '\0'; - remove_control_chars(str); - strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32); - strncpy(auth_dat[auth_num].account_reg2[j].value,v,256); - } - auth_dat[auth_num].account_reg2_num = j; - - if (isGM(account_id) > 0) - GM_count++; - if (auth_dat[auth_num].sex == 'S') - server_count++; - - auth_num++; - if (account_id >= account_id_count) - account_id_count = account_id + 1; - - // Old athena database version reading (v1) - } else if ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t%n", - &account_id, userid, pass, lastlogin, &sex, &logincount, &state, &n)) >= 5) { - if (account_id > END_ACCOUNT_NUM) { - ShowError(CL_RED"mmmo_auth_init: an account has an id higher than %d\n", END_ACCOUNT_NUM); - ShowError(" account id #%d -> account not read (data is lost!)."CL_RESET"\n", account_id); - continue; - } - userid[23] = '\0'; - remove_control_chars(userid); - for(j = 0; j < auth_num; j++) { - if (auth_dat[j].account_id == account_id) { - ShowError(CL_RED"mmo_auth_init: an account has an identical id to another.\n"); - ShowError(" account id #%d -> new account not read (data is lost!)."CL_RESET"\n", account_id); - break; - } else if (strcmp(auth_dat[j].userid, userid) == 0) { - ShowError(CL_RED"mmo_auth_init: account name already exists.\n"); - ShowError(" account name '%s' -> new account not read (data is lost!)."CL_RESET"\n", userid); - break; - } - } - if (j != auth_num) - continue; - - if (auth_num >= auth_max) { - auth_max += 256; - RECREATE(auth_dat, struct mmo_account, auth_max); - } - - memset(&auth_dat[auth_num], '\0', sizeof(struct mmo_account)); - - auth_dat[auth_num].account_id = account_id; - - strncpy(auth_dat[auth_num].userid, userid, 24); - - pass[23] = '\0'; - remove_control_chars(pass); - strncpy(auth_dat[auth_num].pass, pass, 24); - - lastlogin[23] = '\0'; - remove_control_chars(lastlogin); - strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24); - - auth_dat[auth_num].sex = sex; - - if (i >= 6) { - if (logincount >= 0) - auth_dat[auth_num].logincount = logincount; - else - auth_dat[auth_num].logincount = 0; - } else - auth_dat[auth_num].logincount = 0; - - if (i >= 7) { - if (state > 255) - auth_dat[auth_num].state = 100; - else - auth_dat[auth_num].state = state; - } else - auth_dat[auth_num].state = 0; - - // Initialization of new data - strncpy(auth_dat[auth_num].email, "a@a.com", 40); - strncpy(auth_dat[auth_num].error_message, "-", 20); - auth_dat[auth_num].unban_time = 0; - auth_dat[auth_num].expiration_time = 0; - strncpy(auth_dat[auth_num].last_ip, "-", 16); - strncpy(auth_dat[auth_num].memo, "-", 255); - - for(j = 0; j < ACCOUNT_REG2_NUM; j++) { - p += n; - if (sscanf(p, "%[^\t,],%[^\t ] %n", str, v, &n) != 2) { - // We must check if a str is void. If it's, we can continue to read other REG2. - // Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good) - if (p[0] == ',' && sscanf(p, ",%[^\t ] %n", v, &n) == 1) { - j--; - continue; - } else - break; - } - str[31] = '\0'; - remove_control_chars(str); - strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32); - strncpy(auth_dat[auth_num].account_reg2[j].value,v,256); - } - auth_dat[auth_num].account_reg2_num = j; - - if (isGM(account_id) > 0) - GM_count++; - if (auth_dat[auth_num].sex == 'S') - server_count++; - - auth_num++; - if (account_id >= account_id_count) - account_id_count = account_id + 1; - - } else { - int i = 0; - if (sscanf(line, "%d\t%%newid%%\n%n", &account_id, &i) == 1 && - i > 0 && account_id > account_id_count) - account_id_count = account_id; - } - } - fclose(fp); - - if( auth_num == 0 ) - ShowNotice("mmo_auth_init: No account found in %s.\n", account_filename); - else - if( auth_num == 1 ) - ShowStatus("mmo_auth_init: 1 account read in %s,\n", account_filename); - else - ShowStatus("mmo_auth_init: %d accounts read in %s,\n", auth_num, account_filename); - - if( GM_count == 0 ) - ShowStatus(" of which is no GM account, and \n"); - else - if( GM_count == 1 ) - ShowStatus(" of which is 1 GM account, and \n"); - else - ShowStatus(" of which is %d GM accounts, and \n", GM_count); - - if( server_count == 0 ) - ShowStatus(" no server account ('S').\n"); - else - if( server_count == 1 ) - ShowStatus(" 1 server account ('S').\n"); - else - ShowStatus(" %d server accounts ('S').\n", server_count); - - return 0; -} - -//------------------------------------------ -// Writing of the accounts database file -// (accounts are sorted by id before save) -//------------------------------------------ -void mmo_auth_sync(void) -{ - FILE *fp; - unsigned int i, j, k; - int lock; - int account_id; - CREATE_BUFFER(id, int, auth_num); - char line[65536]; - - // Sorting before save - for(i = 0; i < auth_num; i++) { - id[i] = i; - account_id = auth_dat[i].account_id; - for(j = 0; j < i; j++) { - if (account_id < auth_dat[id[j]].account_id) { - for(k = i; k > j; k--) - id[k] = id[k-1]; - id[j] = i; // id[i] - break; - } + int fd = server[i].fd; + if( session_isValid(fd) && fd != sfd ) + { + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + ++c; } } - // Data save - if ((fp = lock_fopen(account_filename, &lock)) == NULL) { - //if (id) aFree(id); - DELETE_BUFFER(id); - return; - } - - fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n"); - fprintf(fp, "// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value)\n"); - fprintf(fp, "// Some explanations:\n"); - fprintf(fp, "// account name : between 4 to 23 char for a normal account (standard client can't send less than 4 char).\n"); - fprintf(fp, "// account password: between 4 to 23 char\n"); - fprintf(fp, "// sex : M or F for normal accounts, S for server accounts\n"); - fprintf(fp, "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n"); - fprintf(fp, "// email : between 3 to 39 char (a@a.com is like no email)\n"); - fprintf(fp, "// error message : text for the state 7: 'Your are Prohibited to login until '. Max 19 char\n"); - fprintf(fp, "// valitidy time : 0: unlimited account, : date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"); - fprintf(fp, "// memo field : max 254 char\n"); - fprintf(fp, "// ban time : 0: no ban, : banned until the date: date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"); - for(i = 0; i < auth_num; i++) { - k = id[i]; // use of sorted index - if (auth_dat[k].account_id == -1) - continue; - - mmo_auth_tostr(line, &auth_dat[k]); - fprintf(fp, "%s\n", line); - } - fprintf(fp, "%d\t%%newid%%\n", account_id_count); - - lock_fclose(fp, account_filename, &lock); - - // set new counter to minimum number of auth before save - auth_before_save_file = auth_num / AUTH_SAVE_FILE_DIVIDER; // Re-initialise counter. We have save. - if (auth_before_save_file < AUTH_BEFORE_SAVE_FILE) - auth_before_save_file = AUTH_BEFORE_SAVE_FILE; - - //if (id) aFree(id); - DELETE_BUFFER(id); - - return; + return c; } -//----------------------------------------------------- -// Check if we must save accounts file or not -// every minute, we check if we must save because we -// have do some authentications without arrive to -// the minimum of authentications for the save. -// Note: all other modification of accounts (deletion, -// change of some informations excepted lastip/ -// lastlogintime, creation) are always save -// immediatly and set the minimum of -// authentications to its initialization value. -//----------------------------------------------------- -int check_auth_sync(int tid, unsigned int tick, int id, intptr data) -{ - // we only save if necessary: - // we have do some authentications without do saving - if (auth_before_save_file < AUTH_BEFORE_SAVE_FILE || - auth_before_save_file < (int)(auth_num / AUTH_SAVE_FILE_DIVIDER)) - mmo_auth_sync(); - - return 0; -} //----------------------------------------------------- // periodic ip address synchronization @@ -746,345 +224,148 @@ static int sync_ip_addresses(int tid, unsigned int tick, int id, intptr data) return 0; } -//----------------------------------------------------- -// Send GM accounts to one or all char-servers -//----------------------------------------------------- -void send_GM_accounts(int fd) -{ - unsigned int i; - uint8 buf[32767]; - uint16 len; - - len = 4; - WBUFW(buf,0) = 0x2732; - for(i = 0; i < GM_num; i++) - // send only existing accounts. We can not create a GM account when server is online. - if (gm_account_db[i].level > 0) { - WBUFL(buf,len) = gm_account_db[i].account_id; - WBUFB(buf,len+4) = (uint8)gm_account_db[i].level; - len += 5; - if (len >= 32000) { - ShowWarning("send_GM_accounts: Too many accounts! Only %d out of %d were sent.\n", i, GM_num); - break; - } - } - - WBUFW(buf,2) = len; - if (fd == -1) // send to all charservers - charif_sendallwos(-1, buf, len); - else { // send only to target - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - - return; -} - -//----------------------------------------------------- -// Check if GM file account have been changed -//----------------------------------------------------- -int check_GM_file(int tid, unsigned int tick, int id, intptr data) -{ - struct stat file_stat; - long new_time; - - // if we would not check - if (gm_account_filename_check_timer < 1) - return 0; - - // get last modify time/date - if (stat(GM_account_filename, &file_stat)) - new_time = 0; // error - else - new_time = (long)file_stat.st_mtime; - - if (new_time != creation_time_GM_account_file) { - read_gm_account(); - send_GM_accounts(-1); - } - - return 0; -} - //----------------------------------------------------- -// encrypted/unencrypted password check +// encrypted/unencrypted password check (from eApp) //----------------------------------------------------- bool check_encrypted(const char* str1, const char* str2, const char* passwd) { char md5str[64], md5bin[32]; - snprintf(md5str, sizeof(md5str), "%s%s", str1, str2); - md5str[sizeof(md5str)-1] = '\0'; + safesnprintf(md5str, sizeof(md5str), "%s%s", str1, str2); MD5_String2binary(md5str, md5bin); return (0==memcmp(passwd, md5bin, 16)); } -bool check_password(struct login_session_data* sd, int passwdenc, const char* passwd, const char* refpass) +bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass) { if(passwdenc == 0) { return (0==strcmp(passwd, refpass)); } - else if(sd != NULL) + else { - // password mode set to 1 -> (md5key, refpass) enable with - // password mode set to 2 -> (refpass, md5key) enable with + // password mode set to 1 -> md5(md5key, refpass) enable with + // password mode set to 2 -> md5(refpass, md5key) enable with - return ((passwdenc&0x01) && check_encrypted(sd->md5key, refpass, passwd)) || - ((passwdenc&0x02) && check_encrypted(refpass, sd->md5key, passwd)); + return ((passwdenc&0x01) && check_encrypted(md5key, refpass, passwd)) || + ((passwdenc&0x02) && check_encrypted(refpass, md5key, passwd)); } - return false; } -//------------------------------------- -// Make new account -//------------------------------------- -int mmo_auth_new(struct mmo_account* account) -{ - static int num_regs = 0; // registration counter - unsigned int tick = gettick(); - - time_t expiration_time = 0; - unsigned int i = auth_num; - - // check if the account doesn't exist already - ARR_FIND( 0, auth_num, i, strcmp(account->userid, auth_dat[i].userid) == 0 ); - if( i < auth_num ) - { - ShowNotice("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s)\n", account->userid, account->sex, auth_dat[i].pass, account->pass); - return 1; // 1 = Incorrect Password - } - - //Account Registration Flood Protection by [Kevin] - if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) - { - ShowNotice("Account registration denied (registration limit exceeded)\n"); - return 3; - } - - if (auth_num >= auth_max) { - auth_max += 256; - auth_dat = (struct mmo_account*)aRealloc(auth_dat, sizeof(struct mmo_account) * auth_max); - } - - memset(&auth_dat[i], '\0', sizeof(struct mmo_account)); - - // find a suitable non-gm account id - while (isGM(account_id_count) > 0) - account_id_count++; - - auth_dat[i].account_id = account_id_count++; - safestrncpy(auth_dat[i].userid, account->userid, NAME_LENGTH); - if( login_config.use_md5_passwds ) - MD5_String(account->pass, auth_dat[i].pass); - else - safestrncpy(auth_dat[i].pass, account->pass, NAME_LENGTH); - safestrncpy(auth_dat[i].lastlogin, "-", sizeof(auth_dat[i].lastlogin)); - auth_dat[i].sex = account->sex; - auth_dat[i].logincount = 0; - auth_dat[i].state = 0; - safestrncpy(auth_dat[i].email, e_mail_check(account->email) ? account->email : "a@a.com", sizeof(auth_dat[i].email)); - safestrncpy(auth_dat[i].error_message, "-", sizeof(auth_dat[i].error_message)); - auth_dat[i].unban_time = 0; - if( login_config.start_limited_time != -1 ) - expiration_time = time(NULL) + login_config.start_limited_time; - auth_dat[i].expiration_time = expiration_time; - strncpy(auth_dat[i].last_ip, "-", 16); - strncpy(auth_dat[i].memo, "-", 255); - auth_dat[i].account_reg2_num = 0; - - ShowNotice("Account creation (account %s, id: %d, pass: %s, sex: %c)\n", account->userid, auth_num, account->pass, account->sex); - auth_num++; - - if( DIFF_TICK(tick, new_reg_tick) > 0 ) - {// Update the registration check. - num_regs = 0; - new_reg_tick = tick + time_allowed*1000; - } - ++num_regs; - - return 0; -} - //----------------------------------------------------- -// Check/authentication of a connection +// custom timestamp formatting (from eApp) //----------------------------------------------------- -int mmo_auth(struct login_session_data* sd) +const char* timestamp2string(char* str, size_t size, time_t timestamp, const char* format) { - unsigned int i; - time_t raw_time; - char tmpstr[256]; - size_t len; - char user_password[32+1]; // reserve for md5-ed pw + size_t len = strftime(str, size, format, localtime(×tamp)); + memset(str + len, '\0', size - len); + return str; +} - char ip[16]; - ip2str(session[sd->fd]->client_addr, ip); - // DNS Blacklist check - if( login_config.use_dnsbl ) - { - char r_ip[16]; - char ip_dnsbl[256]; - char* dnsbl_serv; - bool matched = false; - uint8* sin_addr = (uint8*)&session[sd->fd]->client_addr; - - sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); +//-------------------------------------------- +// Test to know if an IP come from LAN or WAN. +//-------------------------------------------- +int lan_subnetcheck(uint32 ip) +{ + int i; + ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); + return ( i < subnet_count ) ? subnet[i].char_ip : 0; +} - for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) - { - sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); - if( host2ip(ip_dnsbl) ) - matched = true; - } +//---------------------------------- +// Reading Lan Support configuration +//---------------------------------- +int login_lan_config_read(const char *lancfgName) +{ + FILE *fp; + int line_num = 0; + char line[1024], w1[64], w2[64], w3[64], w4[64]; - if( matched ) - { - ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); - return 3; - } + if((fp = fopen(lancfgName, "r")) == NULL) { + ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName); + return 1; } - //Client Version check - if( login_config.check_client_version && sd->version != login_config.client_version_to_connect ) - return 5; - - len = strnlen(sd->userid, NAME_LENGTH); + ShowInfo("Reading the configuration file %s...\n", lancfgName); - // Account creation with _M/_F - if( login_config.new_account_flag ) + while(fgets(line, sizeof(line), fp)) { - if( len > 2 && strnlen(sd->passwd, NAME_LENGTH) > 0 && // valid user and password lengths - sd->passwdenc == 0 && // unencoded password - sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4) && // _M/_F suffix - account_id_count <= END_ACCOUNT_NUM ) - { - struct mmo_account acc; - int result; - - len -= 2; - sd->userid[len] = '\0'; - - memset(&acc, '\0', sizeof(acc)); - safestrncpy(acc.userid, sd->userid, NAME_LENGTH); - safestrncpy(acc.pass, sd->passwd, NAME_LENGTH); - safestrncpy(acc.email, "a@a.com", sizeof(acc.email)); - acc.sex = TOUPPER(sd->userid[len+1]); - - result = mmo_auth_new(&acc); - if( result ) - return result;// Failed to make account. [Skotlex]. + line_num++; + if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') + continue; - auth_before_save_file = 0; // Creation of an account -> save accounts file immediatly + if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) + { + ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); + continue; } - } - - // Strict account search - ARR_FIND( 0, auth_num, i, strcmp(sd->userid, auth_dat[i].userid) == 0 ); - - // if strict account search fails, we do a no sensitive case research for index - if( i < auth_num ) - { - i = search_account_index(sd->userid); - if( i == -1 ) - i = auth_num; - else - memcpy(sd->userid, auth_dat[i].userid, NAME_LENGTH); // for the possible tests/checks afterwards (copy correcte sensitive case). - } - if( i == auth_num ) - { - ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)\n", sd->userid, sd->passwd, ip); - return 0; // 0 = Unregistered ID - } - - if( login_config.use_md5_passwds ) - MD5_String(sd->passwd, user_password); - else - safestrncpy(user_password, sd->passwd, NAME_LENGTH); - - if( !check_password(sd, sd->passwdenc, user_password, auth_dat[i].pass) ) - { - ShowNotice("Invalid password (account: %s, pass: %s, received pass: %s, ip: %s)\n", sd->userid, auth_dat[i].pass, (sd->passwdenc) ? "[MD5]" : sd->passwd, ip); - return 1; // 1 = Incorrect Password - } - - if( auth_dat[i].expiration_time != 0 && auth_dat[i].expiration_time < time(NULL) ) - { - ShowNotice("Connection refused (account: %s, pass: %s, expired ID, ip: %s)\n", sd->userid, sd->passwd, ip); - return 2; // 2 = This ID is expired - } + if( strcmpi(w1, "subnet") == 0 ) + { + subnet[subnet_count].mask = str2ip(w2); + subnet[subnet_count].char_ip = str2ip(w3); + subnet[subnet_count].map_ip = str2ip(w4); - if( auth_dat[i].unban_time != 0 && auth_dat[i].unban_time > time(NULL) ) - { - strftime(tmpstr, 20, login_config.date_format, localtime(&auth_dat[i].unban_time)); - tmpstr[19] = '\0'; - ShowNotice("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)\n", sd->userid, sd->passwd, tmpstr, ip); - return 6; // 6 = Your are Prohibited to log in until %s - } + if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) + { + ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); + continue; + } - if( auth_dat[i].state ) - { - ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, auth_dat[i].state, ip); - return auth_dat[i].state - 1; + subnet_count++; + } } - ShowNotice("Authentication accepted (account: %s, id: %d, ip: %s)\n", sd->userid, auth_dat[i].account_id, ip); - - // auth start : time seed - time(&raw_time); - strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime(&raw_time)); + ShowStatus("Read information about %d subnetworks.\n", subnet_count); - sd->account_id = auth_dat[i].account_id; - sd->login_id1 = rand(); - sd->login_id2 = rand(); - safestrncpy(sd->lastlogin, auth_dat[i].lastlogin, 24); - sd->sex = auth_dat[i].sex; + fclose(fp); + return 0; +} - if( sd->sex != 'S' && sd->account_id < START_ACCOUNT_NUM ) - ShowWarning("Account %s has account id %d! Account IDs must be over %d to work properly!\n", sd->userid, sd->account_id, START_ACCOUNT_NUM); +//----------------------- +// Console Command Parser [Wizputer] +//----------------------- +int parse_console(char* buf) +{ + char command[256]; - safestrncpy(auth_dat[i].lastlogin, tmpstr, sizeof(auth_dat[i].lastlogin)); - safestrncpy(auth_dat[i].last_ip, ip, sizeof(auth_dat[i].last_ip)); - auth_dat[i].unban_time = 0; - auth_dat[i].logincount++; + memset(command, 0, sizeof(command)); - // Save until for change ip/time of auth is not very useful => limited save for that - // Save there informations isnot necessary, because they are saved in log file. - if (--auth_before_save_file <= 0) // Reduce counter. 0 or less, we save - mmo_auth_sync(); + sscanf(buf, "%[^\n]", command); - return -1; // account OK -} + ShowInfo("Console command :%s", command); -static int online_db_setoffline(DBKey key, void* data, va_list ap) -{ - struct online_login_data* p = (struct online_login_data*)data; - int server = va_arg(ap, int); - if( server == -1 ) - { - p->char_server = -1; - if( p->waiting_disconnect != -1 ) - { - delete_timer(p->waiting_disconnect, waiting_disconnect_timer); - p->waiting_disconnect = -1; - } + if( strcmpi("shutdown", command) == 0 || + strcmpi("exit", command) == 0 || + strcmpi("quit", command) == 0 || + strcmpi("end", command) == 0 ) + runflag = 0; + else + if( strcmpi("alive", command) == 0 || + strcmpi("status", command) == 0 ) + ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); + else + if( strcmpi("help", command) == 0 ) { + ShowInfo(CL_BOLD"Help of commands:"CL_RESET"\n"); + ShowInfo(" To shutdown the server:\n"); + ShowInfo(" 'shutdown|exit|quit|end'\n"); + ShowInfo(" To know if server is alive:\n"); + ShowInfo(" 'alive|status'\n"); } - else if( p->char_server == server ) - p->char_server = -2; //Char server disconnected. + return 0; } + //-------------------------------- // Packet parsing for char-servers //-------------------------------- int parse_fromchar(int fd) { - unsigned int i; int j, id; uint32 ipl; char ip[16]; @@ -1117,14 +398,6 @@ int parse_fromchar(int fd) switch( command ) { - case 0x2709: // request from map-server via char-server to reload GM accounts - RFIFOSKIP(fd,2); - ShowStatus("Char-server '%s': Request to re-load GM configuration file (ip: %s).\n", server[id].name, ip); - read_gm_account(); - // send GM accounts to all char-servers - send_GM_accounts(-1); - break; - case 0x2712: // request from char-server to authenticate an account if( RFIFOREST(fd) < 19 ) return 0; @@ -1132,8 +405,8 @@ int parse_fromchar(int fd) struct auth_node* node; int account_id = RFIFOL(fd,2); - int login_id1 = RFIFOL(fd,6); - int login_id2 = RFIFOL(fd,10); + uint32 login_id1 = RFIFOL(fd,6); + uint32 login_id2 = RFIFOL(fd,10); char sex = sex_num2str(RFIFOB(fd,14)); uint32 ip_ = ntohl(RFIFOL(fd,15)); RFIFOSKIP(fd,19); @@ -1146,51 +419,49 @@ int parse_fromchar(int fd) node->sex == sex && node->ip == ip_ ) {// found - uint32 expiration_time; - char email[40]; - unsigned int k; + struct mmo_account acc; + time_t expiration_time = 0; + const char* email = ""; + int gmlevel = 0; //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip); // each auth entry can only be used once idb_remove(auth_db, account_id); - // retrieve email and account expiration time - ARR_FIND( 0, auth_num, k, auth_dat[k].account_id == account_id ); - if( k < auth_num ) + // retrieve email and account expiration time and gm level + if( accounts->load_num(accounts, &acc, account_id) ) { - strcpy(email, auth_dat[k].email); - expiration_time = (uint32)auth_dat[k].expiration_time; - } - else - { - memset(email, 0, sizeof(email)); - expiration_time = 0; + email = acc.email; + expiration_time = acc.expiration_time; + gmlevel = acc.level; } // send ack - WFIFOHEAD(fd,59); + WFIFOHEAD(fd,60); WFIFOW(fd,0) = 0x2713; WFIFOL(fd,2) = account_id; WFIFOL(fd,6) = login_id1; WFIFOL(fd,10) = login_id2; WFIFOB(fd,14) = 0; - memcpy(WFIFOP(fd,15), email, 40); - WFIFOL(fd,55) = expiration_time; - WFIFOSET(fd,59); + safestrncpy((char*)WFIFOP(fd,15), email, 40); + WFIFOL(fd,55) = (uint32)expiration_time; + WFIFOB(fd,59) = gmlevel; + WFIFOSET(fd,60); } else {// authentication not found ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); - WFIFOHEAD(fd,59); + WFIFOHEAD(fd,60); WFIFOW(fd,0) = 0x2713; WFIFOL(fd,2) = account_id; WFIFOL(fd,6) = login_id1; WFIFOL(fd,10) = login_id2; WFIFOB(fd,14) = 1; - // It is unnecessary to send email - // It is unnecessary to send validity date of the account - WFIFOSET(fd,59); + //safestrncpy((char*)WFIFOP(fd,15), "", 40); + //WFIFOL(fd,55) = (uint32)0; + //WFIFOB(fd,59) = 0; + WFIFOSET(fd,60); } } break; @@ -1216,25 +487,23 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 46) return 0; { + struct mmo_account acc; char email[40]; - int acc = RFIFOL(fd,2); + + int account_id = RFIFOL(fd,2); safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); RFIFOSKIP(fd,46); if( e_mail_check(email) == 0 ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, acc, ip); + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); else - { - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == acc && (strcmp(auth_dat[i].email, "a@a.com") == 0 || auth_dat[i].email[0] == '\0') ); - if( i == auth_num ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, acc, ip); - else - { - memcpy(auth_dat[i].email, email, 40); - ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, acc, email, ip); - // Save - mmo_auth_sync(); - } + if( !accounts->load_num(accounts, &acc, account_id) || strcmp(acc.email, "a@a.com") == 0 || acc.email[0] == '\0' ) + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, account_id, ip); + else { + memcpy(acc.email, email, 40); + ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip); + // Save + accounts->save(accounts, &acc); } } break; @@ -1243,27 +512,30 @@ int parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - uint32 expiration_time = 0; + struct mmo_account acc; + time_t expiration_time = 0; char email[40] = ""; + int gmlevel = 0; int account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) - ShowNotice("Char-server '%s': e-mail of the account %d NOT found (ip: %s).\n", server[id].name, RFIFOL(fd,2), ip); + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': e-mail of the account %d NOT found (ip: %s).\n", server[id].name, account_id, ip); else { - safestrncpy(email, auth_dat[i].email, sizeof(email)); - expiration_time = (uint32)auth_dat[i].expiration_time; + safestrncpy(email, acc.email, sizeof(email)); + expiration_time = acc.expiration_time; + gmlevel = acc.level; } - WFIFOHEAD(fd,50); + WFIFOHEAD(fd,51); WFIFOW(fd,0) = 0x2717; WFIFOL(fd,2) = account_id; safestrncpy((char*)WFIFOP(fd,6), email, 40); - WFIFOL(fd,46) = expiration_time; - WFIFOSET(fd,50); + WFIFOL(fd,46) = (uint32)expiration_time; + WFIFOB(fd,50) = gmlevel; + WFIFOSET(fd,51); } break; @@ -1282,32 +554,34 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 86) return 0; { + struct mmo_account acc; char actual_email[40]; char new_email[40]; + int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); remove_control_chars(actual_email); - safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); remove_control_chars(new_email); + safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); + safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else if( e_mail_check(new_email) == 0 ) + else + if( e_mail_check(new_email) == 0 ) ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else if( strcmpi(new_email, "a@a.com") == 0 ) + else + if( strcmpi(new_email, "a@a.com") == 0 ) ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); + else + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip); + else + if( strcmpi(acc.email, actual_email) != 0 ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, acc.email, actual_email, ip); else { - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip); - else - if( strcmpi(auth_dat[i].email, actual_email) != 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, auth_dat[i].userid, auth_dat[i].email, actual_email, ip); - else { - safestrncpy(auth_dat[i].email, new_email, 40); - ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, auth_dat[i].userid, new_email, ip); - // Save - mmo_auth_sync(); - } + safestrncpy(acc.email, new_email, 40); + ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip); + // Save + accounts->save(accounts, &acc); } } break; @@ -1316,18 +590,25 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { + struct mmo_account acc; + int account_id = RFIFOL(fd,2); - uint32 state = RFIFOL(fd,6); + int state = RFIFOL(fd,6); RFIFOSKIP(fd,10); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) + if( !accounts->load_num(accounts, &acc, account_id) ) ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", server[id].name, account_id, state, ip); else - if( auth_dat[i].state == state ) + if( acc.state == state ) ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", server[id].name, account_id, state, ip); else { ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip); + + acc.state = state; + // Save + accounts->save(accounts, &acc); + + // notify other servers if (state != 0) { uint8 buf[11]; WBUFW(buf,0) = 0x2731; @@ -1336,9 +617,6 @@ int parse_fromchar(int fd) WBUFL(buf,7) = state; // status or final date of a banishment charif_sendallwos(-1, buf, 11); } - auth_dat[i].state = state; - // Save - mmo_auth_sync(); } } break; @@ -1347,6 +625,8 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 18) return 0; { + struct mmo_account acc; + int account_id = RFIFOL(fd,2); int year = (short)RFIFOW(fd,6); int month = (short)RFIFOW(fd,8); @@ -1356,24 +636,23 @@ int parse_fromchar(int fd) int sec = (short)RFIFOW(fd,16); RFIFOSKIP(fd,18); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) + if( !accounts->load_num(accounts, &acc, account_id) ) ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else { time_t timestamp; struct tm *tmtime; - if (auth_dat[i].unban_time == 0 || auth_dat[i].unban_time < time(NULL)) - timestamp = time(NULL); + if (acc.unban_time == 0 || acc.unban_time < time(NULL)) + timestamp = time(NULL); // new ban else - timestamp = auth_dat[i].unban_time; + timestamp = acc.unban_time; // add to existing ban tmtime = localtime(×tamp); tmtime->tm_year = tmtime->tm_year + year; - tmtime->tm_mon = tmtime->tm_mon + month; + tmtime->tm_mon = tmtime->tm_mon + month; tmtime->tm_mday = tmtime->tm_mday + mday; tmtime->tm_hour = tmtime->tm_hour + hour; - tmtime->tm_min = tmtime->tm_min + min; - tmtime->tm_sec = tmtime->tm_sec + sec; + tmtime->tm_min = tmtime->tm_min + min; + tmtime->tm_sec = tmtime->tm_sec + sec; timestamp = mktime(tmtime); if (timestamp == -1) ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); @@ -1382,18 +661,21 @@ int parse_fromchar(int fd) ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); else { - unsigned char buf[16]; - char tmpstr[2048]; - strftime(tmpstr, 24, login_config.date_format, localtime(×tamp)); + uint8 buf[11]; + char tmpstr[24]; + timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s).\n", server[id].name, account_id, timestamp, tmpstr, ip); + + acc.unban_time = timestamp; + + // Save + accounts->save(accounts, &acc); + WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = auth_dat[i].account_id; + WBUFL(buf,2) = account_id; WBUFB(buf,6) = 1; // 0: change of status, 1: ban - WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment + WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment charif_sendallwos(-1, buf, 11); - auth_dat[i].unban_time = timestamp; - // Save - mmo_auth_sync(); } } } @@ -1403,29 +685,32 @@ int parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { + struct mmo_account acc; + int account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) + if( !accounts->load_num(accounts, &acc, account_id) ) ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else - if( auth_dat[i].sex == 'S' ) + if( acc.sex == 'S' ) ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", server[id].name, account_id, ip); else { unsigned char buf[7]; - char sex = ( auth_dat[i].sex == 'M' ) ? 'F' : 'M'; //Change gender - - auth_dat[i].sex = sex; + char sex = ( acc.sex == 'M' ) ? 'F' : 'M'; //Change gender ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", server[id].name, account_id, sex, ip); + + acc.sex = sex; + // Save + accounts->save(accounts, &acc); + + // announce to other servers WBUFW(buf,0) = 0x2723; WBUFL(buf,2) = account_id; WBUFB(buf,6) = sex_str2num(sex); charif_sendallwos(-1, buf, 7); - // Save - mmo_auth_sync(); } } break; @@ -1434,37 +719,38 @@ int parse_fromchar(int fd) if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; { - int acc = RFIFOL(fd,4); + struct mmo_account acc; + + int account_id = RFIFOL(fd,4); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == acc ); - if( i == auth_num ) - ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, acc, ip); + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else { int len; int p; - ShowNotice("char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n", server[id].name, acc, ip); - for(j=0,p=13;jsave(accounts, &acc); // Sending information towards the other char-servers. RFIFOW(fd,0) = 0x2729;// reusing read buffer charif_sendallwos(fd, RFIFOP(fd,0), RFIFOW(fd,2)); RFIFOSKIP(fd,RFIFOW(fd,2)); - - // Save - mmo_auth_sync(); } - } break; @@ -1472,19 +758,21 @@ int parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { + struct mmo_account acc; + int account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) + if( !accounts->load_num(accounts, &acc, account_id) ) ShowNotice("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else - if( auth_dat[i].unban_time == 0 ) + if( acc.unban_time == 0 ) ShowNotice("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); else { - auth_dat[i].unban_time = 0; ShowNotice("Char-server '%s': UnBan request (account: %d, ip: %s).\n", server[id].name, account_id, ip); + acc.unban_time = 0; + accounts->save(accounts, &acc); } } break; @@ -1531,39 +819,32 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { + struct mmo_account acc; size_t off; int account_id = RFIFOL(fd,2); int char_id = RFIFOL(fd,6); RFIFOSKIP(fd,10); - WFIFOHEAD(fd,10000); + WFIFOHEAD(fd,ACCOUNT_REG2_NUM*sizeof(struct global_reg)); WFIFOW(fd,0) = 0x2729; WFIFOL(fd,4) = account_id; WFIFOL(fd,8) = char_id; WFIFOB(fd,12) = 1; //Type 1 for Account2 registry - ARR_FIND( 0, auth_num, i, auth_dat[i].account_id == account_id ); - if( i == auth_num ) - { - //Account not found? Send at least empty data, map servers need a reply! - WFIFOW(fd,2) = 13; - WFIFOSET(fd,WFIFOW(fd,2)); - break; - } - - for( off = 13, j = 0; j < auth_dat[i].account_reg2_num && off < 9000; j++ ) + off = 13; + if( accounts->load_num(accounts, &acc, account_id) ) { - if( auth_dat[i].account_reg2[j].str[0] != '\0' ) + for( j = 0; j < acc.account_reg2_num; j++ ) { - off += sprintf((char*)WFIFOP(fd,off), "%s", auth_dat[i].account_reg2[j].str)+1; //We add 1 to consider the '\0' in place. - off += sprintf((char*)WFIFOP(fd,off), "%s", auth_dat[i].account_reg2[j].value)+1; + if( acc.account_reg2[j].str[0] != '\0' ) + { + off += sprintf((char*)WFIFOP(fd,off), "%s", acc.account_reg2[j].str)+1; //We add 1 to consider the '\0' in place. + off += sprintf((char*)WFIFOP(fd,off), "%s", acc.account_reg2[j].value)+1; + } } } - if( off >= 9000 ) - ShowWarning("Too many account2 registries for AID %d. Some registries were not sent.\n", account_id); - WFIFOW(fd,2) = (uint16)off; WFIFOSET(fd,WFIFOW(fd,2)); } @@ -1577,31 +858,194 @@ int parse_fromchar(int fd) RFIFOSKIP(fd,6); break; - case 0x2737: //Request to set all offline. - ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, online_db_setoffline, id); - RFIFOSKIP(fd,2); - break; + case 0x2737: //Request to set all offline. + ShowInfo("Setting accounts from char-server %d offline.\n", id); + online_db->foreach(online_db, online_db_setoffline, id); + RFIFOSKIP(fd,2); + break; + + default: + ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); + set_eof(fd); + return 0; + } // switch + } // while + + RFIFOSKIP(fd,RFIFOREST(fd)); + return 0; +} + + +//------------------------------------- +// Make new account +//------------------------------------- +int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) +{ + static int num_regs = 0; // registration counter + static unsigned int new_reg_tick = 0; + unsigned int tick = gettick(); + struct mmo_account acc; + + //Account Registration Flood Protection by [Kevin] + if( new_reg_tick == 0 ) + new_reg_tick = gettick(); + if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) + { + ShowNotice("Account registration denied (registration limit exceeded)\n"); + return 3; + } + + // check for invalid inputs + if( sex != 'M' && sex != 'F' ) + return 0; // 0 = Unregistered ID + + // check if the account doesn't exist already + if( accounts->load_str(accounts, &acc, userid) ) + { + ShowNotice("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s)\n", userid, sex, acc.pass, pass); + return 1; // 1 = Incorrect Password + } + + memset(&acc, '\0', sizeof(acc)); + acc.account_id = -1; // assigned by account db + safestrncpy(acc.userid, userid, sizeof(acc.userid)); + safestrncpy(acc.pass, pass, sizeof(acc.pass)); + acc.sex = sex; + safestrncpy(acc.email, "a@a.com", sizeof(acc.email)); + acc.expiration_time = ( login_config.start_limited_time != -1 ) ? time(NULL) + login_config.start_limited_time : 0; + safestrncpy(acc.lastlogin, "-", sizeof(acc.lastlogin)); + safestrncpy(acc.last_ip, last_ip, sizeof(acc.last_ip)); + + if( !accounts->create(accounts, &acc) ) + return 0; + + ShowNotice("Account creation (account %s, id: %d, pass: %s, sex: %c)\n", acc.userid, acc.account_id, acc.pass, acc.sex); + + if( DIFF_TICK(tick, new_reg_tick) > 0 ) + {// Update the registration check. + num_regs = 0; + new_reg_tick = tick + time_allowed*1000; + } + ++num_regs; + + return -1; +} + +//----------------------------------------------------- +// Check/authentication of a connection +//----------------------------------------------------- +int mmo_auth(struct login_session_data* sd) +{ + struct mmo_account acc; + int len; + + char ip[16]; + ip2str(session[sd->fd]->client_addr, ip); + + // DNS Blacklist check + if( login_config.use_dnsbl ) + { + char r_ip[16]; + char ip_dnsbl[256]; + char* dnsbl_serv; + bool matched = false; + uint8* sin_addr = (uint8*)&session[sd->fd]->client_addr; + + sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); + + for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) + { + sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); + if( host2ip(ip_dnsbl) ) + matched = true; + } + + if( matched ) + { + ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); + return 3; + } + } + + //Client Version check + if( login_config.check_client_version && sd->version != login_config.client_version_to_connect ) + return 5; + + len = strnlen(sd->userid, NAME_LENGTH); + + // Account creation with _M/_F + if( login_config.new_account_flag ) + { + if( len > 2 && strnlen(sd->passwd, NAME_LENGTH) > 0 && // valid user and password lengths + sd->passwdenc == 0 && // unencoded password + sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4) ) // _M/_F suffix + { + int result; + + // remove the _M/_F suffix + len -= 2; + sd->userid[len] = '\0'; + + result = mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip); + if( result != -1 ) + return result;// Failed to make account. [Skotlex]. + } + } + + if( !accounts->load_str(accounts, &acc, sd->userid) ) + { + ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)\n", sd->userid, sd->passwd, ip); + return 0; // 0 = Unregistered ID + } + + if( !check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) + { + ShowNotice("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", sd->userid, acc.pass, sd->passwd, ip); + return 1; // 1 = Incorrect Password + } + + if( acc.expiration_time != 0 && acc.expiration_time < time(NULL) ) + { + ShowNotice("Connection refused (account: %s, pass: %s, expired ID, ip: %s)\n", sd->userid, sd->passwd, ip); + return 2; // 2 = This ID is expired + } + + if( acc.unban_time != 0 && acc.unban_time > time(NULL) ) + { + char tmpstr[24]; + timestamp2string(tmpstr, sizeof(tmpstr), acc.unban_time, login_config.date_format); + ShowNotice("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)\n", sd->userid, sd->passwd, tmpstr, ip); + return 6; // 6 = Your are Prohibited to log in until %s + } + + if( acc.state != 0 ) + { + ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip); + return acc.state - 1; + } + + ShowNotice("Authentication accepted (account: %s, id: %d, ip: %s)\n", sd->userid, acc.account_id, ip); + + // update session data + sd->account_id = acc.account_id; + sd->login_id1 = rand(); + sd->login_id2 = rand(); + safestrncpy(sd->lastlogin, acc.lastlogin, sizeof(sd->lastlogin)); + sd->sex = acc.sex; + sd->level = acc.level; + + // update account data + timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), login_config.date_format); + safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip)); + acc.unban_time = 0; + acc.logincount++; - default: - ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); - set_eof(fd); - return 0; - } // switch - } // while + accounts->save(accounts, &acc); - RFIFOSKIP(fd,RFIFOREST(fd)); - return 0; -} + if( sd->sex != 'S' && sd->account_id < START_ACCOUNT_NUM ) + ShowWarning("Account %s has account id %d! Account IDs must be over %d to work properly!\n", sd->userid, sd->account_id, START_ACCOUNT_NUM); -//-------------------------------------------- -// Test to know if an IP come from LAN or WAN. -//-------------------------------------------- -int lan_subnetcheck(uint32 ip) -{ - int i; - ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); - return ( i < subnet_count ) ? subnet[i].char_ip : 0; + return -1; // account OK } void login_auth_ok(struct login_session_data* sd) @@ -1614,8 +1058,6 @@ void login_auth_ok(struct login_session_data* sd) struct auth_node* node; int i; - sd->level = isGM(sd->account_id); - if( sd->level < login_config.min_level_to_connect ) { ShowStatus("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d).\n", login_config.min_level_to_connect, sd->userid, sd->level); @@ -1673,6 +1115,8 @@ void login_auth_ok(struct login_session_data* sd) } } + login_log(ip, sd->userid, 100, "login ok"); + if( sd->level > 0 ) ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", sd->level, sd->userid); else @@ -1728,6 +1172,42 @@ void login_auth_ok(struct login_session_data* sd) void login_auth_failed(struct login_session_data* sd, int result) { int fd = sd->fd; + uint32 ip = session[fd]->client_addr; + + if (login_config.log_login) + { + const char* error; + switch( result ) { + case 0: error = "Unregistered ID."; break; // 0 = Unregistered ID + case 1: error = "Incorrect Password."; break; // 1 = Incorrect Password + case 2: error = "Account Expired."; break; // 2 = This ID is expired + case 3: error = "Rejected from server."; break; // 3 = Rejected from Server + case 4: error = "Blocked by GM."; break; // 4 = You have been blocked by the GM Team + case 5: error = "Not latest game EXE."; break; // 5 = Your Game's EXE file is not the latest version + case 6: error = "Banned."; break; // 6 = Your are Prohibited to log in until %s + case 7: error = "Server Over-population."; break; // 7 = Server is jammed due to over populated + case 8: error = "Account limit from company"; break; // 8 = No more accounts may be connected from this company + case 9: error = "Ban by DBA"; break; // 9 = MSI_REFUSE_BAN_BY_DBA + case 10: error = "Email not confirmed"; break; // 10 = MSI_REFUSE_EMAIL_NOT_CONFIRMED + case 11: error = "Ban by GM"; break; // 11 = MSI_REFUSE_BAN_BY_GM + case 12: error = "Working in DB"; break; // 12 = MSI_REFUSE_TEMP_BAN_FOR_DBWORK + case 13: error = "Self Lock"; break; // 13 = MSI_REFUSE_SELF_LOCK + case 14: error = "Not Permitted Group"; break; // 14 = MSI_REFUSE_NOT_PERMITTED_GROUP + case 15: error = "Not Permitted Group"; break; // 15 = MSI_REFUSE_NOT_PERMITTED_GROUP + case 99: error = "Account gone."; break; // 99 = This ID has been totally erased + case 100: error = "Login info remains."; break; // 100 = Login information remains at %s + case 101: error = "Hacking investigation."; break; // 101 = Account has been locked for a hacking investigation. Please contact the GM Team for more information + case 102: error = "Bug investigation."; break; // 102 = This account has been temporarily prohibited from login due to a bug-related investigation + case 103: error = "Deleting char."; break; // 103 = This character is being deleted. Login is temporarily unavailable for the time being + case 104: error = "Deleting spouse char."; break; // 104 = This character is being deleted. Login is temporarily unavailable for the time being + default : error = "Unknown Error."; break; + } + + login_log(ip, sd->userid, result, error); + } + + if( result == 1 && login_config.dynamic_pass_failure_ban ) + ipban_log(ip); // log failed password attempt WFIFOHEAD(fd,23); WFIFOW(fd,0) = 0x6a; @@ -1736,39 +1216,54 @@ void login_auth_failed(struct login_session_data* sd, int result) memset(WFIFOP(fd,3), '\0', 20); else {// 6 = Your are Prohibited to log in until %s - char tmpstr[20]; - int i = search_account_index(sd->userid); - time_t unban_time = ( i >= 0 ) ? auth_dat[i].unban_time : 0; - strftime(tmpstr, 20, login_config.date_format, localtime(&unban_time)); - safestrncpy((char*)WFIFOP(fd,3), tmpstr, 20); // ban timestamp goes here + struct mmo_account acc; + time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; + timestamp2string((char*)WFIFOP(fd,3), 20, unban_time, login_config.date_format); } WFIFOSET(fd,23); } + //---------------------------------------------------------------------------------------- // Default packet parsing (normal players or administation/char-server connection requests) //---------------------------------------------------------------------------------------- int parse_login(int fd) { - struct login_session_data* sd = session[fd]->session_data; + struct login_session_data* sd = (struct login_session_data*)session[fd]->session_data; int result; - uint32 ipl; + char ip[16]; + uint32 ipl = session[fd]->client_addr; + ip2str(ipl, ip); if( session[fd]->flag.eof ) { + ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip); do_close(fd); return 0; } - if( sd == NULL ) { - sd = CREATE(session[fd]->session_data, struct login_session_data, 1); + if( sd == NULL ) + { + // Perform ip-ban check + if( login_config.ipban && ipban_check(ipl) ) + { + ShowStatus("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", ip); + login_log(ipl, "unknown", -3, "ip banned"); + WFIFOHEAD(fd,23); + WFIFOW(fd,0) = 0x6a; + WFIFOB(fd,2) = 3; // 3 = Rejected from Server + WFIFOSET(fd,23); + set_eof(fd); + return 0; + } + + // create a session for this new connection + CREATE(session[fd]->session_data, struct login_session_data, 1); + sd = (struct login_session_data*)session[fd]->session_data; sd->fd = fd; } - ipl = session[fd]->client_addr; - ip2str(ipl, ip); - while( RFIFOREST(fd) >= 2 ) { uint16 command = RFIFOW(fd,0); @@ -1782,42 +1277,55 @@ int parse_login(int fd) RFIFOSKIP(fd,26); break; - case 0x0204: // New alive packet: structure: 0x204 .16B. (new ragexe from 22 june 2004) + // client md5 hash (binary) + case 0x0204: // S 0204 .16B (kRO 2004-05-31aSakexe langtype 0 and 6) if (RFIFOREST(fd) < 18) return 0; RFIFOSKIP(fd,18); break; - case 0x0064: // request client login - case 0x01dd: // request client login (encryption mode) - case 0x0277: // New login packet (kRO 2006-04-24aSakexe langtype 0) - case 0x02b0: // New login packet (kRO 2007-05-14aSakexe langtype 0) + // request client login + case 0x0064: // S 0064 .l .24B .24B .B + case 0x01dd: // S 01dd .l .24B .16B .B + case 0x0277: // S 0277 .l .24B .24B .29B .B (kRO 2006-04-24aSakexe langtype 0) + case 0x02b0: // S 02b0 .l .24B .24B .B .16S .13S .B (kRO 2007-05-14aSakexe langtype 0) { - size_t packet_len = RFIFOREST(fd); // assume no other packet was sent + size_t packet_len = RFIFOREST(fd); if( (command == 0x0064 && packet_len < 55) || (command == 0x01dd && packet_len < 47) || (command == 0x0277 && packet_len < 84) || (command == 0x02b0 && packet_len < 85) ) - return 0; - - // S 0064 .l .24B .24B .B - // S 01dd .l .24B .16B .B - // S 0277 .l .24B .24B .29B .B - // S 02b0 .l .24B .24B .30B .B - - sd->version = RFIFOL(fd,2); - safestrncpy(sd->userid, (char*)RFIFOP(fd,6), NAME_LENGTH); remove_control_chars(sd->userid); - if (command != 0x01dd) { + return 0; + } + { + int version = RFIFOL(fd,2); + char* userid = (char*)RFIFOP(fd,6); + char* passwd = (char*)RFIFOP(fd,30); + RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent + + sd->version = version; + safestrncpy(sd->userid, userid, NAME_LENGTH); + if( command != 0x01dd ) + { ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,30), NAME_LENGTH); remove_control_chars(sd->passwd); + safestrncpy(sd->passwd, passwd, NAME_LENGTH); + if( login_config.use_md5_passwds ) + MD5_String(sd->passwd, sd->passwd); sd->passwdenc = 0; - } else { + } + else + { ShowStatus("Request for connection (encryption mode) of %s (ip: %s).\n", sd->userid, ip); - memcpy(sd->passwd, RFIFOP(fd,30), 16); sd->passwd[16] = '\0'; // raw binary data here! + memcpy(sd->passwd, passwd, 16); sd->passwd[16] = '\0'; // raw binary data here! sd->passwdenc = PASSWORDENC; } - RFIFOSKIP(fd,packet_len); + + if( sd->passwdenc != 0 && login_config.use_md5_passwds ) + { + login_auth_failed(sd, 3); // send "rejected from server" + return 0; + } result = mmo_auth(sd); @@ -1852,25 +1360,26 @@ int parse_login(int fd) return 0; { char server_name[20]; + char message[256]; uint32 server_ip; uint16 server_port; uint16 maintenance; uint16 new_; - safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); //remove_control_chars(account.userid); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); //remove_control_chars(account.passwd); + safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); sd->passwdenc = 0; sd->version = login_config.client_version_to_connect; // hack to skip version check - server_ip = ntohl(RFIFOL(fd,54)); server_port = ntohs(RFIFOW(fd,58)); - - safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); remove_control_chars(server_name); + safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); maintenance = RFIFOW(fd,82); new_ = RFIFOW(fd,84); RFIFOSKIP(fd,86); - ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); + ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); + sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); + login_log(session[fd]->client_addr, sd->userid, 100, message); result = mmo_auth(sd); if( result == -1 && sd->sex == 'S' && sd->account_id < MAX_SERVERS && server[sd->account_id].fd == -1 ) @@ -1893,9 +1402,6 @@ int parse_login(int fd) WFIFOW(fd,0) = 0x2711; WFIFOB(fd,2) = 0; WFIFOSET(fd,3); - - // send GM account to char-server - send_GM_accounts(fd); } else { @@ -1926,57 +1432,25 @@ int parse_login(int fd) case 0x7918: // Request for administation login if ((int)RFIFOREST(fd) < 4 || (int)RFIFOREST(fd) < ((RFIFOW(fd,2) == 0) ? 28 : 20)) return 0; - WFIFOW(fd,0) = 0x7919; - WFIFOB(fd,2) = 1; - if( session[fd]->client_addr != admin_allowed_ip ) { - ShowNotice("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s).\n", ip); - } else { - struct login_session_data *ld = (struct login_session_data*)session[fd]->session_data; - if (RFIFOW(fd,2) == 0) { // non encrypted password - char password[25]; - memcpy(password, RFIFOP(fd,4), 24); - password[24] = '\0'; - remove_control_chars(password); - if( !admin_state ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (non encrypted password: %s, ip: %s)\n", password, ip); - else - if( strcmp(password, admin_pass) != 0) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - invalid password (non encrypted password: %s, ip: %s)\n", password, ip); - else { - // If remote administration is enabled and password sent by client matches password read from login server configuration file - ShowNotice("'ladmin'-login: Connection in administration mode accepted (non encrypted password: %s, ip: %s)\n", password, ip); - WFIFOB(fd,2) = 0; - session[fd]->func_parse = parse_admin; - } - } else { // encrypted password - if (!ld) - ShowError("'ladmin'-login: error! MD5 key not created/requested for an administration login.\n"); - else { - char md5str[64] = "", md5bin[32]; - if (RFIFOW(fd,2) == 1) { - sprintf(md5str, "%s%s", ld->md5key, admin_pass); // 20 24 - } else if (RFIFOW(fd,2) == 2) { - sprintf(md5str, "%s%s", admin_pass, ld->md5key); // 24 20 - } - MD5_String2binary(md5str, md5bin); - if( !admin_state ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (encrypted password, ip: %s)\n", ip); - else - if( memcmp(md5bin, RFIFOP(fd,4), 16) != 0 ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - invalid password (encrypted password, ip: %s)\n", ip); - else { - // If remote administration is enabled and password hash sent by client matches hash of password read from login server configuration file - ShowNotice("'ladmin'-login: Connection in administration mode accepted (encrypted password, ip: %s)\n", ip); - ShowNotice("Connection of a remote administration accepted (encrypted password).\n"); - WFIFOB(fd,2) = 0; - session[fd]->func_parse = parse_admin; - } - } - } + { + int passwdenc = (int)RFIFOW(fd,2); + const char* passwd = (char*)RFIFOP(fd,4); + + if( passwdenc == 0 ) { // non encrypted password + safestrncpy(sd->passwd, passwd, NAME_LENGTH); + sd->passwdenc = 0; + } else { // encrypted password + memcpy(sd->passwd, passwd, 16); sd->passwd[16] = '\0'; // raw binary data here! + sd->passwdenc = passwdenc; } - WFIFOSET(fd,3); - RFIFOSKIP(fd, (RFIFOW(fd,2) == 0) ? 28 : 20); + RFIFOSKIP(fd, (passwdenc == 0) ? 28 : 20); + + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x7919; + WFIFOB(fd,2) = ladmin_auth(sd, ip) ? 0 : 1; + WFIFOSET(fd,3); + } break; default: @@ -1990,102 +1464,30 @@ int parse_login(int fd) return 0; } -//----------------------- -// Console Command Parser [Wizputer] -//----------------------- -int parse_console(char* buf) -{ - char command[256]; - - memset(command, 0, sizeof(command)); - - sscanf(buf, "%[^\n]", command); - - ShowInfo("Console command :%s", command); - - if( strcmpi("shutdown", command) == 0 || - strcmpi("exit", command) == 0 || - strcmpi("quit", command) == 0 || - strcmpi("end", command) == 0 ) - runflag = 0; - else - if( strcmpi("alive", command) == 0 || - strcmpi("status", command) == 0 ) - ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else - if( strcmpi("help", command) == 0 ) { - ShowInfo(CL_BOLD"Help of commands:"CL_RESET"\n"); - ShowInfo(" To shutdown the server:\n"); - ShowInfo(" 'shutdown|exit|quit|end'\n"); - ShowInfo(" To know if server is alive:\n"); - ShowInfo(" 'alive|status'\n"); - } - - return 0; -} - -static int online_data_cleanup_sub(DBKey key, void *data, va_list ap) -{ - struct online_login_data *character= (struct online_login_data*)data; - if (character->char_server == -2) //Unknown server.. set them offline - remove_online_user(character->account_id); - return 0; -} - -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr data) -{ - online_db->foreach(online_db, online_data_cleanup_sub); - return 0; -} -//---------------------------------- -// Reading Lan Support configuration -//---------------------------------- -int login_lan_config_read(const char *lancfgName) +void login_set_defaults() { - FILE *fp; - int line_num = 0; - char line[1024], w1[64], w2[64], w3[64], w4[64]; - - if((fp = fopen(lancfgName, "r")) == NULL) { - ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName); - return 1; - } - - ShowInfo("Reading the configuration file %s...\n", lancfgName); - - while(fgets(line, sizeof(line), fp)) - { - line_num++; - if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') - continue; - - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) - { - ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); - continue; - } - - if( strcmpi(w1, "subnet") == 0 ) - { - subnet[subnet_count].mask = str2ip(w2); - subnet[subnet_count].char_ip = str2ip(w3); - subnet[subnet_count].map_ip = str2ip(w4); - - if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) - { - ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); - continue; - } - - subnet_count++; - } - } - - ShowStatus("Read information about %d subnetworks.\n", subnet_count); + login_config.login_ip = INADDR_ANY; + login_config.login_port = 6900; + login_config.ip_sync_interval = 0; + login_config.log_login = true; + safestrncpy(login_config.date_format, "%Y-%m-%d %H:%M:%S", sizeof(login_config.date_format)); + login_config.console = false; + login_config.new_account_flag = true; + login_config.use_md5_passwds = false; + login_config.min_level_to_connect = 0; + login_config.online_check = true; + login_config.check_client_version = false; + login_config.client_version_to_connect = 20; - fclose(fp); - return 0; + login_config.ipban = true; + login_config.dynamic_pass_failure_ban = true; + login_config.dynamic_pass_failure_ban_interval = 5; + login_config.dynamic_pass_failure_ban_limit = 7; + login_config.dynamic_pass_failure_ban_duration = 5; + login_config.use_dnsbl = false; + safestrncpy(login_config.dnsbl_servs, "", sizeof(login_config.dnsbl_servs)); + safestrncpy(login_config.account_engine, "auto", sizeof(login_config.account_engine)); } //----------------------------------- @@ -2129,26 +1531,6 @@ int login_config_read(const char* cfgName) else if(!strcmpi(w1, "log_login")) login_config.log_login = (bool)config_switch(w2); - else if (strcmpi(w1, "admin_state") == 0) { - admin_state = (bool)config_switch(w2); - } else if (strcmpi(w1, "admin_pass") == 0) { - memset(admin_pass, 0, sizeof(admin_pass)); - strncpy(admin_pass, w2, sizeof(admin_pass)); - admin_pass[sizeof(admin_pass)-1] = '\0'; - } else if (strcmpi(w1, "admin_allowed_ip") == 0) - admin_allowed_ip = host2ip(w2); - else if (strcmpi(w1, "account_filename") == 0) { - memset(account_filename, 0, sizeof(account_filename)); - strncpy(account_filename, w2, sizeof(account_filename)); - account_filename[sizeof(account_filename)-1] = '\0'; - } else if (strcmpi(w1, "gm_account_filename") == 0) { - memset(GM_account_filename, 0, sizeof(GM_account_filename)); - strncpy(GM_account_filename, w2, sizeof(GM_account_filename)); - GM_account_filename[sizeof(GM_account_filename)-1] = '\0'; - } - else if (strcmpi(w1, "gm_account_filename_check_timer") == 0) - gm_account_filename_check_timer = atoi(w2); - else if(!strcmpi(w1, "new_account")) login_config.new_account_flag = (bool)config_switch(w2); else if(!strcmpi(w1, "start_limited_time")) @@ -2165,8 +1547,6 @@ int login_config_read(const char* cfgName) safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format)); else if(!strcmpi(w1, "console")) login_config.console = (bool)config_switch(w2); -// else if(!strcmpi(w1, "case_sensitive")) -// login_config.case_sensitive = config_switch(w2); else if(!strcmpi(w1, "allowed_regs")) //account flood protection system allowed_regs = atoi(w2); else if(!strcmpi(w1, "time_allowed")) @@ -2179,77 +1559,87 @@ int login_config_read(const char* cfgName) safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs)); else if(!strcmpi(w1, "ip_sync_interval")) login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes. + + else if(!strcmpi(w1, "admin_state")) + login_config.admin_state = (bool)config_switch(w2); + else if(!strcmpi(w1, "admin_pass")) + safestrncpy(login_config.admin_pass, w2, sizeof(login_config.admin_pass)); + else if(!strcmpi(w1, "admin_allowed_host")) + safestrncpy(login_config.admin_allowed_host, w2, sizeof(login_config.admin_pass)); + else if(!strcmpi(w1, "import")) login_config_read(w2); + else + if( ipban_config_read(w1, w2) ) + continue; + else if(!strcmpi(w1, "account.engine")) + safestrncpy(login_config.account_engine, w2, sizeof(login_config.account_engine)); + else + {// try the account engines + int i; + for( i = 0; account_engines[i].constructor; ++i ) + { + AccountDB* db = account_engines[i].db; + if( db && db->set_property(db, w1, w2) ) + break; + } + } } fclose(fp); ShowInfo("Finished reading %s.\n", cfgName); return 0; } -//------------------------------------- -// Displaying of configuration warnings -//------------------------------------- -void display_conf_warnings(void) +//----------------------------------- +// Reading interserver configuration file +//----------------------------------- +void inter_config_read(const char* cfgName) { - if( admin_state ) { - if (admin_pass[0] == '\0') { - ShowWarning("Administrator password is void (admin_pass).\n"); - } else if (strcmp(admin_pass, "admin") == 0) { - ShowWarning("You are using the default administrator password (admin_pass).\n"); - ShowWarning(" We highly recommend that you change it.\n"); - } - } - - if (gm_account_filename_check_timer < 0) { - ShowWarning("Invalid value for gm_account_filename_check_timer parameter. Setting to 15 sec (default).\n"); - gm_account_filename_check_timer = 15; - } else if (gm_account_filename_check_timer == 1) { - ShowWarning("Invalid value for gm_account_filename_check_timer parameter. Setting to 2 sec (minimum value).\n"); - gm_account_filename_check_timer = 2; + char line[1024], w1[1024], w2[1024]; + FILE* fp = fopen(cfgName, "r"); + if(fp == NULL) { + ShowError("file not found: %s\n", cfgName); + return; } + ShowInfo("reading configuration file %s...\n", cfgName); + while(fgets(line, sizeof(line), fp)) + { + if (line[0] == '/' && line[1] == '/') + continue; + if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) + continue; - if (login_config.min_level_to_connect < 0) { // 0: all players, 1-99 at least gm level x - ShowWarning("Invalid value for min_level_to_connect (%d) parameter -> setting 0 (any player).\n", login_config.min_level_to_connect); - login_config.min_level_to_connect = 0; - } else if (login_config.min_level_to_connect > 99) { // 0: all players, 1-99 at least gm level x - ShowWarning("Invalid value for min_level_to_connect (%d) parameter -> setting to 99 (only GM level 99)\n", login_config.min_level_to_connect); - login_config.min_level_to_connect = 99; - } + // settings common for multiple components + ipban_config_read(w1,w2); + loginlog_config_read(w1,w2); - if (login_config.start_limited_time < -1) { // -1: create unlimited account, 0 or more: additionnal sec from now to create limited time - ShowWarning("Invalid value for start_limited_time parameter\n"); - ShowWarning(" -> setting to -1 (new accounts are created with unlimited time).\n"); - login_config.start_limited_time = -1; + if (!strcmpi(w1, "import")) + inter_config_read(w2); } - - return; + fclose(fp); + ShowInfo("Done reading %s.\n", cfgName); } -void login_set_defaults() +/// Get the engine selected in the config settings. +/// Updates the config setting with the selected engine if 'auto'. +static AccountDB* get_account_engine(void) { - login_config.login_ip = INADDR_ANY; - login_config.login_port = 6900; - login_config.ip_sync_interval = 0; - login_config.log_login = true; - safestrncpy(login_config.date_format, "%Y-%m-%d %H:%M:%S", sizeof(login_config.date_format)); - login_config.console = false; - login_config.new_account_flag = true; -// login_config.case_sensitive = true; - login_config.use_md5_passwds = false; -// login_config.login_gm_read = true; - login_config.min_level_to_connect = 0; - login_config.online_check = true; - login_config.check_client_version = false; - login_config.client_version_to_connect = 20; + int i; + bool get_first = (strcmp(login_config.account_engine,"auto") == 0); -// login_config.ipban = true; -// login_config.dynamic_pass_failure_ban = true; -// login_config.dynamic_pass_failure_ban_interval = 5; -// login_config.dynamic_pass_failure_ban_limit = 7; -// login_config.dynamic_pass_failure_ban_duration = 5; - login_config.use_dnsbl = false; - safestrncpy(login_config.dnsbl_servs, "", sizeof(login_config.dnsbl_servs)); + for( i = 0; account_engines[i].constructor; ++i ) + { + char name[sizeof(login_config.account_engine)]; + AccountDB* db = account_engines[i].db; + if( db && db->get_property(db, "engine.name", name, sizeof(name)) && + (get_first || strcmp(name, login_config.account_engine) == 0) ) + { + if( get_first ) + safestrncpy(login_config.account_engine, name, sizeof(login_config.account_engine)); + return db; + } + } + return NULL; } //-------------------------------------- @@ -2258,15 +1648,28 @@ void login_set_defaults() void do_final(void) { int i, fd; + + login_log(0, "login server", 100, "login server shutdown"); ShowStatus("Terminating...\n"); - mmo_auth_sync(); + if( login_config.log_login ) + loginlog_final(); + + ipban_final(); + + for( i = 0; account_engines[i].constructor; ++i ) + {// destroy all account engines + AccountDB* db = account_engines[i].db; + if( db ) + { + db->destroy(db); + account_engines[i].db = NULL; + } + } + accounts = NULL; // destroyed in account_engines online_db->destroy(online_db, NULL); auth_db->destroy(auth_db, NULL); - if(auth_dat) aFree(auth_dat); - if(gm_account_db) aFree(gm_account_db); - for (i = 0; i < MAX_SERVERS; i++) { if ((fd = server[i].fd) >= 0) { memset(&server[i], 0, sizeof(struct mmo_char_server)); @@ -2299,20 +1702,27 @@ int do_init(int argc, char** argv) { int i; - login_set_defaults(); + // intialize engines (to accept config settings) + for( i = 0; account_engines[i].constructor; ++i ) + account_engines[i].db = account_engines[i].constructor(); // read login-server configuration + login_set_defaults(); login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); - display_conf_warnings(); // not in login_config_read, because we can use 'import' option, and display same message twice or more login_lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); + inter_config_read(INTER_CONF_NAME); srand((unsigned int)time(NULL)); for( i = 0; i < MAX_SERVERS; i++ ) server[i].fd = -1; - // Accounts database init - mmo_auth_init(); + // initialize logging + if( login_config.log_login ) + loginlog_init(); + + // initialize static and dynamic ipban system + ipban_init(); // Online user database init online_db = idb_alloc(DB_OPT_RELEASE_DATA); @@ -2321,21 +1731,9 @@ int do_init(int argc, char** argv) // Interserver auth init auth_db = idb_alloc(DB_OPT_RELEASE_DATA); - // Read account information. - read_gm_account(); - // set default parser as parse_login function set_defaultparse(parse_login); - add_timer_func_list(check_auth_sync, "check_auth_sync"); - add_timer_interval(gettick() + 60000, check_auth_sync, 0, 0, 60000); // every 60 sec we check if we must save accounts file (only if necessary to save) - - // every x sec we check if gm file has been changed - if( gm_account_filename_check_timer ) { - add_timer_func_list(check_GM_file, "check_GM_file"); - add_timer_interval(gettick() + gm_account_filename_check_timer * 1000, check_GM_file, 0, 0, gm_account_filename_check_timer * 1000); - } - // every 10 minutes cleanup online account db. add_timer_func_list(online_data_cleanup, "online_data_cleanup"); add_timer_interval(gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); @@ -2346,17 +1744,30 @@ int do_init(int argc, char** argv) add_timer_interval(gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); } + // Account database init + accounts = get_account_engine(); + if( accounts == NULL ) + { + ShowError("do_init: account engine '%s' not found.\n", login_config.account_engine); + runflag = 0; + return 1; + } + else + { + ShowInfo("Using account engine '%s'.\n", login_config.account_engine); + accounts->init(accounts); + } + if( login_config.console ) { //##TODO invoke a CONSOLE_START plugin event } - new_reg_tick = gettick(); - // server port open & binding login_fd = make_listen_bind(login_config.login_ip, login_config.login_port); ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); + login_log(0, "login server", 100, "login server started"); return 0; } diff --git a/src/login/login.h b/src/login/login.h index 1147d6bb6..8ffa06eec 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -7,6 +7,7 @@ #include "../common/mmo.h" // NAME_LENGTH #define LOGIN_CONF_NAME "conf/login_athena.conf" +#define INTER_CONF_NAME "conf/inter_athena.conf" #define LAN_CONF_NAME "conf/subnet_athena.conf" // supported encryption types: 1- passwordencrypt, 2- passwordencrypt2, 3- both @@ -38,9 +39,9 @@ struct mmo_char_server { int fd; uint32 ip; uint16 port; - uint16 users; // user count on this server - uint16 maintenance; // in maintenance mode? - uint16 new_; // allows creating new chars? + uint16 users; // user count on this server + uint16 maintenance; // in maintenance mode? + uint16 new_; // should display as 'new'? }; struct Login_Config { @@ -53,42 +54,28 @@ struct Login_Config { bool console; // console input system enabled? bool new_account_flag; // autoregistration via _M/_F ? int start_limited_time; // new account expiration time (-1: unlimited) -// bool case_sensitive; // are logins case sensitive ? bool use_md5_passwds; // work with password hashes instead of plaintext passwords? -// bool login_gm_read; // should the login server handle info about gm accounts? int min_level_to_connect; // minimum level of player/GM (0: player, 1-99: GM) to connect bool online_check; // reject incoming players that are already registered as online ? bool check_client_version; // check the clientversion set in the clientinfo ? int client_version_to_connect; // the client version needed to connect (if checking is enabled) -// bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? -// bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? -// unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures -// unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban -// unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban + bool admin_state; // is ladmin support enabled? + char admin_pass[24]; // security password for ladmin + char admin_allowed_host[32]; // host/ip that is allowed to connect as ladmin + + bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? + bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? + unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures + unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban + unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban bool use_dnsbl; // dns blacklist blocking ? char dnsbl_servs[1024]; // comma-separated list of dnsbl servers + char account_engine[256]; // name of the engine to use (defaults to auto, for the first available engine) }; -struct mmo_account { - - int account_id; - char sex; - char userid[24]; - char pass[32+1]; // 23+1 for normal, 32+1 for md5-ed passwords - char lastlogin[24]; - int logincount; - uint32 state; // packet 0x006a value + 1 (0: compte OK) - char email[40]; // e-mail (by default: a@a.com) - char error_message[20]; // Message of error code #6 = Your are Prohibited to log in until %s (packet 0x006a) - time_t unban_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - char last_ip[16]; // save of last IP of connection - char memo[255]; // a memo field - int account_reg2_num; - struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server) -}; +extern struct Login_Config login_config; #endif /* _LOGIN_H_ */ diff --git a/src/login/loginlog.h b/src/login/loginlog.h new file mode 100644 index 000000000..749d0fbf1 --- /dev/null +++ b/src/login/loginlog.h @@ -0,0 +1,14 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef __LOGINLOG_H_INCLUDED__ +#define __LOGINLOG_H_INCLUDED__ + + +void login_log(uint32 ip, const char* username, int rcode, const char* message); +bool loginlog_init(void); +bool loginlog_final(void); +bool loginlog_config_read(const char* w1, const char* w2); + + +#endif // __LOGINLOG_H_INCLUDED__ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c new file mode 100644 index 000000000..96bff6957 --- /dev/null +++ b/src/login/loginlog_sql.c @@ -0,0 +1,93 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include +#include // exit + +char log_db_ip[32] = "127.0.0.1"; +uint16 log_db_port = 3306; +char log_db_id[32] = "ragnarok"; +char log_db_pw[32] = "ragnarok"; +char log_db_db[32] = "ragnarok"; +char log_db[32] = "log"; + +char loginlog_db[256] = "loginlog"; +Sql* sql_handle; +bool enabled = false; + + +/*============================================= + * Records an event in the login log + *---------------------------------------------*/ +void login_log(uint32 ip, const char* username, int rcode, const char* message) +{ + char esc_username[NAME_LENGTH*2+1]; + char esc_message[255*2+1]; + int retcode; + + if( !enabled ) + return; + + Sql_EscapeStringLen(sql_handle, esc_username, username, strnlen(username, NAME_LENGTH)); + Sql_EscapeStringLen(sql_handle, esc_message, message, strnlen(message, 255)); + + retcode = Sql_Query(sql_handle, + "INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%s', '%s', '%d', '%s')", + loginlog_db, ip2str(ip,NULL), esc_username, rcode, message); + + if( retcode != SQL_SUCCESS ) + Sql_ShowDebug(sql_handle); +} + +bool loginlog_init(void) +{ + sql_handle = Sql_Malloc(); + + if( SQL_ERROR == Sql_Connect(sql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(sql_handle); + exit(EXIT_FAILURE); + } + + enabled = true; + + return true; +} + +bool loginlog_final(void) +{ + Sql_Free(sql_handle); + sql_handle = NULL; + return true; +} + +bool loginlog_config_read(const char* key, const char* value) +{ + if( strcmpi(key, "log_db_ip") == 0 ) + safestrncpy(log_db_ip, value, sizeof(log_db_ip)); + else + if( strcmpi(key, "log_db_port") == 0 ) + log_db_port = (uint16)strtoul(value, NULL, 10); + else + if( strcmpi(key, "log_db_id") == 0 ) + safestrncpy(log_db_id, value, sizeof(log_db_id)); + else + if( strcmpi(key, "log_db_pw") == 0 ) + safestrncpy(log_db_pw, value, sizeof(log_db_pw)); + else + if( strcmpi(key, "log_db") == 0 ) + safestrncpy(log_db, value, sizeof(log_db)); + else + if( strcmpi(key, "loginlog_db") == 0 ) + safestrncpy(loginlog_db, value, sizeof(loginlog_db)); + else + return false; + + return true; +} diff --git a/src/login/loginlog_txt.c b/src/login/loginlog_txt.c new file mode 100644 index 000000000..d40142110 --- /dev/null +++ b/src/login/loginlog_txt.c @@ -0,0 +1,74 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "account.h" +#include "login.h" + +#include +#include +#include + +char login_log_filename[1024] = "log/login.log"; + + + +/*============================================= + * Records an event in the login log + *---------------------------------------------*/ +void login_log(uint32 ip, const char* username, int rcode, const char* message) +{ + FILE* log_fp; + + if( !login_config.log_login ) + return; + + log_fp = fopen(login_log_filename, "a"); + if( log_fp != NULL ) + { + char esc_username[NAME_LENGTH*4+1]; + char esc_message[255*4+1]; + time_t raw_time; + char str_time[24]; + + sv_escape_c(esc_username, username, NAME_LENGTH, NULL); + sv_escape_c(esc_message, message, 255, NULL); + + time(&raw_time); + strftime(str_time, 24, login_config.date_format, localtime(&raw_time)); + str_time[23] = '\0'; + + fprintf(log_fp, "%s\t%s\t%s\t%d\t%s\n", str_time, ip2str(ip,NULL), esc_username, rcode, esc_message); + + fclose(log_fp); + } +} + + +bool loginlog_config_read(const char* w1, const char* w2) +{ + if(!strcmpi(w1, "login_log_filename")) + safestrncpy(login_log_filename, w2, sizeof(login_log_filename)); + else + return false; + + return true; +} + + +bool loginlog_init(void) +{ + return true; +} + + +bool loginlog_final(void) +{ + return true; +} diff --git a/src/login_sql/Makefile.in b/src/login_sql/Makefile.in deleted file mode 100644 index 05bd9262e..000000000 --- a/src/login_sql/Makefile.in +++ /dev/null @@ -1,60 +0,0 @@ - -COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ - ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ - ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ - ../common/obj_all/strlib.o ../common/obj_all/grfio.o ../common/obj_all/mapindex.o \ - ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_sql/sql.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/grfio.h ../common/mapindex.h \ - ../common/ers.h ../common/md5calc.h ../common/sql.h - -LOGIN_OBJ = obj_sql/login.o -LOGIN_H = login.h - -HAVE_MYSQL=@HAVE_MYSQL@ -ifeq ($(HAVE_MYSQL),yes) - LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_OBJ) $(COMMON_OBJ) -else - LOGIN_SERVER_SQL_DEPENDS=needs_mysql -endif - -@SET_MAKE@ - -##################################################################### -.PHONY : all login-server_sql clean help - -all: login-server_sql - -login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ - -clean: - rm -rf *.o obj_sql ../../login-server_sql@EXEEXT@ - -help: - @echo "possible targets are 'login-server_sql' 'all' 'clean' 'help'" - @echo "'login-server_sql' - login server (SQL version)" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" - -##################################################################### - -needs_mysql: - @echo "MySQL not found or disabled by the configure script" - @exit 1 - -obj_sql: - -mkdir obj_sql - -obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) - @CC@ @CFLAGS@ $(CUSTOM_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -# missing common object files -../common/obj_all/%.o: - @$(MAKE) -C ../common sql - -../common/obj_sql/%.o: - @$(MAKE) -C ../common sql diff --git a/src/login_sql/login.c b/src/login_sql/login.c deleted file mode 100644 index cd53f7d4e..000000000 --- a/src/login_sql/login.c +++ /dev/null @@ -1,1982 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/core.h" -#include "../common/socket.h" -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/version.h" -#include "../common/md5calc.h" -#include "../common/sql.h" -#include "login.h" - -#include -#include -#include -#include // for stat/lstat/fstat - -struct Login_Config login_config; - -int login_fd; // login server socket -#define MAX_SERVERS 30 -struct mmo_char_server server[MAX_SERVERS]; // char server data - -#define sex_num2str(num) ( (num == 0 ) ? 'F' : (num == 1 ) ? 'M' : 'S' ) -#define sex_str2num(str) ( (str == 'F' ) ? 0 : (str == 'M' ) ? 1 : 2 ) - -// Advanced subnet check [LuzZza] -struct s_subnet { - uint32 mask; - uint32 char_ip; - uint32 map_ip; -} subnet[16]; - -int subnet_count = 0; - -// GM account management -struct gm_account* gm_account_db = NULL; -unsigned int GM_num = 0; // number of gm accounts - -//Account registration flood protection [Kevin] -int allowed_regs = 1; -int time_allowed = 10; //in seconds -unsigned int new_reg_tick = 0; - - -// data handling (SQL) -Sql* sql_handle; - -// database parameters -uint16 login_server_port = 3306; -char login_server_ip[32] = "127.0.0.1"; -char login_server_id[32] = "ragnarok"; -char login_server_pw[32] = "ragnarok"; -char login_server_db[32] = "ragnarok"; -char default_codepage[32] = ""; - -char login_db[256] = "login"; -char loginlog_db[256] = "loginlog"; -char reg_db[256] = "global_reg_value"; - -// added to help out custom login tables, without having to recompile -// source so options are kept in the login_athena.conf or the inter_athena.conf -char login_db_account_id[256] = "account_id"; -char login_db_userid[256] = "userid"; -char login_db_user_pass[256] = "user_pass"; -char login_db_level[256] = "level"; - - -//----------------------------------------------------- -// Auth database -//----------------------------------------------------- -#define AUTH_TIMEOUT 30000 - -struct auth_node { - int account_id; - uint32 login_id1; - uint32 login_id2; - uint32 ip; - char sex; -}; - -static DBMap* auth_db; // int account_id -> struct auth_node* - -//----------------------------------------------------- -// Online User Database [Wizputer] -//----------------------------------------------------- - -struct online_login_data { - int account_id; - int waiting_disconnect; - int char_server; -}; - -static DBMap* online_db; // int account_id -> struct online_login_data* -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr data); - -static void* create_online_user(DBKey key, va_list args) -{ - struct online_login_data* p; - CREATE(p, struct online_login_data, 1); - p->account_id = key.i; - p->char_server = -1; - p->waiting_disconnect = -1; - return p; -} - -struct online_login_data* add_online_user(int char_server, int account_id) -{ - struct online_login_data* p; - if( !login_config.online_check ) - return NULL; - p = (struct online_login_data*)idb_ensure(online_db, account_id, create_online_user); - p->char_server = char_server; - if( p->waiting_disconnect != -1 ) - { - delete_timer(p->waiting_disconnect, waiting_disconnect_timer); - p->waiting_disconnect = -1; - } - return p; -} - -void remove_online_user(int account_id) -{ - struct online_login_data* p; - if( !login_config.online_check ) - return; - p = (struct online_login_data*)idb_get(online_db, account_id); - if( p == NULL ) - return; - if( p->waiting_disconnect != -1 ) - delete_timer(p->waiting_disconnect, waiting_disconnect_timer); - - idb_remove(online_db, account_id); -} - -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr data) -{ - struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); - if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) - { - p->waiting_disconnect = -1; - remove_online_user(id); - idb_remove(auth_db, id); - } - return 0; -} - -//-------------------------------------------------------------------- -// Packet send to all char-servers, except one (wos: without our self) -//-------------------------------------------------------------------- -int charif_sendallwos(int sfd, uint8* buf, size_t len) -{ - int i, c; - - for( i = 0, c = 0; i < MAX_SERVERS; ++i ) - { - int fd = server[i].fd; - if( session_isValid(fd) && fd != sfd ) - { - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - ++c; - } - } - - return c; -} - -//----------------------------------------------------- -// Read GM accounts -//----------------------------------------------------- -void read_gm_account(void) -{ - if( !login_config.login_gm_read ) - return;// char server's job - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `%s`,`%s` FROM `%s` WHERE `%s` > '0'", login_db_account_id, login_db_level, login_db, login_db_level) ) - { - Sql_ShowDebug(sql_handle); - return;// Failed to read GM list! - } - - RECREATE(gm_account_db, struct gm_account, (size_t)Sql_NumRows(sql_handle)); - - for( GM_num = 0; SQL_SUCCESS == Sql_NextRow(sql_handle); ++GM_num ) - { - char* account; - char* level; - - Sql_GetData(sql_handle, 0, &account, NULL); - Sql_GetData(sql_handle, 1, &level, NULL); - - gm_account_db[GM_num].account_id = atoi(account); - gm_account_db[GM_num].level = atoi(level); - } - - Sql_FreeResult(sql_handle); -} - -//----------------------------------------------------- -// Send GM accounts to one or all char-servers -//----------------------------------------------------- -void send_GM_accounts(int fd) -{ - unsigned int i; - uint8 buf[32767]; - uint16 len; - - if( !login_config.login_gm_read ) - return; - - len = 4; - WBUFW(buf,0) = 0x2732; - for( i = 0; i < GM_num; ++i ) - { - // send only existing accounts. We can not create a GM account when server is online. - if( gm_account_db[i].level > 0 ) - { - WBUFL(buf,len) = gm_account_db[i].account_id; - WBUFB(buf,len+4) = (uint8)gm_account_db[i].level; - len += 5; - if( len >= 32000 ) - { - ShowWarning("send_GM_accounts: Too many accounts! Only %d out of %d were sent.\n", i, GM_num); - break; - } - } - } - - WBUFW(buf,2) = len; - if( fd == -1 )// send to all charservers - charif_sendallwos(-1, buf, len); - else - {// send only to target - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - - return; -} - -/*============================================= - * Does a mysql_ping to all connection handles - *---------------------------------------------*/ -int login_sql_ping(int tid, unsigned int tick, int id, intptr data) -{ - ShowInfo("Pinging SQL server to keep connection alive...\n"); - Sql_Ping(sql_handle); - return 0; -} - -int sql_ping_init(void) -{ - uint32 connection_timeout, connection_ping_interval; - - // set a default value first - connection_timeout = 28800; // 8 hours - - // ask the mysql server for the timeout value - if( SQL_SUCCESS == Sql_GetTimeout(sql_handle, &connection_timeout) && connection_timeout < 60 ) - connection_timeout = 60; - - // establish keepalive - connection_ping_interval = connection_timeout - 30; // 30-second reserve - add_timer_func_list(login_sql_ping, "login_sql_ping"); - add_timer_interval(gettick() + connection_ping_interval*1000, login_sql_ping, 0, 0, connection_ping_interval*1000); - - return 0; -} - -//----------------------------------------------------- -// Read Account database - mysql db -//----------------------------------------------------- -int mmo_auth_sqldb_init(void) -{ - ShowStatus("Login server init....\n"); - - sql_handle = Sql_Malloc(); - - // DB connection start - ShowStatus("Connect Login Database Server....\n"); - if( SQL_ERROR == Sql_Connect(sql_handle, login_server_id, login_server_pw, login_server_ip, login_server_port, login_server_db) ) - { - Sql_ShowDebug(sql_handle); - Sql_Free(sql_handle); - exit(EXIT_FAILURE); - } - else - { - ShowStatus("Connect success!\n"); - } - - if( default_codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) - Sql_ShowDebug(sql_handle); - - if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s` (`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100','login server started')", loginlog_db) ) - Sql_ShowDebug(sql_handle); - - sql_ping_init(); - - return 0; -} - - -//----------------------------------------------------- -// close DB -//----------------------------------------------------- -void mmo_db_close(void) -{ - int i, fd; - - //set log. - if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '0', 'lserver','100', 'login server shutdown')", loginlog_db) ) - Sql_ShowDebug(sql_handle); - - for( i = 0; i < MAX_SERVERS; ++i ) - { - fd = server[i].fd; - if( session_isValid(fd) ) - {// Clean only data related to servers we are connected to. [Skotlex] - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `sstatus` WHERE `index` = '%d'", i) ) - Sql_ShowDebug(sql_handle); - do_close(fd); - } - } - Sql_Free(sql_handle); - sql_handle = NULL; - ShowStatus("close DB connect....\n"); - if( login_fd > 0 ) - do_close(login_fd); -} - -//----------------------------------------------------- -// periodic ip address synchronization -//----------------------------------------------------- -static int sync_ip_addresses(int tid, unsigned int tick, int id, intptr data) -{ - uint8 buf[2]; - ShowInfo("IP Sync in progress...\n"); - WBUFW(buf,0) = 0x2735; - charif_sendallwos(-1, buf, 2); - return 0; -} - -//----------------------------------------------------- -// encrypted/unencrypted password check -//----------------------------------------------------- -bool check_encrypted(const char* str1, const char* str2, const char* passwd) -{ - char md5str[64], md5bin[32]; - - snprintf(md5str, sizeof(md5str), "%s%s", str1, str2); - md5str[sizeof(md5str)-1] = '\0'; - MD5_String2binary(md5str, md5bin); - - return (0==memcmp(passwd, md5bin, 16)); -} - -bool check_password(struct login_session_data* ld, int passwdenc, const char* passwd, const char* refpass) -{ - if(passwdenc == 0) - { - return (0==strcmp(passwd, refpass)); - } - else if (ld) - { - // password mode set to 1 -> (md5key, refpass) enable with - // password mode set to 2 -> (refpass, md5key) enable with - - return ((passwdenc&0x01) && check_encrypted(ld->md5key, refpass, passwd)) || - ((passwdenc&0x02) && check_encrypted(refpass, ld->md5key, passwd)); - } - return false; -} - - -//----------------------------------------------------- -// Make new account -//----------------------------------------------------- -int mmo_auth_new(struct mmo_account* account) -{ - static int num_regs = 0; // registration counter - unsigned int tick = gettick(); - - char md5buf[32+1]; - time_t expiration_time = 0; - SqlStmt* stmt; - int result = 0; - - //Account Registration Flood Protection by [Kevin] - if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) - { - ShowNotice("Account registration denied (registration limit exceeded)\n"); - return 3; - } - - // check if the account doesn't exist already - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "SELECT `%s` FROM `%s` WHERE `userid` = ?", login_db_userid, login_db) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - result = 1;// error - } - else if( SqlStmt_NumRows(stmt) > 0 ) - result = 1;// username already taken - SqlStmt_Free(stmt); - if( result ) - return result;// error or incorrect user - - if( login_config.start_limited_time != -1 ) - expiration_time = time(NULL) + login_config.start_limited_time; - - // insert new entry into db - //TODO: error checking - stmt = SqlStmt_Malloc(sql_handle); - SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`%s`, `%s`, `sex`, `email`, `connect_until`) VALUES (?, ?, '%c', 'a@a.com', '%d')", login_db, login_db_userid, login_db_user_pass, account->sex, expiration_time); - SqlStmt_BindParam(stmt, 0, SQLDT_STRING, account->userid, strnlen(account->userid, NAME_LENGTH)); - if( login_config.use_md5_passwds ) - { - MD5_String(account->pass, md5buf); - SqlStmt_BindParam(stmt, 1, SQLDT_STRING, md5buf, 32); - } - else - SqlStmt_BindParam(stmt, 1, SQLDT_STRING, account->pass, strnlen(account->pass, NAME_LENGTH)); - SqlStmt_Execute(stmt); - - ShowNotice("Account creation (account %s, id: %d, pass: %s, sex: %c)\n", account->userid, (int)SqlStmt_LastInsertId(stmt), account->pass, account->sex); - SqlStmt_Free(stmt); - - if( DIFF_TICK(tick, new_reg_tick) > 0 ) - {// Update the registration check. - num_regs = 0; - new_reg_tick = tick + time_allowed*1000; - } - ++num_regs; - - return 0; -} - - -//----------------------------------------------------- -// Check/authentication of a connection -//----------------------------------------------------- -int mmo_auth(struct login_session_data* sd) -{ - time_t unban_time; - char esc_userid[NAME_LENGTH*2+1];// escaped username - char user_password[256], password[256]; - long expiration_time; - int state; - size_t len; - char* data; - - char ip[16]; - ip2str(session[sd->fd]->client_addr, ip); - - // DNS Blacklist check - if( login_config.use_dnsbl ) - { - char r_ip[16]; - char ip_dnsbl[256]; - char* dnsbl_serv; - bool matched = false; - uint8* sin_addr = (uint8*)&session[sd->fd]->client_addr; - - sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); - - for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) - { - sprintf(ip_dnsbl, "%s.%s", r_ip, dnsbl_serv); - if( host2ip(ip_dnsbl) ) - matched = true; - } - - if( matched ) - { - ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); - return 3; - } - } - - //Client Version check - if( login_config.check_client_version && sd->version != login_config.client_version_to_connect ) - return 5; - - len = strnlen(sd->userid, NAME_LENGTH); - - // Account creation with _M/_F - if( login_config.new_account_flag ) - { - if( len > 2 && strnlen(sd->passwd, NAME_LENGTH) > 0 && // valid user and password lengths - sd->passwdenc == 0 && // unencoded password - sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4) ) // _M/_F suffix - { - struct mmo_account acc; - int result; - - len -= 2; - sd->userid[len] = '\0'; - - memset(&acc, '\0', sizeof(acc)); - safestrncpy(acc.userid, sd->userid, NAME_LENGTH); - safestrncpy(acc.pass, sd->passwd, NAME_LENGTH); - safestrncpy(acc.email, "a@a.com", sizeof(acc.email)); - acc.sex = TOUPPER(sd->userid[len+1]); - - result = mmo_auth_new(&acc); - if( result ) - return result;// Failed to make account. [Skotlex]. - } - } - - // escape username - Sql_EscapeStringLen(sql_handle, esc_userid, sd->userid, len); - - // retrieve login entry for the specified username - if( SQL_ERROR == Sql_Query(sql_handle, - "SELECT `%s`,`%s`,`lastlogin`,`sex`,`connect_until`,`ban_until`,`state`,`%s` FROM `%s` WHERE `%s`= %s '%s'", - login_db_account_id, login_db_user_pass, login_db_level, - login_db, login_db_userid, (login_config.case_sensitive ? "BINARY" : ""), esc_userid) ) - Sql_ShowDebug(sql_handle); - - if( Sql_NumRows(sql_handle) == 0 ) // no such entry - { - ShowNotice("auth failed: no such account '%s'\n", esc_userid); - Sql_FreeResult(sql_handle); - return 0; - } - - Sql_NextRow(sql_handle); //TODO: error checking? - - Sql_GetData(sql_handle, 0, &data, NULL); sd->account_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, &len); safestrncpy(password, data, sizeof(password)); - Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(sd->lastlogin, data, sizeof(sd->lastlogin)); - Sql_GetData(sql_handle, 3, &data, NULL); sd->sex = *data; - Sql_GetData(sql_handle, 4, &data, NULL); expiration_time = atol(data); - Sql_GetData(sql_handle, 5, &data, NULL); unban_time = atol(data); - Sql_GetData(sql_handle, 6, &data, NULL); state = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); sd->level = atoi(data); - if( len > sizeof(password) - 1 ) - ShowDebug("mmo_auth: password buffer is too small (len=%u,buflen=%u)\n", len, sizeof(password)); - if( sd->level > 99 ) - sd->level = 99; - - Sql_FreeResult(sql_handle); - - if( login_config.use_md5_passwds ) - MD5_String(sd->passwd, user_password); - else - safestrncpy(user_password, sd->passwd, NAME_LENGTH); - - if( !check_password(sd, sd->passwdenc, user_password, password) ) - { - ShowInfo("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", - esc_userid, password, (sd->passwdenc) ? "[MD5]" : user_password, ip); - return 1; // 1 = Incorrect Password - } - - if( expiration_time != 0 && expiration_time < time(NULL) ) - return 2; // 2 = This ID is expired - - if( unban_time != 0 && unban_time > time(NULL) ) - return 6; // 6 = Your are Prohibited to log in until %s - - if( state ) - { - ShowInfo("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, state, ip); - return state - 1; - } - - sd->login_id1 = rand(); - sd->login_id2 = rand(); - - if( sd->sex != 'S' && sd->account_id < START_ACCOUNT_NUM ) - ShowWarning("Account %s has account id %d! Account IDs must be over %d to work properly!\n", sd->userid, sd->account_id, START_ACCOUNT_NUM); - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `lastlogin` = NOW(), `logincount`=`logincount`+1, `last_ip`='%s', `ban_until`='0', `state`='0' WHERE `%s` = '%d'", - login_db, ip, login_db_account_id, sd->account_id) ) - Sql_ShowDebug(sql_handle); - - return -1; // account OK -} - -static int online_db_setoffline(DBKey key, void* data, va_list ap) -{ - struct online_login_data* p = (struct online_login_data*)data; - int server = va_arg(ap, int); - if( server == -1 ) - { - p->char_server = -1; - if( p->waiting_disconnect != -1 ) - { - delete_timer(p->waiting_disconnect, waiting_disconnect_timer); - p->waiting_disconnect = -1; - } - } - else if( p->char_server == server ) - p->char_server = -2; //Char server disconnected. - return 0; -} - -//-------------------------------- -// Packet parsing for char-servers -//-------------------------------- -int parse_fromchar(int fd) -{ - unsigned int i; - int id; - uint32 ipl; - char ip[16]; - - ARR_FIND( 0, MAX_SERVERS, id, server[id].fd == fd ); - if( id == MAX_SERVERS ) - {// not a char server - set_eof(fd); - do_close(fd); - return 0; - } - - if( session[fd]->flag.eof ) - { - ShowStatus("Char-server '%s' has disconnected.\n", server[id].name); - online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char server to offline. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `sstatus` WHERE `index`='%d'", id) ) - Sql_ShowDebug(sql_handle); - memset(&server[id], 0, sizeof(struct mmo_char_server)); - server[id].fd = -1; - do_close(fd); - return 0; - } - - ipl = server[id].ip; - ip2str(ipl, ip); - - while( RFIFOREST(fd) >= 2 ) - { - uint16 command = RFIFOW(fd,0); - - switch( command ) - { - - case 0x2709: // request from map-server via char-server to reload GM accounts - RFIFOSKIP(fd,2); - ShowStatus("Char-server '%s': Request to re-load GM configuration file (ip: %s).\n", server[id].name, ip); - if( login_config.log_login ) - { - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`log`) VALUES (NOW(), '%u', '%s', 'GM reload request')", loginlog_db, ipl, server[id].name) ) - Sql_ShowDebug(sql_handle); - } - read_gm_account(); - // send GM accounts to all char-servers - send_GM_accounts(-1); - break; - - case 0x2712: // request from char-server to authenticate an account - if( RFIFOREST(fd) < 19 ) - return 0; - { - struct auth_node* node; - - int account_id = RFIFOL(fd,2); - uint32 login_id1 = RFIFOL(fd,6); - uint32 login_id2 = RFIFOL(fd,10); - char sex = sex_num2str(RFIFOB(fd,14)); - uint32 ip_ = ntohl(RFIFOL(fd,15)); - RFIFOSKIP(fd,19); - - node = (struct auth_node*)idb_get(auth_db, account_id); - if( node != NULL && - node->account_id == account_id && - node->login_id1 == login_id1 && - node->login_id2 == login_id2 && - node->sex == sex && - node->ip == ip_ ) - {// found - uint32 expiration_time; - char email[40]; - - // each auth entry can only be used once - idb_remove(auth_db, account_id); - - // retrieve email and account expiration time - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data = NULL; - size_t len = 0; - - Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(email, data, sizeof(email)); - Sql_GetData(sql_handle, 1, &data, NULL); expiration_time = (uint32)strtoul(data, NULL, 10); - if( len > sizeof(email) ) - ShowDebug("parse_fromchar:0x2712: email is too long (len=%u,maxlen=%u)\n", len, sizeof(email)); - - Sql_FreeResult(sql_handle); - } - else - { - memset(email, 0, sizeof(email)); - expiration_time = 0; - } - - // send ack - WFIFOHEAD(fd,59); - WFIFOW(fd,0) = 0x2713; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = login_id1; - WFIFOL(fd,10) = login_id2; - WFIFOB(fd,14) = 0; - memcpy(WFIFOP(fd,15), email, 40); - WFIFOL(fd,55) = expiration_time; - WFIFOSET(fd,59); - } - else - {// authentication not found - ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); - WFIFOHEAD(fd,59); - WFIFOW(fd,0) = 0x2713; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = login_id1; - WFIFOL(fd,10) = login_id2; - WFIFOB(fd,14) = 1; - // It is unnecessary to send email - // It is unnecessary to send validity date of the account - WFIFOSET(fd,59); - } - } - break; - - case 0x2714: - if( RFIFOREST(fd) < 6 ) - return 0; - { - int users = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - // how many users on world? (update) - if( server[id].users != users ) - { - ShowStatus("set users %s : %d\n", server[id].name, users); - - server[id].users = users; - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `sstatus` SET `user` = '%d' WHERE `index` = '%d'", server[id].users, id) ) - Sql_ShowDebug(sql_handle); - } - } - break; - - case 0x2716: // received an e-mail/limited time request, because a player comes back from a map-server to the char-server - if( RFIFOREST(fd) < 6 ) - return 0; - { - uint32 expiration_time = 0; - char email[40] = ""; - - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - size_t len; - - Sql_GetData(sql_handle, 0, &data, &len); - safestrncpy(email, data, sizeof(email)); - - Sql_GetData(sql_handle, 1, &data, NULL); - expiration_time = (uint32)strtoul(data, NULL, 10); - - Sql_FreeResult(sql_handle); - } - - WFIFOHEAD(fd,50); - WFIFOW(fd,0) = 0x2717; - WFIFOL(fd,2) = account_id; - safestrncpy((char*)WFIFOP(fd,6), email, 40); - WFIFOL(fd,46) = expiration_time; - WFIFOSET(fd,50); - } - break; - - case 0x2719: // ping request from charserver - if( RFIFOREST(fd) < 2 ) - return 0; - RFIFOSKIP(fd,2); - - WFIFOHEAD(fd,2); - WFIFOW(fd,0) = 0x2718; - WFIFOSET(fd,2); - break; - - // Map server send information to change an email of an account via char-server - case 0x2722: // 0x2722 .L .40B .40B - if (RFIFOREST(fd) < 86) - return 0; - { - char actual_email[40]; - char new_email[40]; - int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); - safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); - RFIFOSKIP(fd, 86); - - if( e_mail_check(actual_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else if( e_mail_check(new_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else if( strcmpi(new_email, "a@a.com") == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `%s`,`email` FROM `%s` WHERE `%s` = '%d'", login_db_userid, login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - size_t len; - - Sql_GetData(sql_handle, 1, &data, &len); - if( strncasecmp(data, actual_email, sizeof(actual_email)) == 0 ) - { - char esc_user_id[NAME_LENGTH*2+1]; - char esc_new_email[sizeof(new_email)*2+1]; - - Sql_GetData(sql_handle, 0, &data, &len); - Sql_EscapeStringLen(sql_handle, esc_user_id, data, len); - Sql_EscapeStringLen(sql_handle, esc_new_email, new_email, strnlen(new_email, sizeof(new_email))); - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `email` = '%s' WHERE `%s` = '%d'", login_db, esc_new_email, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - ShowInfo("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d ('%s'), new e-mail: '%s', ip: %s).\n", server[id].name, account_id, esc_user_id, esc_new_email, ip); - } - Sql_FreeResult(sql_handle); - } - } - break; - - case 0x2724: // Receiving an account state update request from a map-server (relayed via char-server) - if (RFIFOREST(fd) < 10) - return 0; - { - int account_id = RFIFOL(fd,2); - int state = RFIFOL(fd,6); - RFIFOSKIP(fd,10); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `state` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - if( atoi(data) != state && state != 0 ) - { - uint8 buf[11]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = 0; // 0: change of state, 1: ban - WBUFL(buf,7) = state; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - Sql_FreeResult(sql_handle); - } - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state` = '%d' WHERE `%s` = '%d'", login_db, state, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - } - break; - - case 0x2725: // Receiving of map-server via char-server a ban request - if (RFIFOREST(fd) < 18) - return 0; - { - struct tm *tmtime; - time_t tmptime = 0; - time_t timestamp = time(NULL); - - int account_id = RFIFOL(fd,2); - int year = (short)RFIFOW(fd,6); - int month = (short)RFIFOW(fd,8); - int mday = (short)RFIFOW(fd,10); - int hour = (short)RFIFOW(fd,12); - int min = (short)RFIFOW(fd,14); - int sec = (short)RFIFOW(fd,16); - RFIFOSKIP(fd,18); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - tmptime = (time_t)strtoul(data, NULL, 10); - if( tmptime > time(NULL) ) - timestamp = tmptime; - } - tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + year; - tmtime->tm_mon = tmtime->tm_mon + month; - tmtime->tm_mday = tmtime->tm_mday + mday; - tmtime->tm_hour = tmtime->tm_hour + hour; - tmtime->tm_min = tmtime->tm_min + min; - tmtime->tm_sec = tmtime->tm_sec + sec; - timestamp = mktime(tmtime); - if( timestamp != (time_t)-1 ) - { - if( timestamp <= time(NULL) ) - timestamp = 0; - if( tmptime != timestamp ) - { - if( timestamp != 0 ) - { - uint8 buf[11]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = 1; // 0: change of statut, 1: ban - WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - ShowNotice("Account: %d Banned until: %lu\n", account_id, (unsigned long)timestamp); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `ban_until` = '%lu' WHERE `%s` = '%d'", login_db, (unsigned long)timestamp, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - } - } - } - break; - - case 0x2727: // Change of sex (sex is reversed) - if( RFIFOREST(fd) < 6 ) - return 0; - { - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `sex` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - unsigned char buf[7]; - int sex; - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - sex = ( *data == 'M' ) ? 'F' : 'M'; //Change gender - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `sex` = '%c' WHERE `%s` = '%d'", login_db, sex, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - - WBUFW(buf,0) = 0x2723; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = sex_str2num(sex); - charif_sendallwos(-1, buf, 7); - } - } - break; - - case 0x2728: // save account_reg2 - if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) - return 0; - if( RFIFOL(fd,4) > 0 ) - { - SqlStmt* stmt; - int account_id; - size_t off; - - account_id = RFIFOL(fd,4); - - //Delete all global account variables.... - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`='1' AND `account_id`='%d';", reg_db, account_id) ) - Sql_ShowDebug(sql_handle); - - //Proceed to insert them.... - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ?);", reg_db, account_id) ) - SqlStmt_ShowDebug(stmt); - for( i = 0, off = 13; i < ACCOUNT_REG2_NUM && off < RFIFOW(fd,2); ++i ) - { - char* p; - size_t len; - - // str - p = (char*)RFIFOP(fd,off); - len = strlen(p); - SqlStmt_BindParam(stmt, 0, SQLDT_STRING, p, len); - off += len + 1; - - // value - p = (char*)RFIFOP(fd,off); - len = strlen(p); - SqlStmt_BindParam(stmt, 1, SQLDT_STRING, p, len); - off += len + 1; - - if( SQL_ERROR == SqlStmt_Execute(stmt) ) - SqlStmt_ShowDebug(stmt); - } - SqlStmt_Free(stmt); - - // Sending information towards the other char-servers. - RFIFOW(fd,0) = 0x2729;// reusing read buffer - charif_sendallwos(fd, RFIFOP(fd,0), RFIFOW(fd,2)); - RFIFOSKIP(fd,RFIFOW(fd,2)); - } - break; - - case 0x272a: // Receiving of map-server via char-server an unban request - if( RFIFOREST(fd) < 6 ) - return 0; - { - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - else if( Sql_NumRows(sql_handle) > 0 ) - {// Found a match - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `ban_until` = '0' WHERE `%s` = '%d'", login_db, login_db_account_id, account_id) ) - Sql_ShowDebug(sql_handle); - } - } - break; - - case 0x272b: // Set account_id to online [Wizputer] - if( RFIFOREST(fd) < 6 ) - return 0; - add_online_user(id, RFIFOL(fd,2)); - RFIFOSKIP(fd,6); - break; - - case 0x272c: // Set account_id to offline [Wizputer] - if( RFIFOREST(fd) < 6 ) - return 0; - remove_online_user(RFIFOL(fd,2)); - RFIFOSKIP(fd,6); - break; - - case 0x272d: // Receive list of all online accounts. [Skotlex] - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - if( login_config.online_check ) - { - struct online_login_data *p; - int aid; - uint32 i, users; - online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char-server offline first - users = RFIFOW(fd,4); - for (i = 0; i < users; i++) { - aid = RFIFOL(fd,6+i*4); - p = (struct online_login_data*)idb_ensure(online_db, aid, create_online_user); - p->char_server = id; - if (p->waiting_disconnect != -1) - { - delete_timer(p->waiting_disconnect, waiting_disconnect_timer); - p->waiting_disconnect = -1; - } - } - } - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - - case 0x272e: //Request account_reg2 for a character. - if (RFIFOREST(fd) < 10) - return 0; - { - size_t off; - - int account_id = RFIFOL(fd,2); - int char_id = RFIFOL(fd,6); - RFIFOSKIP(fd,10); - - WFIFOHEAD(fd,10000); - WFIFOW(fd,0) = 0x2729; - WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = char_id; - WFIFOB(fd,12) = 1; //Type 1 for Account2 registry - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'", reg_db, account_id) ) - Sql_ShowDebug(sql_handle); - - off = 13; - while( SQL_SUCCESS == Sql_NextRow(sql_handle) && off < 9000 ) - { - char* data; - - // str - Sql_GetData(sql_handle, 0, &data, NULL); - if( *data != '\0' ) - { - off += sprintf((char*)WFIFOP(fd,off), "%s", data)+1; //We add 1 to consider the '\0' in place. - - // value - Sql_GetData(sql_handle, 1, &data, NULL); - off += sprintf((char*)WFIFOP(fd,off), "%s", data)+1; - } - } - Sql_FreeResult(sql_handle); - - if( off >= 9000 ) - ShowWarning("Too many account2 registries for AID %d. Some registries were not sent.\n", account_id); - - WFIFOW(fd,2) = (uint16)off; - WFIFOSET(fd,WFIFOW(fd,2)); - } - break; - - case 0x2736: // WAN IP update from char-server - if( RFIFOREST(fd) < 6 ) - return 0; - server[id].ip = ntohl(RFIFOL(fd,2)); - ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip)); - RFIFOSKIP(fd,6); - break; - - case 0x2737: //Request to set all offline. - ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, online_db_setoffline, id); - RFIFOSKIP(fd,2); - break; - - default: - ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); - set_eof(fd); - return 0; - } // switch - } // while - - RFIFOSKIP(fd,RFIFOREST(fd)); - return 0; -} - -//-------------------------------------------- -// Test to know if an IP come from LAN or WAN. -//-------------------------------------------- -int lan_subnetcheck(uint32 ip) -{ - int i; - ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); - return ( i < subnet_count ) ? subnet[i].char_ip : 0; -} - -int login_ip_ban_check(uint32 ip) -{ - uint8* p = (uint8*)&ip; - char* data = NULL; - int matches; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u'", - p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) - { - Sql_ShowDebug(sql_handle); - // close connection because we can't verify their connectivity. - return 1; - } - - if( SQL_ERROR == Sql_NextRow(sql_handle) ) - return 1;// Shouldn't happen, but just in case... - - Sql_GetData(sql_handle, 0, &data, NULL); - matches = atoi(data); - Sql_FreeResult(sql_handle); - - if( matches == 0 ) - return 0;// No ban - - // ip ban ok. - ShowInfo("Packet from banned ip : %u.%u.%u.%u\n", CONVIP(ip)); - - if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, ip) ) - Sql_ShowDebug(sql_handle); - return 1; -} - -void login_auth_ok(struct login_session_data* sd) -{ - int fd = sd->fd; - uint32 ip = session[fd]->client_addr; - - char esc_userid[NAME_LENGTH*2+1]; - uint8 server_num, n; - uint32 subnet_char_ip; - struct auth_node* node; - int i; - - Sql_EscapeStringLen(sql_handle, esc_userid, sd->userid, strlen(sd->userid)); - - if( sd->level < login_config.min_level_to_connect ) - { - ShowStatus("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d).\n", login_config.min_level_to_connect, sd->userid, sd->level); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); - return; - } - - server_num = 0; - for( i = 0; i < MAX_SERVERS; ++i ) - if( session_isValid(server[i].fd) ) - server_num++; - - if( server_num == 0 ) - {// if no char-server, don't send void list of servers, just disconnect the player with proper message - ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); - return; - } - - if( login_config.online_check ) - { - struct online_login_data* data = (struct online_login_data*)idb_get(online_db, sd->account_id); - if( data ) - {// account is already marked as online! - if( data->char_server > -1 ) - {// Request char servers to kick this account out. [Skotlex] - uint8 buf[6]; - ShowNotice("User '%s' is already online - Rejected.\n", sd->userid); - WBUFW(buf,0) = 0x2734; - WBUFL(buf,2) = sd->account_id; - charif_sendallwos(-1, buf, 6); - if( data->waiting_disconnect == -1 ) - data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); - - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 8; // 08 = Server still recognizes your last login - WFIFOSET(fd,3); - return; - } - else - if( data->char_server == -1 ) - {// client has authed but did not access char-server yet - // wipe previous session - idb_remove(auth_db, sd->account_id); - remove_online_user(sd->account_id); - data = NULL; - } - } - } - - if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','100', 'login ok')", loginlog_db, ip, esc_userid) ) - Sql_ShowDebug(sql_handle); - - if( sd->level > 0 ) - ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", sd->level, sd->userid); - else - ShowStatus("Connection of the account '%s' accepted.\n", sd->userid); - - WFIFOHEAD(fd,47+32*server_num); - WFIFOW(fd,0) = 0x69; - WFIFOW(fd,2) = 47+32*server_num; - WFIFOL(fd,4) = sd->login_id1; - WFIFOL(fd,8) = sd->account_id; - WFIFOL(fd,12) = sd->login_id2; - WFIFOL(fd,16) = 0; // in old version, that was for ip (not more used) - //memcpy(WFIFOP(fd,20), sd->lastlogin, 24); // in old version, that was for name (not more used) - WFIFOW(fd,44) = 0; // unknown - WFIFOB(fd,46) = sex_str2num(sd->sex); - for( i = 0, n = 0; i < MAX_SERVERS; ++i ) - { - if( !session_isValid(server[i].fd) ) - continue; - - subnet_char_ip = lan_subnetcheck(ip); // Advanced subnet check [LuzZza] - WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); - WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] - memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20); - WFIFOW(fd,47+n*32+26) = server[i].users; - WFIFOW(fd,47+n*32+28) = server[i].maintenance; - WFIFOW(fd,47+n*32+30) = server[i].new_; - n++; - } - WFIFOSET(fd,47+32*server_num); - - // create temporary auth entry - CREATE(node, struct auth_node, 1); - node->account_id = sd->account_id; - node->login_id1 = sd->login_id1; - node->login_id2 = sd->login_id2; - node->sex = sd->sex; - node->ip = ip; - idb_put(auth_db, sd->account_id, node); - - if( login_config.online_check ) - { - struct online_login_data* data; - - // mark client as 'online' - data = add_online_user(-1, sd->account_id); - - // schedule deletion of this node - data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); - } -} - -void login_auth_failed(struct login_session_data* sd, int result) -{ - int fd = sd->fd; - uint32 ip = session[fd]->client_addr; - char esc_userid[NAME_LENGTH*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_userid, sd->userid, strlen(sd->userid)); - - if (login_config.log_login) - { - const char* error; - switch( result ) { - case 0: error = "Unregistered ID."; break; // 0 = Unregistered ID - case 1: error = "Incorrect Password."; break; // 1 = Incorrect Password - case 2: error = "Account Expired."; break; // 2 = This ID is expired - case 3: error = "Rejected from server."; break; // 3 = Rejected from Server - case 4: error = "Blocked by GM."; break; // 4 = You have been blocked by the GM Team - case 5: error = "Not latest game EXE."; break; // 5 = Your Game's EXE file is not the latest version - case 6: error = "Banned."; break; // 6 = Your are Prohibited to log in until %s - case 7: error = "Server Over-population."; break; // 7 = Server is jammed due to over populated - case 8: error = "Account limit from company"; break; // 8 = No more accounts may be connected from this company - case 9: error = "Ban by DBA"; break; // 9 = MSI_REFUSE_BAN_BY_DBA - case 10: error = "Email not confirmed"; break; // 10 = MSI_REFUSE_EMAIL_NOT_CONFIRMED - case 11: error = "Ban by GM"; break; // 11 = MSI_REFUSE_BAN_BY_GM - case 12: error = "Working in DB"; break; // 12 = MSI_REFUSE_TEMP_BAN_FOR_DBWORK - case 13: error = "Self Lock"; break; // 13 = MSI_REFUSE_SELF_LOCK - case 14: error = "Not Permitted Group"; break; // 14 = MSI_REFUSE_NOT_PERMITTED_GROUP - case 15: error = "Not Permitted Group"; break; // 15 = MSI_REFUSE_NOT_PERMITTED_GROUP - case 99: error = "Account gone."; break; // 99 = This ID has been totally erased - case 100: error = "Login info remains."; break; // 100 = Login information remains at %s - case 101: error = "Hacking investigation."; break; // 101 = Account has been locked for a hacking investigation. Please contact the GM Team for more information - case 102: error = "Bug investigation."; break; // 102 = This account has been temporarily prohibited from login due to a bug-related investigation - case 103: error = "Deleting char."; break; // 103 = This character is being deleted. Login is temporarily unavailable for the time being - case 104: error = "Deleting spouse char."; break; // 104 = This character is being deleted. Login is temporarily unavailable for the time being - default : error = "Unknown Error."; break; - } - - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s', '%d','login failed : %s')", loginlog_db, ip, esc_userid, result, error) ) - Sql_ShowDebug(sql_handle); - } - - if( result == 1 && login_config.dynamic_pass_failure_ban && login_config.log_login ) // failed password - { - unsigned long failures = 0; - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%u' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", - loginlog_db, ip, login_config.dynamic_pass_failure_ban_interval) )// how many times failed account? in one ip. - Sql_ShowDebug(sql_handle); - - //check query result - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - Sql_GetData(sql_handle, 0, &data, NULL); - failures = strtoul(data, NULL, 10); - Sql_FreeResult(sql_handle); - } - if( failures >= login_config.dynamic_pass_failure_ban_limit ) - { - uint8* p = (uint8*)&ip; - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban: %s')", p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration, esc_userid) ) - Sql_ShowDebug(sql_handle); - } - } - - WFIFOHEAD(fd,23); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = (uint8)result; - if( result != 6 ) - memset(WFIFOP(fd,3), '\0', 20); - else - {// 6 = Your are Prohibited to log in until %s - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `ban_until` FROM `%s` WHERE `%s` = %s '%s'", login_db, login_db_userid, (login_config.case_sensitive ? "BINARY" : ""), esc_userid) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - time_t unban_time; - - Sql_GetData(sql_handle, 0, &data, NULL); - unban_time = (time_t)strtoul(data, NULL, 10); - Sql_FreeResult(sql_handle); - - strftime((char*)WFIFOP(fd,3), 20, login_config.date_format, localtime(&unban_time)); - } - } - WFIFOSET(fd,23); -} - -//---------------------------------------------------------------------------------------- -// Default packet parsing (normal players or administation/char-server connection requests) -//---------------------------------------------------------------------------------------- -int parse_login(int fd) -{ - struct login_session_data* sd = session[fd]->session_data; - int result; - uint32 ipl; - char ip[16]; - - if( session[fd]->flag.eof ) - { - do_close(fd); - return 0; - } - - if( sd == NULL ) { - sd = CREATE(session[fd]->session_data, struct login_session_data, 1); - sd->fd = fd; - } - - ipl = session[fd]->client_addr; - ip2str(ipl, ip); - - while( RFIFOREST(fd) >= 2 ) - { - uint16 command = RFIFOW(fd,0); - - switch( command ) - { - - case 0x0200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. - if (RFIFOREST(fd) < 26) - return 0; - RFIFOSKIP(fd,26); - break; - - case 0x0204: // New alive packet: structure: 0x204 .16B. (new ragexe from 22 june 2004) - if (RFIFOREST(fd) < 18) - return 0; - RFIFOSKIP(fd,18); - break; - - case 0x0064: // request client login - case 0x01dd: // request client login (encryption mode) - case 0x0277: // New login packet (kRO 2006-04-24aSakexe langtype 0) - case 0x02b0: // New login packet (kRO 2007-05-14aSakexe langtype 0) - { - size_t packet_len = RFIFOREST(fd); // assume no other packet was sent - - // Perform ip-ban check - if( login_config.ipban && login_ip_ban_check(ipl) ) - { - ShowStatus("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", ip); - WFIFOHEAD(fd,23); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = 3; // 3 = Rejected from Server - WFIFOSET(fd,23); - RFIFOSKIP(fd,packet_len); - set_eof(fd); - break; - } - - if( (command == 0x0064 && packet_len < 55) - || (command == 0x01dd && packet_len < 47) - || (command == 0x0277 && packet_len < 84) - || (command == 0x02b0 && packet_len < 85) ) - return 0; - - // S 0064 .l .24B .24B .B - // S 01dd .l .24B .16B .B - // S 0277 .l .24B .24B .29B .B - // S 02b0 .l .24B .24B .30B .B - - sd->version = RFIFOL(fd,2); - safestrncpy(sd->userid, (char*)RFIFOP(fd,6), NAME_LENGTH);//## does it have to be nul-terminated? - if (command != 0x01dd) { - ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,30), NAME_LENGTH);//## does it have to be nul-terminated? - sd->passwdenc = 0; - } else { - ShowStatus("Request for connection (encryption mode) of %s (ip: %s).\n", sd->userid, ip); - memcpy(sd->passwd, RFIFOP(fd,30), 16); sd->passwd[16] = '\0'; // raw binary data here! - sd->passwdenc = PASSWORDENC; - } - RFIFOSKIP(fd,packet_len); - - result = mmo_auth(sd); - - if( result == -1 ) - login_auth_ok(sd); - else - login_auth_failed(sd, result); - } - break; - - case 0x01db: // Sending request of the coding key - RFIFOSKIP(fd,2); - { - unsigned int i; - - memset(sd->md5key, '\0', sizeof(sd->md5key)); - sd->md5keylen = (uint16)(12 + rand() % 4); - for( i = 0; i < sd->md5keylen; ++i ) - sd->md5key[i] = (char)(1 + rand() % 255); - - WFIFOHEAD(fd,4 + sd->md5keylen); - WFIFOW(fd,0) = 0x01dc; - WFIFOW(fd,2) = 4 + sd->md5keylen; - memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen); - WFIFOSET(fd,WFIFOW(fd,2)); - } - break; - - case 0x2710: // Connection request of a char-server - if (RFIFOREST(fd) < 86) - return 0; - { - char esc_userid[NAME_LENGTH*2+1]; - char server_name[20]; - char esc_server_name[20*2+1]; - uint32 server_ip; - uint16 server_port; - uint16 maintenance; - uint16 new_; - - safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); - sd->passwdenc = 0; - sd->version = login_config.client_version_to_connect; // hack to skip version check - server_ip = ntohl(RFIFOL(fd,54)); - server_port = ntohs(RFIFOW(fd,58)); - safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); - maintenance = RFIFOW(fd,82); - new_ = RFIFOW(fd,84); - RFIFOSKIP(fd,86); - - Sql_EscapeStringLen(sql_handle, esc_server_name, server_name, strnlen(server_name, 20)); - Sql_EscapeStringLen(sql_handle, esc_userid, sd->userid, strnlen(sd->userid, NAME_LENGTH)); - - ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); - - if( login_config.log_login && SQL_ERROR == Sql_Query(sql_handle, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%u.%u.%u.%u:%d')", - loginlog_db, ipl, esc_userid, esc_server_name, esc_server_name, CONVIP(server_ip), server_port) ) - Sql_ShowDebug(sql_handle); - - result = mmo_auth(sd); - if( result == -1 && sd->sex == 'S' && sd->account_id < MAX_SERVERS && server[sd->account_id].fd == -1 ) - { - ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); - safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name)); - server[sd->account_id].fd = fd; - server[sd->account_id].ip = server_ip; - server[sd->account_id].port = server_port; - server[sd->account_id].users = 0; - server[sd->account_id].maintenance = maintenance; - server[sd->account_id].new_ = new_; - - session[fd]->func_parse = parse_fromchar; - session[fd]->flag.server = 1; - realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - - // send connection success - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - - // send GM account to char-server - send_GM_accounts(fd); - - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%d', '%s', '%d')", sd->account_id, esc_server_name, 0) ) - Sql_ShowDebug(sql_handle); - } - else - { - ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 3; - WFIFOSET(fd,3); - } - } - return 0; // processing will continue elsewhere - - case 0x7530: // Server version information request - ShowStatus("Sending server version information to ip: %s\n", ip); - RFIFOSKIP(fd,2); - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_LOGIN; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - break; - - default: - ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, command); - set_eof(fd); - return 0; - } - } - - RFIFOSKIP(fd,RFIFOREST(fd)); - return 0; -} - -//----------------------- -// Console Command Parser [Wizputer] -//----------------------- -int parse_console(char* buf) -{ - char command[256]; - - memset(command, 0, sizeof(command)); - - sscanf(buf, "%[^\n]", command); - - ShowInfo("Console command :%s", command); - - if( strcmpi("shutdown", command) == 0 || - strcmpi("exit", command) == 0 || - strcmpi("quit", command) == 0 || - strcmpi("end", command) == 0 ) - runflag = 0; - else - if( strcmpi("alive", command) == 0 || - strcmpi("status", command) == 0 ) - ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else - if( strcmpi("help", command) == 0 ) { - ShowInfo(CL_BOLD"Help of commands:"CL_RESET"\n"); - ShowInfo(" To shutdown the server:\n"); - ShowInfo(" 'shutdown|exit|quit|end'\n"); - ShowInfo(" To know if server is alive:\n"); - ShowInfo(" 'alive|status'\n"); - } - - return 0; -} - -static int online_data_cleanup_sub(DBKey key, void *data, va_list ap) -{ - struct online_login_data *character= (struct online_login_data*)data; - if (character->char_server == -2) //Unknown server.. set them offline - remove_online_user(character->account_id); - return 0; -} - -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr data) -{ - online_db->foreach(online_db, online_data_cleanup_sub); - return 0; -} - -//---------------------------------- -// Reading Lan Support configuration -//---------------------------------- -int login_lan_config_read(const char *lancfgName) -{ - FILE *fp; - int line_num = 0; - char line[1024], w1[64], w2[64], w3[64], w4[64]; - - if((fp = fopen(lancfgName, "r")) == NULL) { - ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName); - return 1; - } - - ShowInfo("Reading the configuration file %s...\n", lancfgName); - - while(fgets(line, sizeof(line), fp)) - { - line_num++; - if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') - continue; - - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) - { - ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); - continue; - } - - if( strcmpi(w1, "subnet") == 0 ) - { - subnet[subnet_count].mask = str2ip(w2); - subnet[subnet_count].char_ip = str2ip(w3); - subnet[subnet_count].map_ip = str2ip(w4); - - if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) - { - ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); - continue; - } - - subnet_count++; - } - } - - ShowStatus("Read information about %d subnetworks.\n", subnet_count); - - fclose(fp); - return 0; -} - -//----------------------------------------------------- -// clear expired ip bans -//----------------------------------------------------- -int ip_ban_flush(int tid, unsigned int tick, int id, intptr data) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") ) - Sql_ShowDebug(sql_handle); - - return 0; -} - -//----------------------------------- -// Reading main configuration file -//----------------------------------- -int login_config_read(const char* cfgName) -{ - char line[1024], w1[1024], w2[1024]; - FILE* fp = fopen(cfgName, "r"); - if (fp == NULL) { - ShowError("Configuration file (%s) not found.\n", cfgName); - return 1; - } - ShowInfo("Reading configuration file %s...\n", cfgName); - while(fgets(line, sizeof(line), fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) - continue; - - if(!strcmpi(w1,"timestamp_format")) - strncpy(timestamp_format, w2, 20); - else if(!strcmpi(w1,"stdout_with_ansisequence")) - stdout_with_ansisequence = config_switch(w2); - else if(!strcmpi(w1,"console_silent")) { - ShowInfo("Console Silent Setting: %d\n", atoi(w2)); - msg_silent = atoi(w2); - } - else if( !strcmpi(w1, "bind_ip") ) { - char ip_str[16]; - login_config.login_ip = host2ip(w2); - if( login_config.login_ip ) - ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str)); - } - else if( !strcmpi(w1, "login_port") ) { - login_config.login_port = (uint16)atoi(w2); - ShowStatus("set login_port : %s\n",w2); - } - else if(!strcmpi(w1, "log_login")) - login_config.log_login = (bool)config_switch(w2); - - else if(!strcmpi(w1, "ipban")) - login_config.ipban = (bool)config_switch(w2); - else if(!strcmpi(w1, "dynamic_pass_failure_ban")) - login_config.dynamic_pass_failure_ban = (bool)config_switch(w2); - else if(!strcmpi(w1, "dynamic_pass_failure_ban_interval")) - login_config.dynamic_pass_failure_ban_interval = atoi(w2); - else if(!strcmpi(w1, "dynamic_pass_failure_ban_limit")) - login_config.dynamic_pass_failure_ban_limit = atoi(w2); - else if(!strcmpi(w1, "dynamic_pass_failure_ban_duration")) - login_config.dynamic_pass_failure_ban_duration = atoi(w2); - - else if(!strcmpi(w1, "new_account")) - login_config.new_account_flag = (bool)config_switch(w2); - else if(!strcmpi(w1, "start_limited_time")) - login_config.start_limited_time = atoi(w2); - else if(!strcmpi(w1, "check_client_version")) - login_config.check_client_version = (bool)config_switch(w2); - else if(!strcmpi(w1, "client_version_to_connect")) - login_config.client_version_to_connect = atoi(w2); - else if(!strcmpi(w1, "use_MD5_passwords")) - login_config.use_md5_passwds = (bool)config_switch(w2); - else if(!strcmpi(w1, "min_level_to_connect")) - login_config.min_level_to_connect = atoi(w2); - else if(!strcmpi(w1, "date_format")) - safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format)); - else if(!strcmpi(w1, "console")) - login_config.console = (bool)config_switch(w2); - else if(!strcmpi(w1, "case_sensitive")) - login_config.case_sensitive = (bool)config_switch(w2); - else if(!strcmpi(w1, "allowed_regs")) //account flood protection system - allowed_regs = atoi(w2); - else if(!strcmpi(w1, "time_allowed")) - time_allowed = atoi(w2); - else if(!strcmpi(w1, "online_check")) - login_config.online_check = (bool)config_switch(w2); - else if(!strcmpi(w1, "use_dnsbl")) - login_config.use_dnsbl = (bool)config_switch(w2); - else if(!strcmpi(w1, "dnsbl_servers")) - safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs)); - else if(!strcmpi(w1, "ip_sync_interval")) - login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes. - else if(!strcmpi(w1, "import")) - login_config_read(w2); - } - fclose(fp); - ShowInfo("Finished reading %s.\n", cfgName); - return 0; -} - -void sql_config_read(const char* cfgName) -{ - char line[1024], w1[1024], w2[1024]; - FILE* fp = fopen(cfgName, "r"); - if(fp == NULL) { - ShowError("file not found: %s\n", cfgName); - return; - } - ShowInfo("reading configuration file %s...\n", cfgName); - while(fgets(line, sizeof(line), fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) - continue; - - if (!strcmpi(w1, "gm_read_method")) - login_config.login_gm_read = (atoi(w2) == 0); - else if (!strcmpi(w1, "login_db")) - strcpy(login_db, w2); - else if (!strcmpi(w1, "login_server_ip")) - strcpy(login_server_ip, w2); - else if (!strcmpi(w1, "login_server_port")) - login_server_port = (uint16)atoi(w2); - else if (!strcmpi(w1, "login_server_id")) - strcpy(login_server_id, w2); - else if (!strcmpi(w1, "login_server_pw")) - strcpy(login_server_pw, w2); - else if (!strcmpi(w1, "login_server_db")) - strcpy(login_server_db, w2); - else if (!strcmpi(w1, "default_codepage")) - strcpy(default_codepage, w2); - else if (!strcmpi(w1, "login_db_account_id")) - strcpy(login_db_account_id, w2); - else if (!strcmpi(w1, "login_db_userid")) - strcpy(login_db_userid, w2); - else if (!strcmpi(w1, "login_db_user_pass")) - strcpy(login_db_user_pass, w2); - else if (!strcmpi(w1, "login_db_level")) - strcpy(login_db_level, w2); - else if (!strcmpi(w1, "loginlog_db")) - strcpy(loginlog_db, w2); - else if (!strcmpi(w1, "reg_db")) - strcpy(reg_db, w2); - else if (!strcmpi(w1, "import")) - sql_config_read(w2); - } - fclose(fp); - ShowInfo("Done reading %s.\n", cfgName); -} - -void login_set_defaults() -{ - login_config.login_ip = INADDR_ANY; - login_config.login_port = 6900; - login_config.ip_sync_interval = 0; - login_config.log_login = true; - safestrncpy(login_config.date_format, "%Y-%m-%d %H:%M:%S", sizeof(login_config.date_format)); - login_config.console = false; - login_config.new_account_flag = true; - login_config.case_sensitive = true; - login_config.use_md5_passwds = false; - login_config.login_gm_read = true; - login_config.min_level_to_connect = 0; - login_config.online_check = true; - login_config.check_client_version = false; - login_config.client_version_to_connect = 20; - - login_config.ipban = true; - login_config.dynamic_pass_failure_ban = true; - login_config.dynamic_pass_failure_ban_interval = 5; - login_config.dynamic_pass_failure_ban_limit = 7; - login_config.dynamic_pass_failure_ban_duration = 5; - login_config.use_dnsbl = false; - safestrncpy(login_config.dnsbl_servs, "", sizeof(login_config.dnsbl_servs)); -} - -//-------------------------------------- -// Function called at exit of the server -//-------------------------------------- -void do_final(void) -{ - int i, fd; - ShowStatus("Terminating...\n"); - - mmo_db_close(); - online_db->destroy(online_db, NULL); - auth_db->destroy(auth_db, NULL); - - if(gm_account_db) aFree(gm_account_db); - - for (i = 0; i < MAX_SERVERS; i++) { - if ((fd = server[i].fd) >= 0) { - memset(&server[i], 0, sizeof(struct mmo_char_server)); - server[i].fd = -1; - do_close(fd); - } - } - do_close(login_fd); - - ShowStatus("Finished.\n"); -} - -//------------------------------ -// Function called when the server -// has received a crash signal. -//------------------------------ -void do_abort(void) -{ -} - -void set_server_type(void) -{ - SERVER_TYPE = ATHENA_SERVER_LOGIN; -} - -//------------------------------ -// Login server initialization -//------------------------------ -int do_init(int argc, char** argv) -{ - int i; - - login_set_defaults(); - - // read login-server configuration - login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); - sql_config_read(SQL_CONF_NAME); - login_lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); - - srand((unsigned int)time(NULL)); - - for( i = 0; i < MAX_SERVERS; i++ ) - server[i].fd = -1; - - // Online user database init - online_db = idb_alloc(DB_OPT_RELEASE_DATA); - add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); - - // Auth init - auth_db = idb_alloc(DB_OPT_RELEASE_DATA); - mmo_auth_sqldb_init(); - - // Read account information. - if(login_config.login_gm_read) - read_gm_account(); - - // set default parser as parse_login function - set_defaultparse(parse_login); - - // ban deleter timer - add_timer_func_list(ip_ban_flush, "ip_ban_flush"); - add_timer_interval(gettick()+10, ip_ban_flush, 0, 0, 60*1000); - - // every 10 minutes cleanup online account db. - add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - add_timer_interval(gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); - - // add timer to detect ip address change and perform update - if (login_config.ip_sync_interval) { - add_timer_func_list(sync_ip_addresses, "sync_ip_addresses"); - add_timer_interval(gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); - } - - if( login_config.console ) - { - //##TODO invoke a CONSOLE_START plugin event - } - - new_reg_tick = gettick(); - - // server port open & binding - login_fd = make_listen_bind(login_config.login_ip, login_config.login_port); - - ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); - - return 0; -} diff --git a/src/login_sql/login.h b/src/login_sql/login.h deleted file mode 100644 index d343c0905..000000000 --- a/src/login_sql/login.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _LOGIN_SQL_H_ -#define _LOGIN_SQL_H_ - -#include "../common/mmo.h" // NAME_LENGTH - -#define LOGIN_CONF_NAME "conf/login_athena.conf" -#define SQL_CONF_NAME "conf/inter_athena.conf" -#define LAN_CONF_NAME "conf/subnet_athena.conf" - -// supported encryption types: 1- passwordencrypt, 2- passwordencrypt2, 3- both -#define PASSWORDENC 3 - -struct login_session_data { - - int account_id; - long login_id1; - long login_id2; - char sex; - - char userid[NAME_LENGTH]; - char passwd[NAME_LENGTH]; - int passwdenc; - char md5key[20]; - uint16 md5keylen; - - char lastlogin[24]; - uint8 level; - int version; - - int fd; -}; - -struct mmo_char_server { - char name[20]; - int fd; - uint32 ip; - uint16 port; - int users; - int maintenance; - int new_; -}; - -struct Login_Config { - - uint32 login_ip; // the address to bind to - uint16 login_port; // the port to bind to - unsigned int ip_sync_interval; // interval (in minutes) to execute a DNS/IP update (for dynamic IPs) - bool log_login; // whether to log login server actions or not - char date_format[32]; // date format used in messages - bool console; // console input system enabled? - bool new_account_flag; // autoregistration via _M/_F ? - int start_limited_time; // new account expiration time (-1: unlimited) - bool case_sensitive; // are logins case sensitive ? - bool use_md5_passwds; // work with password hashes instead of plaintext passwords? - bool login_gm_read; // should the login server handle info about gm accounts? - int min_level_to_connect; // minimum level of player/GM (0: player, 1-99: GM) to connect - bool online_check; // reject incoming players that are already registered as online ? - bool check_client_version; // check the clientversion set in the clientinfo ? - int client_version_to_connect; // the client version needed to connect (if checking is enabled) - - bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? - bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? - unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures - unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban - unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban - bool use_dnsbl; // dns blacklist blocking ? - char dnsbl_servs[1024]; // comma-separated list of dnsbl servers - -}; - -struct mmo_account { - - int account_id; - char sex; - char userid[24]; - char pass[32+1]; // 23+1 for normal, 32+1 for md5-ed passwords - char lastlogin[24]; - int logincount; - uint32 state; // packet 0x006a value + 1 (0: compte OK) - char email[40]; // e-mail (by default: a@a.com) - char error_message[20]; // Message of error code #6 = Your are Prohibited to log in until %s (packet 0x006a) - time_t unban_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - char last_ip[16]; // save of last IP of connection - char memo[255]; // a memo field - int account_reg2_num; - struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server) -}; - - -#endif /* _LOGIN_SQL_H_ */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 91727695b..dab99cb51 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4187,19 +4187,6 @@ int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char return 0; } -/*========================================== - * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database) - *------------------------------------------*/ -int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message) -{ - nullpo_retr(-1, sd); - chrif_reloadGMdb(); - - clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level. - - return 0; -} - /*========================================== * @mapinfo [0-3] by MC_Cameri * => Shows information about the map [map name] @@ -6632,7 +6619,7 @@ int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* co return -1; } - pc_set_gm_level(pl_sd->status.account_id, newlev); + sd->gmlevel = newlev; return 0; } @@ -8191,7 +8178,7 @@ int atcommand_request(const int fd, struct map_session_data* sd, const char* com } sprintf(atcmd_output, msg_txt(278), message); // (@request): %s - intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output); + intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output); clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output)); clif_displaymessage(sd->fd,msg_txt(279)); // @request sent. return 0; @@ -8400,7 +8387,6 @@ AtCommandInfo atcommand_info[] = { { "reloadmobdb", 99, atcommand_reloadmobdb }, { "reloadskilldb", 99, atcommand_reloadskilldb }, { "reloadscript", 99, atcommand_reloadscript }, - { "reloadgmdb", 99, atcommand_reloadgmdb }, { "reloadatcommand", 99, atcommand_reloadatcommand }, { "reloadbattleconf", 99, atcommand_reloadbattleconf }, { "reloadstatusdb", 99, atcommand_reloadstatusdb }, diff --git a/src/map/battle.c b/src/map/battle.c index d7bae3c0e..98fc40062 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3395,6 +3395,7 @@ static const struct _battle_data { { "guild_max_castles", &battle_config.guild_max_castles, 0, 0, INT_MAX, }, { "guild_skill_relog_delay", &battle_config.guild_skill_relog_delay, 0, 0, 1, }, { "emergency_call", &battle_config.emergency_call, 11, 0, 31, }, + { "lowest_gm_level", &battle_config.lowest_gm_level, 1, 0, 99, }, { "atcommand_gm_only", &battle_config.atc_gmonly, 0, 0, 1, }, { "atcommand_spawn_quantity_limit", &battle_config.atc_spawn_quantity_limit, 100, 0, INT_MAX, }, { "atcommand_slave_clone_limit", &battle_config.atc_slave_clone_limit, 25, 0, INT_MAX, }, diff --git a/src/map/battle.h b/src/map/battle.h index bb7e53278..cb3b0f265 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -141,6 +141,7 @@ extern struct Battle_Config int monster_max_aspd; int view_range_rate; int chase_range_rate; + int lowest_gm_level; int atc_gmonly; int atc_spawn_quantity_limit; int atc_slave_clone_limit; diff --git a/src/map/chrif.c b/src/map/chrif.c index 725fbcc07..a46186fc1 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -36,7 +36,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff 6,-1,18, 7,-1,35,30,-1, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, F->2b07 6,30,-1,-1,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f - 11,10,10, 6,11,-1,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17 + 11,10,10, 6,11,-1,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, F->2b15, U->2b16, U->2b17 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 }; @@ -71,7 +71,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free //2b12: Incoming, chrif_divorceack -> 'divorce chars //2b13: Incoming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....' //2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY' -//2b15: Incoming, chrif_recvgmaccounts -> 'receive gm accs from charserver (seems to be incomplete !)' +//2b15: FREE //2b16: Outgoing, chrif_ragsrvinfo -> 'sends motd / rates ....' //2b17: Outgoing, chrif_char_offline -> 'tell the charserver that the char is now offline' //2b18: Outgoing, chrif_char_reset_offline -> 'set all players OFF!' @@ -512,56 +512,58 @@ int chrif_scdata_request(int account_id, int char_id) } /*========================================== - * new auth system [Kevin] + * Request auth confirmation *------------------------------------------*/ void chrif_authreq(struct map_session_data *sd) { struct auth_node *node= chrif_search(sd->bl.id); - if(!node) { - //request data from char server and store current auth info - WFIFOHEAD(char_fd,19); - WFIFOW(char_fd,0) = 0x2b26; - WFIFOL(char_fd,2) = sd->status.account_id; - WFIFOL(char_fd,6) = sd->status.char_id; - WFIFOL(char_fd,10) = sd->login_id1; - WFIFOB(char_fd,14) = sd->status.sex; - WFIFOL(char_fd,15) = htonl(session[sd->fd]->client_addr); - WFIFOSET(char_fd,19); - chrif_sd_to_auth(sd, ST_LOGIN); + if( node != NULL ) + { + set_eof(sd->fd); return; - } else { //char already online? kick connect request and tell char server that this person is online - //This case shouldn't happen in an ideal system - pc_authfail(sd); - chrif_char_online(sd); } - return; + + WFIFOHEAD(char_fd,19); + WFIFOW(char_fd,0) = 0x2b26; + WFIFOL(char_fd,2) = sd->status.account_id; + WFIFOL(char_fd,6) = sd->status.char_id; + WFIFOL(char_fd,10) = sd->login_id1; + WFIFOB(char_fd,14) = sd->status.sex; + WFIFOL(char_fd,15) = htonl(session[sd->fd]->client_addr); + WFIFOSET(char_fd,19); + chrif_sd_to_auth(sd, ST_LOGIN); } -//character selected, insert into auth db +/*========================================== + * Auth confirmation ack + *------------------------------------------*/ void chrif_authok(int fd) { int account_id; uint32 login_id1; - time_t expiration_time; uint32 login_id2; + time_t expiration_time; + int gmlevel; struct mmo_charstatus* status; int char_id; struct auth_node *node; TBL_PC* sd; //Check if both servers agree on the struct's size - if( RFIFOW(fd,2) - 20 != sizeof(struct mmo_charstatus) ) + if( RFIFOW(fd,2) - 24 != sizeof(struct mmo_charstatus) ) { - ShowError("chrif_authok: Data size mismatch! %d != %d\n", RFIFOW(fd,2) - 20, sizeof(struct mmo_charstatus)); + ShowError("chrif_authok: Data size mismatch! %d != %d\n", RFIFOW(fd,2) - 24, sizeof(struct mmo_charstatus)); return; } account_id = RFIFOL(fd,4); login_id1 = RFIFOL(fd,8); - expiration_time = (time_t)(int32)RFIFOL(fd,12); - login_id2 = RFIFOL(fd,16); - status = (struct mmo_charstatus*)RFIFOP(fd,20); + login_id2 = RFIFOL(fd,12); + expiration_time = (time_t)(int32)RFIFOL(fd,16); + gmlevel = RFIFOL(fd,20); + status = (struct mmo_charstatus*)RFIFOP(fd,24); + char_id = status->char_id; //Check if we don't already have player data in our server @@ -569,33 +571,35 @@ void chrif_authok(int fd) if ((sd = map_id2sd(account_id)) != NULL) return; - if ((node = chrif_search(account_id))) - { //Is the character already awaiting authorization? - if (node->state != ST_LOGIN) - return; //character in logout phase, do not touch that data. - if (node->sd) - { - sd = node->sd; - if(node->char_dat == NULL && - node->account_id == account_id && - node->char_id == char_id && - node->login_id1 == login_id1 ) - { //Auth Ok - if (pc_authok(sd, login_id2, expiration_time, status)) - { - return; - } - } else { //Auth Failed - pc_authfail(sd); - } - chrif_char_offline(sd); //Set client offline - chrif_auth_delete(account_id, char_id, ST_LOGIN); - return; - } + if ((node = chrif_search(account_id)) == NULL) + return; // should not happen + + if (node->state != ST_LOGIN) + return; //character in logout phase, do not touch that data. + + if (node->sd == NULL) + { + /* //When we receive double login info and the client has not connected yet, //discard the older one and keep the new one. chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN); + */ + return; // should not happen + } + + sd = node->sd; + if(node->char_dat == NULL && + node->account_id == account_id && + node->char_id == char_id && + node->login_id1 == login_id1 ) + { //Auth Ok + if (pc_authok(sd, login_id2, expiration_time, gmlevel, status)) + return; + } else { //Auth Failed + pc_authfail(sd); } + chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already. + chrif_auth_delete(account_id, char_id, ST_LOGIN); } // client authentication failed @@ -1035,30 +1039,6 @@ int chrif_disconnectplayer(int fd) return 0; } -/*========================================== - * Request to reload GM accounts and their levels: send to char-server by [Yor] - *------------------------------------------*/ -int chrif_reloadGMdb(void) -{ - chrif_check(-1); - - WFIFOHEAD(char_fd,2); - WFIFOW(char_fd,0) = 0x2af7; - WFIFOSET(char_fd,2); - - return 0; -} - -/*========================================== - * Receiving GM accounts and their levels from char-server by [Yor] - *------------------------------------------*/ -int chrif_recvgmaccounts(int fd) -{ - int nAccounts = pc_read_gm_account(fd); - ShowInfo("From login-server: receiving information of '"CL_WHITE"%d"CL_RESET"' GM accounts.\n", nAccounts); - return 0; -} - /*========================================== * Request/Receive top 10 Fame character list *------------------------------------------*/ @@ -1454,7 +1434,6 @@ int chrif_parse(int fd) case 0x2b12: chrif_divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break; case 0x2b13: chrif_accountdeletion(fd); break; case 0x2b14: chrif_accountban(fd); break; - case 0x2b15: chrif_recvgmaccounts(fd); break; case 0x2b1b: chrif_recvfamelist(fd); break; case 0x2b1d: chrif_load_scdata(fd); break; case 0x2b1e: chrif_update_ip(fd); break; diff --git a/src/map/chrif.h b/src/map/chrif.h index a8487533c..9ff5b9a0e 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -44,7 +44,6 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port); int chrif_searchcharid(int char_id); int chrif_changeemail(int id, const char *actual_email, const char *new_email); int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second); -int chrif_reloadGMdb(void); int chrif_updatefamelist(struct map_session_data *sd); int chrif_buildfamelist(void); int chrif_save_scdata(struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 07d353aed..8c80644d0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -79,8 +79,6 @@ Sql* logmysql_handle; #endif /* not TXT_ONLY */ -int lowest_gm_level = 1; - // This param using for sending mainchat // messages like whispers to this nick. [LuzZza] char main_chat_nick[16] = "Main"; @@ -2955,13 +2953,8 @@ int inter_config_read(char *cfgName) i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2); if(i!=2) continue; - if(strcmpi(w1,"party_share_level")==0){ - party_share_level = config_switch(w2); - } else if(strcmpi(w1,"lowest_gm_level")==0){ - lowest_gm_level = atoi(w2); - - /* Main chat nick [LuzZza] */ - } else if(strcmpi(w1, "main_chat_nick")==0){ + + if(strcmpi(w1, "main_chat_nick")==0){ strcpy(main_chat_nick, w2); #ifndef TXT_ONLY @@ -3068,37 +3061,6 @@ int log_sql_init(void) return 0; } -/*============================================= - * Does a mysql_ping to all connection handles - *---------------------------------------------*/ -int map_sql_ping(int tid, unsigned int tick, int id, intptr data) -{ - ShowInfo("Pinging SQL server to keep connection alive...\n"); - Sql_Ping(mmysql_handle); - if (log_config.sql_logs) - Sql_Ping(logmysql_handle); - return 0; -} - -int sql_ping_init(void) -{ - uint32 connection_timeout, connection_ping_interval; - - // set a default value - connection_timeout = 28800; // 8 hours - - // ask the mysql server for the timeout value - Sql_GetTimeout(mmysql_handle, &connection_timeout); - if (connection_timeout < 60) - connection_timeout = 60; - - // establish keepalive - connection_ping_interval = connection_timeout - 30; // 30-second reserve - add_timer_func_list(map_sql_ping, "map_sql_ping"); - add_timer_interval(gettick() + connection_ping_interval*1000, map_sql_ping, 0, 0, connection_ping_interval*1000); - - return 0; -} #endif /* not TXT_ONLY */ int map_db_final(DBKey k,void *d,va_list ap) @@ -3436,8 +3398,6 @@ int do_init(int argc, char *argv[]) #ifndef TXT_ONLY /* mail system [Valaris] */ if (log_config.sql_logs) log_sql_init(); - - sql_ping_init(); #endif /* not TXT_ONLY */ npc_event_do_oninit(); // npc‚ÌOnInitƒCƒxƒ“ƒg?s diff --git a/src/map/map.h b/src/map/map.h index 2f46c4e3e..429370a95 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -633,7 +633,6 @@ typedef struct homun_data TBL_HOM; ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) ) -extern int lowest_gm_level; extern char main_chat_nick[16]; #ifndef TXT_ONLY diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 44c9ce82e..d7edf69f0 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -14,7 +14,7 @@ #include "pc.h" // struct map_session_data #include "script.h" // set_var() -#include "pcre.h" +#include #include #include diff --git a/src/map/party.c b/src/map/party.c index 28c5154e7..82cecc3ff 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -28,7 +28,6 @@ static DBMap* party_db; // int party_id -> struct party_data* -int party_share_level = 10; int party_send_xy_timer(int tid, unsigned int tick, int id, intptr data); /*========================================== diff --git a/src/map/party.h b/src/map/party.h index 65f585b10..9ad729c28 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -31,8 +31,6 @@ struct party_data { }; -extern int party_share_level; - void do_init_party(void); void do_final_party(void); struct party_data* party_search(int party_id); diff --git a/src/map/pc.c b/src/map/pc.c index 3c9d5756a..bb24b097a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6,7 +6,7 @@ #include "../common/malloc.h" #include "../common/nullpo.h" #include "../common/showmsg.h" -#include "../common/socket.h" // RFIFO*() +#include "../common/socket.h" // session[] #include "../common/strlib.h" // safestrncpy() #include "../common/timer.h" #include "../common/utils.h" @@ -58,9 +58,6 @@ struct fame_list taekwon_fame_list[MAX_FAME_LIST]; static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_AMMO}; -static struct gm_account *gm_account = NULL; -static int GM_num = 0; - #define MOTD_LINE_SIZE 128 char motd_text[MOTD_LINE_SIZE][256]; // Message of the day buffer [Valaris] @@ -85,34 +82,7 @@ int pc_class2idx(int class_) { int pc_isGM(struct map_session_data* sd) { - int i; - nullpo_retr(0, sd); - - if( sd->bl.type != BL_PC ) - return 99; - - ARR_FIND( 0, GM_num, i, gm_account[i].account_id == sd->status.account_id ); - return ( i < GM_num ) ? gm_account[i].level : 0; -} - -int pc_set_gm_level(int account_id, int level) -{ - int i; - - ARR_FIND( 0, GM_num, i, account_id == gm_account[i].account_id ); - if( i < GM_num ) - { - gm_account[i].level = level; - } - else - { - gm_account = (struct gm_account *) aRealloc(gm_account, (GM_num + 1) * sizeof(struct gm_account)); - gm_account[GM_num].account_id = account_id; - gm_account[GM_num].level = level; - GM_num++; - } - - return 0; + return sd->gmlevel; } static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr data) @@ -709,12 +679,13 @@ int pc_isequip(struct map_session_data *sd,int n) * session id‚É–â‘è–³‚µ * charŽI‚©‚ç‘—‚ç‚ê‚Ä‚«‚½ƒXƒe?ƒ^ƒX‚ðÝ’è *------------------------------------------*/ -bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, struct mmo_charstatus *st) +bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int gmlevel, struct mmo_charstatus *st) { int i; unsigned long tick = gettick(); sd->login_id2 = login_id2; + sd->gmlevel = gmlevel; memcpy(&sd->status, st, sizeof(*st)); if (st->sex != sd->status.sex) { @@ -6925,21 +6896,6 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr data) return 0; } -int pc_read_gm_account(int fd) -{ - //FIXME: this implementation is a total failure (direct reading from RFIFO) [ultramage] - int i = 0; - if (gm_account != NULL) - aFree(gm_account); - GM_num = 0; - gm_account = (struct gm_account *) aMallocA(((RFIFOW(fd,2) - 4) / 5)*sizeof(struct gm_account)); - for (i = 4; i < RFIFOW(fd,2); i += 5) { - gm_account[GM_num].account_id = RFIFOL(fd,i); - gm_account[GM_num].level = (int)RFIFOB(fd,i+4); - GM_num++; - } - return GM_num; -} static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { if (sd->state.night != night_flag && map[sd->bl.m].flag.nightenabled) @@ -7487,8 +7443,6 @@ int pc_read_motd(void) *------------------------------------------*/ void do_final_pc(void) { - if (gm_account) - aFree(gm_account); return; } diff --git a/src/map/pc.h b/src/map/pc.h index 81a1e9a75..d8dd582c5 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -130,6 +130,7 @@ struct map_session_data { } special_state; int login_id1, login_id2; unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] + int gmlevel; int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 ... 18 struct mmo_charstatus status; @@ -498,7 +499,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type); int pc_makesavestatus(struct map_session_data *); void pc_respawn(struct map_session_data* sd, uint8 clrtype); int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int); -bool pc_authok(struct map_session_data*, int, time_t, struct mmo_charstatus *); +bool pc_authok(struct map_session_data* sd, int, time_t, int gmlevel, struct mmo_charstatus* status); void pc_authfail(struct map_session_data *); int pc_reg_received(struct map_session_data *sd); @@ -655,7 +656,6 @@ struct map_session_data *pc_get_child(struct map_session_data *sd); void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick); void pc_regen (struct map_session_data *sd, unsigned int diff_tick); -int pc_set_gm_level(int account_id, int level); void pc_setstand(struct map_session_data *sd); int pc_candrop(struct map_session_data *sd,struct item *item); @@ -685,7 +685,6 @@ struct sg_data { }; extern const struct sg_data sg_info[3]; -int pc_read_gm_account(int fd); void pc_setinvincibletimer(struct map_session_data* sd, int val); void pc_delinvincibletimer(struct map_session_data* sd); diff --git a/src/map/pcre.h b/src/map/pcre.h deleted file mode 100644 index e973396ba..000000000 --- a/src/map/pcre.h +++ /dev/null @@ -1,294 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* This is the public header file for the PCRE library, to be #included by -applications that call the PCRE functions. - - Copyright (c) 1997-2006 University of Cambridge - ------------------------------------------------------------------------------ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of the University of Cambridge nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ -*/ - -#ifndef _PCRE_H -#define _PCRE_H - -/* The current PCRE version information. */ - -/* NOTES FOR FUTURE MAINTAINERS: Do not use numbers with leading zeros, because -they may be treated as octal constants. The PCRE_PRERELEASE feature is for -identifying release candidates. It might be defined as -RC2, for example. In -real releases, it should be defined empty. Do not change the alignment of these -statments. The code in ./configure greps out the version numbers by using "cut" -to get values from column 29 onwards. These are substituted into pcre-config -and libpcre.pc. The values are not put into configure.ac and substituted here -(which would simplify this issue) because that makes life harder for those who -cannot run ./configure. As it now stands, this file need not be edited in that -circumstance. */ - -#define PCRE_MAJOR 7 -#define PCRE_MINOR 0 -#define PCRE_PRERELEASE -#define PCRE_DATE 18-Dec-2006 - -/* Win32 uses DLL by default; it needs special stuff for exported functions -when building PCRE. */ - -#ifdef _WIN32 -# ifdef PCRE_DEFINITION -# ifdef DLL_EXPORT -# define PCRE_DATA_SCOPE __declspec(dllexport) -# endif -# else -# ifndef PCRE_STATIC -# define PCRE_DATA_SCOPE extern __declspec(dllimport) -# endif -# endif -#endif - -/* Otherwise, we use the standard "extern". */ - -#ifndef PCRE_DATA_SCOPE -# ifdef __cplusplus -# define PCRE_DATA_SCOPE extern "C" -# else -# define PCRE_DATA_SCOPE extern -# endif -#endif - -/* Have to include stdlib.h in order to ensure that size_t is defined; -it is needed here for malloc. */ - -#include - -/* Allow for C++ users */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Options */ - -#define PCRE_CASELESS 0x00000001 -#define PCRE_MULTILINE 0x00000002 -#define PCRE_DOTALL 0x00000004 -#define PCRE_EXTENDED 0x00000008 -#define PCRE_ANCHORED 0x00000010 -#define PCRE_DOLLAR_ENDONLY 0x00000020 -#define PCRE_EXTRA 0x00000040 -#define PCRE_NOTBOL 0x00000080 -#define PCRE_NOTEOL 0x00000100 -#define PCRE_UNGREEDY 0x00000200 -#define PCRE_NOTEMPTY 0x00000400 -#define PCRE_UTF8 0x00000800 -#define PCRE_NO_AUTO_CAPTURE 0x00001000 -#define PCRE_NO_UTF8_CHECK 0x00002000 -#define PCRE_AUTO_CALLOUT 0x00004000 -#define PCRE_PARTIAL 0x00008000 -#define PCRE_DFA_SHORTEST 0x00010000 -#define PCRE_DFA_RESTART 0x00020000 -#define PCRE_FIRSTLINE 0x00040000 -#define PCRE_DUPNAMES 0x00080000 -#define PCRE_NEWLINE_CR 0x00100000 -#define PCRE_NEWLINE_LF 0x00200000 -#define PCRE_NEWLINE_CRLF 0x00300000 -#define PCRE_NEWLINE_ANY 0x00400000 - -/* Exec-time and get/set-time error codes */ - -#define PCRE_ERROR_NOMATCH (-1) -#define PCRE_ERROR_NULL (-2) -#define PCRE_ERROR_BADOPTION (-3) -#define PCRE_ERROR_BADMAGIC (-4) -#define PCRE_ERROR_UNKNOWN_OPCODE (-5) -#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */ -#define PCRE_ERROR_NOMEMORY (-6) -#define PCRE_ERROR_NOSUBSTRING (-7) -#define PCRE_ERROR_MATCHLIMIT (-8) -#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */ -#define PCRE_ERROR_BADUTF8 (-10) -#define PCRE_ERROR_BADUTF8_OFFSET (-11) -#define PCRE_ERROR_PARTIAL (-12) -#define PCRE_ERROR_BADPARTIAL (-13) -#define PCRE_ERROR_INTERNAL (-14) -#define PCRE_ERROR_BADCOUNT (-15) -#define PCRE_ERROR_DFA_UITEM (-16) -#define PCRE_ERROR_DFA_UCOND (-17) -#define PCRE_ERROR_DFA_UMLIMIT (-18) -#define PCRE_ERROR_DFA_WSSIZE (-19) -#define PCRE_ERROR_DFA_RECURSE (-20) -#define PCRE_ERROR_RECURSIONLIMIT (-21) -#define PCRE_ERROR_NULLWSLIMIT (-22) -#define PCRE_ERROR_BADNEWLINE (-23) - -/* Request types for pcre_fullinfo() */ - -#define PCRE_INFO_OPTIONS 0 -#define PCRE_INFO_SIZE 1 -#define PCRE_INFO_CAPTURECOUNT 2 -#define PCRE_INFO_BACKREFMAX 3 -#define PCRE_INFO_FIRSTBYTE 4 -#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */ -#define PCRE_INFO_FIRSTTABLE 5 -#define PCRE_INFO_LASTLITERAL 6 -#define PCRE_INFO_NAMEENTRYSIZE 7 -#define PCRE_INFO_NAMECOUNT 8 -#define PCRE_INFO_NAMETABLE 9 -#define PCRE_INFO_STUDYSIZE 10 -#define PCRE_INFO_DEFAULT_TABLES 11 - -/* Request types for pcre_config(). Do not re-arrange, in order to remain -compatible. */ - -#define PCRE_CONFIG_UTF8 0 -#define PCRE_CONFIG_NEWLINE 1 -#define PCRE_CONFIG_LINK_SIZE 2 -#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3 -#define PCRE_CONFIG_MATCH_LIMIT 4 -#define PCRE_CONFIG_STACKRECURSE 5 -#define PCRE_CONFIG_UNICODE_PROPERTIES 6 -#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 - -/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine -these bits, just add new ones on the end, in order to remain compatible. */ - -#define PCRE_EXTRA_STUDY_DATA 0x0001 -#define PCRE_EXTRA_MATCH_LIMIT 0x0002 -#define PCRE_EXTRA_CALLOUT_DATA 0x0004 -#define PCRE_EXTRA_TABLES 0x0008 -#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010 - -/* Types */ - -struct real_pcre; /* declaration; the definition is private */ -typedef struct real_pcre pcre; - -/* When PCRE is compiled as a C++ library, the subject pointer type can be -replaced with a custom type. For conventional use, the public interface is a -const char *. */ - -#ifndef PCRE_SPTR -#define PCRE_SPTR const char * -#endif - -/* The structure for passing additional data to pcre_exec(). This is defined in -such as way as to be extensible. Always add new fields at the end, in order to -remain compatible. */ - -typedef struct pcre_extra { - unsigned long int flags; /* Bits for which fields are set */ - void *study_data; /* Opaque data from pcre_study() */ - unsigned long int match_limit; /* Maximum number of calls to match() */ - void *callout_data; /* Data passed back in callouts */ - const unsigned char *tables; /* Pointer to character tables */ - unsigned long int match_limit_recursion; /* Max recursive calls to match() */ -} pcre_extra; - -/* The structure for passing out data via the pcre_callout_function. We use a -structure so that new fields can be added on the end in future versions, -without changing the API of the function, thereby allowing old clients to work -without modification. */ - -typedef struct pcre_callout_block { - int version; /* Identifies version of block */ - /* ------------------------ Version 0 ------------------------------- */ - int callout_number; /* Number compiled into pattern */ - int *offset_vector; /* The offset vector */ - PCRE_SPTR subject; /* The subject being matched */ - int subject_length; /* The length of the subject */ - int start_match; /* Offset to start of this match attempt */ - int current_position; /* Where we currently are in the subject */ - int capture_top; /* Max current capture */ - int capture_last; /* Most recently closed capture */ - void *callout_data; /* Data passed in with the call */ - /* ------------------- Added for Version 1 -------------------------- */ - int pattern_position; /* Offset to next item in the pattern */ - int next_item_length; /* Length of next item in the pattern */ - /* ------------------------------------------------------------------ */ -} pcre_callout_block; - -/* Indirection for store get and free functions. These can be set to -alternative malloc/free functions if required. Special ones are used in the -non-recursive case for "frames". There is also an optional callout function -that is triggered by the (?) regex item. For Virtual Pascal, these definitions -have to take another form. */ - -#ifndef VPCOMPAT -PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t); -PCRE_DATA_SCOPE void (*pcre_free)(void *); -PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t); -PCRE_DATA_SCOPE void (*pcre_stack_free)(void *); -PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *); -#else /* VPCOMPAT */ -PCRE_DATA_SCOPE void *pcre_malloc(size_t); -PCRE_DATA_SCOPE void pcre_free(void *); -PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t); -PCRE_DATA_SCOPE void pcre_stack_free(void *); -PCRE_DATA_SCOPE int pcre_callout(pcre_callout_block *); -#endif /* VPCOMPAT */ - -/* Exported PCRE functions */ - -PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *, - const unsigned char *); -PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **, - int *, const unsigned char *); -PCRE_DATA_SCOPE int pcre_config(int, void *); -PCRE_DATA_SCOPE int pcre_copy_named_substring(const pcre *, const char *, - int *, int, const char *, char *, int); -PCRE_DATA_SCOPE int pcre_copy_substring(const char *, int *, int, int, char *, - int); -PCRE_DATA_SCOPE int pcre_dfa_exec(const pcre *, const pcre_extra *, - const char *, int, int, int, int *, int , int *, int); -PCRE_DATA_SCOPE int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, - int, int, int, int *, int); -PCRE_DATA_SCOPE void pcre_free_substring(const char *); -PCRE_DATA_SCOPE void pcre_free_substring_list(const char **); -PCRE_DATA_SCOPE int pcre_fullinfo(const pcre *, const pcre_extra *, int, - void *); -PCRE_DATA_SCOPE int pcre_get_named_substring(const pcre *, const char *, - int *, int, const char *, const char **); -PCRE_DATA_SCOPE int pcre_get_stringnumber(const pcre *, const char *); -PCRE_DATA_SCOPE int pcre_get_stringtable_entries(const pcre *, const char *, - char **, char **); -PCRE_DATA_SCOPE int pcre_get_substring(const char *, int *, int, int, - const char **); -PCRE_DATA_SCOPE int pcre_get_substring_list(const char *, int *, int, - const char ***); -PCRE_DATA_SCOPE int pcre_info(const pcre *, int *, int *); -PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void); -PCRE_DATA_SCOPE int pcre_refcount(pcre *, int); -PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **); -PCRE_DATA_SCOPE const char *pcre_version(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* End of pcre.h */ diff --git a/src/map/trade.c b/src/map/trade.c index 880657ff0..aca08872a 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -70,7 +70,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta } //Fixed. Only real GMs can request trade from far away! [Lupus] - if (level < lowest_gm_level && (sd->bl.m != target_sd->bl.m || + if (level < battle_config.lowest_gm_level && (sd->bl.m != target_sd->bl.m || !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE) )) { clif_tradestart(sd, 0); // too far @@ -127,7 +127,7 @@ void trade_tradeack(struct map_session_data *sd, int type) return; //If client didn't send accept, it's a broken packet? //Copied here as well since the original character could had warped. - if (pc_isGM(tsd) < lowest_gm_level && (sd->bl.m != tsd->bl.m || + if (pc_isGM(tsd) < battle_config.lowest_gm_level && (sd->bl.m != tsd->bl.m || !check_distance_bl(&sd->bl, &tsd->bl, TRADE_DISTANCE) )) { clif_tradestart(sd, 0); // too far diff --git a/src/mysql/config-win.h b/src/mysql/config-win.h deleted file mode 100644 index b2e1c9831..000000000 --- a/src/mysql/config-win.h +++ /dev/null @@ -1,470 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Defines for Win32 to make it compatible for MySQL */ - -#ifdef __WIN2000__ -/* We have to do this define before including windows.h to get the AWE API -functions */ -#define _WIN32_WINNT 0x0500 -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -/* Avoid endless warnings about sprintf() etc. being unsafe. */ -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif - -#include -#include -#include /* Because of rint() */ -#include -#include -#include - -#define HAVE_SMEM 1 - -#if defined(_WIN64) || defined(WIN64) -#define SYSTEM_TYPE "Win64" -#elif defined(_WIN32) || defined(WIN32) -#define SYSTEM_TYPE "Win32" -#else -#define SYSTEM_TYPE "Windows" -#endif - -#if defined(_M_IA64) -#define MACHINE_TYPE "ia64" -#elif defined(_M_IX86) -#define MACHINE_TYPE "ia32" -#elif defined(_M_ALPHA) -#define MACHINE_TYPE "axp" -#else -#define MACHINE_TYPE "unknown" /* Define to machine type name */ -#endif - -#if !(defined(_WIN64) || defined(WIN64)) -#ifndef _WIN32 -#define _WIN32 /* Compatible with old source */ -#endif -#ifndef __WIN32__ -#define __WIN32__ -#endif -#endif /* _WIN64 */ -#ifndef __WIN__ -#define __WIN__ /* To make it easier in VC++ */ -#endif - -#ifndef MAX_INDEXES -#define MAX_INDEXES 64 -#endif - -/* File and lock constants */ -#define O_SHARE 0x1000 /* Open file in sharing mode */ -#ifdef __BORLANDC__ -#define F_RDLCK LK_NBLCK /* read lock */ -#define F_WRLCK LK_NBRLCK /* write lock */ -#define F_UNLCK LK_UNLCK /* remove lock(s) */ -#else -#define F_RDLCK _LK_NBLCK /* read lock */ -#define F_WRLCK _LK_NBRLCK /* write lock */ -#define F_UNLCK _LK_UNLCK /* remove lock(s) */ -#endif - -#define F_EXCLUSIVE 1 /* We have only exclusive locking */ -#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ -#define F_OK 0 /* parameter to access() */ -#define W_OK 2 - -#define S_IROTH S_IREAD /* for my_lib */ - -#ifdef __BORLANDC__ -#define FILE_BINARY O_BINARY /* my_fopen in binary mode */ -#define O_TEMPORARY 0 -#define O_SHORT_LIVED 0 -#define SH_DENYNO _SH_DENYNO -#else -#define O_BINARY _O_BINARY /* compability with MSDOS */ -#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */ -#define O_TEMPORARY _O_TEMPORARY -#define O_SHORT_LIVED _O_SHORT_LIVED -#define SH_DENYNO _SH_DENYNO -#endif -#define NO_OPEN_3 /* For my_create() */ - -#define SIGQUIT SIGTERM /* No SIGQUIT */ - -#undef _REENTRANT /* Crashes something for win32 */ -#undef SAFE_MUTEX /* Can't be used on windows */ - -#if defined(_MSC_VER) && _MSC_VER >= 1310 -#define LL(A) A##ll -#define ULL(A) A##ull -#else -#define LL(A) ((__int64) A) -#define ULL(A) ((unsigned __int64) A) -#endif - -#define LONGLONG_MIN LL(0x8000000000000000) -#define LONGLONG_MAX LL(0x7FFFFFFFFFFFFFFF) -#define ULONGLONG_MAX ULL(0xFFFFFFFFFFFFFFFF) - -/* Type information */ - -#if defined(__EMX__) || !defined(HAVE_UINT) -#undef HAVE_UINT -#define HAVE_UINT -typedef unsigned short ushort; -typedef unsigned int uint; -#endif /* defined(__EMX__) || !defined(HAVE_UINT) */ - -typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ -typedef __int64 longlong; -#ifndef HAVE_SIGSET_T -typedef int sigset_t; -#endif -#define longlong_defined -/* - off_t should not be __int64 because of conflicts in header files; - Use my_off_t or os_off_t instead -*/ -#ifndef HAVE_OFF_T -typedef long off_t; -#endif -typedef __int64 os_off_t; -#ifdef _WIN64 -typedef UINT_PTR rf_SetTimer; -#else -#ifndef HAVE_SIZE_T -typedef unsigned int size_t; -#endif -typedef uint rf_SetTimer; -#endif - -#define Socket_defined -#define my_socket SOCKET -#define bool BOOL -#define SIGPIPE SIGINT -#define RETQSORTTYPE void -#define QSORT_TYPE_IS_VOID -#define RETSIGTYPE void -#define SOCKET_SIZE_TYPE int -#define my_socket_defined -#define bool_defined -#define byte_defined -#define HUGE_PTR -#define STDCALL __stdcall /* Used by libmysql.dll */ -#define isnan(X) _isnan(X) -#define finite(X) _finite(X) - -#ifndef UNDEF_THREAD_HACK -#define THREAD -#endif -#define VOID_SIGHANDLER -#define SIZEOF_CHAR 1 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_OFF_T 8 -#ifdef _WIN64 -#define SIZEOF_CHARP 8 -#else -#define SIZEOF_CHARP 4 -#endif -#define HAVE_BROKEN_NETINET_INCLUDES -#ifdef __NT__ -#define HAVE_NAMED_PIPE /* We can only create pipes on NT */ -#endif - -/* ERROR is defined in wingdi.h */ -#undef ERROR - -/* We need to close files to break connections on shutdown */ -#ifndef SIGNAL_WITH_VIO_CLOSE -#define SIGNAL_WITH_VIO_CLOSE -#endif - -/* Use all character sets in MySQL */ -#define USE_MB 1 -#define USE_MB_IDENT 1 -#define USE_STRCOLL 1 - -/* All windows servers should support .sym files */ -#undef USE_SYMDIR -#define USE_SYMDIR - -/* If LOAD DATA LOCAL INFILE should be enabled by default */ -#define ENABLED_LOCAL_INFILE 1 - -/* Convert some simple functions to Posix */ - -#define my_sigset(A,B) signal((A),(B)) -#define finite(A) _finite(A) -#define sleep(A) Sleep((A)*1000) -#define popen(A,B) _popen((A),(B)) -#define pclose(A) _pclose(A) - -#ifndef __BORLANDC__ -#define access(A,B) _access(A,B) -#endif - -#if !defined(__cplusplus) -#define inline __inline -#endif /* __cplusplus */ - -inline double rint(double nr) -{ - double f = floor(nr); - double c = ceil(nr); - return (((c-nr) >= (nr-f)) ? f :c); -} - -#ifdef _WIN64 -#define ulonglong2double(A) ((double) (ulonglong) (A)) -#define my_off_t2double(A) ((double) (my_off_t) (A)) - -#else -inline double ulonglong2double(ulonglong value) -{ - longlong nr=(longlong) value; - if (nr >= 0) - return (double) nr; - return (18446744073709551616.0 + (double) nr); -} -#define my_off_t2double(A) ulonglong2double(A) -#endif /* _WIN64 */ - -#if SIZEOF_OFF_T > 4 -#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) -#define tell(A) _telli64(A) -#endif - -#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } - -#define STACK_DIRECTION -1 - -/* Optimized store functions for Intel x86 */ - -#ifndef _WIN64 -#define sint2korr(A) (*((int16 *) (A))) -#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ - (((uint32) 255L << 24) | \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0])) : \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0]))) -#define sint4korr(A) (*((long *) (A))) -#define uint2korr(A) (*((uint16 *) (A))) -/* - ATTENTION ! - - Please, note, uint3korr reads 4 bytes (not 3) ! - It means, that you have to provide enough allocated space ! -*/ -#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) -#define uint4korr(A) (*((unsigned long *) (A))) -#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) ((uchar) (A)[4])) << 32)) -#define uint8korr(A) (*((ulonglong *) (A))) -#define sint8korr(A) (*((longlong *) (A))) -#define int2store(T,A) *((uint16*) (T))= (uint16) (A) -#define int3store(T,A) { *(T)= (uchar) ((A));\ - *(T+1)=(uchar) (((uint) (A) >> 8));\ - *(T+2)=(uchar) (((A) >> 16)); } -#define int4store(T,A) *((long *) (T))= (long) (A) -#define int5store(T,A) { *(T)= (uchar)((A));\ - *((T)+1)=(uchar) (((A) >> 8));\ - *((T)+2)=(uchar) (((A) >> 16));\ - *((T)+3)=(uchar) (((A) >> 24)); \ - *((T)+4)=(uchar) (((A) >> 32)); } -#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) - -#define doubleget(V,M) do { *((long *) &V) = *((long*) M); \ - *(((long *) &V)+1) = *(((long*) M)+1); } while(0) -#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \ - *(((long *) T)+1) = *(((long*) &V)+1); } while(0) -#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } -#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) -#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float)) -#define float8get(V,M) doubleget((V),(M)) -#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) -#define float8store(V,M) doublestore((V),(M)) -#endif /* _WIN64 */ - -#define HAVE_PERROR -#define HAVE_VFPRINT -#define HAVE_RENAME /* Have rename() as function */ -#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */ -#define HAVE_LONG_JMP /* Have long jump function */ -#define HAVE_LOCKING /* have locking() call */ -#define HAVE_ERRNO_AS_DEFINE /* errno is a define */ -#define HAVE_STDLIB /* everything is include in this file */ -#define HAVE_MEMCPY -#define HAVE_MEMMOVE -#define HAVE_GETCWD -#define HAVE_TELL -#define HAVE_TZNAME -#define HAVE_PUTENV -#define HAVE_SELECT -#define HAVE_SETLOCALE -#define HAVE_SOCKET /* Giangi */ -#define HAVE_FLOAT_H -#define HAVE_LIMITS_H -#define HAVE_STDDEF_H -#define HAVE_RINT /* defined in this file */ -#define NO_FCNTL_NONBLOCK /* No FCNTL */ -#define HAVE_ALLOCA -#define HAVE_STRPBRK -#define HAVE_STRSTR -#define HAVE_COMPRESS -#define HAVE_CREATESEMAPHORE -#define HAVE_ISNAN -#define HAVE_FINITE -#define HAVE_QUERY_CACHE -#define SPRINTF_RETURNS_INT -#define HAVE_SETFILEPOINTER -#define HAVE_VIO_READ_BUFF -#define HAVE_STRNLEN - -#ifndef __NT__ -#undef FILE_SHARE_DELETE -#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */ -#endif - -#ifdef NOT_USED -#define HAVE_SNPRINTF /* Gave link error */ -#define _snprintf snprintf -#endif - -#ifdef _MSC_VER -#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ -#define HAVE_ANSI_INCLUDE -#define HAVE_SYS_UTIME_H -#define HAVE_STRTOUL -#endif -#define my_reinterpret_cast(A) reinterpret_cast -#define my_const_cast(A) const_cast - - -/* MYSQL OPTIONS */ - -#ifdef _CUSTOMCONFIG_ -#include -#else -#define DEFAULT_MYSQL_HOME "c:\\mysql" -#define PACKAGE "mysql" -#define DEFAULT_BASEDIR "C:\\" -#define SHAREDIR "share" -#define DEFAULT_CHARSET_HOME "C:/mysql/" -#endif -#ifndef DEFAULT_HOME_ENV -#define DEFAULT_HOME_ENV MYSQL_HOME -#endif -#ifndef DEFAULT_GROUP_SUFFIX_ENV -#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX -#endif - -/* File name handling */ - -#define FN_LIBCHAR '\\' -#define FN_ROOTDIR "\\" -#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ -#define FN_NO_CASE_SENCE /* Files are not case-sensitive */ -#define OS_FILE_LIMIT 2048 - -#define DO_NOT_REMOVE_THREAD_WRAPPERS -#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V)) -#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V)) -/* The following is only used for statistics, so it should be good enough */ -#ifdef __NT__ /* This should also work on Win98 but .. */ -#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) -#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C)) -#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) -#else -#define thread_safe_add(V,C,L) \ - pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L)); -#define thread_safe_sub(V,C,L) \ - pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L)); -#define statistic_add(V,C,L) (V)+=(C) -#endif -#define statistic_increment(V,L) thread_safe_increment((V),(L)) -#define statistic_decrement(V,L) thread_safe_decrement((V),(L)) - -#define shared_memory_buffer_length 16000 -#define default_shared_memory_base_name "MYSQL" - -#ifdef CYBOZU -#define MYSQL_DEFAULT_CHARSET_NAME "utf8" -#define MYSQL_DEFAULT_COLLATION_NAME "utf8_general_cs" -#define HAVE_UTF8_GENERAL_CS 1 -#else -#define MYSQL_DEFAULT_CHARSET_NAME "latin1" -#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" -#endif - -#define HAVE_SPATIAL 1 -#define HAVE_RTREE_KEYS 1 - -#define HAVE_OPENSSL 1 -#define HAVE_YASSL 1 - -/* Define charsets you want */ -/* #undef HAVE_CHARSET_armscii8 */ -/* #undef HAVE_CHARSET_ascii */ -#ifndef CYBOZU -#define HAVE_CHARSET_big5 1 -#define HAVE_CHARSET_cp1250 1 -#endif -/* #undef HAVE_CHARSET_cp1251 */ -/* #undef HAVE_CHARSET_cp1256 */ -/* #undef HAVE_CHARSET_cp1257 */ -/* #undef HAVE_CHARSET_cp850 */ -/* #undef HAVE_CHARSET_cp852 */ -/* #undef HAVE_CHARSET_cp866 */ -#define HAVE_CHARSET_cp932 1 -/* #undef HAVE_CHARSET_dec8 */ -#ifndef CYBOZU -#define HAVE_CHARSET_eucjpms 1 -#define HAVE_CHARSET_euckr 1 -#define HAVE_CHARSET_gb2312 1 -#define HAVE_CHARSET_gbk 1 -#endif -/* #undef HAVE_CHARSET_greek */ -/* #undef HAVE_CHARSET_hebrew */ -/* #undef HAVE_CHARSET_hp8 */ -/* #undef HAVE_CHARSET_keybcs2 */ -/* #undef HAVE_CHARSET_koi8r */ -/* #undef HAVE_CHARSET_koi8u */ -#ifndef CYBOZU -#define HAVE_CHARSET_latin1 1 -#define HAVE_CHARSET_latin2 1 -#endif -/* #undef HAVE_CHARSET_latin5 */ -/* #undef HAVE_CHARSET_latin7 */ -/* #undef HAVE_CHARSET_macce */ -/* #undef HAVE_CHARSET_macroman */ -#define HAVE_CHARSET_sjis 1 -/* #undef HAVE_CHARSET_swe7 */ -#ifndef CYBOZU -#define HAVE_CHARSET_tis620 1 -#define HAVE_CHARSET_ucs2 1 -#define HAVE_CHARSET_ujis 1 -#endif -#define HAVE_CHARSET_utf8 1 -#define HAVE_UCA_COLLATIONS 1 - diff --git a/src/mysql/m_ctype.h b/src/mysql/m_ctype.h deleted file mode 100644 index 54ae41bf2..000000000 --- a/src/mysql/m_ctype.h +++ /dev/null @@ -1,493 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - A better inplementation of the UNIX ctype(3) library. - Notes: my_global.h should be included before ctype.h -*/ - -#ifndef _m_ctype_h -#define _m_ctype_h - -#ifdef __cplusplus -extern "C" { -#endif - -#define MY_CS_NAME_SIZE 32 -#define MY_CS_CTYPE_TABLE_SIZE 257 -#define MY_CS_TO_LOWER_TABLE_SIZE 256 -#define MY_CS_TO_UPPER_TABLE_SIZE 256 -#define MY_CS_SORT_ORDER_TABLE_SIZE 256 -#define MY_CS_TO_UNI_TABLE_SIZE 256 - -#define CHARSET_DIR "charsets/" - -#define my_wc_t ulong - -typedef struct unicase_info_st -{ - uint16 toupper; - uint16 tolower; - uint16 sort; -} MY_UNICASE_INFO; - - -extern MY_UNICASE_INFO *my_unicase_default[256]; -extern MY_UNICASE_INFO *my_unicase_turkish[256]; - - -/* wm_wc and wc_mb return codes */ -#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */ -#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */ -#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */ -#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */ -#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */ -/* These following three are currently not really used */ -#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */ -#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */ -#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */ -/* A helper macros for "need at least n bytes" */ -#define MY_CS_TOOSMALLN(n) (-100-(n)) - -#define MY_SEQ_INTTAIL 1 -#define MY_SEQ_SPACES 2 - - /* My charsets_list flags */ -#define MY_CS_COMPILED 1 /* compiled-in sets */ -#define MY_CS_CONFIG 2 /* sets that have a *.conf file */ -#define MY_CS_INDEX 4 /* sets listed in the Index file */ -#define MY_CS_LOADED 8 /* sets that are currently loaded */ -#define MY_CS_BINSORT 16 /* if binary sort order */ -#define MY_CS_PRIMARY 32 /* if primary collation */ -#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ -#define MY_CS_UNICODE 128 /* is a charset is full unicode */ -#define MY_CS_READY 256 /* if a charset is initialized */ -#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ -#define MY_CS_CSSORT 1024 /* if case sensitive sort order */ -#define MY_CHARSET_UNDEFINED 0 - - -typedef struct my_uni_idx_st -{ - uint16 from; - uint16 to; - uchar *tab; -} MY_UNI_IDX; - -typedef struct -{ - uint beg; - uint end; - uint mblen; -} my_match_t; - -enum my_lex_states -{ - MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, - MY_LEX_IDENT_SEP, MY_LEX_IDENT_START, - MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER, - MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END, - MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL, - MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, - MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, - MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, - MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR, - MY_LEX_IDENT_OR_KEYWORD, - MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR, - MY_LEX_STRING_OR_DELIMITER -}; - -struct charset_info_st; - -typedef struct my_collation_handler_st -{ - my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); - /* Collation routines */ - int (*strnncoll)(struct charset_info_st *, - const uchar *, uint, const uchar *, uint, my_bool); - int (*strnncollsp)(struct charset_info_st *, - const uchar *, uint, const uchar *, uint, - my_bool diff_if_only_endspace_difference); - int (*strnxfrm)(struct charset_info_st *, - uchar *, uint, const uchar *, uint); - uint (*strnxfrmlen)(struct charset_info_st *, uint); - my_bool (*like_range)(struct charset_info_st *, - const char *s, uint s_length, - pchar w_prefix, pchar w_one, pchar w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_len, uint *max_len); - int (*wildcmp)(struct charset_info_st *, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape,int w_one, int w_many); - - int (*strcasecmp)(struct charset_info_st *, const char *, const char *); - - uint (*instr)(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch); - - /* Hash calculation */ - void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len, - ulong *nr1, ulong *nr2); - my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len); -} MY_COLLATION_HANDLER; - -extern MY_COLLATION_HANDLER my_collation_mb_bin_handler; -extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; -extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; -extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; - - -typedef struct my_charset_handler_st -{ - my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); - /* Multibyte routines */ - int (*ismbchar)(struct charset_info_st *, const char *, const char *); - int (*mbcharlen)(struct charset_info_st *, uint); - uint (*numchars)(struct charset_info_st *, const char *b, const char *e); - uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); - uint (*well_formed_len)(struct charset_info_st *, - const char *b,const char *e, - uint nchars, int *error); - uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); - uint (*numcells)(struct charset_info_st *, const char *b, const char *e); - - /* Unicode convertion */ - int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc, - const unsigned char *s,const unsigned char *e); - int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc, - unsigned char *s,unsigned char *e); - - /* Functions for case and sort convertion */ - void (*caseup_str)(struct charset_info_st *, char *); - void (*casedn_str)(struct charset_info_st *, char *); - uint (*caseup)(struct charset_info_st *, char *src, uint srclen, - char *dst, uint dstlen); - uint (*casedn)(struct charset_info_st *, char *src, uint srclen, - char *dst, uint dstlen); - - /* Charset dependant snprintf() */ - int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, - ...); - int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, - long int val); - int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, - int radix, longlong val); - - void (*fill)(struct charset_info_st *, char *to, uint len, int fill); - - /* String-to-number convertion routines */ - long (*strntol)(struct charset_info_st *, const char *s, uint l, - int base, char **e, int *err); - ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, - int base, char **e, int *err); - longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, - int base, char **e, int *err); - ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, - int base, char **e, int *err); - double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, - int *err); - longlong (*strtoll10)(struct charset_info_st *cs, - const char *nptr, char **endptr, int *error); - ulong (*scan)(struct charset_info_st *, const char *b, const char *e, - int sq); -} MY_CHARSET_HANDLER; - -extern MY_CHARSET_HANDLER my_charset_8bit_handler; -extern MY_CHARSET_HANDLER my_charset_ucs2_handler; - - -typedef struct charset_info_st -{ - uint number; - uint primary_number; - uint binary_number; - uint state; - const char *csname; - const char *name; - const char *comment; - const char *tailoring; - uchar *ctype; - uchar *to_lower; - uchar *to_upper; - uchar *sort_order; - uint16 *contractions; - uint16 **sort_order_big; - uint16 *tab_to_uni; - MY_UNI_IDX *tab_from_uni; - MY_UNICASE_INFO **caseinfo; - uchar *state_map; - uchar *ident_map; - uint strxfrm_multiply; - uchar caseup_multiply; - uchar casedn_multiply; - uint mbminlen; - uint mbmaxlen; - uint16 min_sort_char; - uint16 max_sort_char; /* For LIKE optimization */ - uchar pad_char; - my_bool escape_with_backslash_is_dangerous; - - MY_CHARSET_HANDLER *cset; - MY_COLLATION_HANDLER *coll; - -} CHARSET_INFO; - - -extern CHARSET_INFO my_charset_bin; -extern CHARSET_INFO my_charset_big5_chinese_ci; -extern CHARSET_INFO my_charset_big5_bin; -extern CHARSET_INFO my_charset_cp932_japanese_ci; -extern CHARSET_INFO my_charset_cp932_bin; -extern CHARSET_INFO my_charset_eucjpms_japanese_ci; -extern CHARSET_INFO my_charset_eucjpms_bin; -extern CHARSET_INFO my_charset_euckr_korean_ci; -extern CHARSET_INFO my_charset_euckr_bin; -extern CHARSET_INFO my_charset_gb2312_chinese_ci; -extern CHARSET_INFO my_charset_gb2312_bin; -extern CHARSET_INFO my_charset_gbk_chinese_ci; -extern CHARSET_INFO my_charset_gbk_bin; -extern CHARSET_INFO my_charset_latin1; -extern CHARSET_INFO my_charset_latin1_german2_ci; -extern CHARSET_INFO my_charset_latin1_bin; -extern CHARSET_INFO my_charset_latin2_czech_ci; -extern CHARSET_INFO my_charset_sjis_japanese_ci; -extern CHARSET_INFO my_charset_sjis_bin; -extern CHARSET_INFO my_charset_tis620_thai_ci; -extern CHARSET_INFO my_charset_tis620_bin; -extern CHARSET_INFO my_charset_ucs2_general_ci; -extern CHARSET_INFO my_charset_ucs2_bin; -extern CHARSET_INFO my_charset_ucs2_general_uca; -extern CHARSET_INFO my_charset_ujis_japanese_ci; -extern CHARSET_INFO my_charset_ujis_bin; -extern CHARSET_INFO my_charset_utf8_general_ci; -extern CHARSET_INFO my_charset_utf8_bin; -extern CHARSET_INFO my_charset_cp1250_czech_ci; - -/* declarations for simple charsets */ -extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, - uint); -uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); -extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, - const uchar *, uint, my_bool); - -extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint, - const uchar *, uint, - my_bool diff_if_only_endspace_difference); - -extern void my_hash_sort_simple(CHARSET_INFO *cs, - const uchar *key, uint len, - ulong *nr1, ulong *nr2); - -extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length); - -extern uint my_instr_simple(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch); - - -/* Functions for 8bit */ -extern void my_caseup_str_8bit(CHARSET_INFO *, char *); -extern void my_casedn_str_8bit(CHARSET_INFO *, char *); -extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); -extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); - -extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *); - -int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e); -int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e); - -ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); - -int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, - const char *fmt, ...); - -long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, - char **e, int *err); -ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base, - char **e, int *err); -longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base, - char **e, int *err); -ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base, - char **e, int *err); -double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e, - int *err); -int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, - long int val); -int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, - longlong val); - -longlong my_strtoll10_8bit(CHARSET_INFO *cs, - const char *nptr, char **endptr, int *error); -longlong my_strtoll10_ucs2(CHARSET_INFO *cs, - const char *nptr, char **endptr, int *error); - -void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); - -my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_length, uint *max_length); - -my_bool my_like_range_mb(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_length, uint *max_length); - -my_bool my_like_range_ucs2(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_length, uint *max_length); - - -int my_wildcmp_8bit(CHARSET_INFO *, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many); - -int my_wildcmp_bin(CHARSET_INFO *, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many); - -uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); -uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); -uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, - uint pos, int *error); -int my_mbcharlen_8bit(CHARSET_INFO *, uint c); - - -/* Functions for multibyte charsets */ -extern void my_caseup_str_mb(CHARSET_INFO *, char *); -extern void my_casedn_str_mb(CHARSET_INFO *, char *); -extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); -extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); -extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *); - -int my_wildcmp_mb(CHARSET_INFO *, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many); -uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); -uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); -uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, - uint pos, int *error); -uint my_instr_mb(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch); - -int my_wildcmp_unicode(CHARSET_INFO *cs, - const char *str, const char *str_end, - const char *wildstr, const char *wildend, - int escape, int w_one, int w_many, - MY_UNICASE_INFO **weights); - -extern my_bool my_parse_charset_xml(const char *bug, uint len, - int (*add)(CHARSET_INFO *cs)); - -my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len); -my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); - - -#define _MY_U 01 /* Upper case */ -#define _MY_L 02 /* Lower case */ -#define _MY_NMR 04 /* Numeral (digit) */ -#define _MY_SPC 010 /* Spacing character */ -#define _MY_PNT 020 /* Punctuation */ -#define _MY_CTR 040 /* Control character */ -#define _MY_B 0100 /* Blank */ -#define _MY_X 0200 /* heXadecimal digit */ - - -#define my_isascii(c) (!((c) & ~0177)) -#define my_toascii(c) ((c) & 0177) -#define my_tocntrl(c) ((c) & 31) -#define my_toprint(c) ((c) | 64) -#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)]) -#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)]) -#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L)) -#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U) -#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L) -#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR) -#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X) -#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR)) -#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC) -#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT) -#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B)) -#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR)) -#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR) - -/* Some macros that should be cleaned up a little */ -#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_') -#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_') - -#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT) -#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM) -#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d))) -#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0)) -#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \ - ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j))) -#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m))) -#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b))) -#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num)) - - -#define use_mb(s) ((s)->cset->ismbchar != NULL) -#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b))) -#ifdef USE_MB -#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a))) -#else -#define my_mbcharlen(s, a) 1 -#endif - -#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a))) -#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a))) -#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e))) -#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e))) -#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e))) -#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e))) -#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d))) - - -/* XXX: still need to take care of this one */ -#ifdef MY_CHARSET_TIS620 -#error The TIS620 charset is broken at the moment. Tell tim to fix it. -#define USE_TIS620 -#include "t_ctype.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _m_ctype_h */ diff --git a/src/mysql/my_alloc.h b/src/mysql/my_alloc.h deleted file mode 100644 index 1641b3acf..000000000 --- a/src/mysql/my_alloc.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - Data structures for mysys/my_alloc.c (root memory allocator) -*/ - -#ifndef _my_alloc_h -#define _my_alloc_h - -#define ALLOC_MAX_BLOCK_TO_DROP 4096 -#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 - -typedef struct st_used_mem -{ /* struct for once_alloc (block) */ - struct st_used_mem *next; /* Next block in use */ - unsigned int left; /* memory left in block */ - unsigned int size; /* size of block */ -} USED_MEM; - - -typedef struct st_mem_root -{ - USED_MEM *free; /* blocks with free memory in it */ - USED_MEM *used; /* blocks almost without free memory */ - USED_MEM *pre_alloc; /* preallocated block */ - /* if block have less memory it will be put in 'used' list */ - unsigned int min_malloc; - unsigned int block_size; /* initial block size */ - unsigned int block_num; /* allocated blocks counter */ - /* - first free block in queue test counter (if it exceed - MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) - */ - unsigned int first_block_usage; - - void (*error_handler)(void); -} MEM_ROOT; -#endif diff --git a/src/mysql/my_dbug.h b/src/mysql/my_dbug.h deleted file mode 100644 index b76a3fcc8..000000000 --- a/src/mysql/my_dbug.h +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _dbug_h -#define _dbug_h - -#ifdef __cplusplus -extern "C" { -#endif -#if !defined(DBUG_OFF) && !defined(_lint) -extern int _db_on_,_no_db_; -extern FILE *_db_fp_; -extern char *_db_process_; -extern int _db_keyword_(const char *keyword); -extern int _db_strict_keyword_(const char *keyword); -extern void _db_setjmp_(void); -extern void _db_longjmp_(void); -extern void _db_push_(const char *control); -extern void _db_pop_(void); -extern void _db_enter_(const char *_func_,const char *_file_,uint _line_, - const char **_sfunc_,const char **_sfile_, - uint *_slevel_, char ***); -extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_, - uint *_slevel_); -extern void _db_pargs_(uint _line_,const char *keyword); -extern void _db_doprnt_ _VARARGS((const char *format,...)); -extern void _db_dump_(uint _line_,const char *keyword,const char *memory, - uint length); -extern void _db_output_(uint flag); -extern void _db_lock_file(void); -extern void _db_unlock_file(void); - -#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \ - char **_db_framep_; \ - _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \ - &_db_framep_) -#define DBUG_LEAVE \ - (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)) -#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);} -#define DBUG_VOID_RETURN {DBUG_LEAVE; return;} -#define DBUG_EXECUTE(keyword,a1) \ - {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}} -#define DBUG_PRINT(keyword,arglist) \ - {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}} -#define DBUG_PUSH(a1) _db_push_ (a1) -#define DBUG_POP() _db_pop_ () -#define DBUG_PROCESS(a1) (_db_process_ = a1) -#define DBUG_FILE (_db_fp_) -#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1)) -#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2)) -#define DBUG_DUMP(keyword,a1,a2)\ - {if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}} -#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr) -#define DEBUGGER_OFF _no_db_=1;_db_on_=0; -#define DEBUGGER_ON _no_db_=0 -#define DBUG_LOCK_FILE { _db_lock_file(); } -#define DBUG_UNLOCK_FILE { _db_unlock_file(); } -#define DBUG_OUTPUT(A) { _db_output_(A); } -#define DBUG_ASSERT(A) assert(A) -#define DBUG_EXECUTE_IF(keyword,a1) \ - {if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}} -#else /* No debugger */ - -#define DBUG_ENTER(a1) -#define DBUG_RETURN(a1) return(a1) -#define DBUG_VOID_RETURN return -#define DBUG_EXECUTE(keyword,a1) {} -#define DBUG_EXECUTE_IF(keyword,a1) {} -#define DBUG_PRINT(keyword,arglist) {} -#define DBUG_PUSH(a1) {} -#define DBUG_POP() {} -#define DBUG_PROCESS(a1) {} -#define DBUG_FILE (stderr) -#define DBUG_SETJMP setjmp -#define DBUG_LONGJMP longjmp -#define DBUG_DUMP(keyword,a1,a2) {} -#define DBUG_IN_USE 0 -#define DEBUGGER_OFF -#define DEBUGGER_ON -#define DBUG_LOCK_FILE -#define DBUG_UNLOCK_FILE -#define DBUG_OUTPUT(A) -#define DBUG_ASSERT(A) {} -#endif -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/mysql/my_global.h b/src/mysql/my_global.h deleted file mode 100644 index 2417477e2..000000000 --- a/src/mysql/my_global.h +++ /dev/null @@ -1,1306 +0,0 @@ -/* Copyright (C) 2000-2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* This is the include file that should be included 'first' in every C file. */ - -#ifndef _global_h -#define _global_h - -#ifndef EMBEDDED_LIBRARY -#define HAVE_REPLICATION -#define HAVE_EXTERNAL_CLIENT -#endif - -#if defined( __EMX__) && !defined( MYSQL_SERVER) -/* moved here to use below VOID macro redefinition */ -#define INCL_BASE -#define INCL_NOPMAPI -#include -#endif /* __EMX__ */ - -#ifdef __CYGWIN__ -/* We use a Unix API, so pretend it's not Windows */ -#undef WIN -#undef WIN32 -#undef _WIN -#undef _WIN32 -#undef _WIN64 -#undef __WIN__ -#undef __WIN32__ -#define HAVE_ERRNO_AS_DEFINE -#endif /* __CYGWIN__ */ - -#if defined(__QNXNTO__) && !defined(FD_SETSIZE) -#define FD_SETSIZE 1024 /* Max number of file descriptor bits in - fd_set, used when calling 'select' - Must be defined before including - "sys/select.h" and "sys/time.h" - */ -#endif - - -/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */ -#ifdef USE_PRAGMA_IMPLEMENTATION -#define USE_PRAGMA_INTERFACE -#endif - -#if defined(i386) && !defined(__i386__) -#define __i386__ -#endif - -/* Macros to make switching between C and C++ mode easier */ -#ifdef __cplusplus -#define C_MODE_START extern "C" { -#define C_MODE_END } -#else -#define C_MODE_START -#define C_MODE_END -#endif - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#include -#elif defined(OS2) -#include -#elif defined(__NETWARE__) -#include -#include -#if defined(__cplusplus) && defined(inline) -#undef inline /* fix configure problem */ -#endif -#else -#include -#if defined(__cplusplus) && defined(inline) -#undef inline /* fix configure problem */ -#endif -#endif /* _WIN32... */ - -/* Some defines to avoid ifdefs in the code */ -#ifndef NETWARE_YIELD -#define NETWARE_YIELD -#define NETWARE_SET_SCREEN_MODE(A) -#endif - -#include "../common/strlib.h" - -/* - The macros below are borrowed from include/linux/compiler.h in the - Linux kernel. Use them to indicate the likelyhood of the truthfulness - of a condition. This serves two purposes - newer versions of gcc will be - able to optimize for branch predication, which could yield siginficant - performance gains in frequently executed sections of the code, and the - other reason to use them is for documentation -*/ - -#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -#define __builtin_expect(x, expected_value) (x) -#endif - -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - - -/* Fix problem with S_ISLNK() on Linux */ -#if defined(TARGET_OS_LINUX) -#undef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -/* - Temporary solution to solve bug#7156. Include "sys/types.h" before - the thread headers, else the function madvise() will not be defined -*/ -#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) ) -#include -#endif - -/* The client defines this to avoid all thread code */ -#if defined(UNDEF_THREADS_HACK) -#undef THREAD -#undef HAVE_mit_thread -#undef HAVE_LINUXTHREADS -#undef HAVE_NPTL -#undef HAVE_UNIXWARE7_THREADS -#endif - -#ifdef HAVE_THREADS_WITHOUT_SOCKETS -/* MIT pthreads does not work with unix sockets */ -#undef HAVE_SYS_UN_H -#endif - -#define __EXTENSIONS__ 1 /* We want some extension */ -#ifndef __STDC_EXT__ -#define __STDC_EXT__ 1 /* To get large file support on hpux */ -#endif - -/* - Solaris 9 include file refers to X/Open document - - System Interfaces and Headers, Issue 5 - - saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes, - but apparently other systems (namely FreeBSD) don't agree. - - On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600. - Furthermore, it tests that if a program requires older standard - (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be - run on a new compiler (that defines _STDC_C99) and issues an #error. - It's also an #error if a program requires new standard (_XOPEN_SOURCE=600 - or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99. - - To add more to this mess, Sun Studio C compiler defines _STDC_C99 while - C++ compiler does not! - - So, in a desperate attempt to get correct prototypes for both - C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500 - depending on the compiler's announced C standard support. - - Cleaner solutions are welcome. -*/ -#ifdef __sun -#if __STDC_VERSION__ - 0 >= 199901L -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif -#endif - -#if defined(THREAD) && !defined(__WIN__) && !defined(OS2) -#ifndef _POSIX_PTHREAD_SEMANTICS -#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ -#endif - -#if !defined(SCO) -#define _REENTRANT 1 /* Some thread libraries require this */ -#endif -#if !defined(_THREAD_SAFE) && !defined(_AIX) -#define _THREAD_SAFE /* Required for OSF1 */ -#endif -#ifndef HAVE_mit_thread -#ifdef HAVE_UNIXWARE7_THREADS -#include -#else -#if defined(HPUX10) || defined(HPUX11) -C_MODE_START /* HPUX needs this, signal.h bug */ -#include -C_MODE_END -#else -#include /* AIX must have this included first */ -#endif -#endif /* HAVE_UNIXWARE7_THREADS */ -#endif /* HAVE_mit_thread */ -#if !defined(SCO) && !defined(_REENTRANT) -#define _REENTRANT 1 /* Threads requires reentrant code */ -#endif -#endif /* THREAD */ - -/* Go around some bugs in different OS and compilers */ -#ifdef _AIX /* By soren@t.dk */ -#define _H_STRINGS -#define _SYS_STREAM_H -/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */ -#define ulonglong2double(A) my_ulonglong2double(A) -#define my_off_t2double(A) my_ulonglong2double(A) -C_MODE_START -double my_ulonglong2double(unsigned long long A); -C_MODE_END -#endif /* _AIX */ - -#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ -#undef HAVE_SNPRINTF -#endif -#ifdef HAVE_BROKEN_PREAD -/* - pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without - installing the kernel patch PHKL_20349 or greater -*/ -#undef HAVE_PREAD -#undef HAVE_PWRITE -#endif -#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus) -#undef inline -#define inline -#endif - -#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */ -#undef HAVE_GETHOSTBYNAME_R -#endif -#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */ -#undef HAVE_INITGROUPS -#endif - -/* gcc/egcs issues */ - -#if defined(__GNUC) && defined(__EXCEPTIONS) -#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile" -#endif - - -/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */ -#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8) -#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */ -#define __LONG_MAX__ 2147483647 -#endif - -/* egcs 1.1.2 has a problem with memcpy on Alpha */ -#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -#define BAD_MEMCPY -#endif - -#if defined(_lint) && !defined(lint) -#define lint -#endif -#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) -#define _LONG_LONG 1 /* For AIX string library */ -#endif - -#ifndef stdin -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_STDDEF_H -#include -#endif - -#include -#ifdef HAVE_LIMITS_H -#include -#endif -#ifdef HAVE_FLOAT_H -#include -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_FCNTL_H -#include -#endif -#ifdef HAVE_SYS_TIMEB_H -#include /* Avoid warnings on SCO */ -#endif -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif /* TIME_WITH_SYS_TIME */ -#ifdef HAVE_UNISTD_H -#include -#endif -#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) -#undef HAVE_ALLOCA -#undef HAVE_ALLOCA_H -#endif -#ifdef HAVE_ALLOCA_H -#include -#endif -#ifdef HAVE_ATOMIC_ADD -#define new my_arg_new -#define need_to_restore_new 1 -C_MODE_START -#include -C_MODE_END -#ifdef need_to_restore_new /* probably safer than #ifdef new */ -#undef new -#undef need_to_restore_new -#endif -#endif -#include /* Recommended by debian */ -/* We need the following to go around a problem with openssl on solaris */ -#if defined(HAVE_CRYPT_H) -#include -#endif - -/* - A lot of our programs uses asserts, so better to always include it - This also fixes a problem when people uses DBUG_ASSERT without including - assert.h -*/ -#include - -/* Go around some bugs in different OS and compilers */ -#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H) -#include /* HPUX 10.20 defines ulong here. UGLY !!! */ -#define HAVE_ULONG -#endif -#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ -#undef HAVE_FINITE -#endif -#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) -/* Fix bug in setrlimit */ -#undef setrlimit -#define setrlimit cma_setrlimit64 -#endif -/* Declare madvise where it is not declared for C++, like Solaris */ -#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus) -extern "C" int madvise(void *addr, size_t len, int behav); -#endif - -#ifdef __QNXNTO__ -/* This has to be after include limits.h */ -#define HAVE_ERRNO_AS_DEFINE -#define HAVE_FCNTL_LOCK -#undef HAVE_FINITE -#undef LONGLONG_MIN /* These get wrongly defined in QNX 6.2 */ -#undef LONGLONG_MAX /* standard system library 'limits.h' */ -#ifdef __cplusplus -#ifndef HAVE_RINT -#define HAVE_RINT -#endif /* rint() and isnan() functions are not */ -#define rint(a) std::rint(a) /* visible in C++ scope due to an error */ -#define isnan(a) std::isnan(a) /* in the usr/include/math.h on QNX */ -#endif -#endif - -/* We can not live without the following defines */ - -#define USE_MYFUNC 1 /* Must use syscall indirection */ -#define MASTER 1 /* Compile without unireg */ -#define ENGLISH 1 /* Messages in English */ -#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ -#define USE_REGEX 1 /* We want the use the regex library */ -/* Do not define for ultra sparcs */ -#ifndef OS2 -#define USE_BMOVE512 1 /* Use this unless system bmove is faster */ -#endif - -#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */ -#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */ - -/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */ -#ifdef I_AM_PARANOID -#define DONT_ALLOW_USER_CHANGE 1 -#define DONT_USE_MYSQL_PWD 1 -#endif - -/* Does the system remember a signal handler after a signal ? */ -#ifndef HAVE_BSD_SIGNALS -#define DONT_REMEMBER_SIGNAL -#endif - -/* Define void to stop lint from generating "null effekt" comments */ -#ifndef DONT_DEFINE_VOID -#ifdef _lint -int __void__; -#define VOID(X) (__void__ = (int) (X)) -#else -#undef VOID -#define VOID(X) (X) -#endif -#endif /* DONT_DEFINE_VOID */ - -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) -#define LINT_INIT(var) var=0 /* No uninitialize-warning */ -#else -#define LINT_INIT(var) -#endif - -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify) -#define PURIFY_OR_LINT_INIT(var) var=0 -#else -#define PURIFY_OR_LINT_INIT(var) -#endif - -/* Define some useful general macros */ -#if !defined(max) -#define max(a, b) ((a) > (b) ? (a) : (b)) -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#if defined(__EMX__) || !defined(HAVE_UINT) -#undef HAVE_UINT -#define HAVE_UINT -typedef unsigned int uint; -typedef unsigned short ushort; -#endif - -#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) -#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) -#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; } -#define test(a) ((a) ? 1 : 0) -#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) -#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) -#define test_all_bits(a,b) (((a) & (b)) == (b)) -#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) -#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) -#ifndef HAVE_RINT -#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5)) -#endif - -/* Define some general constants */ -#ifndef TRUE -#define TRUE (1) /* Logical true */ -#define FALSE (0) /* Logical false */ -#endif - -#if defined(__GNUC__) -#define function_volatile volatile -#define my_reinterpret_cast(A) reinterpret_cast -#define my_const_cast(A) const_cast -#elif !defined(my_reinterpret_cast) -#define my_reinterpret_cast(A) (A) -#define my_const_cast(A) (A) -#endif -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) -#define __attribute__(A) -#endif - -/* - Wen using the embedded library, users might run into link problems, - dupicate declaration of __cxa_pure_virtual, solved by declaring it a - weak symbol. -*/ -#ifdef USE_MYSYS_NEW -C_MODE_START -int __cxa_pure_virtual () __attribute__ ((weak)); -C_MODE_END -#endif - -/* From old s-system.h */ - -/* - Support macros for non ansi & other old compilers. Since such - things are no longer supported we do nothing. We keep then since - some of our code may still be needed to upgrade old customers. -*/ -#define _VARARGS(X) X -#define _STATIC_VARARGS(X) X -#define _PC(X) X - -#if defined(DBUG_ON) && defined(DBUG_OFF) -#undef DBUG_OFF -#endif - -#if defined(_lint) && !defined(DBUG_OFF) -#define DBUG_OFF -#endif - -#include - -#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ -#define ASCII_BITS_USED 8 /* Bit char used */ -#define NEAR_F /* No near function handling */ - -/* Some types that is different between systems */ - -typedef int File; /* File descriptor */ -#ifndef Socket_defined -typedef int my_socket; /* File descriptor for sockets */ -#define INVALID_SOCKET -1 -#endif -/* Type for fuctions that handles signals */ -#define sig_handler RETSIGTYPE -C_MODE_START -typedef void (*sig_return)();/* Returns type from signal */ -C_MODE_END -#if defined(__GNUC__) && !defined(_lint) -typedef char pchar; /* Mixed prototypes can take char */ -typedef char puchar; /* Mixed prototypes can take char */ -typedef char pbool; /* Mixed prototypes can take char */ -typedef short pshort; /* Mixed prototypes can take short int */ -typedef float pfloat; /* Mixed prototypes can take float */ -#else -typedef int pchar; /* Mixed prototypes can't take char */ -typedef uint puchar; /* Mixed prototypes can't take char */ -typedef int pbool; /* Mixed prototypes can't take char */ -typedef int pshort; /* Mixed prototypes can't take short int */ -typedef double pfloat; /* Mixed prototypes can't take float */ -#endif -C_MODE_START -typedef int (*qsort_cmp)(const void *,const void *); -typedef int (*qsort_cmp2)(void*, const void *,const void *); -C_MODE_END -#ifdef HAVE_mit_thread -#define qsort_t void -#undef QSORT_TYPE_IS_VOID -#define QSORT_TYPE_IS_VOID -#else -#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */ -#endif -#ifdef HAVE_mit_thread -#define size_socket socklen_t /* Type of last arg to accept */ -#else -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -typedef SOCKET_SIZE_TYPE size_socket; -#endif - -#ifndef SOCKOPT_OPTLEN_TYPE -#define SOCKOPT_OPTLEN_TYPE size_socket -#endif - -/* file create flags */ - -#ifndef O_SHARE /* Probably not windows */ -#define O_SHARE 0 /* Flag to my_open for shared files */ -#ifndef O_BINARY -#define O_BINARY 0 /* Flag to my_open for binary files */ -#endif -#ifndef FILE_BINARY -#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */ -#endif -#ifdef HAVE_FCNTL -#define HAVE_FCNTL_LOCK -#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ -#endif -#endif /* O_SHARE */ - -#ifndef O_TEMPORARY -#define O_TEMPORARY 0 -#endif -#ifndef O_SHORT_LIVED -#define O_SHORT_LIVED 0 -#endif -#ifndef O_NOFOLLOW -#define O_NOFOLLOW 0 -#endif - -/* additional file share flags for win32 */ -#ifdef __WIN__ -#define _SH_DENYRWD 0x110 /* deny read/write mode & delete */ -#define _SH_DENYWRD 0x120 /* deny write mode & delete */ -#define _SH_DENYRDD 0x130 /* deny read mode & delete */ -#define _SH_DENYDEL 0x140 /* deny delete only */ -#endif /* __WIN__ */ - - -/* #define USE_RECORD_LOCK */ - - /* Unsigned types supported by the compiler */ -#define UNSINT8 /* unsigned int8 (char) */ -#define UNSINT16 /* unsigned int16 */ -#define UNSINT32 /* unsigned int32 */ - - /* General constants */ -#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */ -#define FN_LEN 256 /* Max file name len */ -#define FN_HEADLEN 253 /* Max length of filepart of file name */ -#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ -#define FN_REFLEN 512 /* Max length of full path-name */ -#define FN_EXTCHAR '.' -#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ -#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ -#define FN_PARENTDIR ".." /* Parent directory; Must be a string */ -#define FN_DEVCHAR ':' - -#ifndef FN_LIBCHAR -#ifdef __EMX__ -#define FN_LIBCHAR '\\' -#define FN_ROOTDIR "\\" -#else -#define FN_LIBCHAR '/' -#define FN_ROOTDIR "/" -#endif -#endif -#define MY_NFILE 64 /* This is only used to save filenames */ -#ifndef OS_FILE_LIMIT -#define OS_FILE_LIMIT 65535 -#endif - -/* #define EXT_IN_LIBNAME */ -/* #define FN_NO_CASE_SENCE */ -/* #define FN_UPPER_CASE TRUE */ - -/* - Io buffer size; Must be a power of 2 and a multiple of 512. May be - smaller what the disk page size. This influences the speed of the - isam btree library. eg to big to slow. -*/ -#define IO_SIZE 4096 -/* - How much overhead does malloc have. The code often allocates - something like 1024-MALLOC_OVERHEAD bytes -*/ -#ifdef SAFEMALLOC -#define MALLOC_OVERHEAD (8+24+4) -#else -#define MALLOC_OVERHEAD 8 -#endif - /* get memory in huncs */ -#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD) - /* Typical record cash */ -#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD) - /* Typical key cash */ -#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD) - /* Default size of a key cache block */ -#define KEY_CACHE_BLOCK_SIZE (uint) 1024 - - - /* Some things that this system doesn't have */ - -#define NO_HASH /* Not needed anymore */ -#ifdef __WIN__ -#define NO_DIR_LIBRARY /* Not standar dir-library */ -#define USE_MY_STAT_STRUCT /* For my_lib */ -#endif - -/* Some defines of functions for portability */ - -#undef remove /* Crashes MySQL on SCO 5.0.0 */ -#ifndef __WIN__ -#ifdef OS2 -#define closesocket(A) soclose(A) -#else -#define closesocket(A) close(A) -#endif -#ifndef ulonglong2double -#define ulonglong2double(A) ((double) (ulonglong) (A)) -#define my_off_t2double(A) ((double) (my_off_t) (A)) -#endif -#endif - -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif -#define ulong_to_double(X) ((double) (ulong) (X)) -#define SET_STACK_SIZE(X) /* Not needed on real machines */ - -#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R) -#define strtok_r(A,B,C) strtok((A),(B)) -#endif - -/* Remove some things that mit_thread break or doesn't support */ -#if defined(HAVE_mit_thread) && defined(THREAD) -#undef HAVE_PREAD -#undef HAVE_REALPATH -#undef HAVE_MLOCK -#undef HAVE_TEMPNAM /* Use ours */ -#undef HAVE_PTHREAD_SETPRIO -#undef HAVE_FTRUNCATE -#undef HAVE_READLINK -#endif - -/* This is from the old m-machine.h file */ - -#if SIZEOF_LONG_LONG > 4 -#define HAVE_LONG_LONG 1 -#endif - -/* - Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define - ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. - Also on Windows we define these constants by hand in config-win.h. -*/ - -#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) -#define LONGLONG_MIN ((long long) 0x8000000000000000LL) -#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) -#endif - -#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX) -/* First check for ANSI C99 definition: */ -#ifdef ULLONG_MAX -#define ULONGLONG_MAX ULLONG_MAX -#else -#define ULONGLONG_MAX ((unsigned long long)(~0ULL)) -#endif -#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/ - -#define INT_MIN32 (~0x7FFFFFFFL) -#define INT_MAX32 0x7FFFFFFFL -#define UINT_MAX32 0xFFFFFFFFL -#define INT_MIN24 (~0x007FFFFF) -#define INT_MAX24 0x007FFFFF -#define UINT_MAX24 0x00FFFFFF -#define INT_MIN16 (~0x7FFF) -#define INT_MAX16 0x7FFF -#define UINT_MAX16 0xFFFF -#define INT_MIN8 (~0x7F) -#define INT_MAX8 0x7F -#define UINT_MAX8 0xFF - -/* From limits.h instead */ -#ifndef DBL_MIN -#define DBL_MIN 4.94065645841246544e-324 -#define FLT_MIN ((float)1.40129846432481707e-45) -#endif -#ifndef DBL_MAX -#define DBL_MAX 1.79769313486231470e+308 -#define FLT_MAX ((float)3.40282346638528860e+38) -#endif - -#if !defined(HAVE_ISINF) && !defined(isinf) -#define isinf(X) 0 -#endif - -/* Define missing math constants. */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_E -#define M_E 2.7182818284590452354 -#endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif - -/* - Max size that must be added to a so that we know Size to make - adressable obj. -*/ -#if SIZEOF_CHARP == 4 -typedef long my_ptrdiff_t; -#else -typedef long long my_ptrdiff_t; -#endif - -#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) -#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) -/* Size to make adressable obj. */ -#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) - /* Offset of field f in structure t */ -#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) -#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) -#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) - -#define NullS (char *) 0 -/* Nowdays we do not support MessyDos */ -#ifndef NEAR -#define NEAR /* Who needs segments ? */ -#define FAR /* On a good machine */ -#ifndef HUGE_PTR -#define HUGE_PTR -#endif -#endif -#if defined(__IBMC__) || defined(__IBMCPP__) -/* This was _System _Export but caused a lot of warnings on _AIX43 */ -#define STDCALL -#elif !defined( STDCALL) -#define STDCALL -#endif - -/* Typdefs for easyier portability */ - -#if defined(VOIDTYPE) -typedef void *gptr; /* Generic pointer */ -#else -typedef char *gptr; /* Generic pointer */ -#endif -#ifndef HAVE_INT_8_16_32 -typedef signed char int8; /* Signed integer >= 8 bits */ -typedef short int16; /* Signed integer >= 16 bits */ -#endif -#ifndef HAVE_UCHAR -typedef unsigned char uchar; /* Short for unsigned char */ -#endif -typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */ -typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */ - -#if SIZEOF_INT == 4 -#ifndef HAVE_INT_8_16_32 -typedef int int32; -#endif -typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */ -#elif SIZEOF_LONG == 4 -#ifndef HAVE_INT_8_16_32 -typedef long int32; -#endif -typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */ -#else -#error "Neither int or long is of 4 bytes width" -#endif - -#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC) -typedef unsigned long ulong; /* Short for unsigned long */ -#endif -#ifndef longlong_defined -#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 -typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ -typedef long long int longlong; -#else -typedef unsigned long ulonglong; /* ulong or unsigned long long */ -typedef long longlong; -#endif -#endif - -#if defined(NO_CLIENT_LONG_LONG) -typedef unsigned long my_ulonglong; -#elif defined (__WIN__) -typedef unsigned __int64 my_ulonglong; -#else -typedef unsigned long long my_ulonglong; -#endif - -#ifdef USE_RAID -/* - The following is done with a if to not get problems with pre-processors - with late define evaluation -*/ -#if SIZEOF_OFF_T == 4 -#define SYSTEM_SIZEOF_OFF_T 4 -#else -#define SYSTEM_SIZEOF_OFF_T 8 -#endif -#undef SIZEOF_OFF_T -#define SIZEOF_OFF_T 8 -#else -#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T -#endif /* USE_RAID */ - -#if SIZEOF_OFF_T > 4 -typedef ulonglong my_off_t; -#else -typedef unsigned long my_off_t; -#endif -#define MY_FILEPOS_ERROR (~(my_off_t) 0) -#if !defined(__WIN__) && !defined(OS2) -typedef off_t os_off_t; -#endif - -#if defined(__WIN__) -#define socket_errno WSAGetLastError() -#define SOCKET_EINTR WSAEINTR -#define SOCKET_EAGAIN WSAEINPROGRESS -#define SOCKET_ETIMEDOUT WSAETIMEDOUT -#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK -#define SOCKET_EADDRINUSE WSAEADDRINUSE -#define SOCKET_ENFILE ENFILE -#define SOCKET_EMFILE EMFILE -#elif defined(OS2) -#define socket_errno sock_errno() -#define SOCKET_EINTR SOCEINTR -#define SOCKET_EAGAIN SOCEINPROGRESS -#define SOCKET_ETIMEDOUT SOCKET_EINTR -#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK -#define SOCKET_EADDRINUSE SOCEADDRINUSE -#define SOCKET_ENFILE SOCENFILE -#define SOCKET_EMFILE SOCEMFILE -#define closesocket(A) soclose(A) -#else /* Unix */ -#define socket_errno errno -#define closesocket(A) close(A) -#define SOCKET_EINTR EINTR -#define SOCKET_EAGAIN EAGAIN -#define SOCKET_ETIMEDOUT SOCKET_EINTR -#define SOCKET_EWOULDBLOCK EWOULDBLOCK -#define SOCKET_EADDRINUSE EADDRINUSE -#define SOCKET_ENFILE ENFILE -#define SOCKET_EMFILE EMFILE -#endif - -typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ -typedef short int15; /* Most effective integer 0 <= x <= 32767 */ -typedef char *my_string; /* String of characters */ -typedef unsigned long size_s; /* Size of strings (In string-funcs) */ -typedef int myf; /* Type of MyFlags in my_funcs */ -#ifndef byte_defined -typedef char byte; /* Smallest addressable unit */ -#endif -typedef char my_bool; /* Small bool */ -#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus)) -typedef char bool; /* Ordinary boolean values 0 1 */ -#endif - /* Macros for converting *constants* to the right type */ -#define INT8(v) (int8) (v) -#define INT16(v) (int16) (v) -#define INT32(v) (int32) (v) -#define MYF(v) (myf) (v) - -#ifndef LL -#ifdef HAVE_LONG_LONG -#define LL(A) A ## LL -#else -#define LL(A) A ## L -#endif -#endif - -#ifndef ULL -#ifdef HAVE_LONG_LONG -#define ULL(A) A ## ULL -#else -#define ULL(A) A ## UL -#endif -#endif - -/* - Defines to make it possible to prioritize register assignments. No - longer that important with modern compilers. -*/ -#ifndef USING_X -#define reg1 register -#define reg2 register -#define reg3 register -#define reg4 register -#define reg5 register -#define reg6 register -#define reg7 register -#define reg8 register -#define reg9 register -#define reg10 register -#define reg11 register -#define reg12 register -#define reg13 register -#define reg14 register -#define reg15 register -#define reg16 register -#endif - -/* - Sometimes we want to make sure that the variable is not put into - a register in debugging mode so we can see its value in the core -*/ - -#ifndef DBUG_OFF -#define dbug_volatile volatile -#else -#define dbug_volatile -#endif - -/* Defines for time function */ -#define SCALE_SEC 100 -#define SCALE_USEC 10000 -#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ -#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ - -#ifdef HAVE_TIMESPEC_TS_SEC -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{ \ - (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ - (ABSTIME).ts_nsec=0; \ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{ \ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).ts_sec= (now / ULL(10000000)); \ - (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#else -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{\ - struct timeval tv;\ - gettimeofday(&tv,0);\ - (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ - (ABSTIME).tv_nsec=tv.tv_usec*1000;\ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{\ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).tv_sec= (now / ULL(10000000)); \ - (ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#endif /* HAVE_TIMESPEC_TS_SEC */ - -/* - Define-funktions for reading and storing in machine independent format - (low byte first) -*/ - -/* Optimized store functions for Intel x86 */ -#if defined(__i386__) && !defined(_WIN64) -#define sint2korr(A) (*((int16 *) (A))) -#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ - (((uint32) 255L << 24) | \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0])) : \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0]))) -#define sint4korr(A) (*((long *) (A))) -#define uint2korr(A) (*((uint16 *) (A))) -#ifdef HAVE_purify -#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16)) -#else -/* - ATTENTION ! - - Please, note, uint3korr reads 4 bytes (not 3) ! - It means, that you have to provide enough allocated space ! -*/ -#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) -#endif -#define uint4korr(A) (*((unsigned long *) (A))) -#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) ((uchar) (A)[4])) << 32)) -#define uint8korr(A) (*((ulonglong *) (A))) -#define sint8korr(A) (*((longlong *) (A))) -#define int2store(T,A) *((uint16*) (T))= (uint16) (A) -#define int3store(T,A) do { *(T)= (uchar) ((A));\ - *(T+1)=(uchar) (((uint) (A) >> 8));\ - *(T+2)=(uchar) (((A) >> 16)); } while (0) -#define int4store(T,A) *((long *) (T))= (long) (A) -#define int5store(T,A) do { *(T)= (uchar)((A));\ - *((T)+1)=(uchar) (((A) >> 8));\ - *((T)+2)=(uchar) (((A) >> 16));\ - *((T)+3)=(uchar) (((A) >> 24)); \ - *((T)+4)=(uchar) (((A) >> 32)); } while(0) -#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) - -typedef union { - double v; - long m[2]; -} doubleget_union; -#define doubleget(V,M) \ -do { doubleget_union _tmp; \ - _tmp.m[0] = *((long*)(M)); \ - _tmp.m[1] = *(((long*) (M))+1); \ - (V) = _tmp.v; } while(0) -#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \ - *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \ - } while (0) -#define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0) -#define float8get(V,M) doubleget((V),(M)) -#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) -#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V),sizeof(float)) -#define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float)) -#define float8store(V,M) doublestore((V),(M)) -#endif /* __i386__ */ - -#ifndef sint2korr -/* - We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines - were done before) -*/ -#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ - ((int16) ((int16) (A)[1]) << 8)) -#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ - (((uint32) 255L << 24) | \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0])) : \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0]))) -#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\ - (((int32) ((uchar) (A)[1]) << 8)) +\ - (((int32) ((uchar) (A)[2]) << 16)) +\ - (((int32) ((int16) (A)[3]) << 24))) -#define sint8korr(A) (longlong) uint8korr(A) -#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\ - ((uint16) ((uchar) (A)[1]) << 8)) -#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16)) -#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) -#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) ((uchar) (A)[4])) << 32)) -#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) (((uint32) ((uchar) (A)[4])) +\ - (((uint32) ((uchar) (A)[5])) << 8) +\ - (((uint32) ((uchar) (A)[6])) << 16) +\ - (((uint32) ((uchar) (A)[7])) << 24))) <<\ - 32)) -#define int2store(T,A) do { uint def_temp= (uint) (A) ;\ - *((uchar*) (T))= (uchar)(def_temp); \ - *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \ - } while(0) -#define int3store(T,A) do { /*lint -save -e734 */\ - *((uchar*)(T))=(uchar) ((A));\ - *((uchar*) (T)+1)=(uchar) (((A) >> 8));\ - *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \ - /*lint -restore */} while(0) -#define int4store(T,A) do { *((char *)(T))=(char) ((A));\ - *(((char *)(T))+1)=(char) (((A) >> 8));\ - *(((char *)(T))+2)=(char) (((A) >> 16));\ - *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0) -#define int5store(T,A) do { *((char *)(T))=((A));\ - *(((char *)(T))+1)=(((A) >> 8));\ - *(((char *)(T))+2)=(((A) >> 16));\ - *(((char *)(T))+3)=(((A) >> 24)); \ - *(((char *)(T))+4)=(((A) >> 32)); } while(0) -#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \ - int4store((T),def_temp); \ - int4store((T+4),def_temp2); } while(0) -#ifdef WORDS_BIGENDIAN -#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\ - *((T)+1)=(char) ((byte *) &A)[2];\ - *((T)+2)=(char) ((byte *) &A)[1];\ - *((T)+3)=(char) ((byte *) &A)[0]; } while(0) - -#define float4get(V,M) do { float def_temp;\ - ((byte*) &def_temp)[0]=(M)[3];\ - ((byte*) &def_temp)[1]=(M)[2];\ - ((byte*) &def_temp)[2]=(M)[1];\ - ((byte*) &def_temp)[3]=(M)[0];\ - (V)=def_temp; } while(0) -#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\ - *((T)+1)=(char) ((byte *) &V)[6];\ - *((T)+2)=(char) ((byte *) &V)[5];\ - *((T)+3)=(char) ((byte *) &V)[4];\ - *((T)+4)=(char) ((byte *) &V)[3];\ - *((T)+5)=(char) ((byte *) &V)[2];\ - *((T)+6)=(char) ((byte *) &V)[1];\ - *((T)+7)=(char) ((byte *) &V)[0]; } while(0) - -#define float8get(V,M) do { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[7];\ - ((byte*) &def_temp)[1]=(M)[6];\ - ((byte*) &def_temp)[2]=(M)[5];\ - ((byte*) &def_temp)[3]=(M)[4];\ - ((byte*) &def_temp)[4]=(M)[3];\ - ((byte*) &def_temp)[5]=(M)[2];\ - ((byte*) &def_temp)[6]=(M)[1];\ - ((byte*) &def_temp)[7]=(M)[0];\ - (V) = def_temp; } while(0) -#else -#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) -#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) - -#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) -#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\ - *(((char*)T)+1)=(char) ((byte *) &V)[5];\ - *(((char*)T)+2)=(char) ((byte *) &V)[6];\ - *(((char*)T)+3)=(char) ((byte *) &V)[7];\ - *(((char*)T)+4)=(char) ((byte *) &V)[0];\ - *(((char*)T)+5)=(char) ((byte *) &V)[1];\ - *(((char*)T)+6)=(char) ((byte *) &V)[2];\ - *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\ - while(0) -#define doubleget(V,M) do { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[4];\ - ((byte*) &def_temp)[1]=(M)[5];\ - ((byte*) &def_temp)[2]=(M)[6];\ - ((byte*) &def_temp)[3]=(M)[7];\ - ((byte*) &def_temp)[4]=(M)[0];\ - ((byte*) &def_temp)[5]=(M)[1];\ - ((byte*) &def_temp)[6]=(M)[2];\ - ((byte*) &def_temp)[7]=(M)[3];\ - (V) = def_temp; } while(0) -#endif /* __FLOAT_WORD_ORDER */ - -#define float8get(V,M) doubleget((V),(M)) -#define float8store(V,M) doublestore((V),(M)) -#endif /* WORDS_BIGENDIAN */ - -#endif /* sint2korr */ - -/* - Macro for reading 32-bit integer from network byte order (big-endian) - from unaligned memory location. -*/ -#define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) |\ - (((uint32) ((uchar) (A)[2])) << 8) |\ - (((uint32) ((uchar) (A)[1])) << 16) |\ - (((uint32) ((uchar) (A)[0])) << 24)) -/* - Define-funktions for reading and storing in machine format from/to - short/long to/from some place in memory V should be a (not - register) variable, M is a pointer to byte -*/ - -#ifdef WORDS_BIGENDIAN - -#define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\ - ((uint16) ((uint16) (M)[0]) << 8)); } while(0) -#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\ - ((short) ((short) (M)[0]) << 8)); } while(0) -#define longget(V,M) do { int32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ - (V)=def_temp; } while(0) -#define ulongget(V,M) do { uint32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ - (V)=def_temp; } while(0) -#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\ - *(((char*)T)+1)=(char)(def_temp); \ - *(((char*)T)+0)=(char)(def_temp >> 8); } while(0) -#define longstore(T,A) do { *(((char*)T)+3)=((A));\ - *(((char*)T)+2)=(((A) >> 8));\ - *(((char*)T)+1)=(((A) >> 16));\ - *(((char*)T)+0)=(((A) >> 24)); } while(0) - -#define floatget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) -#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float)) -#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) -#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) - -#else - -#define ushortget(V,M) do { V = uint2korr(M); } while(0) -#define shortget(V,M) do { V = sint2korr(M); } while(0) -#define longget(V,M) do { V = sint4korr(M); } while(0) -#define ulongget(V,M) do { V = uint4korr(M); } while(0) -#define shortstore(T,V) int2store(T,V) -#define longstore(T,V) int4store(T,V) -#ifndef floatstore -#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float)) -#define floatget(V,M) memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float)) -#endif -#ifndef doubleget -#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) -#endif /* doubleget */ -#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) - -#endif /* WORDS_BIGENDIAN */ - -/* sprintf does not always return the number of bytes :- */ -#ifdef SPRINTF_RETURNS_INT -#define my_sprintf(buff,args) sprintf args -#else -#ifdef SPRINTF_RETURNS_PTR -#define my_sprintf(buff,args) ((int)(sprintf args - buff)) -#else -#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff)) -#endif -#endif - -#ifndef THREAD -#define thread_safe_increment(V,L) (V)++ -#define thread_safe_add(V,C,L) (V)+=(C) -#define thread_safe_sub(V,C,L) (V)-=(C) -#define statistic_increment(V,L) (V)++ -#define statistic_add(V,C,L) (V)+=(C) -#endif - -#ifdef HAVE_CHARSET_utf8 -#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8" -#else -#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME -#endif - -#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL) -#define NO_EMBEDDED_ACCESS_CHECKS -#endif - -#endif /* my_global_h */ diff --git a/src/mysql/my_list.h b/src/mysql/my_list.h deleted file mode 100644 index 92598696f..000000000 --- a/src/mysql/my_list.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _list_h_ -#define _list_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct st_list { - struct st_list *prev,*next; - void *data; -} LIST; - -typedef int (*list_walk_action)(void *,void *); - -extern LIST *list_add(LIST *root,LIST *element); -extern LIST *list_delete(LIST *root,LIST *element); -extern LIST *list_cons(void *data,LIST *root); -extern LIST *list_reverse(LIST *root); -extern void list_free(LIST *root,unsigned int free_data); -extern unsigned int list_length(LIST *); -extern int list_walk(LIST *,list_walk_action action,gptr argument); - -#define list_rest(a) ((a)->next) -#define list_push(a,b) (a)=list_cons((b),(a)) -#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/mysql/my_pthread.h b/src/mysql/my_pthread.h deleted file mode 100644 index 202e047dc..000000000 --- a/src/mysql/my_pthread.h +++ /dev/null @@ -1,717 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Defines to make different thread packages compatible */ - -#ifndef _my_pthread_h -#define _my_pthread_h - -#include -#ifndef ETIME -#define ETIME ETIMEDOUT /* For FreeBSD */ -#endif - -#ifdef __cplusplus -#define EXTERNC extern "C" -extern "C" { -#else -#define EXTERNC -#endif /* __cplusplus */ - -#if defined(__WIN__) || defined(OS2) - -#ifdef OS2 -typedef ULONG HANDLE; -typedef ULONG DWORD; -typedef int sigset_t; -#endif - -#ifdef OS2 -typedef HMTX pthread_mutex_t; -#else -typedef CRITICAL_SECTION pthread_mutex_t; -#endif -typedef HANDLE pthread_t; -typedef struct thread_attr { - DWORD dwStackSize ; - DWORD dwCreatingFlag ; - int priority ; -} pthread_attr_t ; - -typedef struct { int dummy; } pthread_condattr_t; - -/* Implementation of posix conditions */ - -typedef struct st_pthread_link { - DWORD thread_id; - struct st_pthread_link *next; -} pthread_link; - -typedef struct { - uint32 waiting; -#ifdef OS2 - HEV semaphore; -#else - HANDLE semaphore; -#endif -} pthread_cond_t; - - -#ifndef OS2 -struct timespec { /* For pthread_cond_timedwait() */ - time_t tv_sec; - long tv_nsec; -}; -#endif - -typedef int pthread_mutexattr_t; -#define win_pthread_self my_thread_var->pthread_self -#ifdef OS2 -#define pthread_handler_t EXTERNC void * _Optlink -typedef void * (_Optlink *pthread_handler)(void *); -#else -#define pthread_handler_t EXTERNC void * __cdecl -typedef void * (__cdecl *pthread_handler)(void *); -#endif - -void win_pthread_init(void); -int win_pthread_setspecific(void *A,void *B,uint length); -int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); -int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); -int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); -int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime); -int pthread_cond_signal(pthread_cond_t *cond); -int pthread_cond_broadcast(pthread_cond_t *cond); -int pthread_cond_destroy(pthread_cond_t *cond); -int pthread_attr_init(pthread_attr_t *connect_att); -int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack); -int pthread_attr_setprio(pthread_attr_t *connect_att,int priority); -int pthread_attr_destroy(pthread_attr_t *connect_att); -struct tm *localtime_r(const time_t *timep,struct tm *tmp); -struct tm *gmtime_r(const time_t *timep,struct tm *tmp); - - -void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ - -#ifndef OS2 -#define ETIMEDOUT 145 /* Win32 doesn't have this */ -#define getpid() GetCurrentThreadId() -#endif -#define pthread_self() win_pthread_self -#define HAVE_LOCALTIME_R 1 -#define _REENTRANT 1 -#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 - -#ifdef USE_TLS /* For LIBMYSQL.DLL */ -#undef SAFE_MUTEX /* This will cause conflicts */ -#define pthread_key(T,V) DWORD V -#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF) -#define pthread_key_delete(A) TlsFree(A) -#define pthread_getspecific(A) (TlsGetValue(A)) -#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A)) -#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V)) -#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V))) -#define pthread_setspecific(A,B) (!TlsSetValue((A),(B))) -#else -#define pthread_key(T,V) __declspec(thread) T V -#define pthread_key_create(A,B) pthread_dummy(0) -#define pthread_key_delete(A) pthread_dummy(0) -#define pthread_getspecific(A) (&(A)) -#define my_pthread_getspecific(T,A) (&(A)) -#define my_pthread_getspecific_ptr(T,V) (V) -#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0) -#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) -#endif /* USE_TLS */ - -#define pthread_equal(A,B) ((A) == (B)) -#ifdef OS2 -extern int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *); -extern int pthread_mutex_lock (pthread_mutex_t *); -extern int pthread_mutex_unlock (pthread_mutex_t *); -extern int pthread_mutex_destroy (pthread_mutex_t *); -#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A) -#define pthread_kill(A,B) raise(B) -#define pthread_exit(A) pthread_dummy() -#else -#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) -#define pthread_mutex_lock(A) (EnterCriticalSection(A),0) -#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT) -#define pthread_mutex_unlock(A) LeaveCriticalSection(A) -#define pthread_mutex_destroy(A) DeleteCriticalSection(A) -#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) -#define pthread_kill(A,B) pthread_dummy(0) -#endif /* OS2 */ - -/* Dummy defines for easier code */ -#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) -#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B) -#define pthread_attr_setscope(A,B) -#define pthread_detach_this_thread() -#define pthread_condattr_init(A) -#define pthread_condattr_destroy(A) - -/*Irena: compiler does not like this: */ -/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ -#define my_pthread_getprio(thread_id) pthread_dummy(0) - -#elif defined(HAVE_UNIXWARE7_THREADS) - -#include -#include - -#ifndef _REENTRANT -#define _REENTRANT -#endif - -#define HAVE_NONPOSIX_SIGWAIT -#define pthread_t thread_t -#define pthread_cond_t cond_t -#define pthread_mutex_t mutex_t -#define pthread_key_t thread_key_t -typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */ - -#define pthread_key_create(A,B) thr_keycreate((A),(B)) -#define pthread_key_delete(A) thr_keydelete(A) - -#define pthread_handler_t EXTERNC void * -#define pthread_key(T,V) pthread_key_t V - -void * my_pthread_getspecific_imp(pthread_key_t key); -#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B)) -#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V) - -#define pthread_setspecific(A,B) thr_setspecific(A,B) -#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V) - -#define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A)) -#define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL) -#define pthread_cond_destroy(a) cond_destroy(a) -#define pthread_cond_signal(a) cond_signal(a) -#define pthread_cond_wait(a,b) cond_wait((a),(b)) -#define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c)) -#define pthread_cond_broadcast(a) cond_broadcast(a) - -#define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL) -#define pthread_mutex_lock(a) mutex_lock(a) -#define pthread_mutex_unlock(a) mutex_unlock(a) -#define pthread_mutex_destroy(a) mutex_destroy(a) - -#define pthread_self() thr_self() -#define pthread_exit(A) thr_exit(A) -#define pthread_equal(A,B) (((A) == (B)) ? 1 : 0) -#define pthread_kill(A,B) thr_kill((A),(B)) -#define HAVE_PTHREAD_KILL - -#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C)) - -extern int my_sigwait(const sigset_t *set,int *sig); - -#define pthread_detach_this_thread() pthread_dummy(0) - -#define pthread_attr_init(A) pthread_dummy(0) -#define pthread_attr_destroy(A) pthread_dummy(0) -#define pthread_attr_setscope(A,B) pthread_dummy(0) -#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) -#define my_pthread_setprio(A,B) pthread_dummy (0) -#define my_pthread_getprio(A) pthread_dummy (0) -#define my_pthread_attr_setprio(A,B) pthread_dummy(0) - -#else /* Normal threads */ - -#ifdef HAVE_rts_threads -#define sigwait org_sigwait -#include -#undef sigwait -#endif -#include -#ifndef _REENTRANT -#define _REENTRANT -#endif -#ifdef HAVE_THR_SETCONCURRENCY -#include /* Probably solaris */ -#endif -#ifdef HAVE_SCHED_H -#include -#endif -#ifdef HAVE_SYNCH_H -#include -#endif -#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2)) -#error Requires at least rev 2 of EMX pthreads library. -#endif - -#ifdef __NETWARE__ -void my_pthread_exit(void *status); -#define pthread_exit(A) my_pthread_exit(A) -#endif - -extern int my_pthread_getprio(pthread_t thread_id); - -#define pthread_key(T,V) pthread_key_t V -#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V)) -#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V)) -#define pthread_detach_this_thread() -#define pthread_handler_t EXTERNC void * -typedef void *(* pthread_handler)(void *); - -/* Test first for RTS or FSU threads */ - -#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) -#define HAVE_rts_threads -extern int my_pthread_create_detached; -#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached -#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL -#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL -#define USE_ALARM_THREAD -#elif defined(HAVE_mit_thread) -#define USE_ALARM_THREAD -#undef HAVE_LOCALTIME_R -#define HAVE_LOCALTIME_R -#undef HAVE_GMTIME_R -#define HAVE_GMTIME_R -#undef HAVE_PTHREAD_ATTR_SETSCOPE -#define HAVE_PTHREAD_ATTR_SETSCOPE -#undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE /* If we are running linux */ -#undef HAVE_RWLOCK_T -#undef HAVE_RWLOCK_INIT -#undef HAVE_PTHREAD_RWLOCK_RDLOCK -#undef HAVE_SNPRINTF - -#define my_pthread_attr_setprio(A,B) -#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */ - -#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910 -int sigwait(sigset_t *set, int *sig); -#endif - -#ifndef HAVE_NONPOSIX_SIGWAIT -#define my_sigwait(A,B) sigwait((A),(B)) -#else -int my_sigwait(const sigset_t *set,int *sig); -#endif - -#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT -#ifndef SAFE_MUTEX -#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b)) -extern int my_pthread_mutex_init(pthread_mutex_t *mp, - const pthread_mutexattr_t *attr); -#endif /* SAFE_MUTEX */ -#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b)) -extern int my_pthread_cond_init(pthread_cond_t *mp, - const pthread_condattr_t *attr); -#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */ - -#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK) -#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C)) -#endif - -#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX) -int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ -#endif - - -/* - We define my_sigset() and use that instead of the system sigset() so that - we can favor an implementation based on sigaction(). On some systems, such - as Mac OS X, sigset() results in flags such as SA_RESTART being set, and - we want to make sure that no such flags are set. -*/ -#if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction s; sigset_t set; \ - sigemptyset(&set); \ - s.sa_handler = (B); \ - s.sa_mask = set; \ - s.sa_flags = 0; \ - sigaction((A), &s, (struct sigaction *) NULL); \ - } while (0) -#elif defined(HAVE_SIGSET) && !defined(my_sigset) -#define my_sigset(A,B) sigset((A),(B)) -#elif !defined(my_sigset) -#define my_sigset(A,B) signal((A),(B)) -#endif - -#ifndef my_pthread_setprio -#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */ -#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B)) -#elif defined(HAVE_PTHREAD_SETPRIO) -#define my_pthread_setprio(A,B) pthread_setprio((A),(B)) -#else -extern void my_pthread_setprio(pthread_t thread_id,int prior); -#endif -#endif - -#ifndef my_pthread_attr_setprio -#ifdef HAVE_PTHREAD_ATTR_SETPRIO -#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B)) -#else -extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority); -#endif -#endif - -#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS) -#define pthread_attr_setscope(A,B) -#undef HAVE_GETHOSTBYADDR_R /* No definition */ -#endif - -#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX) -extern int my_pthread_cond_timedwait(pthread_cond_t *cond, - pthread_mutex_t *mutex, - struct timespec *abstime); -#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C)) -#endif - -#if defined(OS2) -#define my_pthread_getspecific(T,A) ((T) &(A)) -#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) -#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC) -#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B)) -#else -#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B)) -void *my_pthread_getspecific_imp(pthread_key_t key); -#endif /* OS2 */ - -#ifndef HAVE_LOCALTIME_R -struct tm *localtime_r(const time_t *clock, struct tm *res); -#endif - -#ifndef HAVE_GMTIME_R -struct tm *gmtime_r(const time_t *clock, struct tm *res); -#endif - -#ifdef HAVE_PTHREAD_CONDATTR_CREATE -/* DCE threads on HPUX 10.20 */ -#define pthread_condattr_init pthread_condattr_create -#define pthread_condattr_destroy pthread_condattr_delete -#endif - -/* FSU THREADS */ -#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete) -#define pthread_key_delete(A) pthread_dummy(0) -#endif - -#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */ -#define pthread_cond_destroy(A) pthread_dummy(0) -#define pthread_mutex_destroy(A) pthread_dummy(0) -#define pthread_attr_delete(A) pthread_dummy(0) -#define pthread_condattr_delete(A) pthread_dummy(0) -#define pthread_attr_setstacksize(A,B) pthread_dummy(0) -#define pthread_equal(A,B) ((A) == (B)) -#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b)) -#define pthread_attr_init(A) pthread_attr_create(A) -#define pthread_attr_destroy(A) pthread_attr_delete(A) -#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) -#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) -#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#define pthread_kill(A,B) pthread_dummy(0) -#undef pthread_detach_this_thread -#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } -#endif - -#ifdef HAVE_DARWIN5_THREADS -#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#define pthread_kill(A,B) pthread_dummy(0) -#define pthread_condattr_init(A) pthread_dummy(0) -#define pthread_condattr_destroy(A) pthread_dummy(0) -#undef pthread_detach_this_thread -#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); } -#endif - -#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER) -/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */ -#define pthread_key_create(A,B) \ - pthread_keycreate(A,(B) ?\ - (pthread_destructor_t) (B) :\ - (pthread_destructor_t) pthread_dummy) -#define pthread_attr_init(A) pthread_attr_create(A) -#define pthread_attr_destroy(A) pthread_attr_delete(A) -#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) -#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) -#ifndef pthread_sigmask -#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#endif -#define pthread_kill(A,B) pthread_dummy(0) -#undef pthread_detach_this_thread -#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } -#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */ -#define HAVE_PTHREAD_KILL -#endif - -#endif /* defined(__WIN__) */ - -#if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) -#undef pthread_cond_timedwait -#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c)) -int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime); -#endif - -#if defined(HPUX10) -#define pthread_attr_getstacksize(A,B) my_pthread_attr_getstacksize(A,B) -void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); -#endif - -#if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) -#undef pthread_mutex_trylock -#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a)) -int my_pthread_mutex_trylock(pthread_mutex_t *mutex); -#endif - - /* safe_mutex adds checking to mutex for easier debugging */ - -#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) -#define SAFE_MUTEX_DETECT_DESTROY -#endif - -typedef struct st_safe_mutex_t -{ - pthread_mutex_t global,mutex; - const char *file; - uint line,count; - pthread_t thread; -#ifdef SAFE_MUTEX_DETECT_DESTROY - struct st_safe_mutex_info_t *info; /* to track destroying of mutexes */ -#endif -} safe_mutex_t; - -#ifdef SAFE_MUTEX_DETECT_DESTROY -/* - Used to track the destroying of mutexes. This needs to be a seperate - structure because the safe_mutex_t structure could be freed before - the mutexes are destroyed. -*/ - -typedef struct st_safe_mutex_info_t -{ - struct st_safe_mutex_info_t *next; - struct st_safe_mutex_info_t *prev; - const char *init_file; - uint32 init_line; -} safe_mutex_info_t; -#endif /* SAFE_MUTEX_DETECT_DESTROY */ - -int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, - const char *file, uint line); -int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line); -int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); -int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); -int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, - uint line); -int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, - struct timespec *abstime, const char *file, uint line); -void safe_mutex_global_init(void); -void safe_mutex_end(FILE *file); - - /* Wrappers if safe mutex is actually used */ -#ifdef SAFE_MUTEX -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_unlock -#undef pthread_mutex_destroy -#undef pthread_mutex_wait -#undef pthread_mutex_timedwait -#undef pthread_mutex_t -#undef pthread_cond_wait -#undef pthread_cond_timedwait -#undef pthread_mutex_trylock -#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) -#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__) -#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) -#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) -#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) -#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) -#define pthread_mutex_trylock(A) pthread_mutex_lock(A) -#define pthread_mutex_t safe_mutex_t -#define safe_mutex_assert_owner(mp) \ - DBUG_ASSERT((mp)->count > 0 && \ - pthread_equal(pthread_self(), (mp)->thread)) -#define safe_mutex_assert_not_owner(mp) \ - DBUG_ASSERT(! (mp)->count || \ - ! pthread_equal(pthread_self(), (mp)->thread)) -#else -#define safe_mutex_assert_owner(mp) -#define safe_mutex_assert_not_owner(mp) -#endif /* SAFE_MUTEX */ - - /* READ-WRITE thread locking */ - -#ifdef HAVE_BROKEN_RWLOCK /* For OpenUnix */ -#undef HAVE_PTHREAD_RWLOCK_RDLOCK -#undef HAVE_RWLOCK_INIT -#undef HAVE_RWLOCK_T -#endif - -#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS) -/* use these defs for simple mutex locking */ -#define rw_lock_t pthread_mutex_t -#define my_rwlock_init(A,B) pthread_mutex_init((A),(B)) -#define rw_rdlock(A) pthread_mutex_lock((A)) -#define rw_wrlock(A) pthread_mutex_lock((A)) -#define rw_tryrdlock(A) pthread_mutex_trylock((A)) -#define rw_trywrlock(A) pthread_mutex_trylock((A)) -#define rw_unlock(A) pthread_mutex_unlock((A)) -#define rwlock_destroy(A) pthread_mutex_destroy((A)) -#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK) -#define rw_lock_t pthread_rwlock_t -#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B)) -#define rw_rdlock(A) pthread_rwlock_rdlock(A) -#define rw_wrlock(A) pthread_rwlock_wrlock(A) -#define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A)) -#define rw_trywrlock(A) pthread_rwlock_trywrlock((A)) -#define rw_unlock(A) pthread_rwlock_unlock(A) -#define rwlock_destroy(A) pthread_rwlock_destroy(A) -#elif defined(HAVE_RWLOCK_INIT) -#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */ -#define rw_lock_t rwlock_t -#endif -#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0) -#else -/* Use our own version of read/write locks */ -typedef struct _my_rw_lock_t { - pthread_mutex_t lock; /* lock for structure */ - pthread_cond_t readers; /* waiting readers */ - pthread_cond_t writers; /* waiting writers */ - int state; /* -1:writer,0:free,>0:readers */ - int waiters; /* number of waiting writers */ -} my_rw_lock_t; - -#define rw_lock_t my_rw_lock_t -#define rw_rdlock(A) my_rw_rdlock((A)) -#define rw_wrlock(A) my_rw_wrlock((A)) -#define rw_tryrdlock(A) my_rw_tryrdlock((A)) -#define rw_trywrlock(A) my_rw_trywrlock((A)) -#define rw_unlock(A) my_rw_unlock((A)) -#define rwlock_destroy(A) my_rwlock_destroy((A)) - -extern int my_rwlock_init(my_rw_lock_t *, void *); -extern int my_rwlock_destroy(my_rw_lock_t *); -extern int my_rw_rdlock(my_rw_lock_t *); -extern int my_rw_wrlock(my_rw_lock_t *); -extern int my_rw_unlock(my_rw_lock_t *); -extern int my_rw_tryrdlock(my_rw_lock_t *); -extern int my_rw_trywrlock(my_rw_lock_t *); -#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ - -#define GETHOSTBYADDR_BUFF_SIZE 2048 - -#ifndef HAVE_THR_SETCONCURRENCY -#define thr_setconcurrency(A) pthread_dummy(0) -#endif -#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize) -#define pthread_attr_setstacksize(A,B) pthread_dummy(0) -#endif - -/* Define mutex types, see my_thr_init.c */ -#define MY_MUTEX_INIT_SLOW NULL -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -extern pthread_mutexattr_t my_fast_mutexattr; -#define MY_MUTEX_INIT_FAST &my_fast_mutexattr -#else -#define MY_MUTEX_INIT_FAST NULL -#endif -#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -extern pthread_mutexattr_t my_errorcheck_mutexattr; -#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr -#else -#define MY_MUTEX_INIT_ERRCHK NULL -#endif - -extern my_bool my_thread_global_init(void); -extern void my_thread_global_end(void); -extern my_bool my_thread_init(void); -extern void my_thread_end(void); -extern const char *my_thread_name(void); -extern long my_thread_id(void); -extern int pthread_no_free(void *); -extern int pthread_dummy(int); - -/* All thread specific variables are in the following struct */ - -#define THREAD_NAME_SIZE 10 -#ifndef DEFAULT_THREAD_STACK -#if SIZEOF_CHARP > 4 -/* - MySQL can survive with 32K, but some glibc libraries require > 128K stack - To resolve hostnames. Also recursive stored procedures needs stack. -*/ -#define DEFAULT_THREAD_STACK (256*1024L) -#else -#define DEFAULT_THREAD_STACK (192*1024) -#endif -#endif - -struct st_my_thread_var -{ - int thr_errno; - pthread_cond_t suspend; - pthread_mutex_t mutex; - pthread_mutex_t * volatile current_mutex; - pthread_cond_t * volatile current_cond; - pthread_t pthread_self; - long id; - int cmp_length; - int volatile abort; - my_bool init; - struct st_my_thread_var *next,**prev; - void *opt_info; -#ifndef DBUG_OFF - gptr dbug; - char name[THREAD_NAME_SIZE+1]; -#endif -}; - -extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); -#define my_thread_var (_my_thread_var()) -#define my_errno my_thread_var->thr_errno -/* - Keep track of shutdown,signal, and main threads so that my_end() will not - report errors with them -*/ -extern pthread_t shutdown_th, main_th, signal_th; - - /* statistics_xxx functions are for not essential statistic */ - -#ifndef thread_safe_increment -#ifdef HAVE_ATOMIC_ADD -#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V) -#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V) -#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V) -#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V) -#else -#define thread_safe_increment(V,L) \ - (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L))) -#define thread_safe_decrement(V,L) \ - (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L))) -#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L))) -#define thread_safe_sub(V,C,L) \ - (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L))) -#endif /* HAVE_ATOMIC_ADD */ -#ifdef SAFE_STATISTICS -#define statistic_increment(V,L) thread_safe_increment((V),(L)) -#define statistic_decrement(V,L) thread_safe_decrement((V),(L)) -#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) -#else -#define statistic_decrement(V,L) (V)-- -#define statistic_increment(V,L) (V)++ -#define statistic_add(V,C,L) (V)+=(C) -#endif /* SAFE_STATISTICS */ -#endif /* thread_safe_increment */ - -#ifdef __cplusplus -} -#endif -#endif /* _my_ptread_h */ diff --git a/src/mysql/my_sys.h b/src/mysql/my_sys.h deleted file mode 100644 index 44fe383bf..000000000 --- a/src/mysql/my_sys.h +++ /dev/null @@ -1,904 +0,0 @@ -/* Copyright (C) 2000-2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _my_sys_h -#define _my_sys_h -C_MODE_START - -#ifdef HAVE_AIOWAIT -#include /* Used by record-cache */ -typedef struct my_aio_result { - aio_result_t result; - int pending; -} my_aio_result; -#endif - -#ifndef THREAD -extern int NEAR my_errno; /* Last error in mysys */ -#else -#include -#endif - -#ifndef _m_ctype_h -#include /* for CHARSET_INFO */ -#endif - -#include -#include - -#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; } -#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} -#define MY_INIT(name); { my_progname= name; my_init(); } - -#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ -#define NRERRBUFFS (2) /* Buffers for parameters */ -#define MY_FILE_ERROR ((uint) ~0) - - /* General bitmaps for my_func's */ -#define MY_FFNF 1 /* Fatal if file not found */ -#define MY_FNABP 2 /* Fatal if not all bytes read/writen */ -#define MY_NABP 4 /* Error if not all bytes read/writen */ -#define MY_FAE 8 /* Fatal if any error */ -#define MY_WME 16 /* Write message on error */ -#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ -#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ -#define MY_RAID 64 /* Support for RAID */ -#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ -#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ -#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ -#define MY_COPYTIME 64 /* my_redel() copys time */ -#define MY_DELETE_OLD 256 /* my_create_with_symlink() */ -#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ -#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ -#define MY_REDEL_MAKE_BACKUP 256 -#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ -#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ -#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ -#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ -#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ -#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ -#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ -#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ - -#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ -#define MY_GIVE_INFO 2 /* Give time info about process*/ - -#define ME_HIGHBYTE 8 /* Shift for colours */ -#define ME_NOCUR 1 /* Don't use curses message */ -#define ME_OLDWIN 2 /* Use old window */ -#define ME_BELL 4 /* Ring bell then printing message */ -#define ME_HOLDTANG 8 /* Don't delete last keys */ -#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */ -#define ME_WAITTANG 32 /* Wait for a user action */ -#define ME_NOREFRESH 64 /* Dont refresh screen */ -#define ME_NOINPUT 128 /* Dont use the input libary */ -#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ -#define ME_COLOUR2 ((2 << ME_HIGHBYTE)) -#define ME_COLOUR3 ((3 << ME_HIGHBYTE)) - - /* Bits in last argument to fn_format */ -#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ -#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ -#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ -#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ -#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ -#define MY_RETURN_REAL_PATH 32 /* return full path for file */ -#define MY_SAFE_PATH 64 /* Return NULL if too long path */ -#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ - - /* My seek flags */ -#define MY_SEEK_SET 0 -#define MY_SEEK_CUR 1 -#define MY_SEEK_END 2 - - /* Some constants */ -#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ -#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ -#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ -#define DFLT_INIT_HITS 3 - - /* root_alloc flags */ -#define MY_KEEP_PREALLOC 1 -#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ - - /* Internal error numbers (for assembler functions) */ -#define MY_ERRNO_EDOM 33 -#define MY_ERRNO_ERANGE 34 - - /* Bits for get_date timeflag */ -#define GETDATE_DATE_TIME 1 -#define GETDATE_SHORT_DATE 2 -#define GETDATE_HHMMSSTIME 4 -#define GETDATE_GMT 8 -#define GETDATE_FIXEDLENGTH 16 - - /* defines when allocating data */ -#ifdef SAFEMALLOC -#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) -#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG ) -#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG ) -#define my_checkmalloc() _sanity( __FILE__, __LINE__ ) -#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG) -#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C) -#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C) -#define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C) -#define TRASH(A,B) bfill(A, B, 0x8F) -#define QUICK_SAFEMALLOC sf_malloc_quick=1 -#define NORMAL_SAFEMALLOC sf_malloc_quick=0 -extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; -extern ulonglong sf_malloc_mem_limit; - -#define CALLER_INFO_PROTO , const char *sFile, uint uLine -#define CALLER_INFO , __FILE__, __LINE__ -#define ORIG_CALLER_INFO , sFile, uLine -#else -#define my_checkmalloc() -#undef TERMINATE -#define TERMINATE(A) {} -#define QUICK_SAFEMALLOC -#define NORMAL_SAFEMALLOC -extern gptr my_malloc(uint Size,myf MyFlags); -#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) -extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); -extern void my_no_flags_free(gptr ptr); -extern gptr my_memdup(const byte *from,uint length,myf MyFlags); -extern char *my_strdup(const char *from,myf MyFlags); -extern char *my_strdup_with_length(const byte *from, uint length, - myf MyFlags); -/* we do use FG (as a no-op) in below so that a typo on FG is caught */ -#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) -#define CALLER_INFO_PROTO /* nothing */ -#define CALLER_INFO /* nothing */ -#define ORIG_CALLER_INFO /* nothing */ -#define TRASH(A,B) /* nothing */ -#endif - -#ifdef HAVE_LARGE_PAGES -extern uint my_get_large_page_size(void); -extern gptr my_large_malloc(uint size, myf my_flags); -extern void my_large_free(gptr ptr, myf my_flags); -#else -#define my_get_large_page_size() (0) -#define my_large_malloc(A,B) my_malloc_lock((A),(B)) -#define my_large_free(A,B) my_free_lock((A),(B)) -#endif /* HAVE_LARGE_PAGES */ - -#ifdef HAVE_ALLOCA -#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) -#pragma alloca -#endif /* _AIX */ -#if defined(__MWERKS__) -#undef alloca -#define alloca _alloca -#endif /* __MWERKS__ */ -#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca) -#define alloca __builtin_alloca -#endif /* GNUC */ -#define my_alloca(SZ) alloca((size_t) (SZ)) -#define my_afree(PTR) {} -#else -#define my_alloca(SZ) my_malloc(SZ,MYF(0)) -#define my_afree(PTR) my_free(PTR,MYF(MY_WME)) -#endif /* HAVE_ALLOCA */ - -#ifdef MSDOS -#ifdef __ZTC__ -void * __CDECL halloc(long count,size_t length); -void __CDECL hfree(void *ptr); -#endif -#if defined(USE_HALLOC) -#if defined(_VCM_) || defined(M_IC80386) -#undef USE_HALLOC -#endif -#endif -#ifdef USE_HALLOC -#define malloc(a) halloc((long) (a),1) -#define free(a) hfree(a) -#endif -#endif /* MSDOS */ - -#ifndef errno /* did we already get it? */ -#ifdef HAVE_ERRNO_AS_DEFINE -#include /* errno is a define */ -#else -extern int errno; /* declare errno */ -#endif -#endif /* #ifndef errno */ -extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; -extern char *home_dir; /* Home directory for user */ -extern const char *my_progname; /* program-name (printed in errors) */ -extern char NEAR curr_dir[]; /* Current directory for user */ -extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); -extern int (*fatal_error_handler_hook)(uint my_err, const char *str, - myf MyFlags); -extern uint my_file_limit; - -#ifdef HAVE_LARGE_PAGES -extern my_bool my_use_large_pages; -extern uint my_large_page_size; -#endif - -/* charsets */ -extern CHARSET_INFO *default_charset_info; -extern CHARSET_INFO *all_charsets[256]; -extern CHARSET_INFO compiled_charsets[]; - -/* statistics */ -extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern uint mysys_usage_id; -extern my_bool my_init_done; - - /* Point to current my_message() */ -extern void (*my_sigtstp_cleanup)(void), - /* Executed before jump to shell */ - (*my_sigtstp_restart)(void), - (*my_abort_hook)(int); - /* Executed when comming from shell */ -extern int NEAR my_umask, /* Default creation mask */ - NEAR my_umask_dir, - NEAR my_recived_signals, /* Signals we have got */ - NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ - NEAR my_dont_interrupt; /* call remember_intr when set */ -extern my_bool NEAR mysys_uses_curses, my_use_symdir; -extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; - -extern ulong my_default_record_cache_size; -extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, - NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; -extern char wild_many,wild_one,wild_prefix; -extern const char *charsets_dir; -extern char *defaults_extra_file; -extern const char *defaults_group_suffix; -extern const char *defaults_file; - -extern my_bool timed_mutexes; - -typedef struct wild_file_pack /* Struct to hold info when selecting files */ -{ - uint wilds; /* How many wildcards */ - uint not_pos; /* Start of not-theese-files */ - my_string *wild; /* Pointer to wildcards */ -} WF_PACK; - -enum loglevel { - ERROR_LEVEL, - WARNING_LEVEL, - INFORMATION_LEVEL -}; - -enum cache_type -{ - TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE, - SEQ_READ_APPEND /* sequential read or append */, - READ_FIFO, READ_NET,WRITE_NET}; - -enum flush_type -{ - FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE -}; - -typedef struct st_record_cache /* Used when cacheing records */ -{ - File file; - int rc_seek,error,inited; - uint rc_length,read_length,reclength; - my_off_t rc_record_pos,end_of_file; - byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; -#ifdef HAVE_AIOWAIT - int use_async_io; - my_aio_result aio_result; -#endif - enum cache_type type; -} RECORD_CACHE; - -enum file_type -{ - UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, - FILE_BY_MKSTEMP, FILE_BY_DUP -}; - -struct st_my_file_info -{ - my_string name; - enum file_type type; -#if defined(THREAD) && !defined(HAVE_PREAD) - pthread_mutex_t mutex; -#endif -}; - -extern struct st_my_file_info *my_file_info; - -typedef struct st_my_tmpdir -{ - char **list; - uint cur, max; -#ifdef THREAD - pthread_mutex_t mutex; -#endif -} MY_TMPDIR; - -typedef struct st_dynamic_array -{ - char *buffer; - uint elements,max_element; - uint alloc_increment; - uint size_of_element; -} DYNAMIC_ARRAY; - -typedef struct st_dynamic_string -{ - char *str; - uint length,max_length,alloc_increment; -} DYNAMIC_STRING; - -struct st_io_cache; -typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); - -#ifdef THREAD -typedef struct st_io_cache_share -{ - /* to sync on reads into buffer */ - pthread_mutex_t mutex; - pthread_cond_t cond; - int count, total; - /* actual IO_CACHE that filled the buffer */ - struct st_io_cache *active; -#ifdef NOT_YET_IMPLEMENTED - /* whether the structure should be free'd */ - my_bool alloced; -#endif -} IO_CACHE_SHARE; -#endif - -typedef struct st_io_cache /* Used when cacheing files */ -{ - /* Offset in file corresponding to the first byte of byte* buffer. */ - my_off_t pos_in_file; - /* - The offset of end of file for READ_CACHE and WRITE_CACHE. - For SEQ_READ_APPEND it the maximum of the actual end of file and - the position represented by read_end. - */ - my_off_t end_of_file; - /* Points to current read position in the buffer */ - byte *read_pos; - /* the non-inclusive boundary in the buffer for the currently valid read */ - byte *read_end; - byte *buffer; /* The read buffer */ - /* Used in ASYNC_IO */ - byte *request_pos; - - /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ - byte *write_buffer; - /* - Only used in SEQ_READ_APPEND, and points to the current read position - in the write buffer. Note that reads in SEQ_READ_APPEND caches can - happen from both read buffer (byte* buffer) and write buffer - (byte* write_buffer). - */ - byte *append_read_pos; - /* Points to current write position in the write buffer */ - byte *write_pos; - /* The non-inclusive boundary of the valid write area */ - byte *write_end; - - /* - Current_pos and current_end are convenience variables used by - my_b_tell() and other routines that need to know the current offset - current_pos points to &write_pos, and current_end to &write_end in a - WRITE_CACHE, and &read_pos and &read_end respectively otherwise - */ - byte **current_pos, **current_end; -#ifdef THREAD - /* - The lock is for append buffer used in SEQ_READ_APPEND cache - need mutex copying from append buffer to read buffer. - */ - pthread_mutex_t append_buffer_lock; - /* - The following is used when several threads are reading the - same file in parallel. They are synchronized on disk - accesses reading the cached part of the file asynchronously. - It should be set to NULL to disable the feature. Only - READ_CACHE mode is supported. - */ - IO_CACHE_SHARE *share; -#endif - /* - A caller will use my_b_read() macro to read from the cache - if the data is already in cache, it will be simply copied with - memcpy() and internal variables will be accordinging updated with - no functions invoked. However, if the data is not fully in the cache, - my_b_read() will call read_function to fetch the data. read_function - must never be invoked directly. - */ - int (*read_function)(struct st_io_cache *,byte *,uint); - /* - Same idea as in the case of read_function, except my_b_write() needs to - be replaced with my_b_append() for a SEQ_READ_APPEND cache - */ - int (*write_function)(struct st_io_cache *,const byte *,uint); - /* - Specifies the type of the cache. Depending on the type of the cache - certain operations might not be available and yield unpredicatable - results. Details to be documented later - */ - enum cache_type type; - /* - Callbacks when the actual read I/O happens. These were added and - are currently used for binary logging of LOAD DATA INFILE - when a - block is read from the file, we create a block create/append event, and - when IO_CACHE is closed, we create an end event. These functions could, - of course be used for other things - */ - IO_CACHE_CALLBACK pre_read; - IO_CACHE_CALLBACK post_read; - IO_CACHE_CALLBACK pre_close; - /* - Counts the number of times, when we were forced to use disk. We use it to - increase the binlog_cache_disk_use status variable. - */ - ulong disk_writes; - void* arg; /* for use by pre/post_read */ - char *file_name; /* if used with 'open_cached_file' */ - char *dir,*prefix; - File file; /* file descriptor */ - /* - seek_not_done is set by my_b_seek() to inform the upcoming read/write - operation that a seek needs to be preformed prior to the actual I/O - error is 0 if the cache operation was successful, -1 if there was a - "hard" error, and the actual number of I/O-ed bytes if the read/write was - partial. - */ - int seek_not_done,error; - /* buffer_length is memory size allocated for buffer or write_buffer */ - uint buffer_length; - /* read_length is the same as buffer_length except when we use async io */ - uint read_length; - myf myflags; /* Flags used to my_read/my_write */ - /* - alloced_buffer is 1 if the buffer was allocated by init_io_cache() and - 0 if it was supplied by the user. - Currently READ_NET is the only one that will use a buffer allocated - somewhere else - */ - my_bool alloced_buffer; -#ifdef HAVE_AIOWAIT - /* - As inidicated by ifdef, this is for async I/O, which is not currently - used (because it's not reliable on all systems) - */ - uint inited; - my_off_t aio_read_pos; - my_aio_result aio_result; -#endif -} IO_CACHE; - -typedef int (*qsort2_cmp)(const void *, const void *, const void *); - - /* defines for mf_iocache */ - - /* Test if buffer is inited */ -#define my_b_clear(info) (info)->buffer=0 -#define my_b_inited(info) (info)->buffer -#define my_b_EOF INT_MIN - -#define my_b_read(info,Buffer,Count) \ - ((info)->read_pos + (Count) <= (info)->read_end ?\ - (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \ - ((info)->read_pos+=(Count)),0) :\ - (*(info)->read_function)((info),Buffer,Count)) - -#define my_b_write(info,Buffer,Count) \ - ((info)->write_pos + (Count) <=(info)->write_end ?\ - (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ - ((info)->write_pos+=(Count)),0) : \ - (*(info)->write_function)((info),(Buffer),(Count))) - -#define my_b_get(info) \ - ((info)->read_pos != (info)->read_end ?\ - ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\ - _my_b_get(info)) - - /* my_b_write_byte dosn't have any err-check */ -#define my_b_write_byte(info,chr) \ - (((info)->write_pos < (info)->write_end) ?\ - ((*(info)->write_pos++)=(chr)) :\ - (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr)))) - -#define my_b_fill_cache(info) \ - (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) - -#define my_b_tell(info) ((info)->pos_in_file + \ - (uint) (*(info)->current_pos - (info)->request_pos)) - -/* tell write offset in the SEQ_APPEND cache */ -my_off_t my_b_append_tell(IO_CACHE* info); -my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ - -#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ - *(info)->current_pos) - -typedef uint32 ha_checksum; - -/* Define the type of function to be passed to process_default_option_files */ -typedef int (*Process_option_func)(void *ctx, const char *group_name, - const char *option); - -#include - - /* Prototypes for mysys and my_func functions */ - -extern int my_copy(const char *from,const char *to,myf MyFlags); -extern int my_append(const char *from,const char *to,myf MyFlags); -extern int my_delete(const char *name,myf MyFlags); -extern int my_getwd(my_string buf,uint size,myf MyFlags); -extern int my_setwd(const char *dir,myf MyFlags); -extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); -extern gptr my_once_alloc(uint Size,myf MyFlags); -extern void my_once_free(void); -extern char *my_once_strdup(const char *src,myf myflags); -extern char *my_once_memdup(const char *src, uint len, myf myflags); -extern File my_open(const char *FileName,int Flags,myf MyFlags); -extern File my_register_filename(File fd, const char *FileName, - enum file_type type_of_file, - uint error_message_number, myf MyFlags); -extern File my_create(const char *FileName,int CreateFlags, - int AccsesFlags, myf MyFlags); -extern int my_close(File Filedes,myf MyFlags); -extern File my_dup(File file, myf MyFlags); -extern int my_mkdir(const char *dir, int Flags, myf MyFlags); -extern int my_readlink(char *to, const char *filename, myf MyFlags); -extern int my_realpath(char *to, const char *filename, myf MyFlags); -extern File my_create_with_symlink(const char *linkname, const char *filename, - int createflags, int access_flags, - myf MyFlags); -extern int my_delete_with_symlink(const char *name, myf MyFlags); -extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); -extern int my_symlink(const char *content, const char *linkname, myf MyFlags); -extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); -extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, - myf MyFlags); -extern int my_rename(const char *from,const char *to,myf MyFlags); -extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); -extern my_off_t my_tell(File fd,myf MyFlags); -extern uint my_write(File Filedes,const byte *Buffer,uint Count, - myf MyFlags); -extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, - my_off_t offset,myf MyFlags); -extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); -extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, - myf MyFlags); -extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); -extern my_off_t my_ftell(FILE *stream,myf MyFlags); -extern gptr _mymalloc(uint uSize,const char *sFile, - uint uLine, myf MyFlag); -extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, - uint uLine, myf MyFlag); -extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); -extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); -extern int _sanity(const char *sFile,unsigned int uLine); -extern gptr _my_memdup(const byte *from,uint length, - const char *sFile, uint uLine,myf MyFlag); -extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, - myf MyFlag); -extern char *_my_strdup_with_length(const byte *from, uint length, - const char *sFile, uint uLine, - myf MyFlag); - -#ifdef __WIN__ -extern int my_access(const char *path, int amode); -extern File my_sopen(const char *path, int oflag, int shflag, int pmode); -#else -#define my_access access -#endif -extern int check_if_legal_filename(const char *path); - -#ifndef TERMINATE -extern void TERMINATE(FILE *file); -#endif -extern void init_glob_errs(void); -extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); -extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); -extern int my_fclose(FILE *fd,myf MyFlags); -extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); -extern int my_sync(File fd, myf my_flags); -extern int my_error _VARARGS((int nr,myf MyFlags, ...)); -extern int my_printf_error _VARARGS((uint my_err, const char *format, - myf MyFlags, ...) - __attribute__ ((format (printf, 2, 4)))); -extern int my_error_register(const char **errmsgs, int first, int last); -extern const char **my_error_unregister(int first, int last); -extern int my_message(uint my_err, const char *str,myf MyFlags); -extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags); -extern int my_message_curses(uint my_err, const char *str,myf MyFlags); -extern my_bool my_init(void); -extern void my_end(int infoflag); -extern int my_redel(const char *from, const char *to, int MyFlags); -extern int my_copystat(const char *from, const char *to, int MyFlags); -extern my_string my_filename(File fd); - -#ifndef THREAD -extern void dont_break(void); -extern void allow_break(void); -#else -#define dont_break() -#define allow_break() -#endif - -extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); -extern char *my_tmpdir(MY_TMPDIR *tmpdir); -extern void free_tmpdir(MY_TMPDIR *tmpdir); - -extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); -extern uint dirname_part(my_string to,const char *name); -extern uint dirname_length(const char *name); -#define base_name(A) (A+dirname_length(A)) -extern int test_if_hard_path(const char *dir_name); -extern my_bool has_path(const char *name); -extern char *convert_dirname(char *to, const char *from, const char *from_end); -extern void to_unix_path(my_string name); -extern my_string fn_ext(const char *name); -extern my_string fn_same(my_string toname,const char *name,int flag); -extern my_string fn_format(my_string to,const char *name,const char *dir, - const char *form, uint flag); -extern size_s strlength(const char *str); -extern void pack_dirname(my_string to,const char *from); -extern uint unpack_dirname(my_string to,const char *from); -extern uint cleanup_dirname(my_string to,const char *from); -extern uint system_filename(my_string to,const char *from); -extern uint unpack_filename(my_string to,const char *from); -extern my_string intern_filename(my_string to,const char *from); -extern my_string directory_file_name(my_string dst, const char *src); -extern int pack_filename(my_string to, const char *name, size_s max_length); -extern my_string my_path(my_string to,const char *progname, - const char *own_pathname_part); -extern my_string my_load_path(my_string to, const char *path, - const char *own_path_prefix); -extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern); -extern WF_PACK *wf_comp(my_string str); -extern int wf_test(struct wild_file_pack *wf_pack,const char *name); -extern void wf_end(struct wild_file_pack *buffer); -extern size_s strip_sp(my_string str); -extern void get_date(my_string to,int timeflag,time_t use_time); -extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage); -extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, - uint reclength,enum cache_type type, - pbool use_async_io); -extern int read_cache_record(RECORD_CACHE *info,byte *to); -extern int end_record_cache(RECORD_CACHE *info); -extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, - const byte *record,uint length); -extern int flush_write_cache(RECORD_CACHE *info); -extern long my_clock(void); -extern sig_handler sigtstp_handler(int signal_number); -extern void handle_recived_signals(void); - -extern sig_handler my_set_alarm_variable(int signo); -extern void my_string_ptr_sort(void *base,uint items,size_s size); -extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, - size_s size_of_element,uchar *buffer[]); -extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, - qsort2_cmp cmp, void *cmp_argument); -extern qsort2_cmp get_ptr_compare(uint); -void my_store_ptr(byte *buff, uint pack_length, my_off_t pos); -my_off_t my_get_ptr(byte *ptr, uint pack_length); -extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, - enum cache_type type,my_off_t seek_offset, - pbool use_async_io, myf cache_myflags); -extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, - my_off_t seek_offset,pbool use_async_io, - pbool clear_cache); -extern void setup_io_cache(IO_CACHE* info); -extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count); -#ifdef THREAD -extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); -extern void init_io_cache_share(IO_CACHE *info, - IO_CACHE_SHARE *s, uint num_threads); -extern void remove_io_thread(IO_CACHE *info); -#endif -extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count); -extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count); -extern int _my_b_get(IO_CACHE *info); -extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); -extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); -extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); -extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); - -extern int my_block_write(IO_CACHE *info, const byte *Buffer, - uint Count, my_off_t pos); -extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); - -#define flush_io_cache(info) my_b_flush_io_cache((info),1) - -extern int end_io_cache(IO_CACHE *info); -extern uint my_b_fill(IO_CACHE *info); -extern void my_b_seek(IO_CACHE *info,my_off_t pos); -extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); -extern my_off_t my_b_filelength(IO_CACHE *info); -extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); -extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); -extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, - const char *prefix, uint cache_size, - myf cache_myflags); -extern my_bool real_open_cached_file(IO_CACHE *cache); -extern void close_cached_file(IO_CACHE *cache); -File create_temp_file(char *to, const char *dir, const char *pfx, - int mode, myf MyFlags); -#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) -#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) -extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, - uint init_alloc,uint alloc_increment - CALLER_INFO_PROTO); -extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); -extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); -extern byte *pop_dynamic(DYNAMIC_ARRAY*); -extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); -extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); -extern void delete_dynamic(DYNAMIC_ARRAY *array); -extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); -extern void freeze_size(DYNAMIC_ARRAY *array); -#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) -#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) -#define push_dynamic(A,B) insert_dynamic(A,B) -#define reset_dynamic(array) ((array)->elements= 0) - -extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, - uint init_alloc,uint alloc_increment); -extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); -my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, - uint length); -extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); -extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); -extern void dynstr_free(DYNAMIC_STRING *str); -#ifdef HAVE_MLOCK -extern byte *my_malloc_lock(uint length,myf flags); -extern void my_free_lock(byte *ptr,myf flags); -#else -#define my_malloc_lock(A,B) my_malloc((A),(B)) -#define my_free_lock(A,B) my_free((A),(B)) -#endif -#define alloc_root_inited(A) ((A)->min_malloc != 0) -#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) -#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) -extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, - uint pre_alloc_size); -extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); -extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...); -extern void free_root(MEM_ROOT *root, myf MyFLAGS); -extern void set_prealloc_root(MEM_ROOT *root, char *ptr); -extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, - uint prealloc_size); -extern char *strdup_root(MEM_ROOT *root,const char *str); -extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); -extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); -extern int get_defaults_options(int argc, char **argv, - char **defaults, char **extra_defaults, - char **group_suffix); -extern int load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv); -extern int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option); -extern int my_search_option_files(const char *conf_file, int *argc, - char ***argv, uint *args_used, - Process_option_func func, void *func_ctx); -extern void free_defaults(char **argv); -extern void my_print_default_files(const char *conf_file); -extern void print_defaults(const char *conf_file, const char **groups); -extern my_bool my_compress(byte *, ulong *, ulong *); -extern my_bool my_uncompress(byte *, ulong *, ulong *); -extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); -extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); -extern uint my_bit_log2(ulong value); -extern uint my_count_bits(ulonglong v); -extern uint my_count_bits_ushort(ushort v); -extern void my_sleep(ulong m_seconds); -extern ulong crc32(ulong crc, const uchar *buf, uint len); -extern uint my_set_max_open_files(uint files); -void my_free_open_file_info(void); - -ulonglong my_getsystime(void); -my_bool my_gethwaddr(uchar *to); - -#ifdef HAVE_SYS_MMAN_H -#include - -#ifndef MAP_NOSYNC -#define MAP_NOSYNC 0 -#endif - -#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) -#ifdef HAVE_GETPAGESIZE -#define my_getpagesize() getpagesize() -#else -/* qnx ? */ -#define my_getpagesize() 8192 -#endif -#define my_munmap(a,b) munmap((a),(b)) - -#else -/* not a complete set of mmap() flags, but only those that nesessary */ -#define PROT_READ 1 -#define PROT_WRITE 2 -#define MAP_SHARED 0x0001 -#define MAP_NOSYNC 0x0800 -#define MAP_FAILED ((void *)-1) -#define MS_SYNC 0x0000 - -#ifndef __NETWARE__ -#define HAVE_MMAP -#endif - -int my_getpagesize(void); -void *my_mmap(void *, size_t, int, int, int, my_off_t); -int my_munmap(void *, size_t); -#endif - -int my_msync(int, void *, size_t, int); - -/* character sets */ -extern uint get_charset_number(const char *cs_name, uint cs_flags); -extern uint get_collation_number(const char *name); -extern const char *get_charset_name(uint cs_number); - -extern CHARSET_INFO *get_charset(uint cs_number, myf flags); -extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); -extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, - uint cs_flags, myf my_flags); -extern void free_charsets(void); -extern char *get_charsets_dir(char *buf); -extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); -extern my_bool init_compiled_charsets(myf flags); -extern void add_compiled_collation(CHARSET_INFO *cs); -extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length); -#ifdef __WIN__ -#define BACKSLASH_MBTAIL -/* File system character set */ -extern CHARSET_INFO *fs_character_set(void); -#endif -extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length); - -extern void thd_increment_bytes_sent(ulong length); -extern void thd_increment_bytes_received(ulong length); -extern void thd_increment_net_big_packet_count(ulong length); - -#ifdef __WIN__ -extern my_bool have_tcpip; /* Is set if tcpip is used */ - -/* implemented in my_windac.c */ - -int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, - DWORD owner_rights, DWORD everybody_rights); - -void my_security_attr_free(SECURITY_ATTRIBUTES *sa); - -/* implemented in my_conio.c */ -char* my_cgets(char *string, unsigned long clen, unsigned long* plen); - -#endif -#ifdef __NETWARE__ -void netware_reg_user(const char *ip, const char *user, - const char *application); -#endif - -C_MODE_END -#include "raid.h" -#endif /* _my_sys_h */ diff --git a/src/mysql/mysql-5.0.20 b/src/mysql/mysql-5.0.20 deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/mysql/mysql.h b/src/mysql/mysql.h deleted file mode 100644 index 925a45253..000000000 --- a/src/mysql/mysql.h +++ /dev/null @@ -1,847 +0,0 @@ -/* Copyright (C) 2000-2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _mysql_h -#define _mysql_h - -#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */ -#undef WIN -#undef _WIN -#undef _WIN32 -#undef _WIN64 -#undef __WIN__ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _global_h /* If not standard header */ -#include -#ifdef __LCC__ -#include /* For windows */ -#endif -typedef char my_bool; -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) -#define __WIN__ -#endif -#if !defined(__WIN__) -#define STDCALL -#else -#define STDCALL __stdcall -#endif -typedef char * gptr; - -#ifndef my_socket_defined -#ifdef __WIN__ -#define my_socket SOCKET -#else -typedef int my_socket; -#endif /* __WIN__ */ -#endif /* my_socket_defined */ -#endif /* _global_h */ - -#include "mysql_com.h" -#include "mysql_time.h" -#include "mysql_version.h" -#include "typelib.h" - -#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */ - -extern unsigned int mysql_port; -extern char *mysql_unix_port; - -#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */ -#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */ - -#ifdef __NETWARE__ -#pragma pack(push, 8) /* 8 byte alignment */ -#endif - -#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) -#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) -#define IS_BLOB(n) ((n) & BLOB_FLAG) -#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL) -#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) -#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR) - - -typedef struct st_mysql_field { - char *name; /* Name of column */ - char *org_name; /* Original column name, if an alias */ - char *table; /* Table of column if column was a field */ - char *org_table; /* Org table name, if table was an alias */ - char *db; /* Database for table */ - char *catalog; /* Catalog for table */ - char *def; /* Default value (set by mysql_list_fields) */ - unsigned long length; /* Width of column (create length) */ - unsigned long max_length; /* Max width for selected set */ - unsigned int name_length; - unsigned int org_name_length; - unsigned int table_length; - unsigned int org_table_length; - unsigned int db_length; - unsigned int catalog_length; - unsigned int def_length; - unsigned int flags; /* Div flags */ - unsigned int decimals; /* Number of decimals in field */ - unsigned int charsetnr; /* Character set */ - enum enum_field_types type; /* Type of field. See mysql_com.h for types */ -} MYSQL_FIELD; - -typedef char **MYSQL_ROW; /* return data as array of strings */ -typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ - -#ifndef _global_h -#if defined(NO_CLIENT_LONG_LONG) -typedef unsigned long my_ulonglong; -#elif defined (__WIN__) -typedef unsigned __int64 my_ulonglong; -#else -typedef unsigned long long my_ulonglong; -#endif -#endif - -#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0) - -/* backward compatibility define - to be removed eventually */ -#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED - -typedef struct st_mysql_rows { - struct st_mysql_rows *next; /* list of rows */ - MYSQL_ROW data; - unsigned long length; -} MYSQL_ROWS; - -typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ - -#include "my_alloc.h" - -typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; -typedef struct st_mysql_data { - my_ulonglong rows; - unsigned int fields; - MYSQL_ROWS *data; - MEM_ROOT alloc; - /* extra info for embedded library */ - struct embedded_query_result *embedded_info; -} MYSQL_DATA; - -enum mysql_option -{ - MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, - MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, - MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, - MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, - MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, - MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, - MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, - MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT -}; - -struct st_mysql_options { - unsigned int connect_timeout, read_timeout, write_timeout; - unsigned int port, protocol; - unsigned long client_flag; - char *host,*user,*password,*unix_socket,*db; - struct st_dynamic_array *init_commands; - char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; - char *ssl_key; /* PEM key file */ - char *ssl_cert; /* PEM cert file */ - char *ssl_ca; /* PEM CA file */ - char *ssl_capath; /* PEM directory of CA-s? */ - char *ssl_cipher; /* cipher to use */ - char *shared_memory_base_name; - unsigned long max_allowed_packet; - my_bool use_ssl; /* if to use SSL or not */ - my_bool compress,named_pipe; - /* - On connect, find out the replication role of the server, and - establish connections to all the peers - */ - my_bool rpl_probe; - /* - Each call to mysql_real_query() will parse it to tell if it is a read - or a write, and direct it to the slave or the master - */ - my_bool rpl_parse; - /* - If set, never read from a master, only from slave, when doing - a read that is replication-aware - */ - my_bool no_master_reads; -#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY) - my_bool separate_thread; -#endif - enum mysql_option methods_to_use; - char *client_ip; - /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */ - my_bool secure_auth; - /* 0 - never report, 1 - always report (default) */ - my_bool report_data_truncation; - - /* function pointers for local infile support */ - int (*local_infile_init)(void **, const char *, void *); - int (*local_infile_read)(void *, char *, unsigned int); - void (*local_infile_end)(void *); - int (*local_infile_error)(void *, char *, unsigned int); - void *local_infile_userdata; -}; - -enum mysql_status -{ - MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT -}; - -enum mysql_protocol_type -{ - MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, - MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY -}; -/* - There are three types of queries - the ones that have to go to - the master, the ones that go to a slave, and the adminstrative - type which must happen on the pivot connectioin -*/ -enum mysql_rpl_type -{ - MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN -}; - -typedef struct character_set -{ - unsigned int number; /* character set number */ - unsigned int state; /* character set state */ - const char *csname; /* collation name */ - const char *name; /* character set name */ - const char *comment; /* comment */ - const char *dir; /* character set directory */ - unsigned int mbminlen; /* min. length for multibyte strings */ - unsigned int mbmaxlen; /* max. length for multibyte strings */ -} MY_CHARSET_INFO; - -struct st_mysql_methods; - -typedef struct st_mysql -{ - NET net; /* Communication parameters */ - gptr connector_fd; /* ConnectorFd for SSL */ - char *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info; - char *db; - struct charset_info_st *charset; - MYSQL_FIELD *fields; - MEM_ROOT field_alloc; - my_ulonglong affected_rows; - my_ulonglong insert_id; /* id if insert on table with NEXTNR */ - my_ulonglong extra_info; /* Not used */ - unsigned long thread_id; /* Id for connection in server */ - unsigned long packet_length; - unsigned int port; - unsigned long client_flag,server_capabilities; - unsigned int protocol_version; - unsigned int field_count; - unsigned int server_status; - unsigned int server_language; - unsigned int warning_count; - struct st_mysql_options options; - enum mysql_status status; - my_bool free_me; /* If free in mysql_close */ - my_bool reconnect; /* set to 1 if automatic reconnect */ - - /* session-wide random string */ - char scramble[SCRAMBLE_LENGTH+1]; - - /* - Set if this is the original connection, not a master or a slave we have - added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() - */ - my_bool rpl_pivot; - /* - Pointers to the master, and the next slave connections, points to - itself if lone connection. - */ - struct st_mysql* master, *next_slave; - - struct st_mysql* last_used_slave; /* needed for round-robin slave pick */ - /* needed for send/read/store/use result to work correctly with replication */ - struct st_mysql* last_used_con; - - LIST *stmts; /* list of all statements */ - const struct st_mysql_methods *methods; - void *thd; - /* - Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag - from mysql_stmt_close if close had to cancel result set of this object. - */ - my_bool *unbuffered_fetch_owner; -#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100 - /* needed for embedded server - no net buffer to store the 'info' */ - char *info_buffer; -#endif -} MYSQL; - -typedef struct st_mysql_res { - my_ulonglong row_count; - MYSQL_FIELD *fields; - MYSQL_DATA *data; - MYSQL_ROWS *data_cursor; - unsigned long *lengths; /* column lengths of current row */ - MYSQL *handle; /* for unbuffered reads */ - MEM_ROOT field_alloc; - unsigned int field_count, current_field; - MYSQL_ROW row; /* If unbuffered read */ - MYSQL_ROW current_row; /* buffer to current row */ - my_bool eof; /* Used by mysql_fetch_row */ - /* mysql_stmt_close() had to cancel this result */ - my_bool unbuffered_fetch_cancelled; - const struct st_mysql_methods *methods; -} MYSQL_RES; - -#define MAX_MYSQL_MANAGER_ERR 256 -#define MAX_MYSQL_MANAGER_MSG 256 - -#define MANAGER_OK 200 -#define MANAGER_INFO 250 -#define MANAGER_ACCESS 401 -#define MANAGER_CLIENT_ERR 450 -#define MANAGER_INTERNAL_ERR 500 - -#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT) -#define MYSQL_CLIENT -#endif - - -typedef struct st_mysql_manager -{ - NET net; - char *host,*user,*passwd; - unsigned int port; - my_bool free_me; - my_bool eof; - int cmd_status; - int last_errno; - char* net_buf,*net_buf_pos,*net_data_end; - int net_buf_size; - char last_error[MAX_MYSQL_MANAGER_ERR]; -} MYSQL_MANAGER; - -typedef struct st_mysql_parameters -{ - unsigned long *p_max_allowed_packet; - unsigned long *p_net_buffer_length; -} MYSQL_PARAMETERS; - -#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) -#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet) -#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) -#endif - -/* - Set up and bring down the server; to ensure that applications will - work when linked against either the standard client library or the - embedded server library, these functions should be called. -*/ -int STDCALL mysql_server_init(int argc, char **argv, char **groups); -void STDCALL mysql_server_end(void); -/* - mysql_server_init/end need to be called when using libmysqld or - libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so - you don't need to call it explicitely; but you need to call - mysql_server_end() to free memory). The names are a bit misleading - (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general - names which suit well whether you're using libmysqld or libmysqlclient. We - intend to promote these aliases over the mysql_server* ones. -*/ -#define mysql_library_init mysql_server_init -#define mysql_library_end mysql_server_end - -MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void); - -/* - Set up and bring down a thread; these function should be called - for each thread in an application which opens at least one MySQL - connection. All uses of the connection(s) should be between these - function calls. -*/ -my_bool STDCALL mysql_thread_init(void); -void STDCALL mysql_thread_end(void); - -/* - Functions to get information from the MYSQL and MYSQL_RES structures - Should definitely be used if one uses shared libraries. -*/ - -my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); -unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); -my_bool STDCALL mysql_eof(MYSQL_RES *res); -MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, - unsigned int fieldnr); -MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res); -MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res); -MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res); - -unsigned int STDCALL mysql_field_count(MYSQL *mysql); -my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); -my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); -unsigned int STDCALL mysql_errno(MYSQL *mysql); -const char * STDCALL mysql_error(MYSQL *mysql); -const char *STDCALL mysql_sqlstate(MYSQL *mysql); -unsigned int STDCALL mysql_warning_count(MYSQL *mysql); -const char * STDCALL mysql_info(MYSQL *mysql); -unsigned long STDCALL mysql_thread_id(MYSQL *mysql); -const char * STDCALL mysql_character_set_name(MYSQL *mysql); -int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname); - -MYSQL * STDCALL mysql_init(MYSQL *mysql); -my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, - const char *cert, const char *ca, - const char *capath, const char *cipher); -my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, - const char *passwd, const char *db); -MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, - const char *user, - const char *passwd, - const char *db, - unsigned int port, - const char *unix_socket, - unsigned long clientflag); -int STDCALL mysql_select_db(MYSQL *mysql, const char *db); -int STDCALL mysql_query(MYSQL *mysql, const char *q); -int STDCALL mysql_send_query(MYSQL *mysql, const char *q, - unsigned long length); -int STDCALL mysql_real_query(MYSQL *mysql, const char *q, - unsigned long length); -MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); -MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); - -/* perform query on master */ -my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q, - unsigned long length); -my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, - unsigned long length); -/* perform query on slave */ -my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q, - unsigned long length); -my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, - unsigned long length); -void STDCALL mysql_get_character_set_info(MYSQL *mysql, - MY_CHARSET_INFO *charset); - -/* local infile support */ - -#define LOCAL_INFILE_ERROR_LEN 512 - -void -mysql_set_local_infile_handler(MYSQL *mysql, - int (*local_infile_init)(void **, const char *, - void *), - int (*local_infile_read)(void *, char *, - unsigned int), - void (*local_infile_end)(void *), - int (*local_infile_error)(void *, char*, - unsigned int), - void *); - -void -mysql_set_local_infile_default(MYSQL *mysql); - - -/* - enable/disable parsing of all queries to decide if they go on master or - slave -*/ -void STDCALL mysql_enable_rpl_parse(MYSQL* mysql); -void STDCALL mysql_disable_rpl_parse(MYSQL* mysql); -/* get the value of the parse flag */ -int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql); - -/* enable/disable reads from master */ -void STDCALL mysql_enable_reads_from_master(MYSQL* mysql); -void STDCALL mysql_disable_reads_from_master(MYSQL* mysql); -/* get the value of the master read flag */ -my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql); - -enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len); - -/* discover the master and its slaves */ -my_bool STDCALL mysql_rpl_probe(MYSQL* mysql); - -/* set the master, close/free the old one, if it is not a pivot */ -int STDCALL mysql_set_master(MYSQL* mysql, const char* host, - unsigned int port, - const char* user, - const char* passwd); -int STDCALL mysql_add_slave(MYSQL* mysql, const char* host, - unsigned int port, - const char* user, - const char* passwd); - -int STDCALL mysql_shutdown(MYSQL *mysql, - enum mysql_enum_shutdown_level - shutdown_level); -int STDCALL mysql_dump_debug_info(MYSQL *mysql); -int STDCALL mysql_refresh(MYSQL *mysql, - unsigned int refresh_options); -int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); -int STDCALL mysql_set_server_option(MYSQL *mysql, - enum enum_mysql_set_option - option); -int STDCALL mysql_ping(MYSQL *mysql); -const char * STDCALL mysql_stat(MYSQL *mysql); -const char * STDCALL mysql_get_server_info(MYSQL *mysql); -const char * STDCALL mysql_get_client_info(void); -unsigned long STDCALL mysql_get_client_version(void); -const char * STDCALL mysql_get_host_info(MYSQL *mysql); -unsigned long STDCALL mysql_get_server_version(MYSQL *mysql); -unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); -MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); -MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); -MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); -int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, - const char *arg); -void STDCALL mysql_free_result(MYSQL_RES *result); -void STDCALL mysql_data_seek(MYSQL_RES *result, - my_ulonglong offset); -MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, - MYSQL_ROW_OFFSET offset); -MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, - MYSQL_FIELD_OFFSET offset); -MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); -unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); -MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); -MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, - const char *wild); -unsigned long STDCALL mysql_escape_string(char *to,const char *from, - unsigned long from_length); -unsigned long STDCALL mysql_hex_string(char *to,const char *from, - unsigned long from_length); -unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, - char *to,const char *from, - unsigned long length); -void STDCALL mysql_debug(const char *debug); -char * STDCALL mysql_odbc_escape_string(MYSQL *mysql, - char *to, - unsigned long to_length, - const char *from, - unsigned long from_length, - void *param, - char * - (*extend_buffer) - (void *, char *to, - unsigned long *length)); -void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name); -unsigned int STDCALL mysql_thread_safe(void); -my_bool STDCALL mysql_embedded(void); -MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con); -MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con, - const char* host, - const char* user, - const char* passwd, - unsigned int port); -void STDCALL mysql_manager_close(MYSQL_MANAGER* con); -int STDCALL mysql_manager_command(MYSQL_MANAGER* con, - const char* cmd, int cmd_len); -int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, - char* res_buf, - int res_buf_size); -my_bool STDCALL mysql_read_query_result(MYSQL *mysql); - - -/* - The following definitions are added for the enhanced - client-server protocol -*/ - -/* statement state */ -enum enum_mysql_stmt_state -{ - MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE, - MYSQL_STMT_FETCH_DONE -}; - - -/* - This structure is used to define bind information, and - internally by the client library. - Public members with their descriptions are listed below - (conventionally `On input' refers to the binds given to - mysql_stmt_bind_param, `On output' refers to the binds given - to mysql_stmt_bind_result): - - buffer_type - One of the MYSQL_* types, used to describe - the host language type of buffer. - On output: if column type is different from - buffer_type, column value is automatically converted - to buffer_type before it is stored in the buffer. - buffer - On input: points to the buffer with input data. - On output: points to the buffer capable to store - output data. - The type of memory pointed by buffer must correspond - to buffer_type. See the correspondence table in - the comment to mysql_stmt_bind_param. - - The two above members are mandatory for any kind of bind. - - buffer_length - the length of the buffer. You don't have to set - it for any fixed length buffer: float, double, - int, etc. It must be set however for variable-length - types, such as BLOBs or STRINGs. - - length - On input: in case when lengths of input values - are different for each execute, you can set this to - point at a variable containining value length. This - way the value length can be different in each execute. - If length is not NULL, buffer_length is not used. - Note, length can even point at buffer_length if - you keep bind structures around while fetching: - this way you can change buffer_length before - each execution, everything will work ok. - On output: if length is set, mysql_stmt_fetch will - write column length into it. - - is_null - On input: points to a boolean variable that should - be set to TRUE for NULL values. - This member is useful only if your data may be - NULL in some but not all cases. - If your data is never NULL, is_null should be set to 0. - If your data is always NULL, set buffer_type - to MYSQL_TYPE_NULL, and is_null will not be used. - - is_unsigned - On input: used to signify that values provided for one - of numeric types are unsigned. - On output describes signedness of the output buffer. - If, taking into account is_unsigned flag, column data - is out of range of the output buffer, data for this column - is regarded truncated. Note that this has no correspondence - to the sign of result set column, if you need to find it out - use mysql_stmt_result_metadata. - error - where to write a truncation error if it is present. - possible error value is: - 0 no truncation - 1 value is out of range or buffer is too small - - Please note that MYSQL_BIND also has internals members. -*/ - -typedef struct st_mysql_bind -{ - unsigned long *length; /* output length pointer */ - my_bool *is_null; /* Pointer to null indicator */ - void *buffer; /* buffer to get/put data */ - /* set this if you want to track data truncations happened during fetch */ - my_bool *error; - enum enum_field_types buffer_type; /* buffer type */ - /* output buffer length, must be set when fetching str/binary */ - unsigned long buffer_length; - unsigned char *row_ptr; /* for the current data position */ - unsigned long offset; /* offset position for char/binary fetch */ - unsigned long length_value; /* Used if length is 0 */ - unsigned int param_number; /* For null count and error messages */ - unsigned int pack_length; /* Internal length for packed data */ - my_bool error_value; /* used if error is 0 */ - my_bool is_unsigned; /* set if integer type is unsigned */ - my_bool long_data_used; /* If used with mysql_send_long_data */ - my_bool is_null_value; /* Used if is_null is 0 */ - void (*store_param_func)(NET *net, struct st_mysql_bind *param); - void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *, - unsigned char **row); - void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, - unsigned char **row); -} MYSQL_BIND; - - -/* statement handler */ -typedef struct st_mysql_stmt -{ - MEM_ROOT mem_root; /* root allocations */ - LIST list; /* list to keep track of all stmts */ - MYSQL *mysql; /* connection handle */ - MYSQL_BIND *params; /* input parameters */ - MYSQL_BIND *bind; /* output parameters */ - MYSQL_FIELD *fields; /* result set metadata */ - MYSQL_DATA result; /* cached result set */ - MYSQL_ROWS *data_cursor; /* current row in cached result */ - /* copy of mysql->affected_rows after statement execution */ - my_ulonglong affected_rows; - my_ulonglong insert_id; /* copy of mysql->insert_id */ - /* - mysql_stmt_fetch() calls this function to fetch one row (it's different - for buffered, unbuffered and cursor fetch). - */ - int (*read_row_func)(struct st_mysql_stmt *stmt, - unsigned char **row); - unsigned long stmt_id; /* Id for prepared statement */ - unsigned long flags; /* i.e. type of cursor to open */ - unsigned long prefetch_rows; /* number of rows per one COM_FETCH */ - /* - Copied from mysql->server_status after execute/fetch to know - server-side cursor status for this statement. - */ - unsigned int server_status; - unsigned int last_errno; /* error code */ - unsigned int param_count; /* input parameter count */ - unsigned int field_count; /* number of columns in result set */ - enum enum_mysql_stmt_state state; /* statement state */ - char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ - char sqlstate[SQLSTATE_LENGTH+1]; - /* Types of input parameters should be sent to server */ - my_bool send_types_to_server; - my_bool bind_param_done; /* input buffers were supplied */ - unsigned char bind_result_done; /* output buffers were supplied */ - /* mysql_stmt_close() had to cancel this result */ - my_bool unbuffered_fetch_cancelled; - /* - Is set to true if we need to calculate field->max_length for - metadata fields when doing mysql_stmt_store_result. - */ - my_bool update_max_length; -} MYSQL_STMT; - -enum enum_stmt_attr_type -{ - /* - When doing mysql_stmt_store_result calculate max_length attribute - of statement metadata. This is to be consistent with the old API, - where this was done automatically. - In the new API we do that only by request because it slows down - mysql_stmt_store_result sufficiently. - */ - STMT_ATTR_UPDATE_MAX_LENGTH, - /* - unsigned long with combination of cursor flags (read only, for update, - etc) - */ - STMT_ATTR_CURSOR_TYPE, - /* - Amount of rows to retrieve from server per one fetch if using cursors. - Accepts unsigned long attribute in the range 1 - ulong_max - */ - STMT_ATTR_PREFETCH_ROWS -}; - - -typedef struct st_mysql_methods -{ - my_bool (*read_query_result)(MYSQL *mysql); - my_bool (*advanced_command)(MYSQL *mysql, - enum enum_server_command command, - const char *header, - unsigned long header_length, - const char *arg, - unsigned long arg_length, - my_bool skip_check); - MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields); - MYSQL_RES * (*use_result)(MYSQL *mysql); - void (*fetch_lengths)(unsigned long *to, - MYSQL_ROW column, unsigned int field_count); - void (*flush_use_result)(MYSQL *mysql); -#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (*list_fields)(MYSQL *mysql); - my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (*stmt_execute)(MYSQL_STMT *stmt); - int (*read_binary_rows)(MYSQL_STMT *stmt); - int (*unbuffered_fetch)(MYSQL *mysql, char **row); - void (*free_embedded_thd)(MYSQL *mysql); - const char *(*read_statistics)(MYSQL *mysql); - my_bool (*next_result)(MYSQL *mysql); - int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd); - int (*read_rows_from_cursor)(MYSQL_STMT *stmt); -#endif -} MYSQL_METHODS; - - -MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql); -int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, - unsigned long length); -int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt); -int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt); -int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, - unsigned int column, - unsigned long offset); -int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); -unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt); -my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, - enum enum_stmt_attr_type attr_type, - const void *attr); -my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, - enum enum_stmt_attr_type attr_type, - void *attr); -my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt); -my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt); -my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt); -my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, - unsigned int param_number, - const char *data, - unsigned long length); -MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt); -MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt); -unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt); -const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt); -const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt); -MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, - MYSQL_ROW_OFFSET offset); -MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); -void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset); -my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt); -my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); -my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt); -unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt); - -my_bool STDCALL mysql_commit(MYSQL * mysql); -my_bool STDCALL mysql_rollback(MYSQL * mysql); -my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode); -my_bool STDCALL mysql_more_results(MYSQL *mysql); -int STDCALL mysql_next_result(MYSQL *mysql); -void STDCALL mysql_close(MYSQL *sock); - - -/* status return codes */ -#define MYSQL_NO_DATA 100 -#define MYSQL_DATA_TRUNCATED 101 - -#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) - -#ifdef USE_OLD_FUNCTIONS -MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, - const char *user, const char *passwd); -int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); -int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); -#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) -#endif -#define HAVE_MYSQL_REAL_CONNECT - -/* - The following functions are mainly exported because of mysqlbinlog; - They are not for general usage -*/ - -#define simple_command(mysql, command, arg, length, skip_check) \ - (*(mysql)->methods->advanced_command)(mysql, command, \ - NullS, 0, arg, length, skip_check) -unsigned long net_safe_read(MYSQL* mysql); - -#ifdef __NETWARE__ -#pragma pack(pop) /* restore alignment */ -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _mysql_h */ diff --git a/src/mysql/mysql_com.h b/src/mysql/mysql_com.h deleted file mode 100644 index ec1c13379..000000000 --- a/src/mysql/mysql_com.h +++ /dev/null @@ -1,452 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* -** Common definition between mysql server & client -*/ - -#ifndef _mysql_com_h -#define _mysql_com_h - -#define NAME_LEN 64 /* Field/table name length */ -#define HOSTNAME_LENGTH 60 -#define USERNAME_LENGTH 16 -#define SERVER_VERSION_LENGTH 60 -#define SQLSTATE_LENGTH 5 - -/* - USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain - username and hostname parts of the user identifier with trailing zero in - MySQL standard format: - user_name_part@host_name_part\0 -*/ -#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2 - -#define LOCAL_HOST "localhost" -#define LOCAL_HOST_NAMEDPIPE "." - - -#if defined(__WIN__) && !defined( _CUSTOMCONFIG_) -#define MYSQL_NAMEDPIPE "MySQL" -#define MYSQL_SERVICENAME "MySQL" -#endif /* __WIN__ */ - -/* - You should add new commands to the end of this list, otherwise old - servers won't be able to handle them as 'unsupported'. -*/ - -enum enum_server_command -{ - COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, - COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, - COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, - COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, - COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE, - COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, - COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, - /* don't forget to update const char *command_name[] in sql_parse.cc */ - - /* Must be last */ - COM_END -}; - - -/* - Length of random string sent by server on handshake; this is also length of - obfuscated password, recieved from client -*/ -#define SCRAMBLE_LENGTH 20 -#define SCRAMBLE_LENGTH_323 8 -/* length of password stored in the db: new passwords are preceeded with '*' */ -#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) -#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2) - - -#define NOT_NULL_FLAG 1 /* Field can't be NULL */ -#define PRI_KEY_FLAG 2 /* Field is part of a primary key */ -#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ -#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ -#define BLOB_FLAG 16 /* Field is a blob */ -#define UNSIGNED_FLAG 32 /* Field is unsigned */ -#define ZEROFILL_FLAG 64 /* Field is zerofill */ -#define BINARY_FLAG 128 /* Field is binary */ - -/* The following are only sent to new clients */ -#define ENUM_FLAG 256 /* field is an enum */ -#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ -#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ -#define SET_FLAG 2048 /* field is a set */ -#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ -#define NUM_FLAG 32768 /* Field is num (for clients) */ -#define PART_KEY_FLAG 16384 /* Intern; Part of some key */ -#define GROUP_FLAG 32768 /* Intern: Group field */ -#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ -#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */ - -#define REFRESH_GRANT 1 /* Refresh grant tables */ -#define REFRESH_LOG 2 /* Start on new log file */ -#define REFRESH_TABLES 4 /* close all tables */ -#define REFRESH_HOSTS 8 /* Flush host cache */ -#define REFRESH_STATUS 16 /* Flush status variables */ -#define REFRESH_THREADS 32 /* Flush thread cache */ -#define REFRESH_SLAVE 64 /* Reset master info and restart slave - thread */ -#define REFRESH_MASTER 128 /* Remove all bin logs in the index - and truncate the index */ - -/* The following can't be set with mysql_refresh() */ -#define REFRESH_READ_LOCK 16384 /* Lock tables for read */ -#define REFRESH_FAST 32768 /* Intern flag */ - -/* RESET (remove all queries) from query cache */ -#define REFRESH_QUERY_CACHE 65536 -#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ -#define REFRESH_DES_KEY_FILE 0x40000L -#define REFRESH_USER_RESOURCES 0x80000L - -#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ -#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ -#define CLIENT_LONG_FLAG 4 /* Get all column flags */ -#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ -#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ -#define CLIENT_COMPRESS 32 /* Can use compression protocol */ -#define CLIENT_ODBC 64 /* Odbc client */ -#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ -#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ -#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */ -#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ -#define CLIENT_SSL 2048 /* Switch to SSL after handshake */ -#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ -#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ -#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ -#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ -#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ -#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ -#define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31) - -#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ -#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ -#define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */ -#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ -#define SERVER_QUERY_NO_GOOD_INDEX_USED 16 -#define SERVER_QUERY_NO_INDEX_USED 32 -/* - The server was able to fulfill the clients request and opened a - read-only non-scrollable cursor for a query. This flag comes - in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. -*/ -#define SERVER_STATUS_CURSOR_EXISTS 64 -/* - This flag is sent when a read-only cursor is exhausted, in reply to - COM_STMT_FETCH command. -*/ -#define SERVER_STATUS_LAST_ROW_SENT 128 -#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ -#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 - -#define MYSQL_ERRMSG_SIZE 512 -#define NET_READ_TIMEOUT 30 /* Timeout on read */ -#define NET_WRITE_TIMEOUT 60 /* Timeout on write */ -#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */ - -#define ONLY_KILL_QUERY 1 - -struct st_vio; /* Only C */ -typedef struct st_vio Vio; - -#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */ -#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */ -#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */ -#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */ -#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */ -#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ -#define MAX_BLOB_WIDTH 8192 /* Default width for blob */ - -typedef struct st_net { -#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) - Vio* vio; - unsigned char *buff,*buff_end,*write_pos,*read_pos; - my_socket fd; /* For Perl DBI/dbd */ - unsigned long max_packet,max_packet_size; - unsigned int pkt_nr,compress_pkt_nr; - unsigned int write_timeout, read_timeout, retry_count; - int fcntl; - my_bool compress; - /* - The following variable is set if we are doing several queries in one - command ( as in LOAD TABLE ... FROM MASTER ), - and do not want to confuse the client with OK at the wrong time - */ - unsigned long remain_in_buf,length, buf_length, where_b; - unsigned int *return_status; - unsigned char reading_or_writing; - char save_char; - my_bool no_send_ok; /* For SPs and other things that do multiple stmts */ - my_bool no_send_eof; /* For SPs' first version read-only cursors */ - /* - Set if OK packet is already sent, and we do not need to send error - messages - */ - my_bool no_send_error; - /* - Pointer to query object in query cache, do not equal NULL (0) for - queries in cache that have not stored its results yet - */ -#endif - char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1]; - unsigned int last_errno; - unsigned char error; - gptr query_cache_query; - my_bool report_error; /* We should report error (we have unreported error) */ - my_bool return_errno; -} NET; - -#define packet_error (~(unsigned long) 0) - -enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, - MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, - MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, - MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, - MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, - MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, - MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, - MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, - MYSQL_TYPE_BIT, - MYSQL_TYPE_NEWDECIMAL=246, - MYSQL_TYPE_ENUM=247, - MYSQL_TYPE_SET=248, - MYSQL_TYPE_TINY_BLOB=249, - MYSQL_TYPE_MEDIUM_BLOB=250, - MYSQL_TYPE_LONG_BLOB=251, - MYSQL_TYPE_BLOB=252, - MYSQL_TYPE_VAR_STRING=253, - MYSQL_TYPE_STRING=254, - MYSQL_TYPE_GEOMETRY=255 - -}; - -/* For backward compatibility */ -#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS -#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL -#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL -#define FIELD_TYPE_TINY MYSQL_TYPE_TINY -#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT -#define FIELD_TYPE_LONG MYSQL_TYPE_LONG -#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT -#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE -#define FIELD_TYPE_NULL MYSQL_TYPE_NULL -#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP -#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG -#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 -#define FIELD_TYPE_DATE MYSQL_TYPE_DATE -#define FIELD_TYPE_TIME MYSQL_TYPE_TIME -#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME -#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR -#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE -#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM -#define FIELD_TYPE_SET MYSQL_TYPE_SET -#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB -#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB -#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB -#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB -#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING -#define FIELD_TYPE_STRING MYSQL_TYPE_STRING -#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY -#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM -#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY -#define FIELD_TYPE_BIT MYSQL_TYPE_BIT - - -/* Shutdown/kill enums and constants */ - -/* Bits for THD::killable. */ -#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) -#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) -#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) -#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) - -enum mysql_enum_shutdown_level { - /* - We want levels to be in growing order of hardness (because we use number - comparisons). Note that DEFAULT does not respect the growing property, but - it's ok. - */ - SHUTDOWN_DEFAULT = 0, - /* wait for existing connections to finish */ - SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT, - /* wait for existing trans to finish */ - SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS, - /* wait for existing updates to finish (=> no partial MyISAM update) */ - SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE, - /* flush InnoDB buffers and other storage engines' buffers*/ - SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), - /* don't flush InnoDB buffers, flush other storage engines' buffers*/ - SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, - /* Now the 2 levels of the KILL command */ -#if MYSQL_VERSION_ID >= 50000 - KILL_QUERY= 254, -#endif - KILL_CONNECTION= 255 -}; - - -enum enum_cursor_type -{ - CURSOR_TYPE_NO_CURSOR= 0, - CURSOR_TYPE_READ_ONLY= 1, - CURSOR_TYPE_FOR_UPDATE= 2, - CURSOR_TYPE_SCROLLABLE= 4 -}; - - -/* options for mysql_set_option */ -enum enum_mysql_set_option -{ - MYSQL_OPTION_MULTI_STATEMENTS_ON, - MYSQL_OPTION_MULTI_STATEMENTS_OFF -}; - -#define net_new_transaction(net) ((net)->pkt_nr=0) - -#ifdef __cplusplus -extern "C" { -#endif - -my_bool my_net_init(NET *net, Vio* vio); -void my_net_local_init(NET *net); -void net_end(NET *net); -void net_clear(NET *net); -my_bool net_realloc(NET *net, unsigned long length); -my_bool net_flush(NET *net); -my_bool my_net_write(NET *net,const char *packet,unsigned long len); -my_bool net_write_command(NET *net,unsigned char command, - const char *header, unsigned long head_len, - const char *packet, unsigned long len); -int net_real_write(NET *net,const char *packet,unsigned long len); -unsigned long my_net_read(NET *net); - -/* - The following function is not meant for normal usage - Currently it's used internally by manager.c -*/ -struct sockaddr; -int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, - unsigned int timeout); - -struct rand_struct { - unsigned long seed1,seed2,max_value; - double max_value_dbl; -}; - -#ifdef __cplusplus -} -#endif - - /* The following is for user defined functions */ - -enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, - DECIMAL_RESULT}; - -typedef struct st_udf_args -{ - unsigned int arg_count; /* Number of arguments */ - enum Item_result *arg_type; /* Pointer to item_results */ - char **args; /* Pointer to argument */ - unsigned long *lengths; /* Length of string arguments */ - char *maybe_null; /* Set to 1 for all maybe_null args */ - char **attributes; /* Pointer to attribute name */ - unsigned long *attribute_lengths; /* Length of attribute arguments */ -} UDF_ARGS; - - /* This holds information about the result */ - -typedef struct st_udf_init -{ - my_bool maybe_null; /* 1 if function can return NULL */ - unsigned int decimals; /* for real functions */ - unsigned long max_length; /* For string functions */ - char *ptr; /* free pointer for function data */ - my_bool const_item; /* 0 if result is independent of arguments */ -} UDF_INIT; - - /* Constants when using compression */ -#define NET_HEADER_SIZE 4 /* standard header size */ -#define COMP_HEADER_SIZE 3 /* compression header extra size */ - - /* Prototypes to password functions */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - These functions are used for authentication by client and server and - implemented in sql/password.c -*/ - -void randominit(struct rand_struct *, unsigned long seed1, - unsigned long seed2); -double my_rnd(struct rand_struct *); -void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st); - -void hash_password(unsigned long *to, const char *password, unsigned int password_len); -void make_scrambled_password_323(char *to, const char *password); -void scramble_323(char *to, const char *message, const char *password); -my_bool check_scramble_323(const char *, const char *message, - unsigned long *salt); -void get_salt_from_password_323(unsigned long *res, const char *password); -void make_password_from_salt_323(char *to, const unsigned long *salt); - -void make_scrambled_password(char *to, const char *password); -void scramble(char *to, const char *message, const char *password); -my_bool check_scramble(const char *reply, const char *message, - const unsigned char *hash_stage2); -void get_salt_from_password(unsigned char *res, const char *password); -void make_password_from_salt(char *to, const unsigned char *hash_stage2); -char *octet2hex(char *to, const char *str, unsigned int len); - -/* end of password.c */ - -char *get_tty_password(char *opt_message); -const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); - -/* Some other useful functions */ - -my_bool my_init(void); -extern int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option); -int load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv); -my_bool my_thread_init(void); -void my_thread_end(void); - -#ifdef _global_h -ulong STDCALL net_field_length(uchar **packet); -my_ulonglong net_field_length_ll(uchar **packet); -char *net_store_length(char *pkg, ulonglong length); -#endif - -#ifdef __cplusplus -} -#endif - -#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ -#define MYSQL_STMT_HEADER 4 -#define MYSQL_LONG_DATA_HEADER 6 - -#endif diff --git a/src/mysql/mysql_time.h b/src/mysql/mysql_time.h deleted file mode 100644 index 5f4fc12c0..000000000 --- a/src/mysql/mysql_time.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _mysql_time_h_ -#define _mysql_time_h_ - -/* - Time declarations shared between the server and client API: - you should not add anything to this header unless it's used - (and hence should be visible) in mysql.h. - If you're looking for a place to add new time-related declaration, - it's most likely my_time.h. See also "C API Handling of Date - and Time Values" chapter in documentation. -*/ - -enum enum_mysql_timestamp_type -{ - MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, - MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 -}; - - -/* - Structure which is used to represent datetime values inside MySQL. - - We assume that values in this structure are normalized, i.e. year <= 9999, - month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions - in server such as my_system_gmt_sec() or make_time() family of functions - rely on this (actually now usage of make_*() family relies on a bit weaker - restriction). Also functions that produce MYSQL_TIME as result ensure this. - There is one exception to this rule though if this structure holds time - value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold - bigger values. -*/ -typedef struct st_mysql_time -{ - unsigned int year, month, day, hour, minute, second; - unsigned long second_part; - my_bool neg; - enum enum_mysql_timestamp_type time_type; -} MYSQL_TIME; - -#endif /* _mysql_time_h_ */ diff --git a/src/mysql/mysql_version.h b/src/mysql/mysql_version.h deleted file mode 100644 index 473a19987..000000000 --- a/src/mysql/mysql_version.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright Abandoned 1996, 1999, 2001 MySQL AB - This file is public domain and comes with NO WARRANTY of any kind */ - -/* Version numbers for protocol & mysqld */ - -#ifndef _mysql_version_h -#define _mysql_version_h -#ifdef _CUSTOMCONFIG_ -#include -#else -#define PROTOCOL_VERSION 10 -#define MYSQL_SERVER_VERSION "5.0.20" -#define MYSQL_BASE_VERSION "mysqld-5.0" -#define MYSQL_SERVER_SUFFIX_DEF "-community-max-nt" -#define FRM_VER 6 -#define MYSQL_VERSION_ID 50020 -#define MYSQL_PORT 3306 -#define MYSQL_UNIX_ADDR "/tmp/mysql.sock" -#define MYSQL_CONFIG_NAME "my" -#define MYSQL_COMPILATION_COMMENT "MySQL Community Edition - Max (GPL)" - -/* mysqld compile time options */ -#endif /* _CUSTOMCONFIG_ */ - -#ifndef LICENSE -#define LICENSE GPL -#endif /* LICENSE */ - -#endif /* _mysql_version_h */ diff --git a/src/mysql/raid.h b/src/mysql/raid.h deleted file mode 100644 index c840afcba..000000000 --- a/src/mysql/raid.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Parser needs these defines always, even if USE_RAID is not defined */ -#define RAID_TYPE_0 1 /* Striping */ -#define RAID_TYPE_x 2 /* Some new modes */ -#define RAID_TYPE_y 3 - -#define RAID_DEFAULT_CHUNKS 4 -#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */ - -C_MODE_START -#define my_raid_type(raid_type) raid_type_string[(int)(raid_type)] -extern const char *raid_type_string[]; -C_MODE_END - -#ifdef DONT_USE_RAID -#undef USE_RAID -#endif -#if defined(USE_RAID) - -#include "my_dir.h" - -/* Trap all occurences of my_...() in source and use our wrapper around this function */ - -#ifdef MAP_TO_USE_RAID -#define my_read(A,B,C,D) my_raid_read(A,B,C,D) -#define my_write(A,B,C,D) my_raid_write(A,B,C,D) -#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E) -#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E) -#define my_chsize(A,B,C,D) my_raid_chsize(A,B,C,D) -#define my_close(A,B) my_raid_close(A,B) -#define my_tell(A,B) my_raid_tell(A,B) -#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D) -#define my_lock(A,B,C,D,E) my_raid_lock(A,B,C,D,E) -#define my_fstat(A,B,C) my_raid_fstat(A,B,C) -#endif /* MAP_TO_USE_RAID */ - -#ifdef __cplusplus -extern "C" { -#endif - - void init_raid(void); - void end_raid(void); - - bool is_raid(File fd); - File my_raid_create(const char *FileName, int CreateFlags, int access_flags, - uint raid_type, uint raid_chunks, ulong raid_chunksize, - myf MyFlags); - File my_raid_open(const char *FileName, int Flags, - uint raid_type, uint raid_chunks, ulong raid_chunksize, - myf MyFlags); - int my_raid_rename(const char *from, const char *to, uint raid_chunks, - myf MyFlags); - int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags); - int my_raid_redel(const char *old_name, const char *new_name, - uint raid_chunks, myf MyFlags); - - my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags); - my_off_t my_raid_tell(File fd, myf MyFlags); - - uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags); - uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags); - - uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, - myf MyFlags); - uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count, - my_off_t offset, myf MyFlags); - - int my_raid_lock(File,int locktype, my_off_t start, my_off_t length, - myf MyFlags); - int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags); - int my_raid_close(File, myf MyFlags); - int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags); - -#ifdef __cplusplus -} - -#ifdef USE_PRAGMA_INTERFACE -#pragma interface /* gcc class implementation */ -#endif - -class RaidName { - public: - RaidName(const char *FileName); - ~RaidName(); - bool IsRaid(); - int Rename(const char * from, const char * to, myf MyFlags); - private: - uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ - uint _raid_chunks; /* 1..n */ - ulong _raid_chunksize; /* 1..n in bytes */ -}; - -class RaidFd { - public: - RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize); - ~RaidFd(); - File Create(const char *FileName, int CreateFlags, int access_flags, - myf MyFlags); - File Open(const char *FileName, int Flags, myf MyFlags); - my_off_t Seek(my_off_t pos,int whence,myf MyFlags); - my_off_t Tell(myf MyFlags); - int Write(const byte *Buffer, uint Count, myf MyFlags); - int Read(const byte *Buffer, uint Count, myf MyFlags); - int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags); - int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags); - int Fstat(int fd, MY_STAT *stat_area, myf MyFlags ); - int Close(myf MyFlags); - static bool IsRaid(File fd); - static DYNAMIC_ARRAY _raid_map; /* Map of RaidFD* */ - private: - - uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */ - uint _raid_chunks; /* 1..n */ - ulong _raid_chunksize; /* 1..n in bytes */ - - ulong _total_block; /* We are operating with block no x (can be 0..many). */ - uint _this_block; /* can be 0.._raid_chunks */ - uint _remaining_bytes; /* Maximum bytes that can be written in this block */ - - my_off_t _position; - my_off_t _size; /* Cached file size for faster seek(SEEK_END) */ - File _fd; - File *_fd_vector; /* Array of File */ - off_t *_seek_vector; /* Array of cached seek positions */ - - inline void Calculate() - { - DBUG_ENTER("RaidFd::_Calculate"); - DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu", - (ulong) _position, _raid_chunksize, (ulong) _size)); - - _total_block = (ulong) (_position / _raid_chunksize); - _this_block = _total_block % _raid_chunks; /* can be 0.._raid_chunks */ - _remaining_bytes = (uint) (_raid_chunksize - - (_position - _total_block * _raid_chunksize)); - DBUG_PRINT("info", - ("_total_block: %d this_block: %d _remaining_bytes:%d", - _total_block, _this_block, _remaining_bytes)); - DBUG_VOID_RETURN; - } -}; - -#endif /* __cplusplus */ -#endif /* USE_RAID */ diff --git a/src/mysql/typelib.h b/src/mysql/typelib.h deleted file mode 100644 index 4d6a90ad5..000000000 --- a/src/mysql/typelib.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - -#ifndef _typelib_h -#define _typelib_h - -typedef struct st_typelib { /* Different types saved here */ - unsigned int count; /* How many types */ - const char *name; /* Name of typelib */ - const char **type_names; - unsigned int *type_lengths; -} TYPELIB; - -extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name); -extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); -extern const char *get_type(TYPELIB *typelib,unsigned int nr); - -extern TYPELIB sql_protocol_typelib; - -#endif /* _typelib_h */ diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c index edd59d77b..78717287d 100644 --- a/src/txt-converter/login-converter.c +++ b/src/txt-converter/login-converter.c @@ -1,157 +1,50 @@ // (c) eAthena Dev Team - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define WITH_TXT +#define WITH_SQL + #include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/mmo.h" // struct mmo_account #include "../common/core.h" -#include "../common/db.h" #include "../common/showmsg.h" -#include "../common/sql.h" -#include "../common/malloc.h" - +#include "../login/account.h" #include -#include #include -char login_account_id[256]="account_id"; -char login_userid[256]="userid"; -char login_user_pass[256]="user_pass"; -char login_db[256]="login"; -char globalreg_db[256]="global_reg_value"; - -static DBMap* gm_account_db=NULL; // int account_id -> struct gm_account* +#define LOGIN_CONF_NAME "conf/login_athena.conf" -int db_server_port = 3306; -char db_server_ip[32] = "127.0.0.1"; -char db_server_id[32] = "ragnarok"; -char db_server_pw[32] = "ragnarok"; -char db_server_logindb[32] = "ragnarok"; +AccountDB* txtdb = NULL; +AccountDB* sqldb = NULL; -#define INTER_CONF_NAME "conf/inter_athena.conf" -#define GM_ACCOUNT_NAME "conf/GM_account.txt" -#define ACCOUNT_TXT_NAME "save/account.txt" //-------------------------------------------------------- -int isGM(int account_id) -{ - struct gm_account* p = (struct gm_account*)idb_get(gm_account_db,account_id); - return( p != NULL ) ? p->level : 0; -} - -int read_gm_account() -{ - char line[8192]; - struct gm_account *p; - FILE *fp; - int line_counter = 0, gm_counter = 0; - - ShowStatus("Starting reading gm_account\n"); - - if( (fp = fopen(GM_ACCOUNT_NAME,"r")) == NULL ) - return 1; - - gm_account_db = idb_alloc(DB_OPT_RELEASE_DATA); - - while(fgets(line,sizeof(line),fp)) - { - line_counter++; - if ((line[0] == '/' && line[1] == '/') || line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - - p = (struct gm_account*)aMalloc(sizeof(struct gm_account)); - if(p==NULL){ - ShowFatalError("gm_account: out of memory!\n"); - exit(EXIT_FAILURE); - } - - if(sscanf(line,"%d %d",&p->account_id,&p->level) != 2 || p->level <= 0) { - ShowWarning("gm_account: unsupported data format [conf/GM_account.txt] on line %d\n", line_counter); - continue; - } - else { - if(p->level > 99) - p->level = 99; - p = (struct gm_account*)idb_put(gm_account_db,p->account_id,p); - if( p ) - aFree(p);// old entry replaced - gm_counter++; - ShowInfo("GM ID: %d Level: %d\n",p->account_id,p->level); - } - } - - fclose(fp); - ShowStatus("%d ID of gm_accounts read.\n", gm_counter); - return 0; -} - int convert_login(void) { - Sql* mysql_handle; - SqlStmt* stmt; - int line_counter = 0; - FILE *fp; - int account_id, logincount, user_level, state, n, i; - char line[2048], userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048]; - int unban_time, expiration_time; - char dummy[2048]; + AccountDBIterator* iter; + struct mmo_account acc; - mysql_handle = Sql_Malloc(); - if ( SQL_ERROR == Sql_Connect(mysql_handle, db_server_id, db_server_pw, db_server_ip, db_server_port, db_server_logindb) ) + if( !txtdb->init(txtdb) || !sqldb->init(sqldb) ) { - Sql_ShowDebug(mysql_handle); - Sql_Free(mysql_handle); - exit(EXIT_FAILURE); - } - ShowStatus("Connect: Success!\n"); - - ShowStatus("Convert start...\n"); - fp = fopen(ACCOUNT_TXT_NAME,"r"); - if(fp == NULL) + ShowFatalError("Initialization failed, unable to start conversion.\n"); return 0; + } - while(fgets(line,sizeof(line),fp) != NULL) - { - line_counter++; - if(line[0]=='/' && line[1]=='/') - continue; - - i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t%[^\t]\t%[^\t]\t%d\t%[^\t]\t%[^\t]\t%d\t%[^\r\n]%n", - &account_id, userid, pass, lastlogin, &sex, &logincount, &state, - email, error_message, &expiration_time, last_ip, memo, &unban_time, dummy, &n); + ShowStatus("Conversion started...\n"); + //TODO: do some counting & statistics - if (i < 13) { - ShowWarning("Skipping incompatible data on line %d\n", line_counter); - continue; - } - - if (i > 13) - ShowWarning("Reading login account variables is not implemented, data will be lost! (line %d)\n", line_counter); - - user_level = isGM(account_id); - ShowInfo("Converting user (id: %d, name: %s, gm level: %d)\n", account_id, userid, user_level); - - stmt = SqlStmt_Malloc(mysql_handle); - if( SQL_ERROR == SqlStmt_Prepare(stmt, - "REPLACE INTO `login` " - "(`account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`, `error_message`, `expiration_time`, `last_ip`, `memo`, `unban_time`, `state`) " - "VALUES " - "(%d, ?, ?, '%s', '%c', %d, '%s', %d, '%s', %d, '%s', '%s', %d, %d)", - account_id, lastlogin, sex, logincount, email, user_level, error_message, expiration_time, last_ip, memo, unban_time, state) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_STRING, userid, strnlen(userid, 255)) - || SQL_ERROR == SqlStmt_BindParam(stmt, 1, SQLDT_STRING, pass, strnlen(pass, 32)) - || SQL_ERROR == SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - } - SqlStmt_Free(stmt); - - //TODO: parse the rest of the line to read the login-stored account variables, and import them to `global_reg_value` - // then remove the 'dummy' buffer + iter = txtdb->iterator(txtdb); + while( iter->next(iter, &acc) ) + { + ShowInfo("Converting user (id: %d, name: %s, gm level: %d)...", acc.account_id, acc.userid, acc.level); + if( sqldb->create(sqldb, &acc) ) + ShowMessage(CL_GREEN "success.\n"); + else + ShowMessage(CL_RED "failed!\n"); } - fclose(fp); - Sql_Free(mysql_handle); + iter->destroy(iter); - ShowStatus("Convert end...\n"); + ShowStatus("Conversion finished.\n"); return 0; } @@ -162,7 +55,7 @@ int login_config_read(const char* cfgName) char line[1024], w1[1024], w2[1024]; FILE *fp; - ShowStatus("Start reading interserver configuration: %s\n", cfgName); + ShowStatus("Start reading login server configuration: %s\n", cfgName); fp=fopen(cfgName,"r"); if(fp==NULL){ @@ -179,56 +72,40 @@ int login_config_read(const char* cfgName) if(i!=2) continue; - //add for DB connection - if(strcmpi(w1,"db_server_ip")==0){ - strcpy(db_server_ip, w2); - ShowStatus("set db_server_ip : %s\n",w2); - } - else if(strcmpi(w1,"db_server_port")==0){ - db_server_port=atoi(w2); - ShowStatus("set db_server_port : %s\n",w2); - } - else if(strcmpi(w1,"db_server_id")==0){ - strcpy(db_server_id, w2); - ShowStatus("set db_server_id : %s\n",w2); - } - else if(strcmpi(w1,"db_server_pw")==0){ - strcpy(db_server_pw, w2); - ShowStatus("set db_server_pw : %s\n",w2); - } - else if(strcmpi(w1,"db_server_logindb")==0){ - strcpy(db_server_logindb, w2); - ShowStatus("set db_server_logindb : %s\n",w2); - } + txtdb->set_property(txtdb, w1, w2); + sqldb->set_property(sqldb, w1, w2); + //support the import command, just like any other config - else if(strcmpi(w1,"import")==0){ + if( strcmpi(w1,"import") == 0 ) login_config_read(w2); - } } + fclose(fp); - ShowStatus("End reading interserver configuration...\n"); + ShowStatus("End reading login server configuration...\n"); return 0; } int do_init(int argc, char** argv) { int input; - login_config_read( (argc > 1) ? argv[1] : INTER_CONF_NAME ); - read_gm_account(); + + txtdb = account_db_txt(); + sqldb = account_db_sql(); + + login_config_read( (argc > 1) ? argv[1] : LOGIN_CONF_NAME ); ShowInfo("\nWarning : Make sure you backup your databases before continuing!\n"); ShowInfo("\nDo you wish to convert your Login Database to SQL? (y/n) : "); input = getchar(); + if(input == 'y' || input == 'Y') convert_login(); + return 0; } void do_final(void) { - if( gm_account_db ) - { - db_destroy(gm_account_db); - gm_account_db = NULL; - } + txtdb->destroy(txtdb); + sqldb->destroy(sqldb); } diff --git a/src/zlib/zconf.h b/src/zlib/zconf.h deleted file mode 100644 index 03a9431c8..000000000 --- a/src/zlib/zconf.h +++ /dev/null @@ -1,332 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define deflatePrime z_deflatePrime -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -# define zError z_zError - -# define alloc_func z_alloc_func -# define free_func z_free_func -# define in_func z_in_func -# define out_func z_out_func -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/src/zlib/zlib-1.2.3 b/src/zlib/zlib-1.2.3 deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/zlib/zlib.h b/src/zlib/zlib.h deleted file mode 100644 index 022817927..000000000 --- a/src/zlib/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/tools/cgi/addaccount.cgi b/tools/cgi/addaccount.cgi deleted file mode 100644 index 2134a78a3..000000000 --- a/tools/cgi/addaccount.cgi +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/perl - -#========================================================================= -# addaccount.cgi ver.1.00 -# ladmin‚ðƒ‰ƒbƒv‚µ‚½AƒAƒJƒEƒ“ƒg‚ð쬂·‚éCGIB -# ladmin ver.1.04‚ł̓®ì‚ðŠm”FB -# -# ** Ý’è•û–@ ** -# -# - ‰º‚Ì$ladmin•Ï”‚Éladmin‚ւ̃pƒX‚ðÝ’è‚·‚邱‚ÆB -# - UNIXŒnOS‚ÅŽg—p‚·‚éꇂÍladmin‚Æ‹¤‚ɉüsƒR[ƒh‚ð•ÏŠ·‚·‚邱‚ÆA‚Ü‚½ -# ƒtƒ@ƒCƒ‹æ“ªs‚ðperl‚̳‚µ‚¢ƒpƒX‚É‚·‚邱‚ÆB—á> $ which perl -# - ƒT[ƒo[ƒvƒƒOƒ‰ƒ€‚âƒuƒ‰ƒEƒU‚É‚æ‚Á‚Ä‚Í $cgiuri ‚É‚±‚̃tƒ@ƒCƒ‹‚Ö‚Ì -# Š®‘S‚ÈURI‚ðƒZƒbƒg‚µ‚È‚¯‚ê‚΂Ȃç‚È‚¢ê‡‚à‚ ‚éB -# - perl‚ɃpƒX‚ª’Ê‚Á‚Ä‚¢‚È‚¢ê‡‚Í $perl ‚ðperl‚ւ̳‚µ‚¢ƒpƒX‚É‚·‚邱‚ÆB -# - ‘¼‚Í•’Ê‚ÌCGI‚Æ“¯‚¶‚Å‚·BiŽÀsŒ ‚âcgi-binƒtƒHƒ‹ƒ_‚È‚Çj -# -# ** ‚»‚Ì‘¼ ** -# addaccount.cgi ‚ðƒuƒ‰ƒEƒU‚ÅŠJ‚­‚ƃTƒ“ƒvƒ‹HTMLi‚»‚̂܂܎g‚¦‚Ü‚·j‚ª -# ŠJ‚«‚Ü‚·B‚Ü‚½A‚±‚Ìcgi‚̓uƒ‰ƒEƒU‚©‚ç‘—‚ç‚ê‚éAccept-Language‚ª -# ja‚ÅŽn‚Ü‚Á‚Ä‚¢‚ê‚΃ƒbƒZ[ƒW‚̈ꕔ‚ð“ú–{Œê‚ɕϊ·‚µ‚Ü‚·B -# (IE‚È‚çƒCƒ“ƒ^[ƒlƒbƒgƒIƒvƒVƒ‡ƒ“‚ÌŒ¾ŒêÝ’è‚ňê”Ôã‚É“ú–{Œê‚ð’u‚­) -# ‚»‚êˆÈŠO‚Ìꇂ͉pŒê‚̂܂Üo—Í‚µ‚Ü‚·B -#------------------------------------------------------------------------- - -my($ladmin) = "../ladmin"; # ladmin‚̃pƒX(‚¨‚»‚ç‚­•ÏX‚ª•K—v) - -my($cgiuri) = "./addaccount.cgi"; # ‚±‚̃tƒ@ƒCƒ‹‚ÌURI -my($perl) = "perl"; # perl‚̃Rƒ}ƒ“ƒh–¼ - - - -#--------------------------- ݒ肱‚±‚܂Š-------------------------------- - - - - - - -use strict; -use CGI; - -my($cgi)= new CGI; -my(%langconv)=( - 'Athena login-server administration tool.*' => '', - 'logged on.*' => '', -); - -# ----- “ú–{ŒêŠÂ‹«‚È‚ç•ÏŠ·ƒe[ƒuƒ‹‚ðƒZƒbƒg ----- -if($ENV{'HTTP_ACCEPT_LANGUAGE'}=~/^ja/){ - my(%tmp)=( - 'Account \[(.+)\] is successfully created.*' - => 'ƒAƒJƒEƒ“ƒg "$1" ‚ð쬂µ‚Ü‚µ‚½.', - 'Account \[(.+)\] creation failed\. same account exists.*' - => 'ƒAƒJƒEƒ“ƒg "$1" ‚ÍŠù‚É‘¶Ý‚µ‚Ü‚·.', - 'Illeagal charactor found in UserID.*' - => 'ID‚Ì’†‚É•s³‚È•¶Žš‚ª‚ ‚è‚Ü‚·.', - 'Illeagal charactor found in Password.*' - => 'Password‚Ì’†‚É•s³‚È•¶Žš‚ª‚ ‚è‚Ü‚·.', - 'input UserID 4-24 bytes.' - => 'ID‚Í”¼Šp4`24•¶Žš‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚¢.', - 'input Password 4-24 bytes.' - => 'Password‚Í”¼Šp4`24•¶Žš‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚¢.', - 'Illeagal gender.*' - => '«•Ê‚ª‚¨‚©‚µ‚¢‚Å‚·.', - 'Cant connect to login server.*' - => 'ƒƒOƒCƒ“ƒT[ƒo[‚ÉÚ‘±‚Å‚«‚Ü‚¹‚ñ.', - 'login error.*' - => 'ƒƒOƒCƒ“ƒT[ƒo[‚Ö‚ÌŠÇ—ŽÒŒ ŒÀƒƒOƒCƒ“‚ÉŽ¸”s‚µ‚Ü‚µ‚½', - "Can't execute ladmin.*" - => 'ladmin‚ÌŽÀs‚ÉŽ¸”s‚µ‚Ü‚µ‚½', - 'UserID "(.+)" is already used.*' - => 'ID "$1" ‚ÍŠù‚ÉŽg—p‚³‚ê‚Ä‚¢‚Ü‚·.', - 'You can use UserID \"(.+)\".*' - => 'ID "$1" ‚ÍŽg—p‰Â”\‚Å‚·.', - - 'account making' =>'ƒAƒJƒEƒ“ƒgì¬', - '\>UserID' =>'>‚h‚c', - '\>Password' =>'>ƒpƒXƒ[ƒh', - '\>Gender' =>'>«•Ê', - '\>Male' =>'>’j«', - '\>Female' =>'>—«', - '\"Make Account\"' =>'"ƒAƒJƒEƒ“ƒgì¬"', - '\"Check UserID\"' =>'"ID‚̃`ƒFƒbƒN"', - ); - map { $langconv{$_}=$tmp{$_}; } keys (%tmp); -} - -# ----- ’ljÁ ----- -if( $cgi->param("addaccount") ){ - my($userid)= $cgi->param("userid"); - my($passwd)= $cgi->param("passwd"); - my($gender)= lc(substr($cgi->param("gender"),0,1)); - if(length($userid)<4 || length($userid)>24){ - HttpError("input UserID 4-24 bytes."); - } - if(length($passwd)<4 || length($passwd)>24){ - HttpError("input Password 4-24 bytes."); - } - if($userid=~/[^0-9A-Za-z\@\_\-\']/){ - HttpError("Illeagal charactor found in UserID."); - } - if($passwd=~/[\x00-\x1f\x80-\xff\']/){ - HttpError("Illeagal charactor found in Password."); - } - if($gender!~/[mf]/){ - HttpError("Gender error."); - } - open PIPE,"$perl $ladmin --add $userid $gender $passwd |" - or HttpError("Can't execute ladmin."); - my(@msg)=; - close PIPE; - HttpMsg(@msg); -} -# ----- ‘¶Ýƒ`ƒFƒbƒN ----- -elsif( $cgi->param("check") ){ - my($userid)= $cgi->param("userid"); - if(length($userid)<4 || length($userid)>24){ - HttpError("input UserID 4-24 bytes."); - } - if($userid=~/[^0-9A-Za-z\@\_\-\']/){ - HttpError("Illeagal charactor found in UserID."); - } - open PIPE,"$perl $ladmin --search --regex \\b$userid\\b |" - or HttpError("Can't execute ladmin."); - my(@msg)=; - close PIPE; - if(scalar(@msg)==6 && (split /[\s\0]+/,substr($msg[4],11,24))[0] eq $userid){ - HttpMsg("NG : UserID \"$userid\" is already used."); - }elsif(scalar(@msg)==5){ - HttpMsg("OK : You can use UserID \"$userid\""); - } - HttpError("ladmin error ?\n---output---\n",@msg); -} - -# ----- ƒtƒH[ƒ€ ----- -else{ - print LangConv( <<"EOM" ); -Content-type: text/html\n - - - Athena account making cgi - - -

Athena account making cgi

-
- - - - - - - - - - - - - - - - -
UserID
Password
Gender - Male - Female -
- - -
-
- - -EOM - exit; -} - -sub LangConv { - my(@lst)= @_; - my($a,$b,@out)=(); - foreach $a(@lst){ - foreach $b(keys %langconv){ - $a=~s/$b/$langconv{$b}/g; - my($rep1)=$1; - $a=~s/\$1/$rep1/g; - } - push @out,$a; - } - return @out; -} - -sub HttpMsg { - my($msg)=join("", LangConv(@_)); - $msg=~s/\n/
\n/g; - print LangConv("Content-type: text/html\n\n"),$msg; - exit; -} - -sub HttpError { - my($msg)=join("", LangConv(@_)); - $msg=~s/\n/
\n/g; - print LangConv("Content-type: text/html\n\n"),$msg; - exit; -} - diff --git a/tools/ladmin b/tools/ladmin deleted file mode 100644 index e3319d5de..000000000 --- a/tools/ladmin +++ /dev/null @@ -1,3793 +0,0 @@ -#!/usr/bin/perl -use POSIX; -########################################################################## -# EAthena login-server remote administration tool -# New ladamin by [Yor] -########################################################################## -#-------------------------------INSTRUCTIONS------------------------------ -# Set the 4 variables below: -# IP of the login server. -# Port where the login-server listens incoming packets. -# Password of administration (same of config_athena.conf). -# Displayed language of the sofware (if not correct, english is used). -# IMPORTANT: -# Be sure that you authorize remote administration in login-server -# (see login_athena.conf, 'admin_state' parameter) -#------------------------------------------------------------------------- -my($loginserverip) = "127.0.0.1"; # IP of login-server -my($loginserverport) = 6900; # Port of login-server -my($loginserveradminpassword) = "admin"; # Administration password -my($connecttimeout) = 10; # Timeout of connection (in seconds) -my($passenc) = 2; # Encoding type of the password -my($defaultlanguage) = "E"; # Default language (F: Français/E: English) - # (if it's not 'F', default is English) - -#------------------------------------------------------------------------- -# LIST of COMMANDs that you can type at the prompt: -# To use these commands you can only type only the first letters. -# You must type a minimum of letters (you can not type 'a', -# because ladmin doesn't know if it's for 'aide' or for 'add') -# q <= quit, li <= list, pass <= passwd, etc. -# -# Note: every time you must give a account_name, you can use "" or '' (spaces can be included) -# -# aide/help/? -# Display the description of the commands -# aide/help/? [command] -# Display the description of the specified command -# -# add -# Create an account with the default email (a@a.com). -# Concerning the sex, only the first letter is used (F or M). -# The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail. -# When the password is omitted, the input is done without displaying of the pressed keys. -# add testname Male testpass -# -# ban/banish yyyy/mm/dd hh:mm:ss -# Changes the final date of a banishment of an account. -# Same command of banset, except that account_name is at end -# -# banadd -# Adds or substracts time from the final date of a banishment of an account. -# Modifier is done as follows: -# Adjustment value (-1, 1, +1, etc...) -# Modified element: -# a or y: year -# m: month -# j or d: day -# h: hour -# mn: minute -# s: second -# banadd testname +1m-2mn1s-6y -# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. -# NOTE: If you modify the final date of a non-banished account, -# you fix the final date to (actual time +- adjustments) -# -# banset yyyy/mm/dd [hh:mm:ss] -# Changes the final date of a banishment of an account. -# Default time: 23:59:59 -# banset 0 -# Set a non-banished account (0 = unbanished). -# -# block -# Set state 5 (You have been blocked by the GM Team) to an account. -# Same command of state 5. -# -# check -# Check the validity of a password for an account -# NOTE: Server will never sends back a password. -# It's the only method you have to know if a password is correct. -# The other method is to have a ('physical') access to the accounts file. -# -# create -# Like the 'add' command, but with e-mail moreover. -# create testname Male my@mail.com testpass -# -# del -# Remove an account. -# This order requires confirmation. After confirmation, the account is deleted. -# -# email -# Modify the e-mail of an account. -# -# getcount -# Give the number of players online on all char-servers. -# -# gm [GM_level] -# Modify the GM level of an account. -# Default value remove GM level (GM level = 0). -# gm testname 80 -# -# id -# Give the id of an account. -# -# info -# Display complete information of an account. -# -# kami -# Sends a broadcast message on all map-server (in yellow). -# kamib -# Sends a broadcast message on all map-server (in blue). -# -# language -# Change the language of displaying. -# -# list/ls [start_id [end_id]] -# Display a list of accounts. -# 'start_id', 'end_id': indicate end and start identifiers. -# Research by name is not possible with this command. -# list 10 9999999 -# -# listBan/lsBan [start_id [end_id]] -# Like list/ls, but only for accounts with state or banished -# -# listGM/lsGM [start_id [end_id]] -# Like list/ls, but only for GM accounts -# -# listOK/lsOK [start_id [end_id]] -# Like list/ls, but only for accounts without state and not banished -# -# memo -# Modify the memo of an account. -# 'memo': it can have until 253 characters (with spaces or not). -# -# name -# Give the name of an account. -# -# passwd -# Change the password of an account. -# When new password is omitted, the input is done without displaying of the pressed keys. -# -# quit/end/exit -# End of the program of administration -# -# reloadGM -# Reload GM configuration file -# -# search -# Seek accounts. -# Displays the accounts whose names correspond. -# search -r/-e/--expr/--regex -# Seek accounts by regular expression. -# Displays the accounts whose names correspond. -# -# sex -# Modify the sex of an account. -# sex testname Male -# -# state -# Change the state of an account. -# 'new_state': state is the state of the packet 0x006a + 1. The possibilities are: -# 0 = Account ok 6 = Your Game's EXE file is not the latest version -# 1 = Unregistered ID 7 = You are Prohibited to log in until %s -# 2 = Incorrect Password 8 = Server is jammed due to over populated -# 3 = This ID is expired 9 = No MSG -# 4 = Rejected from Server 100 = This ID has been totally erased -# 5 = You have been blocked by the GM Team -# all other values are 'No MSG', then use state 9 please. -# 'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a) -# -# timeadd -# Adds or substracts time from the validity limit of an account. -# Modifier is done as follows: -# Adjustment value (-1, 1, +1, etc...) -# Modified element: -# a or y: year -# m: month -# j or d: day -# h: hour -# mn: minute -# s: second -# timeadd testname +1m-2mn1s-6y -# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. -# NOTE: You can not modify a unlimited validity limit. -# If you want modify it, you want probably create a limited validity limit. -# So, at first, you must set the validity limit to a date/time. -# -# timeset yyyy/mm/dd [hh:mm:ss] -# Changes the validity limit of an account. -# Default time: 23:59:59 -# timeset 0 -# Gives an unlimited validity limit (0 = unlimited). -# -# unban/unbanish -# Unban an account. -# Same command of banset 0. -# -# unblock -# Set state 0 (Account ok) to an account. -# Same command of state 0. -# -# version -# Display the version of the login-server. -# -# who -# Displays complete information of an account. -# -#------------------------------------------------------------------------- -# Possibilities to execute ladmin in command line by usage of the software with a parameter: -# ./ladmin --mode param1 ... -# -# --makesymlink -- Create the symbolic links for a use in shell -# --add -- Create an account with the default email (or -a) -# --ban yyyy/mm/dd hh:mm:ss -- Change the final date of a banishment of an account (or -b) -# --banadd -- Add or substract time from the final date of a banishment of an account (or - ba) -# --banset yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account (or -bs) -# --banset 0 -- Unbanish an account (or -bs) -# --block -- Set state 5 to an account (or -bl) -# --check -- Check the validity of a password for an account (or -check) -# --create -- Create an account with email (or -c) -# --del -- Remove an account (or -d) -# --email -- Modify an email of an account (or -e) -# --getcount -- Give the number of players online on all char-servers (or -g) -# --gm -- Change the GM level of an account (or -gm) -# --id -- Give the id of an account (or -i) -# --info -- Display complete information of an account (or -info) -# --kami -- Sends a broadcast message on all map-server (in yellow). -# --kamib -- Sends a broadcast message on all map-server (in blue). -# --language -- Change the language of displaying (-lang). -# --list [First_id [Last_id]] -- Display a list of accounts (or -l) -# --listBan [start_id [end_id]] -- Display a list of accounts with state or banished (or -lBan) -# --listGM [First_id [Last_id]] -- Display a list of GM accounts (or -lGM) -# --listOK [start_id [end_id]] -- Display a list of accounts without state and not banished (or -lOK) -# --memo -- Modify the memo of an account (or -e) -# --name -- Give the name of an account (or -n) -# --passwd -- Change the password of an account (or -p) -# --reloadGM -- Reload GM configuration file (or -r) -# --search -- Seek accounts (or -s) -# --search -e/-r/--expr/--regex -- Seek accounts by REGEX (or -s) -# --sex -- Change the sex of an account (or -sex) -# --state -- Change the state of an account (or -t) -# --timeadd -- Add or substract time from the validity limit of an account (or - ta) -# --timeset yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account (or -ts) -# --timeset 0 -- Give a unlimited validity limit (or -ts) -# --unban/unbanish -- Unban an account (or -uba) -# --unblock -- Set state 0 to an account (or -ubl) -# --version -- Display the version of the login-server (or -v) -# --who -- Display complete information of an account (or -w) -# -# ./ladmin --addaccount testname Male testpass -# -#------------------------------------------------------------------------- -# Possibilities to execute ladmin with symbolic links in Shell -# To create the symbolic links, execute ladmin with the '-- makesymlink' option. -# -# addaccount -- Create an account with the default email -# banaccount yyyy/mm/dd hh:mm:ss -- Change the final date of a banishment of an account -# banaddaccount -- Add or substract time from the final date of a banishment of an account -# bansetaccount yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account -# bansetaccount 0 -- Unbanish an account -# blockaccount -- Set state 5 (blocked by the GM Team) to an account -# checkaccount -- Check the validity of a password for an account -# createaccount -- Create an account with email -# delaccount -- Remove an account -# emailaccount -- Modify an email of an account -# getcount -- Give the number of players online on all char-servers -# gmaccount -- Change the GM level of an account -# idaccount -- Give the id of an account -# infoaccount -- Display complete information of an account -# kami -- Sends a broadcast message on all map-server (in yellow). -# kamib -- Sends a broadcast message on all map-server (in blue). -# ladminlanguage -- Change the language of displaying. -# listaccount [First_id [Last_id]] -- Display a list of accounts -# listBanaccount [start_id [end_id]] -- Display a list of accounts with state or banished -# listGMaccount [First_id [Last_id]] -- Display a list of GM accounts -# listOKaccount [start_id [end_id]] -- Display a list of accounts without state and not banished -# loginserverversion -- Display the version of the login-server -# memoaccount -- Modify the memo of an account -# nameaccount -- Give the name of an account -# passwdaccount -- Change the password of an account -# reloadGM -- Reload GM configuration file -# searchaccount -- Seek accounts -# searchaccount -e/-r/--expr/--regex -- Seek accounts by REGEX -# sexaccount -- Change the sex of an account (or -sex) -# stateaccount -- Change the state of an account -# timeaddaccount -- Add or substract time from the validity limit of an account -# timesetaccount yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account -# timesetaccount 0 -- Give a unlimited validity limit -# unbanaccount -- Unban an account -# unblockaccount -- Set state 0 (Account ok) to an account -# whoaccount -- Display complete information of an account -# ./addaccount testname Male testpass -# -#------------------------------------------------------------------------- -# About the encoding: -# -# The Digest::MD5 module is necessary to use the encrypted password system. -# When the software cannot found the Digest::MD5 module, -# encoding is automatically disabled ($passenc=0), which allows -# to use this program in any cases. -# -#------------------------------------------------------------------------- -# How to use ladmin with UNIX: -# -# You excecute ladmin as a standard command. -# -# $ mv ladmin ladmin_org -# $ nkf -eLu ladmin_org > ladmin -# $ chmod 700 ladmin -# -# $ perl ladmin -# -########################################################################## - - -use strict; -use IO::Socket; -use Term::ReadLine; -eval { use POSIX qw(:termios_h); }; -eval { use Digest::MD5 qw(md5); } if $passenc; -$passenc = 0 if($@); - -my($ver) = "1.00"; - -# Start of termios -my($termios, $orgterml, $termlecho, $termlnoecho) = (); -eval{ - $termios = POSIX::Termios->new(); - $termios->getattr(fileno(STDIN)); - $orgterml = $termios->getlflag(); - $termlecho = ECHO | ECHOK | ICANON; - $termlnoecho = $orgterml & ~$termlecho; -}; - -# Modification of termios for the displaying of passwords (no displays for pressed keys) -sub cbreak() { - if ($termios) { - $termios->setlflag($termlnoecho); - $termios->setcc(VTIME, 1); - $termios->setattr(fileno(STDIN), TCSANOW); - } -} -# Modification of termios to return at the normal displaying (after input of the passwords) -sub cooked() { - if ($termios) { - $termios->setlflag($orgterml); - $termios->setcc(VTIME,0); - $termios->setattr(fileno(STDIN),TCSANOW); - } -} -END{ cooked() } - -if ($defaultlanguage eq "F") { - print "Outil d'administration à distance de eAthena V.$ver\n"; -} else { - print "EAthena login-server administration tool V.$ver\n"; -} - -# Creation of the symbolic links for call of the program in line command of the shell -if ($ARGV[0] eq "--makesymlink") { - symlink $0, "loginserverversion"; - symlink $0, "addaccount"; - symlink $0, "banaccount"; - symlink $0, "banaddaccount"; - symlink $0, "bansetaccount"; - symlink $0, "blockaccount"; - symlink $0, "checkaccount"; - symlink $0, "createaccount"; - symlink $0, "delaccount"; - symlink $0, "emailaccount"; - symlink $0, "getcount"; - symlink $0, "gmaccount"; - symlink $0, "idaccount"; - symlink $0, "infoaccount"; - symlink $0, "kami"; - symlink $0, "kamib"; - symlink $0, "ladminlanguage"; - symlink $0, "listaccount"; - symlink $0, "listBanaccount"; - symlink $0, "listGMaccount"; - symlink $0, "listOKaccount"; - symlink $0, "memoaccount"; - symlink $0, "nameaccount"; - symlink $0, "passwdaccount"; - symlink $0, "reloadGM"; - symlink $0, "searchaccount"; - symlink $0, "sexaccount"; - symlink $0, "stateaccount"; - symlink $0, "timeaddaccount"; - symlink $0, "timesetaccount"; - symlink $0, "unbanaccount"; - symlink $0, "unblockaccount"; - symlink $0, "whoaccount"; - if ($defaultlanguage eq "F") { - print "Liens symbliques créés.\n"; - } else { - print "Symbolic links created.\n"; - } - exit(0); -} - -# Connection to the login-server -my($so,$er) = (); -eval{ - $so = IO::Socket::INET->new( - PeerAddr=> $loginserverip, - PeerPort=> $loginserverport, -# Proto => "tcp", - Timeout => $connecttimeout) or $er = 1; -}; -if ($er || $@) { - if ($defaultlanguage eq "F") { - print "\nImpossible de se connecter au serveur de login [${loginserverip}:$loginserverport] !\n"; - } else { - print "\nImpossible to have a connection with the login-server [${loginserverip}:$loginserverport] !\n"; - } - print "$!\n"; # Displaying of the error - exit(2); -} - -# Sending the administration password -if ($passenc == 0) { - print $so pack("v2a24",0x7918,0,$loginserveradminpassword); - $so->flush(); -} else { - print $so pack("v",0x791a); - $so->flush(); - my($buf) = readso(4); - if (unpack("v",$buf) != 0x01dc) { - if ($defaultlanguage eq "F") { - print "Erreur au login (échec de la création de la clef md5).\n"; - } else { - print "Error at login (failure of the md5 key creation).\n"; - } - } - $buf = readso(unpack("x2v",$buf)-4); - my($md5bin) = md5(($passenc == 1) ? $buf.$loginserveradminpassword : $loginserveradminpassword.$buf); - print $so pack("v2a16",0x7918,$passenc,$md5bin); - $so->flush(); -} - -# Waiting of the server reply -my($buf) = readso(3); - -if (unpack("v",$buf) != 0x7919 || unpack("x2c",$buf) != 0) { - if ($defaultlanguage eq "F") { - print "Erreur de login:\n"; - print " - mot de passe incorrect,\n"; - print " - système d'administration non activé, ou\n"; - print " - IP non autorisée.\n"; - } else { - print "Error at login:\n"; - print " - incorrect password,\n"; - print " - administration system not activated, or\n"; - print " - unauthorised IP.\n"; - } - quit(); - exit(4); -} - -if ($defaultlanguage eq "F") { - print "Connexion établie.\n"; -} else { - print "Established connection.\n"; -} - -#------------------------------------------------------------------------- -# Here are checked the command lines with arguments and symbolic links (no prompt) - -if ($0 =~ /addaccount$/ || - (($ARGV[0] eq "-a" || $ARGV[0] eq "--add") && ((shift @ARGV), 1))) { - my($r) = addaccount($ARGV[0], $ARGV[1], $ARGV[2]); - quit(); - exit($r); -} elsif ($0 =~ /banaccount$/ || $0 =~ /banishaccount$/ || - (($ARGV[0] eq "-b" || $ARGV[0] eq "--ban" || $ARGV[0] eq "--banish") && ((shift @ARGV), 1))) { - my($r) = bansetaccount($ARGV[1], $ARGV[2], $ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /banaddaccount$/ || - (($ARGV[0] eq "-ba" || $ARGV[0] eq "--banadd") && ((shift @ARGV), 1))) { - my($r) = banaddaccount($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /bansetaccount$/ || - (($ARGV[0] eq "-bs" || $ARGV[0] eq "--banset") && ((shift @ARGV), 1))) { - my($r) = bansetaccount($ARGV[0], $ARGV[1], $ARGV[2]); - quit(); - exit($r); -} elsif ($0 =~ /blockaccount$/ || - (($ARGV[0] eq "-bl" || $ARGV[0] eq "--block") && ((shift @ARGV), 1))) { - my($r) = changestate($ARGV[0], 5, ""); - quit(); - exit($r); -} elsif ($0 =~ /checkaccount$/ || - (($ARGV[0] eq "-check" || $ARGV[0] eq "--check") && ((shift @ARGV), 1))) { - my($r) = checkaccount($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /createaccount$/ || - (($ARGV[0] eq "-c" || $ARGV[0] eq "--create") && ((shift @ARGV), 1))) { - my($r) = createaccount($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]); - quit(); - exit($r); -} elsif ($0 =~ /delaccount$/ || - (($ARGV[0] eq "-d" || $ARGV[0] eq "--del") && ((shift @ARGV), 1))) { - my($r) = delaccount($ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /emailaccount$/ || - (($ARGV[0] eq "-e" || $ARGV[0] eq "--email") && ((shift @ARGV), 1))) { - my($r) = changeemail($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /getcount$/ || - (($ARGV[0] eq "-g" || $ARGV[0] eq "--getcount") && ((shift @ARGV), 1))) { - my($r) = getlogincount(); - quit(); - exit($r); -} elsif ($0 =~ /gmaccount$/ || - (($ARGV[0] eq "-gm" || $ARGV[0] eq "--gm") && ((shift @ARGV), 1))) { - my($r) = changegmlevel($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /id$/ || - (($ARGV[0] eq "-i" || $ARGV[0] eq "--id") && ((shift @ARGV), 1))) { - my($r) = idaccount($ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /infoaccount$/ || - (($ARGV[0] eq "-info" || $ARGV[0] eq "--info") && ((shift @ARGV), 1))) { - my($r) = infoaccount($ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /kami$/ || - (($ARGV[0] eq "-kami" || $ARGV[0] eq "--kami") && ((shift @ARGV), 1))) { - my($r) = sendbroadcast(0, $ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /kamib$/ || - (($ARGV[0] eq "-kamib" || $ARGV[0] eq "--kamib") && ((shift @ARGV), 1))) { - my($r) = sendbroadcast(0x10, $ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /ladminlanguage$/ || - (($ARGV[0] eq "-lang" || $ARGV[0] eq "--language") && ((shift @ARGV), 1))) { - my($r) = changelanguage($ARGV[0]); - quit(); - exit($r); -} elsif ($0 =~ /listaccount$/ || - (($ARGV[0] eq "-l" || $ARGV[0] eq "--list") && ((shift @ARGV), 1))) { - my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 0); # 0: to list all - quit(); - exit($r); -} elsif ($0 =~ /listBanaccount$/ || - (($ARGV[0] eq "-lBan" || $ARGV[0] eq "--listBan") && ((shift @ARGV), 1))) { - my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 3); # 3: to list only accounts with state or banished - quit(); - exit($r); -} elsif ($0 =~ /listGMaccount$/ || - (($ARGV[0] eq "-lGM" || $ARGV[0] eq "--listGM") && ((shift @ARGV), 1))) { - my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 1); # 1: to list only GM - quit(); - exit($r); -} elsif ($0 =~ /listOKaccount$/ || - (($ARGV[0] eq "-lOK" || $ARGV[0] eq "--listOK") && ((shift @ARGV), 1))) { - my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 4); # 4: to list only accounts without state and not banished - quit(); - exit($r); -} elsif ($0 =~ /loginserverversion$/ || - (($ARGV[0] eq "-v" || $ARGV[0] eq "--version") && ((shift @ARGV), 1))) { - my($r) = checkloginversion(); - quit(); - exit($r); -} elsif ($0 =~ /memoaccount$/ || - (($ARGV[0] eq "-m" || $ARGV[0] eq "--memo") && ((shift @ARGV), 1))) { - my($r) = changememo($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /nameaccount$/ || - (($ARGV[0] eq "-n" || $ARGV[0] eq "--name") && ((shift @ARGV), 1))) { - my($r) = nameaccount(int($ARGV[0])); - quit(); - exit($r); -} elsif ($0 =~ /passwdaccount$/ || - (($ARGV[0] eq "-p" || $ARGV[0] eq "--passwd") && ((shift @ARGV), 1))) { - my($r) = changepasswd($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /reloadGM$/ || - (($ARGV[0] eq "-r" || $ARGV[0] eq "--reloadGM") && ((shift @ARGV), 1))) { - my($r) = reloadGM(); - quit(); - exit($r); -} elsif ($0 =~ /searchaccount$/ || - (($ARGV[0] eq "-s" || $ARGV[0] eq "--search") && ((shift @ARGV), 1))) { - my($r) = searchaccount($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /sexaccount$/ || - (($ARGV[0] eq "-sex" || $ARGV[0] eq "--sex") && ((shift @ARGV), 1))) { - my($r) = changesex($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /stateaccount$/ || - (($ARGV[0] eq "-t" || $ARGV[0] eq "--state") && ((shift @ARGV), 1))) { - my($r) = changestate($ARGV[0], $ARGV[1], $ARGV[2]); - quit(); - exit($r); -} elsif ($0 =~ /timeaddaccount$/ || - (($ARGV[0] eq "-ta" || $ARGV[0] eq "--timeadd") && ((shift @ARGV), 1))) { - my($r) = timeaddaccount($ARGV[0], $ARGV[1]); - quit(); - exit($r); -} elsif ($0 =~ /timesetaccount$/ || - (($ARGV[0] eq "-ts" || $ARGV[0] eq "--timeset") && ((shift @ARGV), 1))) { - my($r) = timesetaccount($ARGV[0], $ARGV[1], $ARGV[2]); - quit(); - exit($r); -} elsif ($0 =~ /unbanaccount$/ || $0 =~ /unbanishaccount$/ || - (($ARGV[0] eq "-uba" || $ARGV[0] eq "--unban" || $ARGV[0] eq "--unbanish") && ((shift @ARGV), 1))) { - my($r) = bansetaccount($ARGV[0], 0, ""); - quit(); - exit($r); -} elsif ($0 =~ /unblockaccount$/ || - (($ARGV[0] eq "-ubl" || $ARGV[0] eq "--unblock") && ((shift @ARGV), 1))) { - my($r) = changestate($ARGV[0], 0, ""); - quit(); - exit($r); -} elsif ($0 =~ /whoaccount$/ || - (($ARGV[0] eq "-w" || $ARGV[0] eq "--who") && ((shift @ARGV), 1))) { - my($r) = whoaccount($ARGV[0]); - quit(); - exit($r); -} - -#------------------------------------------------------------------------- -if ($defaultlanguage eq "F") { - print "Lecture de la version du serveur de login...\n"; -} else { - print "Reading of the version of the login-server...\n"; -} -checkloginversion(); - -# Set the prompt line -my($term) = new Term::ReadLine "ladmin"; - -# Here begin the infinite loop to read prompts -while(1) { - # Displaying of the prompt - print "\n"; - if ($defaultlanguage eq "F") { - printf "\033[32mPour afficher les commandes, tapez 'Entrée'.\033[0m\n"; - } else { - printf "\033[32mTo list the commands, type 'enter'.\033[0m\n"; - } - my($cmd) = $term->readline("ladmin> "); - # split and recovery of the input - chomp $cmd; # remove cariage return - $cmd =~ s/\x1b\[\d*\w//g; # remove (esc)[(number)(1alpha) = screen control sequence - $cmd =~ s/[\x00-\x1f]//g; # remove control char - my($command, $parameters) = split /\s+/,$cmd,2; # extract command and parameters - $command = lc($command); # command in lowercase - my(@paramlist) = split /\s+/,$parameters; # get list of parameters - - if ($command eq "?" || $command eq "") { - $command = "aide" if ($defaultlanguage eq "F"); - $command = "help" if ($defaultlanguage ne "F"); - } - - # Analyse of the command - eval { -# help - if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - displayhelp("aide", $paramlist[0]); - } elsif ("help" =~ /^\Q$command/) { - displayhelp("help", $paramlist[0]); - -# general commands - } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(.*)/)) { - addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - addaccount($paramlist[0], $paramlist[1], ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(.*)/)) { - addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - addaccount($paramlist[0], $paramlist[1], ""); # - } else { - @paramlist = split /\s+/,$parameters; - addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # - } - - } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { - if (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+"(.*)"/)) { # yyyy/mm/dd hh:mm:ss - bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+'(.*)'/)) { # yyyy/mm/dd hh:mm:ss - bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] - } else { - @paramlist = split /\s+/,$parameters,3; # yyyy/mm/dd hh:mm:ss - bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] - } - - } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - banaddaccount($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - banaddaccount($paramlist[0], $paramlist[1]); # - } else { - @paramlist = split /\s+/,$parameters; - banaddaccount($paramlist[0], $paramlist[1]); # - } - - } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { - bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { - bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] - } else { - @paramlist = split /\s+/,$parameters; - bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } - - } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - changestate($paramlist[0], 5, ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - changestate($paramlist[0], 5, ""); # - } else { - @paramlist = split /\s+/,$parameters,1; - changestate($paramlist[0], 5, ""); # - } - - } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { - checkaccount($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { - checkaccount($paramlist[0], ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { - checkaccount($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - checkaccount($paramlist[0], ""); # - } else { - @paramlist = split /\s+/,$parameters; - checkaccount($paramlist[0], $paramlist[1]); # - } - - } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)\s+(.*)/)) { - createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { - createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)\s+(.*)/)) { - createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { - createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # - } else { - @paramlist = split /\s+/,$parameters; - createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # - } - - } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - delaccount($paramlist[0]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - delaccount($paramlist[0]); # - } else { - @paramlist = split /\s+/,$parameters,1; - delaccount($paramlist[0]); # - } - - } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - changeemail($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - changeemail($paramlist[0], $paramlist[1]); # - } else { - @paramlist = split /\s+/,$parameters; - changeemail($paramlist[0], $paramlist[1]); # - } - - } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - getlogincount(); - - } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - changegmlevel($paramlist[0], int($paramlist[1])); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { - changegmlevel($paramlist[0], 0); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - changegmlevel($paramlist[0], int($paramlist[1])); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - changegmlevel($paramlist[0], 0); # - } else { - @paramlist = split /\s+/,$parameters; - changegmlevel($paramlist[0], int($paramlist[1])); # - } - - } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - idaccount($paramlist[0]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - idaccount($paramlist[0]); # - } else { - @paramlist = split /\s+/,$parameters,1; - idaccount($paramlist[0]); # - } - - } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - infoaccount(int($paramlist[0])); # - - } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? - @paramlist = split /\s+/,$parameters,1; - sendbroadcast(0, $paramlist[0]); # - - } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? - @paramlist = split /\s+/,$parameters,1; - sendbroadcast(0x10, $paramlist[0]); # - - } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? - changelanguage($paramlist[0]); # - - } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? - listaccount(int($paramlist[0]), int($paramlist[1]), 0); # [start_id [end_id]] 0: to list all - - } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? - listaccount(int($paramlist[0]), int($paramlist[1]), 3); # [start_id [end_id]] 3: to list only accounts with state or banished - - } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? - listaccount(int($paramlist[0]), int($paramlist[1]), 1); # [start_id [end_id]] 1: to list only GM - - } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? - listaccount(int($paramlist[0]), int($paramlist[1]), 4); # [start_id [end_id]] 4: to list only accounts without state and not banished - - } elsif ("memo" =~ /^\Q$command/) { - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { - changememo($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { - changememo($paramlist[0], $paramlist[1]); # - } else { - @paramlist = split /\s+/,$parameters,2; - changememo($paramlist[0], $paramlist[1]); # - } - - } elsif ("name" =~ /^\Q$command/) { - nameaccount(int($paramlist[0])); # - - } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { - changepasswd($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { - changepasswd($paramlist[0], ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { - changepasswd($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - changepasswd($paramlist[0], ""); # - } else { - @paramlist = split /\s+/,$parameters,2; - changepasswd($paramlist[0], $paramlist[1]); # - } - - } elsif ("reloadgm" =~ /^\Q$command/) { - reloadGM(); - - } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - if (@paramlist = ($parameters =~ m/^(-{1,2}[re]\S*)\s+(.*)/)) { - searchaccount($paramlist[0], $paramlist[1]); # -r/-e/--expr/--regex | - } else { - @paramlist = split /\s+/,$parameters,1; - searchaccount($paramlist[0], ""); # -r/-e/--expr/--regex | - } - - } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - changesex($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - changesex($paramlist[0], $paramlist[1]); # - } else { - @paramlist = split /\s+/,$parameters; - changesex($paramlist[0], $paramlist[1]); # - } - - } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)\s+(.*)/)) { - changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # - } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)/)) { - changestate($paramlist[0], int($paramlist[1]), ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)\s+(.*)/)) { - changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)/)) { - changestate($paramlist[0], int($paramlist[1]), ""); # - } else { - @paramlist = split /\s+/,$parameters,3; - changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # - } - - } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - timeaddaccount($paramlist[0], $paramlist[1]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - timeaddaccount($paramlist[0], $paramlist[1]); # - } else { - @paramlist = split /\s+/,$parameters; - timeaddaccount($paramlist[0], $paramlist[1]); # - } - - } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { - timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { - timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { - timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { - timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] - } else { - @paramlist = split /\s+/,$parameters; - timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] - } - - } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] - } else { - @paramlist = split /\s+/,$parameters,1; - bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] - } - - } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - changestate($paramlist[0], 0, ""); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - changestate($paramlist[0], 0, ""); # - } else { - @paramlist = split /\s+/,$parameters,1; - changestate($paramlist[0], 0, ""); # - } - - } elsif ("version" =~ /^\Q$command/) { - checkloginversion(); - - } elsif ("who" =~ /^\Q$command/) { - if (@paramlist = ($parameters =~ m/^"(.*)"/)) { - whoaccount($paramlist[0]); # - } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { - whoaccount($paramlist[0]); # - } else { - @paramlist = split /\s+/,$parameters,1; - whoaccount($paramlist[0]); # - } - -# quit - } elsif ("quit" =~ /^\Q$command/ || - (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'? - last; - -# unknown command - } elsif ($command) { - if ($defaultlanguage eq "F") { - print "Commande inconnue [".$command."]\n"; - } else { - print "Unknown command [".$command."]\n"; - } - } -# $term->addhistory($cmd) if $command; - }; - if ($@) { - if ($defaultlanguage eq "F") { - print "Erreur [".$command."]\n$@"; - } else { - print "Error [".$command."]\n$@"; - } - } -}; - -# End of the software -quit(); - -if ($defaultlanguage eq "F") { - print "Au revoir.\n"; -} else { - print "Bye.\n"; -} -exit(0); - -#-------------------------------------------------------------------------- - -# Sub-function: Displaying of the version of the login-server -sub checkloginversion() { - print $so pack("v",30000); # 0x7530 - $so->flush(); - $buf = readso(10); - # Analyse du Packet - my($ret, $maver, $miver, $rev, $dev, $mod, $type, $mdver) = unpack("vc6v", $buf); - if ($ret != 30001) { #0x7531 - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - exit(6); - } - - print " Login-Server [$loginserverip:$loginserverport]\n"; - printf " eAthena version %s-%d.%d", ("stable", "dev")[$dev], $maver, $miver; - printf " revision %d", $rev if $rev; - printf "%s%d.\n", ("", "-mod")[$mod], $mdver; - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Displaying of the help -sub displayhelp() { - my($help, $receivedcommand) = @_; - - my($command) = lc($receivedcommand); # command in lowercase - - if ($command eq "") { - $command = "not a command"; # any value that is not a command - } - - if ($command eq "?") { - $command = "aide" if ($defaultlanguage eq "F"); - $command = "help" if ($defaultlanguage ne "F"); - } - - if ($help eq "aide") { - if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - printf "aide/help/?\n"; - printf " Affiche la description des commandes\n"; - printf "aide/help/? [commande]\n"; - printf " Affiche la description de la commande specifiée\n"; - } elsif ("help" =~ /^\Q$command/) { - printf "aide/help/?\n"; - printf " Display the description of the commands\n"; - printf "aide/help/? [command]\n"; - printf " Display the description of the specified command\n"; - } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - printf "add \n"; - printf " Crée un compte avec l'email par défaut (a\@a.com).\n"; - printf " Concernant le sexe, seule la première lettre compte (F ou M).\n"; - printf " L'e-mail est a\@a.com (e-mail par défaut). C'est comme n'avoir aucun e-mail.\n"; - printf " Lorsque motdepasse est omis, la saisie se fait sans que la frappe se voit.\n"; - printf " add testname Male testpass\n"; - } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { - printf "ban/banish aaaa/mm/jj hh:mm:ss \n"; - printf " Change la date de fin de bannissement d'un compte.\n"; - printf " La différence avec banset est la position du nom du compte.\n"; - } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - printf "banadd \n"; - printf " Ajoute ou soustrait du temps à la date de banissement d'un compte.\n"; - printf " Les modificateurs sont construits comme suit:\n"; - printf " Valeur d'ajustement (-1, 1, +1, etc...)\n"; - printf " Elément modifié:\n"; - printf " a ou y: année\n"; - printf " m: mois\n"; - printf " j ou d: jour\n"; - printf " h: heure\n"; - printf " mn: minute\n"; - printf " s: seconde\n"; - printf " banadd testname +1m-2mn1s-6a\n"; - printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"; - printf " et 6 ans dans le même temps.\n"; - printf "NOTE: Si vous modifez la date de banissement d'un compte non bani,\n"; - printf " vous indiquez comme date (le moment actuel +- les ajustements)\n"; - } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - printf "banset aaaa/mm/jj [hh:mm:ss]\n"; - printf " Change la date de fin de bannissement d'un compte.\n"; - printf " Heure par défaut: 23:59:59\n"; - printf "banset 0\n"; - printf " Débanni un compte (0 = de-banni).\n"; - } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { - printf "block \n"; - printf " Place le status d'un compte à 5 (You have been blocked by the GM Team).\n"; - printf " La commande est l'équivalent de state 5.\n"; - } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - printf "check \n"; - printf " Vérifie la validité d'un mot de passe pour un compte\n"; - printf " NOTE: Le serveur n'enverra jamais un mot de passe.\n"; - printf " C'est la seule méthode que vous possédez pour savoir\n"; - printf " si un mot de passe est le bon. L'autre méthode est\n"; - printf " d'avoir un accès ('physique') au fichier des comptes.\n"; - } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - printf "create \n"; - printf " Comme la commande add, mais avec l'e-mail en plus.\n"; - printf " create testname Male mon\@mail.com testpass\n"; - } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { - printf "del \n"; - printf " Supprime un compte.\n"; - printf " La commande demande confirmation. Après confirmation, le compte est détruit.\n"; - } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? - printf "email \n"; - printf " Modifie l'e-mail d'un compte.\n"; - } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - printf "getcount\n"; - printf " Donne le nombre de joueurs en ligne par serveur de char.\n"; - } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - printf "gm [Niveau_GM]\n"; - printf " Modifie le niveau de GM d'un compte.\n"; - printf " Valeur par défaut: 0 (suppression du niveau de GM).\n"; - printf " gm nomtest 80\n"; - } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - printf "id \n"; - printf " Donne l'id d'un compte.\n"; - } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - printf "info \n"; - printf " Affiche les informations sur un compte.\n"; - } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? - printf "kami \n"; - printf " Envoi un message général sur tous les serveurs de map (en jaune).\n"; - } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? - printf "kamib \n"; - printf " Envoi un message général sur tous les serveurs de map (en bleu).\n"; - } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? - printf("language \n"); - printf(" Change la langue d'affichage.\n"); - printf(" Langues possibles: 'Français' ou 'English'.\n"); - } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? - printf "list/ls [Premier_id [Dernier_id]]\n"; - printf " Affiche une liste de comptes.\n"; - printf " 'Premier_id', 'Dernier_id': indique les identifiants de départ et de fin.\n"; - printf " La recherche par nom n'est pas possible avec cette commande.\n"; - printf " list 10 9999999\n"; - } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? - printf "listBan/lsBan [Premier_id [Dernier_id]]\n"; - printf " Comme list/ls, mais seulement pour les comptes GM avec un statut ou bannis.\n"; - } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? - printf "listGM/lsGM [Premier_id [Dernier_id]]\n"; - printf " Comme list/ls, mais seulement pour les comptes GM.\n"; - } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? - printf "listOK/lsOK [Premier_id [Dernier_id]]\n"; - printf " Comme list/ls, mais seulement pour les comptes sans statut et non bannis.\n"; - } elsif ("memo" =~ /^\Q$command/) { - printf "memo \n"; - printf " Modifie le mémo d'un compte.\n"; - printf " 'memo': Il peut avoir jusqu'à 253 caractères (avec des espaces ou non).\n"; - } elsif ("name" =~ /^\Q$command/) { - printf "name \n"; - printf " Donne le nom d'un compte.\n"; - } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { - printf "passwd \n"; - printf " Change le mot de passe d'un compte.\n"; - printf " Lorsque nouveaumotdepasse est omis,\n"; - printf " la saisie se fait sans que la frappe ne se voit.\n"; - } elsif ("reloadgm" =~ /^\Q$command/) { - printf "reloadGM\n"; - printf " Reload GM configuration file\n"; - } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - printf "search \n"; - printf " Cherche des comptes.\n"; - printf " Affiche les comptes dont les noms correspondent.\n"; - printf "search -r/-e/--expr/--regex \n"; - printf " Cherche des comptes par expression regulière.\n"; - printf " Affiche les comptes dont les noms correspondent.\n"; - } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - printf "sex \n"; - printf " Modifie le sexe d'un compte.\n"; - printf " sex testname Male\n"; - } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? - printf "state \n"; - printf " Change le statut d'un compte.\n"; - printf " 'nouveaustatut': Le statut est le même que celui du packet 0x006a + 1.\n"; - printf " les possibilités sont:\n"; - printf " 0 = Compte ok\n"; - printf " 1 = Unregistered ID\n"; - printf " 2 = Incorrect Password\n"; - printf " 3 = This ID is expired\n"; - printf " 4 = Rejected from Server\n"; - printf " 5 = You have been blocked by the GM Team\n"; - printf " 6 = Your Game's EXE file is not the latest version\n"; - printf " 7 = You are Prohibited to log in until...\n"; - printf " 8 = Server is jammed due to over populated\n"; - printf " 9 = No MSG\n"; - printf " 100 = This ID has been totally erased\n"; - printf " all other values are 'No MSG', then use state 9 please.\n"; - printf " 'message_erreur_7': message du code erreur 6 =\n"; - printf " = Your are Prohibited to log in until... (packet 0x006a)\n"; - } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - printf "timeadd \n"; - printf " Ajoute/soustrait du temps à la limite de validité d'un compte.\n"; - printf " Le modificateur est composé comme suit:\n"; - printf " Valeur modificatrice (-1, 1, +1, etc...)\n"; - printf " Elément modifié:\n"; - printf " a ou y: année\n"; - printf " m: mois\n"; - printf " j ou d: jour\n"; - printf " h: heure\n"; - printf " mn: minute\n"; - printf " s: seconde\n"; - printf " timeadd testname +1m-2mn1s-6a\n"; - printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"; - printf " et 6 ans dans le même temps.\n"; - printf "NOTE: Vous ne pouvez pas modifier une limite de validité illimitée. Si vous\n"; - printf " désirez le faire, c'est que vous voulez probablement créer un limite de\n"; - printf " validité limitée. Donc, en premier, fixé une limite de valitidé.\n"; - } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - printf "timeset aaaa/mm/jj [hh:mm:ss]\n"; - printf " Change la limite de validité d'un compte.\n"; - printf " Heure par défaut: 23:59:59\n"; - printf "timeset 0\n"; - printf " Donne une limite de validité illimitée (0 = illimitée).\n"; - } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { - printf "unban/unbanish \n"; - printf " Ote le banissement d'un compte.\n"; - printf " La commande est l'équivalent de banset 0.\n"; - } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { - printf "unblock \n"; - printf " Place le status d'un compte à 0 (Compte ok).\n"; - printf " La commande est l'équivalent de state 0.\n"; - } elsif ("version" =~ /^\Q$command/) { - printf "version\n"; - printf " Affiche la version du login-serveur.\n"; - } elsif ("who" =~ /^\Q$command/) { - printf "who \n"; - printf " Affiche les informations sur un compte.\n"; - } elsif ("quit" =~ /^\Q$command/ || - (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n"; - printf "quit/end/exit\n"; - printf " Fin du programme d'administration.\n"; - } else { - if ($receivedcommand ne "") { - printf "Commande inconnue [%s] pour l'aide. Affichage de toutes les commandes.\n", $receivedcommand; - } - print << "ENDOFAIDE"; - aide/help/? -- Affiche cet aide - aide/help/? [commande] -- Affiche l'aide de la commande - add -- Crée un compte (sans email) - ban/banish aaaa/mm/jj hh:mm:ss -- Change la date finale de banismnt - banadd/ba -- Ajout/soustrait du temps à la - exemple: ba moncompte +1m-2mn1s-2y date finale de banissement - banset/bs aaaa/mm/jj [hh:mm:ss] -- Change la date fin de banisemnt - banset/bs 0 -- Dé-banis un compte. - block -- Mets le status d'un compte à 5 (blocked by the GM Team) - check -- Vérifie un mot de passe d'un compte - create -- Crée un compte (avec email) - del -- Supprime un compte - email -- Modifie l'e-mail d'un compte - getcount -- Donne le nb de joueurs en ligne - gm [Niveau_GM] -- Modifie le niveau de GM d'un compte - id -- Donne l'id d'un compte - info -- Affiche les infos sur un compte - kami -- Envoi un message général (en jaune) - kamib -- Envoi un message général (en bleu) - language -- Change la langue d'affichage. - list/ls [Premier_id [Dernier_id] ] -- Affiche une liste de comptes - listBan/lsBan [Premier_id [Dernier_id] ]-- Affiche une liste de comptes - avec un statut ou bannis - listGM/lsGM [Premier_id [Dernier_id] ] -- Affiche une liste de comptes GM - listOK/lsOK [Premier_id [Dernier_id] ] -- Affiche une liste de comptes - sans status et non bannis - memo -- Modifie le memo d'un compte - name -- Donne le nom d'un compte - passwd -- Change le mot de passe d'un compte - quit/end/exit -- Fin du programme d'administation - reloadGM -- Recharger le fichier de config des GM - search -- Cherche des comptes - search -e/-r/--expr/--regex -- Cherche des comptes par REGEX - sex -- Modifie le sexe d'un compte - state -- Change le statut d'1 compte - timeadd/ta -- Ajout/soustrait du temps à la - exemple: ta moncompte +1m-2mn1s-2y limite de validité - timeset/ts aaaa/mm/jj [hh:mm:ss] -- Change la limite de validité - timeset/ts 0 -- limite de validité = illimitée - unban/unbanish -- Ote le banissement d'un compte - unblock -- Mets le status d'un compte à 0 (Compte ok) - version -- Donne la version du login-serveur - who -- Affiche les infos sur un compte -ENDOFAIDE - printf(" Note: Pour les noms de compte avec des espaces, tapez \"\" (ou ').\n"); - } - } else { - if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - printf "aide/help/?\n"; - printf " Display the description of the commands\n"; - printf "aide/help/? [command]\n"; - printf " Display the description of the specified command\n"; - } elsif ("help" =~ /^\Q$command/) { - printf "aide/help/?\n"; - printf " Display the description of the commands\n"; - printf "aide/help/? [command]\n"; - printf " Display the description of the specified command\n"; - } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? - printf "add \n"; - printf " Create an account with the default email (a\@a.com).\n"; - printf " Concerning the sex, only the first letter is used (F or M).\n"; - printf " The e-mail is set to a\@a.com (default e-mail). It's like to have no e-mail.\n"; - printf " When the password is omitted,\n"; - printf " the input is done without displaying of the pressed keys.\n"; - printf " add testname Male testpass\n"; - } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { - printf "ban/banish yyyy/mm/dd hh:mm:ss \n"; - printf " Changes the final date of a banishment of an account.\n"; - printf " The difference with banset is the position of the account name.\n"; - } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - printf "banadd \n"; - printf " Adds or substracts time from the final date of a banishment of an account.\n"; - printf " Modifier is done as follows:\n"; - printf " Adjustment value (-1, 1, +1, etc...)\n"; - printf " Modified element:\n"; - printf " a or y: year\n"; - printf " m: month\n"; - printf " j or d: day\n"; - printf " h: hour\n"; - printf " mn: minute\n"; - printf " s: second\n"; - printf " banadd testname +1m-2mn1s-6y\n"; - printf " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - printf " and 6 years at the same time.\n"; - printf "NOTE: If you modify the final date of a non-banished account,\n"; - printf " you fix the final date to (actual time +- adjustments)\n"; - } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? - printf "banset yyyy/mm/dd [hh:mm:ss]\n"; - printf " Changes the final date of a banishment of an account.\n"; - printf " Default time: 23:59:59\n"; - printf "banset 0\n"; - printf " Set a non-banished account (0 = unbanished).\n"; - } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { - printf "block \n"; - printf " Set state 5 (You have been blocked by the GM Team) to an account.\n"; - printf " Same command of state 5.\n"; - } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - printf "check \n"; - printf " Check the validity of a password for an account.\n"; - printf " NOTE: Server will never sends back a password.\n"; - printf " It's the only method you have to know if a password is correct.\n"; - printf " The other method is to have a ('physical') access to the accounts file.\n"; - } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? - printf "create \n"; - printf " Like the 'add' command, but with e-mail moreover.\n"; - printf " create testname Male my\@mail.com testpass\n"; - } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { - printf "del \n"; - printf " Remove an account.\n"; - printf " This order requires confirmation. After confirmation, the account is deleted.\n"; - } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? - printf "email \n"; - printf " Modify the e-mail of an account.\n"; - } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - printf "getcount\n"; - printf " Give the number of players online on all char-servers.\n"; - } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? - printf "gm [GM_level]\n"; - printf " Modify the GM level of an account.\n"; - printf " Default value remove GM level (GM level = 0).\n"; - printf " gm testname 80\n"; - } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - printf "id \n"; - printf " Give the id of an account.\n"; - } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? - printf "info \n"; - printf " Display complete information of an account.\n"; - } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? - printf "kami \n"; - printf " Sends a broadcast message on all map-server (in yellow).\n"; - } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? - printf "kamib \n"; - printf " Sends a broadcast message on all map-server (in blue).\n"; - } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? - printf("language \n"); - printf(" Change the language of displaying.\n"); - printf(" Possible languages: Français or English.\n"); - } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? - printf "list/ls [start_id [end_id]]\n"; - printf " Display a list of accounts.\n"; - printf " 'start_id', 'end_id': indicate end and start identifiers.\n"; - printf " Research by name is not possible with this command.\n"; - printf " list 10 9999999\n"; - } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? - printf "listBan/lsBan [start_id [end_id]]\n"; - printf " Like list/ls, but only for accounts with state or banished.\n"; - } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? - printf "listGM/lsGM [start_id [end_id]]\n"; - printf " Like list/ls, but only for GM accounts.\n"; - } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? - printf "listOK/lsOK [start_id [end_id]]\n"; - printf " Like list/ls, but only for accounts without state and not banished.\n"; - } elsif ("memo" =~ /^\Q$command/) { - printf "memo \n"; - printf " Modify the memo of an account.\n"; - printf " 'memo': it can have until 253 characters (with spaces or not).\n"; - } elsif ("name" =~ /^\Q$command/) { - printf "name \n"; - printf " Give the name of an account.\n"; - } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { - printf "passwd \n"; - printf " Change the password of an account.\n"; - printf " When new password is omitted,\n"; - printf " the input is done without displaying of the pressed keys.\n"; - } elsif ("reloadgm" =~ /^\Q$command/) { - printf "reloadGM\n"; - printf " Reload GM configuration file\n"; - } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - printf "search \n"; - printf " Seek accounts.\n"; - printf " Displays the accounts whose names correspond.\n"; - printf "search -r/-e/--expr/--regex \n"; - printf " Seek accounts by regular expression.\n"; - printf " Displays the accounts whose names correspond.\n"; - } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? - $command ne "se") { # check 2 letters command: 'search' or 'sex'? - printf "sex \n"; - printf " Modify the sex of an account.\n"; - printf " sex testname Male\n"; - } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? - printf "state \n"; - printf " Change the state of an account.\n"; - printf " 'new_state': state is the state of the packet 0x006a + 1.\n"; - printf " The possibilities are:\n"; - printf " 0 = Account ok\n"; - printf " 1 = Unregistered ID\n"; - printf " 2 = Incorrect Password\n"; - printf " 3 = This ID is expired\n"; - printf " 4 = Rejected from Server\n"; - printf " 5 = You have been blocked by the GM Team\n"; - printf " 6 = Your Game's EXE file is not the latest version\n"; - printf " 7 = You are Prohibited to log in until...\n"; - printf " 8 = Server is jammed due to over populated\n"; - printf " 9 = No MSG\n"; - printf " 100 = This ID has been totally erased\n"; - printf " all other values are 'No MSG', then use state 9 please.\n"; - printf " 'error_message_#7': message of the code error 6\n"; - printf " = Your are Prohibited to log in until... (packet 0x006a)\n"; - } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - printf "timeadd \n"; - printf " Adds or substracts time from the validity limit of an account.\n"; - printf " Modifier is done as follows:\n"; - printf " Adjustment value (-1, 1, +1, etc...)\n"; - printf " Modified element:\n"; - printf " a or y: year\n"; - printf " m: month\n"; - printf " j or d: day\n"; - printf " h: hour\n"; - printf " mn: minute\n"; - printf " s: second\n"; - printf " timeadd testname +1m-2mn1s-6y\n"; - printf " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - printf " and 6 years at the same time.\n"; - printf "NOTE: You can not modify a unlimited validity limit.\n"; - printf " If you want modify it, you want probably create a limited validity limit.\n"; - printf " So, at first, you must set the validity limit to a date/time.\n"; - } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? - printf "timeset yyyy/mm/dd [hh:mm:ss]\n"; - printf " Changes the validity limit of an account.\n"; - printf " Default time: 23:59:59\n"; - printf "timeset 0\n"; - printf " Gives an unlimited validity limit (0 = unlimited).\n"; - } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { - printf "unban/unbanish \n"; - printf " Remove the banishment of an account.\n"; - printf " This command works like banset 0.\n"; - } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { - printf "unblock \n"; - printf " Set state 0 (Account ok) to an account.\n"; - printf " This command works like state 0.\n"; - } elsif ("version" =~ /^\Q$command/) { - printf "version\n"; - printf " Display the version of the login-server.\n"; - } elsif ("who" =~ /^\Q$command/) { - printf "who \n"; - printf " Displays complete information of an account.\n"; - } elsif ("quit" =~ /^\Q$command/ || - (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n"; - printf "quit/end/exit\n"; - printf " End of the program of administration.\n"; - } else { - if ($receivedcommand ne "") { - printf "Unknown command [%s] for help. Displaying of all commands.\n", $receivedcommand; - } - print << "ENDOFHELP"; - aide/help/? -- Display this help - aide/help/? [command] -- Display the help of the command - add -- Create an account with default email - ban/banish yyyy/mm/dd hh:mm:ss -- Change final date of a ban - banadd/ba -- Add or substract time from the final - example: ba apple +1m-2mn1s-2y date of a banishment of an account - banset/bs yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban - banset/bs 0 -- Un-banish an account - block -- Set state 5 (blocked by the GM Team) to an account - check -- Check the validity of a password - create -- Create an account with email - del -- Remove an account - email -- Modify an email of an account - getcount -- Give the number of players online - gm [GM_level] -- Modify the GM level of an account - id -- Give the id of an account - info -- Display all information of an account - kami -- Sends a broadcast message (in yellow) - kamib -- Sends a broadcast message (in blue) - language -- Change the language of displaying. - list/ls [First_id [Last_id]] -- Display a list of accounts - listBan/lsBan [First_id [Last_id]] -- Display a list of accounts - with state or banished - listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts - listOK/lsOK [First_id [Last_id]] -- Display a list of accounts - without state and not banished - memo -- Modify the memo of an account - name -- Give the name of an account - passwd -- Change the password of an account - quit/end/exit -- End of the program of administation - reloadGM -- Reload GM configuration file - search -- Seek accounts - search -e/-r/--expr/--regex -- Seek accounts by regular-expression - sex -- Modify the sex of an account - state -- Change the state - timeadd/ta -- Add or substract time from the - example: ta apple +1m-2mn1s-2y validity limit of an account - timeset/ts yyyy/mm/dd [hh:mm:ss] -- Change the validify limit - timeset/ts 0 -- Give a unlimited validity limit - unban/unbanish -- Remove the banishment of an account - unblock -- Set state 0 (Account ok) to an account - version -- Gives the version of the login-server - who -- Display all information of an account -ENDOFHELP - printf(" Note: To use spaces in an account name, type \"\" (or ').\n"); - } - } - - return 0; -} -#-------------------------------------------------------------------------- - -# Sub-function: Displaying of the accounts list -sub listaccount() { - my($st, $ed, $listflag) = @_; - my($i); - my($n) = (0); - # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 - if ($defaultlanguage eq "F") { - print " id_compte GM nom_utilisateur sexe count statut\n"; - } else { - print "account_id GM user_name sex count state\n"; - } - print "-------------------------------------------------------------------------------\n"; - while(1) { - print $so pack("vV2", 0x7920, $st, $ed); - $so->flush(); - $buf = readso(4); - if (unpack("v", $buf) != 0x7921) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - exit(10); - } - my($len) = unpack("x2v", $buf); - last if ($len <= 4); - for($i = 4; $i < $len; $i += 38) { - my(@dat) = unpack("VCa24cVV", readso(38)); - $st = $dat[0] + 1; - if ($listflag == 0 || - ($listflag == 1 && $dat[1] > 0) || # check GM flag - ($listflag == 3 && $dat[5] != 0) || # check with state or banished - ($listflag == 4 && $dat[5] == 0)) { # check without state and not banished - printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0], - ($dat[1] == 0 ? " " : $dat[1]), - $dat[2], - ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]), - $dat[4], - (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), - "Unregistered ID", - "Incorrect Password", - "This ID is expired", - "Rejected from Server", - "Blocked by the GM Team", # You have been blocked by the GM Team - "Your EXE file is too old", # Your Game's EXE file is not the latest version - "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s - "Server is over populated", # Server is jammed due to over populated - "No MSG", - "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased - $n++; - } - } - } - if ($defaultlanguage eq "F") { - if ($n == 0) { - print "Aucun compte trouvé.\n"; - } elsif ($n == 1) { - print "1 compte trouvé.\n"; - } else { - print "$n comptes trouvés.\n"; - } - } else { - if ($n == 0) { - print "No account found.\n"; - } elsif ($n == 1) { - print "1 account found.\n"; - } else { - print "$n accounts found.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: add an account with the default e-mail -sub addaccount() { - my($userid, $sex, $passwd) = @_; - if ($userid eq "" || !defined($userid)) { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " add nomtest Male motdepassetest\n"; - } else { - print "Please input an account name.\n"; - print " add testname Male testpass\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } -# if ($userid =~ /[^A-Za-z0-9\@-_]/) { -# if ($defaultlanguage eq "F") { -# print "Caractère interdit trouvé dans le nom du compte ".$`."[${&}]${'}\n"; -# } else { -# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; -# } -# return 101; -# } - $sex = uc(substr($sex, 0, 1)); - if ($sex !~ /^[MF]$/) { - if ($defaultlanguage eq "F") { - print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; - } else { - print "Illegal gender [$sex]. Please input M or F.\n"; - } - return 103; - } - if ($passwd eq "") { - return 108 if (($passwd = typepasswd()) eq ""); - } - if (verify_password($passwd) == 0) { - return 104; - } - print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, ""); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7931) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 106; - } - $buf = readso(28); - if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec à la création du compte [$userid]. Un compte identique existe déjà.\n"; - } else { - print "Account [$userid] creation failed. Same account already exists.\n"; - } - return 107; - } else { - if ($defaultlanguage eq "F") { - printf "Compte [$userid] créé avec succès [id: %d].\n", unpack("V",$buf); - } else { - printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf); - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: add an account with an e-mail -sub createaccount() { - my($userid, $sex, $email, $passwd) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " create nomtest Male mon\@email.com motdepassetest\n"; - } else { - print "Please input an account name.\n"; - print " create testname Male my\@mail.com testpass\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } -# if ($userid =~ /[^A-Za-z0-9\@-_]/) { -# if ($defaultlanguage eq "F") { -# print "Caractère interdit trouvé dans le nom du compte ".$`."[${&}]${'}\n"; -# } else { -# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; -# } -# return 101; -# } - $sex = uc(substr($sex, 0, 1)); - if ($sex !~ /^[MF]$/) { - if ($defaultlanguage eq "F") { - print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; - } else { - print "Illegal gender [$sex]. Please input M or F.\n"; - } - return 103; - } - if (length($email) < 3) { - if ($defaultlanguage eq "F") { - print "Email trop courte [$email]. Entrez une e-mail valide svp.\n"; - } else { - print "Email is too short [$email]. Please input a valid e-mail.\n"; - } - return 109; - } - if (length($email) > 39) { - if ($defaultlanguage eq "F") { - print "Email trop longue [$email]. Entrez une e-mail de 39 caractères maximum svp.\n"; - } else { - print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n"; - } - return 109; - } - if (verify_email($email) == 0) { - if ($defaultlanguage eq "F") { - print "Email incorrecte [$email]. Entrez une e-mail valide svp.\n"; - } else { - print "Invalid email [$email]. Please input a valid e-mail.\n"; - } - return 109; - } - if ($passwd eq "") { - return 108 if (($passwd = typepasswd()) eq ""); - } - if (verify_password($passwd) == 0) { - return 104; - } - print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, $email); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7931) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 106; - } - $buf = readso(28); - if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec à la création du compte [$userid]. Un compte identique existe déjà.\n"; - } else { - print "Account [$userid] creation failed. Same account already exists.\n"; - } - return 107; - } else { - if ($defaultlanguage eq "F") { - printf "Compte [$userid] créé avec succès [id: %d].\n", unpack("V",$buf); - } else { - printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf); - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: deletion of an account -sub delaccount() { - my($userid) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " del nomtestasupprimer\n"; - } else { - print "Please input an account name.\n"; - print " del testnametodelete\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if ($defaultlanguage eq "F") { - print "** Etes-vous vraiment sûr de vouloir SUPPRIMER le compte [$userid]? (o/n) "; - } else { - print "** Are you really sure to DELETE account [$userid]? (y/n) "; - } - if (lc(substr(, 0, 1)) !~ /[oy]/) { - if ($defaultlanguage eq "F") { - print "Suppression annulée\n."; - } else { - print "Deletion canceled\n"; - } - return 121; - } - print $so pack("va24", 0x7932, $userid); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7933) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 122; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec de la suppression du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] deletion failed. Account doesn't exist.\n"; - } - return 123; - } else { - if ($defaultlanguage eq "F") { - print "Compte [$name][id: $id2] SUPPRIME avec succès.\n"; - } else { - print "Account [$name][id: $id2] is successfully DELETED.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: modification of a password -sub changepasswd() { - my($userid, $passwd) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " passwd nomtest nouveaumotdepasse\n"; - } else { - print "Please input an account name.\n"; - print " passwd testname newpassword\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if ($passwd eq "") { - return 134 if (($passwd = typepasswd()) eq ""); - } - if (verify_password($passwd) == 0) { - return 131; - } - print $so pack("va24a24", 0x7934, $userid,$passwd); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7935) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 132; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec de la modification du mot de passe du compte [$userid].\n"; - print "Le compte [$userid] n'existe pas.\n"; - } else { - print "Account [$userid] password changing failed.\n"; - print "Account [$userid] doesn't exist.\n"; - } - return 133; - } else { - if ($defaultlanguage eq "F") { - print "Modification du mot de passe du compte [$name][id: $id2] réussie.\n"; - } else { - print "Account [$name][id: $id2] password successfully changed.\n"; - } - } - return 130; -} - -#-------------------------------------------------------------------------- - -# Sub-function: modification of an account e-mail -sub changeemail() { - my($userid, $email) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " email testname nouveauemail\n"; - } else { - print "Please input an account name.\n"; - print " email testname newemail\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if (length($email) < 3) { - if ($defaultlanguage eq "F") { - print "Email trop courte [$email]. Entrez une e-mail valide svp.\n"; - } else { - print "Email is too short [$email]. Please input a valid e-mail.\n"; - } - return 109; - } - if (length($email) > 39) { - if ($defaultlanguage eq "F") { - print "Email trop longue [$email]. Entrez une e-mail de 39 caractères maximum svp.\n"; - } else { - print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n"; - } - return 109; - } - if (verify_email($email) == 0) { - if ($defaultlanguage eq "F") { - print "Email incorrect [$email]. Entrez une e-mail valide svp.\n"; - } else { - print "Invalid email [$email]. Please input a valid e-mail.\n"; - } - return 109; - } - print $so pack("va24a40", 0x7940, $userid, $email); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7941) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 162; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec de la modification de l'e-mail du compte [$userid].\n"; - print "Le compte [$userid] n'existe pas.\n"; - } else { - print "Account [$userid] e-mail changing failed.\n"; - print "Account [$userid] doesn't exist.\n"; - } - return 133; - } else { - if ($defaultlanguage eq "F") { - print "Modification de l'e-mail du compte [$name][id: $id2] réussie.\n"; - } else { - print "Account [$name][id: $id2] e-mail successfully changed.\n"; - } - } - return 160; -} - -#-------------------------------------------------------------------------- - -# Sub-function: search of accounts -sub searchaccount() { - my($p1, $p2) = @_; - my($exp) = (""); - if ($p1 eq "-e" || $p1 eq "-r" || $p1 eq "--regex" || $p1 eq "--expr") { - if ($p2 eq "") { - if ($defaultlanguage eq "F") { - print "Entrez une expression régulière ou utilisez 'ls' pour avoir tous les comptes.\n"; - } else { - print "Input a regular expression or use 'ls' to obtain all accounts.\n"; - } - return 141; - } - $exp = $p2; - } else { - if ($p1 eq "") { - if ($defaultlanguage eq "F") { - print "Entrez une chaîne ou utilisez 'ls' pour avoir tous les comptes.\n"; - } else { - print "Input a string or use 'ls' to obtain all accounts.\n"; - } - return 141; - } - my($c) = 0; - $exp = lc($p1); - $exp =~ s/([\@])/\\$1/g; - $c += $exp =~ s/([\-\[\]])/\\$1/g; - $c += $exp =~ s/([\*\?])/.$1/g; - $c += $exp =~ s/\\\[(.)\\\-(.)\\\]/[$1-$2]/g; - $exp = "^$exp\$" if $c; - } - if (eval{ "" =~ /$exp/; }, $@) { - if ($defaultlanguage eq "F") { - print "Expression régulière non reconnue.\n"; - } else { - print "Regular-Expression compiling failed.\n"; - } - return 141; - } - my($i); - my($n, $st) = (0, 0); - # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 - if ($defaultlanguage eq "F") { - print " id_compte GM nom_utilisateur sexe count statut\n"; - } else { - print "account_id GM user_name sex count state\n"; - } - print "-------------------------------------------------------------------------------\n"; - while(1) { - print $so pack("vV2", 0x7920, $st, 0); - $so->flush(); - $buf = readso(4); - if (unpack("v", $buf) != 0x7921) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - exit(10); - } - my($len) = unpack("x2v", $buf); - last if ($len <= 4); - for($i = 4; $i < $len; $i += 38) { - my(@dat) = unpack("VCa24cVV", readso(38)); - $st = $dat[0] + 1; - next if (lc($dat[2]) !~ /$exp/); - printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0], - ($dat[1] == 0 ? " " : $dat[1]), - $dat[2], - ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]), - $dat[4], - (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), - "Unregistered ID", - "Incorrect Password", - "This ID is expired", - "Rejected from Server", - "Blocked by the GM Team", # You have been blocked by the GM Team - "Your EXE file is too old", # Your Game's EXE file is not the latest version - "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s - "Server is over populated", # Server is jammed due to over populated - "No MSG", - "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased - $n++; - } - } - if ($defaultlanguage eq "F") { - if ($n == 0) { - print "Aucun compte trouvé.\n"; - } elsif ($n == 1) { - print "1 compte trouvé.\n"; - } else { - print "$n comptes trouvés.\n"; - } - } else { - if ($n == 0) { - print "No account found.\n"; - } elsif ($n == 1) { - print "1 account found.\n"; - } else { - print "$n accounts found.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: modify the sex of an account -sub changesex() { - my($userid, $sex) = @_; - if ($userid eq "" || !defined($userid)) { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " sex nomtest Male\n"; - } else { - print "Please input an account name.\n"; - print " sex testname Male\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } -# if ($userid =~ /[^A-Za-z0-9\@-_]/) { -# if ($defaultlanguage eq "F") { -# print "Caractère interdit trouvé dans le nom du compte ".$`."[${&}]${'}\n"; -# } else { -# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; -# } -# return 101; -# } - $sex = uc(substr($sex, 0, 1)); - if ($sex !~ /^[MF]$/) { - if ($defaultlanguage eq "F") { - print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; - } else { - print "Illegal gender [$sex]. Please input M or F.\n"; - } - return 103; - } - print $so pack("va24a1", 0x793c, $userid, $sex); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x793d) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec du changement du sexe du compte [$userid].\n"; - print "Le compte n'existe pas ou le sexe est déjà celui demandé.\n"; - } else { - print "Account [$userid] sex changing failed.\n"; - print "Account doesn't exist or the sex is already the good sex.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Sexe du compte [$name][id: $id2] changé avec succès.\n"; - } else { - print "Account [$name][id: $id2] sex successfully changed.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: modify the GM level of an account -sub changegmlevel() { - my($userid, $gm_level) = @_; - if ($userid eq "" || !defined($userid)) { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " gm nomtest 80\n"; - } else { - print "Please input an account name.\n"; - print " gm testname 80\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } -# if ($userid =~ /[^A-Za-z0-9\@-_]/) { -# if ($defaultlanguage eq "F") { -# print "Caractère interdit trouvé dans le nom du compte ".$`."[${&}]${'}\n"; -# } else { -# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; -# } -# return 101; -# } - $gm_level = int($gm_level); - if ($gm_level < 0 || $gm_level > 99) { - if ($defaultlanguage eq "F") { - print "Niveau de GM incorrect [$gm_level]. Entrez une valeur de 0 à 99 svp.\n"; - } else { - print "Illegal GM level [$gm_level]. Please input a value from 0 to 99.\n"; - } - return 103; - } - print $so pack("va24C", 0x793e, $userid, $gm_level); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x793f) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec du changement du niveau de GM du compte [$userid].\n"; - print "Le compte n'existe pas, le niveau de GM est déjà celui demandé,\n"; - print "ou il est impossible de modifier le fichier des comptes GM.\n"; - } else { - print "Account [$userid] GM level changing failed.\n"; - print "Account doesn't exist, the GM level is already the good GM level,\n"; - print "or it's impossible to modify the GM accounts file.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Niveau de GM du compte [$name][id: $id2] changé avec succès.\n"; - } else { - print "Account [$name][id: $id2] GM level successfully changed.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Modification of a state -sub changestate { - my($userid, $s, $error_message) = @_; - # Valid values: 0: ok, or value of the 0x006a packet + 1 - if ($s eq "" || (($s < 0 || $s > 9) && $s != 100)) { - if ($defaultlanguage eq "F") { - print "Entrez une des valeurs suivantes svp:\n"; - print " 0 = Compte ok 6 = Your Game's EXE file is not the latest version\n"; - } else { - print "Please input one of these values:\n"; - print " 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"; - } - print " 1 = Unregistered ID 7 = You are Prohibited to log in until %s\n"; - print " 2 = Incorrect Password 8 = Server is jammed due to over populated\n"; - print " 3 = This ID is expired 9 = No MSG\n"; - print " 4 = Rejected from Server 100 = This ID has been totally erased\n"; - print " 5 = You have been blocked by the GM Team\n"; - if ($defaultlanguage eq "F") { - print " state nomtest 5\n"; - print " state nomtest 7 fin de votre ban\n"; - print " block \n"; - print " unblock \n"; - } else { - print " state testname 5\n"; - print " state testname 7 end of your ban\n"; - print " block \n"; - print " unblock \n"; - } - return 151; - } - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " state nomtest 5\n"; - print " state nomtest 7 fin de votre ban\n"; - print " block \n"; - print " unblock \n"; - } else { - print "Please input an account name.\n"; - print " state testname 5\n"; - print " state testname 7 end of your ban\n"; - print " block \n"; - print " unblock \n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if ($s != 7) { - $error_message = "-"; - } else { - if (length($error_message) < 1) { - if ($defaultlanguage eq "F") { - print "Message d'erreur trop court. Entrez un message de 1-19 caractères.\n"; - } else { - print "Error message is too short. Please input a message of 1-19 bytes.\n"; - } - return 102; - } - if (length($error_message) > 19) { - if ($defaultlanguage eq "F") { - print "Message d'erreur trop long. Entrez un message de 1-19 caractères.\n"; - } else { - print "Error message is too long. Please input a message of 1-19 bytes.\n"; - } - return 102; - } - } - print $so pack("va24Va20", 0x7936, $userid, $s, $error_message); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7937) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(32); - my(@dat) = unpack("Va24V", $buf); - while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { - chop($dat[1]); - }; - if ($dat[0] != -1 && $dat[0] != 4294967295) { - if ($defaultlanguage eq "F") { - print "Statut du compte [$dat[1]][id: $dat[0]] changé avec succès en ["; - } else { - print "Account [$dat[1]][id: $dat[0]] state successfully changed in ["; - } - print ((($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), - "Unregistered ID", - "Incorrect Password", - "This ID is expired", - "Rejected from Server", - "You have been blocked by the GM Team", - "Your Game's EXE file is not the latest version", - "You are Prohibited to log in until %s", - "Server is jammed due to over populated", - "No MSG", - "This ID has been totally erased")[$dat[2] == 100 ? 10 : $dat[2]]); - print "].\n"; - } else { - if ($defaultlanguage eq "F") { - print "Echec du changement du statut du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] state changing failed. Account doesn't exist.\n"; - } - } -} - -#-------------------------------------------------------------------------- - -# Sub-function: Displaying of the number of online players -sub getlogincount { - # Request to the login-server - print $so pack("v", 0x7938); - $so->flush(); - - $buf = readso(4); - # Connection failed - if (unpack("v", $buf) != 0x7939) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - exit(3); - } - - # Get length of the received packet - my($len) = unpack("x2v", $buf) - 4; - - # Read information of the servers - if ($len < 1) { - if ($defaultlanguage eq "F") { - printf " Aucun serveur n'est connecté au login serveur.\n"; - } else { - printf " No server is connected to the login-server.\n"; - } - } else { - my(@slist) = (); - for(; $len > 0; $len -= 32) { - my($name, $count) = unpack("x6 a20 V", readso(32)); - $name = substr($name, 0, index($name, "\0")); - push @slist, [ $name, $count ]; - } - # Displaying of result - my($i); - if ($defaultlanguage eq "F") { - printf " Nombre de joueurs en ligne (serveur: nb):\n"; - } else { - printf " Number of online players (server: number).\n"; - } - foreach $i(@slist) { - printf " %-20s : %5d\n", $i->[0], $i->[1]; - } - } -} - -#-------------------------------------------------------------------------- - -# Sub-function: Modification of a memo field -sub changememo { - my($userid, $memo) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " memo nomtest nouveau memo\n"; - } else { - print "Please input an account name.\n"; - print " memo testname new memo\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if (length($memo) > 254) { - if ($defaultlanguage eq "F") { - print "Mémo trop long (".length($memo)." caractères).\n"; - print "Entrez un mémo de 254 caractères maximum svp.\n"; - } else { - print "Memo is too long (".length($memo)." characters).\n"; - print "Please input a memo of 254 bytes at the maximum.\n"; - } - return 102; - } - if (length($memo) == 0) { - print $so pack("va24v", 0x7942, $userid, 0); - } else { - print $so pack("va24va".length($memo), 0x7942, $userid, length($memo), $memo); - } - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7943) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec du changement du mémo du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] memo changing failed. Account doesn't exist.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Mémo du compte [$name][id: $id2] changé avec succès.\n"; - } else { - print "Account [$name][id: $id2] memo successfully changed.\n"; - } - } -} - -#-------------------------------------------------------------------------- - -# Sub-function: Request to obtain an account id -sub idaccount() { - my($userid) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " id nomtest\n"; - } else { - print "Please input an account name.\n"; - print " id testname\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - print $so pack("va24", 0x7944, $userid); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7945) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 122; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Impossible de trouver l'id du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Unabled to find the account [$userid] id. Account doesn't exist.\n"; - } - return 123; - } else { - if ($defaultlanguage eq "F") { - print "Le compte [$name] a pour id: $id2.\n"; - } else { - print "The account [$name] have the id: $id2.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Request to obtain an account name -sub nameaccount() { - my($id) = @_; - if ($id < 0) { - if ($defaultlanguage eq "F") { - print "Entrez un id ayant une valeur positive svp.\n"; - } else { - print "Please input a positive value for the id.\n"; - } - return 136; - } - print $so pack("vV", 0x7946, $id); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7947) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 122; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if (length($name) == 0 || $name eq "") { - if ($defaultlanguage eq "F") { - print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n"; - } else { - print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n"; - } - return 123; - } else { - if ($defaultlanguage eq "F") { - print "Le compte [id: $id2] a pour nom: $name.\n"; - } else { - print "The account [id: $id2] have the name: $name.\n"; - } - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Set a validity limit of an account -sub timesetaccount() { - my($userid, $date, $time) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print ": timeset aaaa/mm/jj [hh:mm:ss]\n"; - print " timeset 0 (0 = illimité)\n"; - printf " Heure par défaut [hh:mm:ss]: 23:59:59\n"; - } else { - print "Please input an account name.\n"; - print ": timeset yyyy/mm/dd [hh:mm:ss]\n"; - print " timeset 0 (0 = unlimited)\n"; - printf " Default time [hh:mm:ss]: 23:59:59\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - my($year, $month, $day) = split(/[.\-\/]/, $date); - my($hour, $minute, $second) = split(/:/, $time); - if ($time eq "") { - $hour = 23; - $minute = 59; - $second = 59; - } - my($timestamp); - if ($year eq "" || - ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) { - if ($defaultlanguage eq "F") { - print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; - } else { - print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; - } - return 102; - } - if ($year == 0) { - $timestamp = 0; - } else { - if ($year < 70) { - $year = $year + 100; - } - if ($year >= 1900) { - $year = $year - 1900; - } - if ($month < 1 || $month > 12) { - if ($defaultlanguage eq "F") { - print "Entrez un mois correct svp (entre 1 et 12).\n"; - } else { - print "Please give a correct value for the month (from 1 to 12).\n"; - } - return 102; - } - $month = $month - 1; - if ($day < 1 || $day > 31) { - if ($defaultlanguage eq "F") { - print "Entrez un jour correct svp (entre 1 et 31).\n"; - } else { - print "Please give a correct value for the day (from 1 to 31).\n"; - } - return 102; - } - if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) || - ($month == 1 && $day > 29)) { - if ($defaultlanguage eq "F") { - print "Entrez un jour correct en fonction du mois svp.\n"; - } else { - print "Please give a correct value for a day of this month.\n"; - } - return 102; - } - if ($hour < 0 || $hour > 23) { - if ($defaultlanguage eq "F") { - print "Entrez une heure correcte svp (entre 0 et 23).\n"; - } else { - print "Please give a correct value for the hour (from 0 to 23).\n"; - } - return 102; - } - if ($minute < 0 || $minute > 59) { - if ($defaultlanguage eq "F") { - print "Entrez des minutes correctes svp (entre 0 et 59).\n"; - } else { - print "Please give a correct value for the minutes (from 0 to 59).\n"; - } - return 102; - } - if ($second < 0 || $second > 59) { - if ($defaultlanguage eq "F") { - print "Entrez des secondes correctes svp (entre 0 et 59).\n"; - } else { - print "Please give a correct value for the seconds (from 0 to 59).\n"; - } - return 102; - } - $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification - if ($timestamp == undef) { - if ($defaultlanguage eq "F") { - print "Date incorrecte.\n"; - print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; - } else { - print "Invalid date.\n"; - print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; - } - return 102; - } - } - - print $so pack("va24V", 0x7948, $userid, $timestamp); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7949) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(32); - my(@dat) = unpack("Va24V", $buf); - while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { - chop($dat[1]); - }; - if ($dat[0] != -1 && $dat[0] != 4294967295) { - if ($defaultlanguage eq "F") { - print "Limite de validité du compte [$dat[1]][id: $dat[0]] changée avec succès ". - ($dat[2] == 0 ? "en [illimité].\n" : "pour être jusqu'au ".(POSIX::ctime($dat[2]))); - } else { - print "Validity Limit of the account [$dat[1]][id: $dat[0]] successfully changed ". - ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2]))); - } - # localtime($dat[2]) is also possible to display instead of POSIX::ctime. - } else { - if ($defaultlanguage eq "F") { - print "Echec du changement de la validité du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] validity limit changing failed. Account doesn't exist.\n"; - } - } - - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Add/substract time to the validity limit of an account -sub timeaddaccount() { - my($userid, $modif) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " timeadd nomtest +1m-2mn1s-6y\n"; - print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; - print " et 6 ans dans le même temps.\n"; - } else { - print "Please input an account name.\n"; - print " timeadd testname +1m-2mn1s-6y\n"; - print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - print " and 6 years at the same time.\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - my($year, $month, $day) = (0, 0 ,0); - my($hour, $minute, $second) = (0, 0 ,0); - - $modif = lc($modif); - while (length($modif) > 0) { - my($value) = int($modif); - if ($value == 0) { - $modif = substr($modif, 1); - } else { - if (substr($modif, 0, 1) =~ /[\-\+]/) { - $modif = substr($modif, 1); - } - while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) { - $modif = substr($modif, 1); - } - if (index($modif, "s") == 0) { - $second = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "mn") == 0) { - $minute = $value; - $modif = substr($modif, 2); - } elsif (index($modif, "h") == 0) { - $hour = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) { - $day = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "m") == 0) { - $month = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) { - $year = $value; - $modif = substr($modif, 1); - } else { - $modif = substr($modif, 1); - } - } - } - - if ($defaultlanguage eq "F") { - print " année: $year\n"; - print " mois: $month\n"; - print " jour: $day\n"; - print " heure: $hour\n"; - print " minute: $minute\n"; - print " seconde: $second\n"; - } else { - print " year: $year\n"; - print " month: $month\n"; - print " day: $day\n"; - print " hour: $hour\n"; - print " minute: $minute\n"; - print " second: $second\n"; - } - - if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) { - if ($defaultlanguage eq "F") { - print "Vous devez entrer un ajustement avec cette commande, svp:\n"; - print " Valeur d'ajustement (-1, 1, +1, etc...)\n"; - print " Element modifié:\n"; - print " a ou y: année\n"; - print " m: mois\n"; - print " j ou d: jour\n"; - print " h: heure\n"; - print " mn: minute\n"; - print " s: seconde\n"; - print " timeadd nomtest +1m-2mn1s-6y\n"; - print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; - print " et 6 ans dans le même temps.\n"; - } else { - print "Please give an adjustment with this command:\n"; - print " Adjustment value (-1, 1, +1, etc...)\n"; - print " Modified element:\n"; - print " a or y: year\n"; - print " m: month\n"; - print " j or d: day\n"; - print " h: hour\n"; - print " mn: minute\n"; - print " s: second\n"; - print " timeadd testname +1m-2mn1s-6y\n"; - print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - print " and 6 years at the same time.\n"; - } - return 137; - } - if ($year > 127 || $year < -127) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement d'années correct (de -127 à 127), svp.\n"; - } else { - print "Please give a correct adjustment for the years (from -127 to 127).\n"; - } - return 137; - } - if ($month > 255 || $month < -255) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de mois correct (de -255 à 255), svp.\n"; - } else { - print "Please give a correct adjustment for the months (from -255 to 255).\n"; - } - return 137; - } - if ($day > 32767 || $day < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de jours correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the days (from -32767 to 32767).\n"; - } - return 137; - } - if ($hour > 32767 || $hour < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement d'heures correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the hours (from -32767 to 32767).\n"; - } - return 137; - } - if ($minute > 32767 || $minute < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de minutes correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n"; - } - return 137; - } - if ($second > 32767 || $second < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de secondes correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n"; - } - return 137; - } - - print $so pack("va24vvvvvv", 0x7950, $userid, $year, $month, $day, $hour, $minute, $second); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x7951) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(32); - my(@dat) = unpack("Va24V", $buf); - while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { - chop($dat[1]); - }; - if ($dat[0] == -1 || $dat[0] == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec du changement de la validité du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] validity limit changing failed. Account doesn't exist.\n"; - } - } elsif ($dat[2] == 0) { - if ($defaultlanguage eq "F") { - print "Limite de validité du compte [$dat[1]][id: $dat[0]] inchangée.\n"; - print "Le compte a une validité illimitée ou\n"; - print "la modification est impossible avec les ajustements demandés.\n"; - } else { - print "Validity limit of the account [$dat[1]][id: $dat[0]] unchanged.\n"; - print "The account have an unlimited validity limit or\n"; - print "the changing is impossible with the proposed adjustments.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Limite de validité du compte [$dat[1]][id: $dat[0]] changée avec succès ". - ($dat[2] == 0 ? "en [illimité].\n" : "pour être jusqu'au ".(POSIX::ctime($dat[2]))); - } else { - print "Validity limit of the account [$dat[1]][id: $dat[0]] successfully changed ". - ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2]))); - } - # localtime($dat[2]) is also possible to display instead of POSIX::ctime. - } - - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Set the final date of a banishment of an account -sub bansetaccount() { - my($userid, $date, $time) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print ": banset aaaa/mm/jj [hh:mm:ss]\n"; - print " banset 0 (0 = dé-bani)\n"; - print " ban/banish aaaa/mm/jj hh:mm:ss \n"; - print " unban/unbanish \n"; - printf " Heure par défaut [hh:mm:ss]: 23:59:59\n"; - } else { - print "Please input an account name.\n"; - print ": banset yyyy/mm/dd [hh:mm:ss]\n"; - print " banset 0 (0 = un-banished)\n"; - print " ban/banish yyyy/mm/dd hh:mm:ss \n"; - print " unban/unbanish \n"; - printf " Default time [hh:mm:ss]: 23:59:59\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - my($year, $month, $day) = split(/[.\-\/]/, $date); - my($hour, $minute, $second) = split(/:/, $time); - if ($time eq "") { - $hour = 23; - $minute = 59; - $second = 59; - } - my($timestamp); - if ($year eq "" || - ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) { - if ($defaultlanguage eq "F") { - print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; - } else { - print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; - } - return 102; - } - if ($year == 0) { - $timestamp = 0; - } else { - if ($year < 70) { - $year = $year + 100; - } - if ($year >= 1900) { - $year = $year - 1900; - } - if ($month < 1 || $month > 12) { - if ($defaultlanguage eq "F") { - print "Entrez un mois correct svp (entre 1 et 12).\n"; - } else { - print "Please give a correct value for the month (from 1 to 12).\n"; - } - return 102; - } - $month = $month - 1; - if ($day < 1 || $day > 31) { - if ($defaultlanguage eq "F") { - print "Entrez un jour correct svp (entre 1 et 31).\n"; - } else { - print "Please give a correct value for the day (from 1 to 31).\n"; - } - return 102; - } - if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) || - ($month == 1 && $day > 29)) { - if ($defaultlanguage eq "F") { - print "Entrez un jour correct en fonction du mois svp.\n"; - } else { - print "Please give a correct value for a day of this month.\n"; - } - return 102; - } - if ($hour < 0 || $hour > 23) { - if ($defaultlanguage eq "F") { - print "Entrez une heure correcte svp (entre 0 et 23).\n"; - } else { - print "Please give a correct value for the hour (from 0 to 23).\n"; - } - return 102; - } - if ($minute < 0 || $minute > 59) { - if ($defaultlanguage eq "F") { - print "Entrez des minutes correctes svp (entre 0 et 59).\n"; - } else { - print "Please give a correct value for the minutes (from 0 to 59).\n"; - } - return 102; - } - if ($second < 0 || $second > 59) { - if ($defaultlanguage eq "F") { - print "Entrez des secondes correctes svp (entre 0 et 59).\n"; - } else { - print "Please give a correct value for the seconds (from 0 to 59).\n"; - } - return 102; - } - $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification - if ($timestamp == undef) { - if ($defaultlanguage eq "F") { - print "Date incorrecte.\n"; - print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; - } else { - print "Invalid date.\n"; - print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; - } - return 102; - } - } - - print $so pack("va24V", 0x794a, $userid, $timestamp); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x794b) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(32); - my(@dat) = unpack("Va24V", $buf); - while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { - chop($dat[1]); - }; - if ($dat[0] != -1 && $dat[0] != 4294967295) { - if ($defaultlanguage eq "F") { - print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] changée avec succès ". - ($dat[2] == 0 ? "en [dé-bannie].\n" : "pour être jusqu'au ".(POSIX::ctime($dat[2]))); - } else { - print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ". - ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2]))); - } - # localtime($dat[2]) is also possible to display instead of POSIX::ctime. - } else { - if ($defaultlanguage eq "F") { - print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n"; - } - } - - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Add/substract time to the final date of a banishment of an account -sub banaddaccount() { - my($userid, $modif) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " banadd nomtest +1m-2mn1s-6y\n"; - print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; - print " et 6 ans dans le même temps.\n"; - } else { - print "Please input an account name.\n"; - print " banadd testname +1m-2mn1s-6y\n"; - print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - print " and 6 years at the same time.\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - my($year, $month, $day) = (0, 0 ,0); - my($hour, $minute, $second) = (0, 0 ,0); - - $modif = lc($modif); - while (length($modif) > 0) { - my($value) = int($modif); - if ($value == 0) { - $modif = substr($modif, 1); - } else { - if (substr($modif, 0, 1) =~ /[\-\+]/) { - $modif = substr($modif, 1); - } - while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) { - $modif = substr($modif, 1); - } - if (index($modif, "s") == 0) { - $second = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "mn") == 0) { - $minute = $value; - $modif = substr($modif, 2); - } elsif (index($modif, "h") == 0) { - $hour = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) { - $day = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "m") == 0) { - $month = $value; - $modif = substr($modif, 1); - } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) { - $year = $value; - $modif = substr($modif, 1); - } else { - $modif = substr($modif, 1); - } - } - } - - if ($defaultlanguage eq "F") { - print " année: $year\n"; - print " mois: $month\n"; - print " jour: $day\n"; - print " heure: $hour\n"; - print " minute: $minute\n"; - print " seconde: $second\n"; - } else { - print " year: $year\n"; - print " month: $month\n"; - print " day: $day\n"; - print " hour: $hour\n"; - print " minute: $minute\n"; - print " second: $second\n"; - } - - if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) { - if ($defaultlanguage eq "F") { - print "Vous devez entrer un ajustement avec cette commande, svp:\n"; - print " Valeur d'ajustement (-1, 1, +1, etc...)\n"; - print " Element modifié:\n"; - print " a ou y: année\n"; - print " m: mois\n"; - print " j ou d: jour\n"; - print " h: heure\n"; - print " mn: minute\n"; - print " s: seconde\n"; - print " banadd nomtest +1m-2mn1s-6y\n"; - print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; - print " et 6 ans dans le même temps.\n"; - } else { - print "Please give an adjustment with this command:\n"; - print " Adjustment value (-1, 1, +1, etc...)\n"; - print " Modified element:\n"; - print " a or y: year\n"; - print " m: month\n"; - print " j or d: day\n"; - print " h: hour\n"; - print " mn: minute\n"; - print " s: second\n"; - print " banadd testname +1m-2mn1s-6y\n"; - print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; - print " and 6 years at the same time.\n"; - } - return 137; - } - if ($year > 127 || $year < -127) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement d'années correct (de -127 à 127), svp.\n"; - } else { - print "Please give a correct adjustment for the years (from -127 to 127).\n"; - } - return 137; - } - if ($month > 255 || $month < -255) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de mois correct (de -255 à 255), svp.\n"; - } else { - print "Please give a correct adjustment for the months (from -255 to 255).\n"; - } - return 137; - } - if ($day > 32767 || $day < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de jours correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the days (from -32767 to 32767).\n"; - } - return 137; - } - if ($hour > 32767 || $hour < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement d'heures correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the hours (from -32767 to 32767).\n"; - } - return 137; - } - if ($minute > 32767 || $minute < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de minutes correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n"; - } - return 137; - } - if ($second > 32767 || $second < -32767) { - if ($defaultlanguage eq "F") { - print "Entrez un ajustement de secondes correct (de -32767 à 32767), svp.\n"; - } else { - print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n"; - } - return 137; - } - - print $so pack("va24vvvvvv", 0x794c, $userid, $year, $month, $day, $hour, $minute, $second); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x794d) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(32); - my(@dat) = unpack("Va24V", $buf); - while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { - chop($dat[1]); - }; - if ($dat[0] == -1 || $dat[0] == 4294967295) { - if ($defaultlanguage eq "F") { - print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] changée avec succès ". - ($dat[2] == 0 ? "en [dé-bannie].\n" : "pour être jusqu'au ".(POSIX::ctime($dat[2]))); - } else { - print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ". - ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2]))); - } - # localtime($dat[2]) is also possible to display instead of POSIX::ctime. - } - - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Request to displaying information about an account (by its name) -sub whoaccount() { - my($userid) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " who nomtest\n"; - } else { - print "Please input an account name.\n"; - print " who testname\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - - print $so pack("va24", 0x7952, $userid); - $so->flush(); - - $buf = readso(2); - if (unpack("v", $buf) != 0x7953) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 122; - } - my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148)); - my($memo) = ""; - if ($memo_size > 0) { - $memo = unpack("a".$memo_size, readso($memo_size)); - } - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) { - chop($error_message); - }; - while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) { - chop($last_login); - }; - while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) { - chop($last_ip); - }; - while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) { - chop($email); - }; - while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) { - chop($memo); - }; - - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Impossible de trouver le compte [$userid]. Le compte n'existe pas.\n"; - } else { - print "Unabled to find the account [$userid]. Account doesn't exist.\n"; - } - return 123; - } else { - if ($defaultlanguage eq "F") { - print "Le compte [$userid] a les caractéristiques suivantes:\n"; - } else { - print "The account [$userid] is set with:\n"; - } - if ($GM_level == 0) { - print " Id: $id2 (non-GM)\n"; - } else { - if ($defaultlanguage eq "F") { - print " Id: $id2 (GM niveau $GM_level)\n"; - } else { - print " Id: $id2 (GM level $GM_level)\n"; - } - } - if ($defaultlanguage eq "F") { - print " Nom: '$name'\n"; - print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n"; - } else { - print " Name: '$name'\n"; - print " Sex: ".("Female", "Male", "Server")[$sex]."\n"; - } - print " E-mail: $email\n"; - if ($status == 7) { - print " Statut: 7 [You are Prohibited to log in until $error_message]\n"; - } else { - print " Statut: $status [".( - ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), - "Unregistered ID", - "Incorrect Password", - "This ID is expired", - "Rejected from Server", - "You have been blocked by the GM Team", - "Your Game's EXE file is not the latest version", - "You are Prohibited to log in until %s", - "Server is jammed due to over populated", - "No MSG", - "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n"; - } - if ($defaultlanguage eq "F") { - print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date))); - print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n"; - print " Dernière connexion le: $last_login (ip: $last_ip)\n"; - print " Limite de validité: ".($validite == 0 ? "illimité.\n" : "jusqu'au ".(POSIX::ctime($validite))); - } else { - print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date))); - print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n"; - print " Last connection at: $last_login (ip: $last_ip)\n"; - print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite))); - } - print " Memo: '$memo'\n"; - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Request to displaying information about an account (by its id) -sub infoaccount() { - my($id) = @_; - if ($id < 0) { - if ($defaultlanguage eq "F") { - print "Entrez un id ayant une valeur positive svp.\n"; - } else { - print "Please input a positive value for the id.\n"; - } - return 136; - } - - print $so pack("vV", 0x7954, $id); - $so->flush(); - - $buf = readso(2); - if (unpack("v", $buf) != 0x7953) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 122; - } - my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148)); - my($memo) = ""; - if ($memo_size > 0) { - $memo = unpack("a".$memo_size, readso($memo_size)); - } - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) { - chop($error_message); - }; - while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) { - chop($last_login); - }; - while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) { - chop($last_ip); - }; - while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) { - chop($email); - }; - while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) { - chop($memo); - }; - - if (length($name) == 0 || $name eq "") { - if ($defaultlanguage eq "F") { - print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n"; - } else { - print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n"; - } - return 123; - } else { - if ($defaultlanguage eq "F") { - print "Le compte [id: $id2] a les caractéristiques suivantes:\n"; - } else { - print "The account [id: $id2] is set with:\n"; - } - if ($GM_level == 0) { - print " Id: $id2 (non-GM)\n"; - } else { - if ($defaultlanguage eq "F") { - print " Id: $id2 (GM niveau $GM_level)\n"; - } else { - print " Id: $id2 (GM level $GM_level)\n"; - } - } - if ($defaultlanguage eq "F") { - print " Nom: '$name'\n"; - print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n"; - } else { - print " Name: '$name'\n"; - print " Sex: ".("Female", "Male", "Server")[$sex]."\n"; - } - print " E-mail: $email\n"; - if ($status == 7) { - print " Statut: 7 [You are Prohibited to log in until $error_message]\n"; - } else { - print " Statut: $status [".( - ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), - "Unregistered ID", - "Incorrect Password", - "This ID is expired", - "Rejected from Server", - "You have been blocked by the GM Team", - "Your Game's EXE file is not the latest version", - "You are Prohibited to log in until %s", - "Server is jammed due to over populated", - "No MSG", - "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n"; - } - if ($defaultlanguage eq "F") { - print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date))); - print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n"; - print " Dernière connexion le: $last_login (ip: $last_ip)\n"; - print " Limite de validité: ".($validite == 0 ? "illimité.\n" : "jusqu'au ".(POSIX::ctime($validite))); - } else { - print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date))); - print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n"; - print " Last connection at: $last_login (ip: $last_ip)\n"; - print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite))); - } - print " Memo: '$memo'\n"; - } - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Check the validity of a password -# (Note: never send back a password with login-server!! security of passwords) -sub checkaccount() { - my($userid, $passwd) = @_; - if ($userid eq "") { - if ($defaultlanguage eq "F") { - print "Entrez un nom de compte svp.\n"; - print " check testname motdepasse\n"; - } else { - print "Please input an account name.\n"; - print " check testname password\n"; - } - return 136; - } - if (verify_accountname($userid) == 0) { - return 102; - } - if ($passwd eq "") { - return 134 if (($passwd = typepasswd()) eq ""); - } - if (verify_password($passwd) == 0) { - return 131; - } - print $so pack("va24a24", 0x793a, $userid,$passwd); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x793b) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 132; - } - $buf = readso(28); - my($id2, $name) = unpack("Va24", $buf); - while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { - chop($name); - }; - if ($id2 == -1 || $id2 == 4294967295) { - if ($defaultlanguage eq "F") { - print "Le compte [$userid] n'existe pas ou le mot de passe est incorrect.\n"; - } else { - print "The account [$userid] doesn't exist or the password is incorrect.\n"; - } - return 133; - } else { - if ($defaultlanguage eq "F") { - print "Le mot de passe donné correspond bien au compte [$name][id: $id2].\n"; - } else { - print "The proposed password is correct for the account [$name][id: $id2].\n"; - } - } - return 130; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Request to login-server to reload GM configuration file -sub reloadGM() { - print $so pack("v", 0x7955); - $so->flush(); - if ($defaultlanguage eq "F") { - print "Demande de recharger le fichier de configuration des GM envoyée.\n"; - print "Vérifiez les comptes GM actuels (après rechargement):\n"; - } else { - print "Request to reload the GM configuration file sended.\n"; - print "Check the actual GM accounts (after reloading):\n"; - } - &listaccount(0, 0, 1); # 1: to list only GM - return 180; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Send a broadcast message -sub sendbroadcast() { - my($type, $message) = @_; - if ($message eq "" || length($message) == 0) { - if ($defaultlanguage eq "F") { - print "Entrez un message svp.\n"; - if ($type == 0) { - print " kami un message\n"; - } else { - print " kamib un message\n"; - } - } else { - print "Please input a message.\n"; - if ($type == 0) { - print " kami a message\n"; - } else { - print " kamib a message\n"; - } - } - return 136; - } - - print $so pack("vvVa".length($message), 0x794e, $type, length($message), $message); - $so->flush(); - $buf = readso(2); - if (unpack("v", $buf) != 0x794f) { - if ($defaultlanguage eq "F") { - print "Problème de connexion au serveur (réponse incorrecte).\n"; - } else { - print "Connection error to the server (incorrect answer).\n"; - } - return 152; - } - $buf = readso(2); - my($answer) = unpack("v", $buf); - if ($answer == -1 || $answer == 65535) { - if ($defaultlanguage eq "F") { - print "Echec de l'envoi du message. Aucun server de char en ligne.\n"; - } else { - print "Message sending failed. No online char-server.\n"; - } - } else { - if ($defaultlanguage eq "F") { - print "Message transmis au server de logins avec succès.\n"; - } else { - print "Message successfully sended to login-server.\n"; - } - } -} - -#-------------------------------------------------------------------------- - -# Sub-function: Change language of displaying -sub changelanguage() { - my($language) = @_; - if ($language eq "" || length($language) == 0) { - if ($defaultlanguage == 'F') { - printf("Entrez une langue svp.\n"); - printf(" language english\n"); - printf(" language français\n"); - } else { - printf("Please input a language.\n"); - printf(" language english\n"); - printf(" language français\n"); - } - return 136; - } - - $language = uc(substr($language, 0, 1)); - if ($language =~ /^[EF]$/) { - $defaultlanguage = $language; - if ($defaultlanguage == 'F') { - printf("Changement de la langue d'affichage en Français.\n"); - } else { - printf("Displaying language changed to English.\n"); - } - } else { - if ($defaultlanguage == 'F') { - printf("Langue non paramétrée (langues possibles: 'Français' ou 'English').\n"); - } else { - printf("Undefined language (possible languages: Français or English).\n"); - } - } - - return 0; -} - -#-------------------------------------------------------------------------- - -# Sub-function: sending 'end of connection' packet -sub quit() { - print $so pack("v", 0x7532); - $so->flush(); -} - -#-------------------------------------------------------------------------- - -# Sub-function: Get datas from the socket -sub readso() { - my($len) = shift; - my($buf); - if (read($so, $buf, $len) < $len) { - if ($defaultlanguage eq "F") { - print "Erreur de lecture sur la Socket.\n"; - } else { - print "Socket read error.\n"; - } - exit(3); - } - return $buf; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Input of a password -sub typepasswd { - my($passwd1, $passwd2); - cbreak(); - if ($defaultlanguage eq "F") { - print "Entrez le mot de passe > "; $passwd1 = ; chomp($passwd1); print "\n"; - print "Ré-entrez le mot de passe > "; $passwd2 = ; chomp($passwd2); print "\n"; - } else { - print "Type the password > "; $passwd1 = ; chomp($passwd1); print "\n"; - print "Verify the password > "; $passwd2 = ; chomp($passwd2); print "\n"; - } - cooked(); - if ($passwd1 ne $passwd2) { - if ($defaultlanguage eq "F") { - print "Erreur de vérification du mot de passe: Saisissez le même mot de passe svp.\n"; - } else { - print "Password verification failed. Please input same password.\n"; - } - return ""; - } - return $passwd1; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Return ordonal text of a number -sub makeordinal { - my($c) = shift; - if ($defaultlanguage eq "F") { - if ($c < 1) { - return $c; - } - return $c.("er", "ème")[$c == 1 ? 0 : 1]; - } else { - if ($c % 10 < 4 && $c % 10 != 0 && ($c < 10 || $c > 20)) { - return $c.("st","nd","rd")[$c % 10 - 1]; - } - return $c."th"; - } -} - -#-------------------------------------------------------------------------- - -# Sub-function: Test of the validity of an account name (return 0 if incorrect, and 1 if ok) -sub verify_accountname { - my($account_name) = @_; # Get the account_name - if ($account_name =~ /[\x00-\x1f]/) { # remove control char - my($c) = length($`) + 1; - if ($defaultlanguage eq "F") { - print "Caractère interdit trouvé dans le nom du compte (".makeordinal($c)." caractère).\n"; - } else { - print "Illegal character found in the account name (".makeordinal($c)." character).\n"; - } - return 0; - } - if (length($account_name) < 4) { - if ($defaultlanguage eq "F") { - print "Nom du compte trop court. Entrez un nom de compte de 4-23 caractères.\n"; - } else { - print "Account name is too short. Please input an account name of 4-23 bytes.\n"; - } - return 0; - } - if (length($account_name) > 23) { - if ($defaultlanguage eq "F") { - print "Nom du compte trop long. Entrez un nom de compte de 4-23 caractères.\n"; - } else { - print "Account name is too long. Please input an account name of 4-23 bytes.\n"; - } - return 0; - } - return 1; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Test of the validity of password (return 0 if incorrect, and 1 if ok) -sub verify_password { - my($password) = @_; # Get the password - if ($password =~ /[\x00-\x1f]/) { - my($c) = length($`) + 1; - if ($defaultlanguage eq "F") { - print "Caractère interdit trouvé dans le mot de passe (".makeordinal($c)." caractère).\n"; - } else { - print "Illegal character found in the password (".makeordinal($c)." character).\n"; - } - return 0; - } - if (length($password) < 4) { - if ($defaultlanguage eq "F") { - print "Mot de passe trop court. Entrez un mot de passe de 4-23 caractères.\n"; - } else { - print "Password is too short. Please input a password of 4-23 bytes.\n"; - } - return 0; - } - if (length($password) > 23) { - if ($defaultlanguage eq "F") { - print "Mot de passe trop long. Entrez un mot de passe de 4-23 caractères.\n"; - } else { - print "Password is too long. Please input a password of 4-23 bytes.\n"; - } - return 0; - } - return 1; -} - -#-------------------------------------------------------------------------- - -# Sub-function: Test of the validity of an e-mail (return 0 if incorrect, and 1 if ok) -sub verify_email { - my($email) = @_; # Get the e-mail - # To ignore a '.' before the @ (wanadoo, a provider, do that) - $email =~ s/\.\@/\@/; - # If the e-mail is void, it's not correct -> return 0 - if ($email eq '') { - return(0); - } - # If the e-mail have no "@", it's not correct -> return 0 - if ($email !~ /\@/) { - return(0); - } - # If the e-mail have a ",", a space, a tab or a ";", it's not correct -> return 0 - if ($email =~ /[\,|\s|\;]/) { - return(0) - }; - # IF - # (the e-mail contains 2 "@", or ".." or "@." or starts or finishes by a ".") - # OR IF - # (the e-mail doesn't contain "@localhost" AND - # - it doesn't contain characters followed by "@" itself followed by letters itself followed by "." and 2 or more letters - # - or an IP address) - # -> so, it's not good ! (finish !) - if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ || - ($email !~ /^.+\@localhost$/ && - $email !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?$/)) { - return(0); # non-valid email - } else { - # If not, the e-email address is correct - return(1); # valid email - } -} \ No newline at end of file diff --git a/vcproj-6/char-server_sql.dsp b/vcproj-6/char-server_sql.dsp index 25ef235af..0286dbd8f 100644 --- a/vcproj-6/char-server_sql.dsp +++ b/vcproj-6/char-server_sql.dsp @@ -1,270 +1,270 @@ -# Microsoft Developer Studio Project File - Name="char_sql" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=char_sql - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "char-server_sql.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "char-server_sql.mak" CFG="char_sql - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "char_sql - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /I "..\src\mysql" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/char_sql/char-server_sql.pch" /YX /Fo"tmp/char_sql/" /Fd"tmp/char_sql/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 wsock32.lib libmysql.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/char_sql/char-server_sql.pdb" /machine:I386 /out:"../char-server_sql.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "char_sql - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "char_sql" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\char_sql\char.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\char.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_auction.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_auction.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_guild.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_guild.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_homun.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_homun.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_mail.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_mail.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_party.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_party.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_pet.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_pet.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_storage.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_storage.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_quest.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\int_quest.h -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\inter.c -# End Source File -# Begin Source File - -SOURCE=..\src\char_sql\inter.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="char_sql" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=char_sql - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "char-server_sql.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "char-server_sql.mak" CFG="char_sql - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "char_sql - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/char_sql/char-server_sql.pch" /YX /Fo"tmp/char_sql/" /Fd"tmp/char_sql/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 wsock32.lib libmysql.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/char_sql/char-server_sql.pdb" /machine:I386 /out:"../char-server_sql.exe" /libpath:"..\3rdparty\mysql\lib" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "char_sql - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "char_sql" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\char_sql\char.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\char.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_auction.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_auction.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_guild.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_guild.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_homun.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_homun.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_mail.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_mail.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_party.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_party.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_pet.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_pet.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_quest.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_quest.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_storage.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\int_storage.h +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\inter.c +# End Source File +# Begin Source File + +SOURCE=..\src\char_sql\inter.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-6/char-server_txt.dsp b/vcproj-6/char-server_txt.dsp index d1945db25..9fa2e55dc 100644 --- a/vcproj-6/char-server_txt.dsp +++ b/vcproj-6/char-server_txt.dsp @@ -1,246 +1,246 @@ -# Microsoft Developer Studio Project File - Name="char_txt" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=char_txt - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "char-server_txt.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "char-server_txt.mak" CFG="char_txt - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "char_txt - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "TXT_ONLY" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/char_txt/char-server_txt.pch" /YX /Fo"tmp/char_txt/" /Fd"tmp/char_txt/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 wsock32.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/char-txt/char-server_txt.pdb" /machine:I386 /out:"../char-server_txt.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "char_txt - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "char" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\char\char.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\char.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_guild.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_guild.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_homun.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_homun.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_party.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_party.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_pet.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_pet.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_status.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_status.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_storage.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\int_storage.h -# End Source File -# Begin Source File - -SOURCE=..\src\char\inter.c -# End Source File -# Begin Source File - -SOURCE=..\src\char\inter.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="char_txt" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=char_txt - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "char-server_txt.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "char-server_txt.mak" CFG="char_txt - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "char_txt - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "TXT_ONLY" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/char_txt/char-server_txt.pch" /YX /Fo"tmp/char_txt/" /Fd"tmp/char_txt/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 wsock32.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/char-txt/char-server_txt.pdb" /machine:I386 /out:"../char-server_txt.exe" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "char_txt - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "char" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\char\char.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\char.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_guild.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_guild.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_homun.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_homun.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_party.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_party.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_pet.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_pet.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_status.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_status.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_storage.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\int_storage.h +# End Source File +# Begin Source File + +SOURCE=..\src\char\inter.c +# End Source File +# Begin Source File + +SOURCE=..\src\char\inter.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-6/login-server_sql.dsp b/vcproj-6/login-server_sql.dsp index 07f853727..561976f4e 100644 --- a/vcproj-6/login-server_sql.dsp +++ b/vcproj-6/login-server_sql.dsp @@ -1,210 +1,238 @@ -# Microsoft Developer Studio Project File - Name="login_sql" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=login_sql - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "login-server_sql.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "login-server_sql.mak" CFG="login_sql - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "login_sql - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /I "..\src\mysql" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D PACKETVER=6 /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/login_sql/login-server_sql.pch" /YX /Fo"tmp/login_sql/" /Fd"tmp/login_sql/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 WSOCK32.lib libmysql.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/login_sql/login-server_sql.pdb" /machine:I386 /out:"../login-server_sql.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "login_sql - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\md5calc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\md5calc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\svnversion.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "login_sql" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\login_sql\login.c -# End Source File -# Begin Source File - -SOURCE=..\src\login_sql\login.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="login_sql" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=login_sql - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "login-server_sql.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "login-server_sql.mak" CFG="login_sql - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "login_sql - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D PACKETVER=6 /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_SQL" /Fp"tmp/login_sql/login-server_sql.pch" /YX /Fo"tmp/login_sql/" /Fd"tmp/login_sql/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 WSOCK32.lib libmysql.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/login_sql/login-server_sql.pdb" /machine:I386 /out:"../login-server_sql.exe" /libpath:"..\3rdparty\mysql\lib" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "login_sql - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\md5calc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\md5calc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\svnversion.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "login_sql" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\login\account.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\account_sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\admin.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\ipban.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\ipban_sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\login.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\login.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\loginlog.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\loginlog_sql.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-6/login-server_txt.dsp b/vcproj-6/login-server_txt.dsp index c6b39002f..8f93aaa7b 100644 --- a/vcproj-6/login-server_txt.dsp +++ b/vcproj-6/login-server_txt.dsp @@ -1,202 +1,230 @@ -# Microsoft Developer Studio Project File - Name="login_txt" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=login_txt - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "login-server_txt.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "login-server_txt.mak" CFG="login_txt - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "login_txt - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D "TXT_ONLY" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/login_txt/login-server_txt.pch" /YX /Fo"tmp/login_txt/" /Fd"tmp/login_txt/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 WSOCK32.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/login_txt/login-server_txt.pdb" /machine:I386 /out:"../login-server_txt.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "login_txt - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\md5calc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\svnversion.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "login" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\login\admin.c -# End Source File -# Begin Source File - -SOURCE=..\src\login\login.c -# End Source File -# Begin Source File - -SOURCE=..\src\login\login.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="login_txt" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=login_txt - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "login-server_txt.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "login-server_txt.mak" CFG="login_txt - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "login_txt - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /D "ACCOUNTDB_ENGINE_0=rj" /Fp"tmp/login_txt/login-server_txt.pch" /YX /Fo"tmp/login_txt/" /Fd"tmp/login_txt/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 WSOCK32.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/login_txt/login-server_txt.pdb" /machine:I386 /out:"../login-server_txt.exe" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "login_txt - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\md5calc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\svnversion.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "login" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\login\account.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\account_rj.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\account_txt.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\admin.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\ipban.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\ipban_txt.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\login.c +# End Source File +# Begin Source File + +SOURCE=..\src\login\login.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\loginlog.h +# End Source File +# Begin Source File + +SOURCE=..\src\login\loginlog_txt.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp index cfcf61a39..0fa675847 100644 --- a/vcproj-6/map-server_sql.dsp +++ b/vcproj-6/map-server_sql.dsp @@ -1,450 +1,434 @@ -# Microsoft Developer Studio Project File - Name="map_sql" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=map_sql - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "map-server_sql.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "map-server_sql.mak" CFG="map_sql - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "map_sql - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /I "..\src\zlib" /I "..\src\mysql" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D "PCRE_SUPPORT" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/map_sql/map-server_sql.pch" /YX /Fo"tmp/map_sql/" /Fd"tmp/map_sql/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 WSOCK32.lib libmysql.lib pcre.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/map_sql/map-server_sql.pdb" /machine:I386 /out:"../map-server_sql.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "map_sql - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\grfio.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\grfio.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\sql.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\svnversion.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "map" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\map\atcommand.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\atcommand.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\battle.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\battle.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\charcommand.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\charcommand.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\chat.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\chat.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\chrif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\chrif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\clif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\clif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\date.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\date.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\guild.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\guild.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\intif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\intif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\irc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\irc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\itemdb.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\itemdb.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\log.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\log.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mail.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mail.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\map.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\map.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mercenary.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mercenary.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mob.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mob.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc_chat.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\party.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\party.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\path.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\path.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\pc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pcre.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pet.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\pet.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\script.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\script.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\skill.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\skill.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\status.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\status.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\storage.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\storage.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\trade.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\trade.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\unit.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\vending.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\vending.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\quest.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\quest.h -# End Source File -# End Group -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=..\src\zlib\zlib.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="map_sql" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=map_sql - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "map-server_sql.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "map-server_sql.mak" CFG="map_sql - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "map_sql - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\pcre\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D "PCRE_SUPPORT" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/map_sql/map-server_sql.pch" /YX /Fo"tmp/map_sql/" /Fd"tmp/map_sql/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 WSOCK32.lib libmysql.lib zdll.lib pcre.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/map_sql/map-server_sql.pdb" /machine:I386 /out:"../map-server_sql.exe" /libpath:"..\3rdparty\mysql\lib" /libpath:"..\3rdparty\zlib\lib" /libpath:"..\3rdparty\pcre\lib" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "map_sql - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\grfio.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\grfio.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\sql.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\svnversion.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "map" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\map\atcommand.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\atcommand.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\battle.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\battle.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\charcommand.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\charcommand.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\chat.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\chat.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\chrif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\chrif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\clif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\clif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\date.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\date.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\guild.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\guild.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\intif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\intif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\irc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\irc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\itemdb.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\itemdb.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\log.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\log.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mail.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mail.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\map.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\map.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mercenary.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mercenary.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mob.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mob.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc_chat.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\party.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\party.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\path.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\path.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\pc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\pc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\pet.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\pet.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\quest.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\quest.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\script.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\script.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\skill.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\skill.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\status.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\status.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\storage.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\storage.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\trade.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\trade.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\unit.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\vending.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\vending.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-6/map-server_txt.dsp b/vcproj-6/map-server_txt.dsp index 4f2e4409e..2bc1da93e 100644 --- a/vcproj-6/map-server_txt.dsp +++ b/vcproj-6/map-server_txt.dsp @@ -1,446 +1,430 @@ -# Microsoft Developer Studio Project File - Name="map_txt" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=map_txt - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "map-server_txt.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "map-server_txt.mak" CFG="map_txt - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "map_txt - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W2 /GX /O2 /I "..\src\common" /I "..\src\zlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "TXT_ONLY" /D "__WIN32" /D "PCRE_SUPPORT" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/map_txt/map-server_txt.pch" /YX /Fo"tmp/map_txt/" /Fd"tmp/map_txt/" /FD /c -# ADD BASE RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 WSOCK32.lib pcre.lib zdll.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/map_txt/map-server_txt.pdb" /machine:I386 /out:"../map-server_txt.exe" /libpath:"../lib" -# SUBTRACT LINK32 /pdb:none -# Begin Target - -# Name "map_txt - Win32 Release" -# Begin Group "common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\common\cbasetypes.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\core.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\db.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\ers.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\grfio.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\grfio.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\lock.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\malloc.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\mapindex.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\mmo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\nullpo.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugin.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\plugins.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\showmsg.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\socket.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\strlib.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\svnversion.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\timer.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.c -# End Source File -# Begin Source File - -SOURCE=..\src\common\utils.h -# End Source File -# Begin Source File - -SOURCE=..\src\common\version.h -# End Source File -# End Group -# Begin Group "map" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\map\atcommand.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\battle.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\charcommand.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\chat.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\chrif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\clif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\date.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\guild.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\intif.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\irc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\itemdb.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\log.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mail.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\map.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mercenary.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\mob.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc_chat.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\party.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\path.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\pc.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\pet.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\script.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\skill.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\status.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\storage.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\trade.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\unit.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\vending.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\atcommand.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\battle.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\charcommand.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\chat.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\chrif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\clif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\date.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\guild.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\intif.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\irc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\itemdb.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\log.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mail.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\map.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mercenary.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\mob.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\npc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\party.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\path.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pc.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pcre.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\pet.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\script.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\skill.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\status.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\storage.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\trade.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\unit.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\vending.h -# End Source File -# Begin Source File - -SOURCE=..\src\map\quest.c -# End Source File -# Begin Source File - -SOURCE=..\src\map\quest.h -# End Source File -# End Group -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\src\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=..\src\zlib\zlib.h -# End Source File -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="map_txt" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=map_txt - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "map-server_txt.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "map-server_txt.mak" CFG="map_txt - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "map_txt - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W2 /GX /O2 /I "..\3rdparty\zlib\include" /I "..\3rdparty\pcre\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32" /D "TXT_ONLY" /D "__WIN32" /D "PCRE_SUPPORT" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /Fp"tmp/map_txt/map-server_txt.pch" /YX /Fo"tmp/map_txt/" /Fd"tmp/map_txt/" /FD /c +# ADD BASE RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 WSOCK32.lib zdll.lib pcre.lib ws2_32.lib /nologo /subsystem:console /pdb:"tmp/map_txt/map-server_txt.pdb" /machine:I386 /out:"../map-server_txt.exe" /libpath:"..\3rdparty\zlib\lib" /libpath:"..\3rdparty\pcre\lib" +# SUBTRACT LINK32 /pdb:none +# Begin Target + +# Name "map_txt - Win32 Release" +# Begin Group "common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\common\cbasetypes.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\core.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\db.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\ers.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\grfio.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\grfio.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\lock.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\malloc.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\mapindex.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\mmo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\nullpo.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugin.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\plugins.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\showmsg.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\socket.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\strlib.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\svnversion.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\timer.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\utils.h +# End Source File +# Begin Source File + +SOURCE=..\src\common\version.h +# End Source File +# End Group +# Begin Group "map" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\src\map\atcommand.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\battle.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\charcommand.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\chat.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\chrif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\clif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\date.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\guild.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\intif.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\irc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\itemdb.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\log.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mail.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\map.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mercenary.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\mob.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc_chat.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\party.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\path.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\pc.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\pet.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\quest.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\script.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\skill.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\status.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\storage.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\trade.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\unit.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\vending.c +# End Source File +# Begin Source File + +SOURCE=..\src\map\atcommand.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\battle.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\charcommand.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\chat.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\chrif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\clif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\date.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\guild.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\intif.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\irc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\itemdb.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\log.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mail.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\map.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mercenary.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mob.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\npc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\party.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\path.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\pc.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\pet.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\quest.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\script.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\skill.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\status.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\storage.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\trade.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\unit.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\vending.h +# End Source File +# End Group +# End Target +# End Project diff --git a/vcproj-7.1/char-server_sql.vcproj b/vcproj-7.1/char-server_sql.vcproj index 118c7b9d6..a252b9f65 100644 --- a/vcproj-7.1/char-server_sql.vcproj +++ b/vcproj-7.1/char-server_sql.vcproj @@ -20,7 +20,7 @@
+ RelativePath="..\src\char_sql\int_quest.c"> + RelativePath="..\src\char_sql\int_quest.h"> + RelativePath="..\src\char_sql\int_storage.c"> + RelativePath="..\src\char_sql\int_storage.h"> diff --git a/vcproj-7.1/char-server_txt.vcproj b/vcproj-7.1/char-server_txt.vcproj index 786f0f067..f23d56be2 100644 --- a/vcproj-7.1/char-server_txt.vcproj +++ b/vcproj-7.1/char-server_txt.vcproj @@ -20,7 +20,7 @@ + RelativePath="..\src\login\account.h"> + RelativePath="..\src\login\account_sql.c"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + @@ -322,12 +325,6 @@ - - - - - - - - - - diff --git a/vcproj-7.1/map-server_txt.vcproj b/vcproj-7.1/map-server_txt.vcproj index e389684da..35a91acf3 100644 --- a/vcproj-7.1/map-server_txt.vcproj +++ b/vcproj-7.1/map-server_txt.vcproj @@ -21,7 +21,7 @@ AdditionalOptions="/wd4018 /wd4100" Optimization="0" - AdditionalIncludeDirectories="..\src\common;..\src\zlib" + AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="TRUE" @@ -42,10 +42,10 @@ - - + + + + @@ -322,12 +325,6 @@ - - - - - - - - - - diff --git a/vcproj-7.1/mapcache.vcproj b/vcproj-7.1/mapcache.vcproj index b0a09a288..5c5cbe8e5 100644 --- a/vcproj-7.1/mapcache.vcproj +++ b/vcproj-7.1/mapcache.vcproj @@ -1,166 +1,156 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/char-server_sql.vcproj b/vcproj-8/char-server_sql.vcproj index 0a11b2ab7..4d83d6c88 100644 --- a/vcproj-8/char-server_sql.vcproj +++ b/vcproj-8/char-server_sql.vcproj @@ -41,7 +41,7 @@ + + + + + + + + + + + + + + diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index d4611de8d..61e395b30 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -41,8 +41,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/wd4100" Optimization="0" - AdditionalIncludeDirectories="..\src\common;..\src\zlib" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_TXT;ACCOUNTDB_ENGINE_0=rj" GeneratePreprocessedFile="0" MinimalRebuild="true" ExceptionHandling="0" @@ -67,11 +66,11 @@ /> + + + + + + + + + + @@ -215,6 +233,14 @@ RelativePath="..\src\login\login.h" > + + + + - - - - - - @@ -523,15 +511,19 @@ > + + - - - - diff --git a/vcproj-8/map-server_txt.vcproj b/vcproj-8/map-server_txt.vcproj index db7453962..e3f5d75af 100644 --- a/vcproj-8/map-server_txt.vcproj +++ b/vcproj-8/map-server_txt.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/wd4018 /wd4100" Optimization="0" - AdditionalIncludeDirectories="..\src\common;..\src\zlib" + AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="true" @@ -71,7 +71,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\map-server.exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\lib" + AdditionalLibraryDirectories="..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" GenerateDebugInformation="true" ProgramDatabaseFile="$(OutDir)\map-server.pdb" @@ -136,7 +136,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\src\common;..\src\zlib" + AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="true" RuntimeLibrary="0" @@ -162,7 +162,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\map-server.exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\lib" + AdditionalLibraryDirectories="..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" GenerateDebugInformation="true" ProgramDatabaseFile="$(OutDir)\map-server.pdb" @@ -370,15 +370,19 @@ > + + - - - - - - - - - - - - - - - - diff --git a/vcproj-8/txt-converter-char.vcproj b/vcproj-8/txt-converter-char.vcproj index bacd687a2..608544d68 100644 --- a/vcproj-8/txt-converter-char.vcproj +++ b/vcproj-8/txt-converter-char.vcproj @@ -41,7 +41,7 @@ + + + + + + + + + + + + + + diff --git a/vcproj-9/login-server_txt.vcproj b/vcproj-9/login-server_txt.vcproj index 78cc1d041..e5897aaaa 100644 --- a/vcproj-9/login-server_txt.vcproj +++ b/vcproj-9/login-server_txt.vcproj @@ -41,8 +41,7 @@ + + + + + + + + @@ -212,6 +226,14 @@ RelativePath="..\src\login\login.h" > + + + + - - - - - - @@ -518,10 +506,6 @@ RelativePath="..\src\map\pc.h" > - - diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj index 5b3872dc0..779ff5f25 100644 --- a/vcproj-9/map-server_txt.vcproj +++ b/vcproj-9/map-server_txt.vcproj @@ -41,7 +41,7 @@ - - @@ -442,18 +438,6 @@ > - - - - - - diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 113611965..29c07715c 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -41,7 +41,7 @@ - - - - - - diff --git a/vcproj-9/txt-converter-char.vcproj b/vcproj-9/txt-converter-char.vcproj index 97debfe11..31a48cc8b 100644 --- a/vcproj-9/txt-converter-char.vcproj +++ b/vcproj-9/txt-converter-char.vcproj @@ -42,7 +42,7 @@ + + + + diff --git a/vcproj-9/txt-converter-login.vcproj b/vcproj-9/txt-converter-login.vcproj index 2b2097e11..124d35715 100644 --- a/vcproj-9/txt-converter-login.vcproj +++ b/vcproj-9/txt-converter-login.vcproj @@ -42,7 +42,7 @@ + + + + @@ -259,7 +267,27 @@ RelativePath="..\src\common\strlib.h" > + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 2533e5169c9dd9843eb2d6c23d03faeda9841f27 Mon Sep 17 00:00:00 2001 From: ultramage Date: Sun, 27 Jul 2008 07:07:20 +0000 Subject: * Removed some leftover code that shouldn't have been merged * Possibly corrected a guild saving problem (bugreport:1908) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13003 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ conf/atcommand_athena.conf | 3 --- configure | 36 ++---------------------------------- src/common/mmo.h | 5 ++--- vcproj-6/login-server_txt.dsp | 4 ---- vcproj-7.1/login-server_txt.vcproj | 3 --- vcproj-8/login-server_txt.vcproj | 4 ---- 7 files changed, 6 insertions(+), 51 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index f8679cabf..70251b7ba 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2008/07/27 + * Possibly corrected a guild saving problem (bugreport:1908) + * Removed some leftover code that shouldn't have been merged [ultramage] * Fixed a memory leak in mmo_auth_tosql (extra sql statement being allocated). * Added missing option 'log_db_db' to loginlog_config_read(loginlog_sql.c). * Fixed a memory leak in account_db_sql_destroy. [FlavioJS] diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index d2deb9777..af2fd1c26 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -709,9 +709,6 @@ reloadskilldb: 99 // Re-load scripts (admin command) reloadscript: 99 -// Re-load GM level (admin command) -reloadgmdb: 99 - // Change a battle_config flag without rebooting server setbattleflag: 99 diff --git a/configure b/configure index 290958782..c94e71e72 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 12731 . +# From configure.in Revision: 13000 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -663,7 +663,6 @@ OBJEXT CPP GREP EGREP -HAVE_OPENRJ_TXT MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION @@ -1261,8 +1260,6 @@ Optional Features: instead of TXT files in the sql map-server. (disabled by default) --enable-debug Compiles extra debug code. (disabled by default) - --disable-openrj-txt Disables the openrj-based account engine in the TXT - login-server (enabled by default) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1810,28 +1807,6 @@ fi -# -# OpenRJ account engine in the txt login server -# -# Check whether --enable-openrj-txt was given. -if test "${enable_openrj_txt+set}" = set; then - enableval=$enable_openrj_txt; - HAVE_OPENRJ_TXT="$enableval" - case $enableval in - no);; - yes);; - *) { { echo "$as_me:$LINENO: error: invalid argument --enable-openrj-txt=$enableval... stopping" >&5 -echo "$as_me: error: invalid argument --enable-openrj-txt=$enableval... stopping" >&2;} - { (exit 1); exit 1; }; };; - esac - -else - HAVE_OPENRJ_TXT="yes" - -fi - - - # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # @@ -4555,12 +4530,6 @@ if test "$enable_debug" = "yes" ; then fi -# -# OpenRJ account engine in the txt login server -# - - - # # zlib library (required) # @@ -6145,7 +6114,6 @@ OBJEXT!$OBJEXT$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim -HAVE_OPENRJ_TXT!$HAVE_OPENRJ_TXT$ac_delim MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim HAVE_MYSQL!$HAVE_MYSQL$ac_delim MYSQL_VERSION!$MYSQL_VERSION$ac_delim @@ -6159,7 +6127,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 60; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/src/common/mmo.h b/src/common/mmo.h index 9e419c65b..858a8a513 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -414,9 +414,8 @@ struct guild { struct guild_alliance alliance[MAX_GUILDALLIANCE]; struct guild_expulsion expulsion[MAX_GUILDEXPULSION]; struct guild_skill skill[MAX_GUILDSKILL]; -#ifndef TXT_ONLY - unsigned short save_flag; -#endif + + unsigned short save_flag; // for TXT saving }; struct guild_castle { diff --git a/vcproj-6/login-server_txt.dsp b/vcproj-6/login-server_txt.dsp index 8f93aaa7b..f1d604759 100644 --- a/vcproj-6/login-server_txt.dsp +++ b/vcproj-6/login-server_txt.dsp @@ -191,10 +191,6 @@ SOURCE=..\src\login\account.h # End Source File # Begin Source File -SOURCE=..\src\login\account_rj.c -# End Source File -# Begin Source File - SOURCE=..\src\login\account_txt.c # End Source File # Begin Source File diff --git a/vcproj-7.1/login-server_txt.vcproj b/vcproj-7.1/login-server_txt.vcproj index 266289303..37086403c 100644 --- a/vcproj-7.1/login-server_txt.vcproj +++ b/vcproj-7.1/login-server_txt.vcproj @@ -148,9 +148,6 @@ - - diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index 61e395b30..4ed7a7d61 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -205,10 +205,6 @@ RelativePath="..\src\login\account.h" > - - -- cgit v1.2.3-70-g09d2 From 349da469d7355798a916749d055ab2c131bffe76 Mon Sep 17 00:00:00 2001 From: akrus Date: Thu, 31 Jul 2008 07:03:12 +0000 Subject: * Improved: added --enable-debug=gdb option in configure script to use gdb optimized debug mode [akrus] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13024 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + configure | 22 ++++++++++++++++------ configure.in | 22 ++++++++++++++++------ 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 766ba6f73..9c7198d19 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2008/07/31 + * Improved: added --enable-debug=gdb option in configure script to use gdb optimized debug mode [akrus] * Removed the mob controller system, now a customization (see topic:194375) [ultramage] * Fixed: commented out loginlog in convert engine sql tables (loginlog table is in logs database now) [akrus] 2008/07/30 diff --git a/configure b/configure index c94e71e72..66966f493 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 13000 . +# From configure.in Revision: 13024 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1260,6 +1260,7 @@ Optional Features: instead of TXT files in the sql map-server. (disabled by default) --enable-debug Compiles extra debug code. (disabled by default) + (available options: yes, no, gdb) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1793,8 +1794,9 @@ if test "${enable_debug+set}" = set; then enableval=$enable_debug; enable_debug="$enableval" case $enableval in - no);; - yes);; + "no");; + "yes");; + "gdb");; *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; @@ -4525,9 +4527,17 @@ fi # # Debug # -if test "$enable_debug" = "yes" ; then - CFLAGS="$CFLAGS -g -DDEBUG" -fi +case $enable_debug in + "no") + # default value + ;; + "yes") + CFLAGS="$CFLAGS -g -DDEBUG" + ;; + "gdb") + CFLAGS="$CFLAGS -ggdb -DDEBUG" + ;; +esac # diff --git a/configure.in b/configure.in index 5ebbe1561..aab1f58fb 100644 --- a/configure.in +++ b/configure.in @@ -78,13 +78,15 @@ AC_ARG_ENABLE( [debug], AC_HELP_STRING( [--enable-debug], - [Compiles extra debug code. (disabled by default)] + [Compiles extra debug code. (disabled by default)], + [(available options: yes, no, gdb)] ), [ enable_debug="$enableval" case $enableval in - no);; - yes);; + "no");; + "yes");; + "gdb");; *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);; esac ], @@ -347,9 +349,17 @@ fi # # Debug # -if test "$enable_debug" = "yes" ; then - CFLAGS="$CFLAGS -g -DDEBUG" -fi +case $enable_debug in + "no") + # default value + ;; + "yes") + CFLAGS="$CFLAGS -g -DDEBUG" + ;; + "gdb") + CFLAGS="$CFLAGS -ggdb -DDEBUG" + ;; +esac # -- cgit v1.2.3-70-g09d2 From 814fdef302ca6522d934d3e4e26c7c98bed053ec Mon Sep 17 00:00:00 2001 From: ultramage Date: Tue, 12 Aug 2008 04:52:39 +0000 Subject: Added gcc compiler flags to silence some warnings in non-debug builds (bugreport:1993) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13073 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 1 + configure.in | 1 + 2 files changed, 2 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 66966f493..af8acf6b5 100755 --- a/configure +++ b/configure @@ -4530,6 +4530,7 @@ fi case $enable_debug in "no") # default value + CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses" ;; "yes") CFLAGS="$CFLAGS -g -DDEBUG" diff --git a/configure.in b/configure.in index aab1f58fb..c8252048a 100644 --- a/configure.in +++ b/configure.in @@ -352,6 +352,7 @@ fi case $enable_debug in "no") # default value + CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses" ;; "yes") CFLAGS="$CFLAGS -g -DDEBUG" -- cgit v1.2.3-70-g09d2 From 0d67a194537e8e69426c8f55ced61b0a8701e90a Mon Sep 17 00:00:00 2001 From: ultramage Date: Fri, 15 Aug 2008 11:14:45 +0000 Subject: Split off mapreg code from script.c * new mapserver files, mapreg.h, mapreg_txt.c, mapreg_sql.c * removed MAPREGSQL from project files / makefiles * mapreg storage engine is now fully dependent on the server type * added config settings mapreg_txt and mapreg_db to inter config * added get_str() function to complement add_str() * fixed txt mapreg code allowing too long variable names git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13081 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 7 + conf/Changelog.txt | 2 + conf/inter_athena.conf | 4 + conf/map_athena.conf | 2 - configure | 35 +--- configure.in | 29 --- doc/script_commands.txt | 2 +- src/map/Makefile.in | 8 +- src/map/map.c | 7 +- src/map/mapreg.h | 17 ++ src/map/mapreg_sql.c | 242 +++++++++++++++++++++++ src/map/mapreg_txt.c | 202 +++++++++++++++++++ src/map/script.c | 387 +++++++------------------------------ src/map/script.h | 5 +- src/txt-converter/char-converter.c | 2 - vcproj-6/map-server_sql.dsp | 8 + vcproj-6/map-server_txt.dsp | 8 + vcproj-7.1/map-server_sql.vcproj | 10 +- vcproj-7.1/map-server_txt.vcproj | 6 + vcproj-8/map-server_sql.vcproj | 12 +- vcproj-8/map-server_txt.vcproj | 8 + vcproj-9/map-server_sql.vcproj | 12 +- vcproj-9/map-server_txt.vcproj | 8 + 23 files changed, 623 insertions(+), 400 deletions(-) create mode 100644 src/map/mapreg.h create mode 100644 src/map/mapreg_sql.c create mode 100644 src/map/mapreg_txt.c (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 6f7a5f702..f1932113e 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,13 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2008/08/15 + * Split off mapreg code from script.c [ultramage] + - new mapserver files, mapreg.h, mapreg_txt.c, mapreg_sql.c + - removed MAPREGSQL from project files / makefiles + - mapreg storage engine is now fully dependent on the server type + - added config settings mapreg_txt and mapreg_db to inter config + - added get_str() function to complement add_str() + - fixed txt mapreg code allowing too long variable names * Removed gm_cant_party_max_lv. It now uses gm_cant_party_min_lv as the threshold. (bugreport:2051) [SketchyPhoenix] 2008/08/11 * Fixed right-click npc unload not unloading duplicates (bugreport:2014) diff --git a/conf/Changelog.txt b/conf/Changelog.txt index 6884ffc0b..ebcf65639 100644 --- a/conf/Changelog.txt +++ b/conf/Changelog.txt @@ -1,5 +1,7 @@ Date Added +2008/08/13 + * Added config settings mapreg_txt and mapreg_db to inter config [ultramage] 2008/08/10 * Removed duplicate gef_cas mapflags [Yommy] 2008/08/01 diff --git a/conf/inter_athena.conf b/conf/inter_athena.conf index 9d8a1917b..00d3f155f 100644 --- a/conf/inter_athena.conf +++ b/conf/inter_athena.conf @@ -38,6 +38,9 @@ castle_txt: save/castle.txt // Status change flatfile database, for status changes that are saved between sessions. scdata_txt: save/scdata.txt +// Mapserver permanent script variables ($-type) +mapreg_txt: save/mapreg.txt + // SQL version options only @@ -114,6 +117,7 @@ item_db_db: item_db item_db2_db: item_db2 mob_db_db: mob_db mob_db2_db: mob_db2 +mapreg_db: mapreg //Use SQL item_db and mob_db for the map server use_sql_db: no diff --git a/conf/map_athena.conf b/conf/map_athena.conf index 5859008ca..fcd368668 100644 --- a/conf/map_athena.conf +++ b/conf/map_athena.conf @@ -121,8 +121,6 @@ help_txt: conf/help.txt help2_txt: conf/help2.txt charhelp_txt: conf/charhelp.txt -mapreg_txt: save/mapreg.txt - // Scripts import: npc/scripts_main.conf diff --git a/configure b/configure index af8acf6b5..d473ad2ca 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 13024 . +# From configure.in Revision: 13073 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1256,9 +1256,6 @@ Optional Features: gcollect, bcheck (defaults to builtin) --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see src/map/clif.h) - --enable-mapregsql Makes map-wide script variables be saved to SQL - instead of TXT files in the sql map-server. - (disabled by default) --enable-debug Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) @@ -1764,28 +1761,6 @@ fi -# -# mapregsql -# -# Check whether --enable-mapregsql was given. -if test "${enable_mapregsql+set}" = set; then - enableval=$enable_mapregsql; - enable_mapregsql="$enableval" - case $enableval in - no);; - yes);; - *) { { echo "$as_me:$LINENO: error: invalid argument --enable-mapregsql=$enableval... stopping" >&5 -echo "$as_me: error: invalid argument --enable-mapregsql=$enableval... stopping" >&2;} - { (exit 1); exit 1; }; };; - esac - -else - enable_mapregsql="no" - -fi - - - # # debug # @@ -4516,14 +4491,6 @@ if test -n "$enable_packetver" ; then fi -# -# Mapregsql -# -if test "$enable_mapregsql" = "yes" ; then - CFLAGS="$CFLAGS -DMAPREGSQL" -fi - - # # Debug # diff --git a/configure.in b/configure.in index c8252048a..d0d15e0ca 100644 --- a/configure.in +++ b/configure.in @@ -50,27 +50,6 @@ AC_ARG_ENABLE( ) -# -# mapregsql -# -AC_ARG_ENABLE( - [mapregsql], - AC_HELP_STRING( - [--enable-mapregsql], - [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (disabled by default)] - ), - [ - enable_mapregsql="$enableval" - case $enableval in - no);; - yes);; - *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enableval... stopping]]);; - esac - ], - [enable_mapregsql="no"] -) - - # # debug # @@ -338,14 +317,6 @@ if test -n "$enable_packetver" ; then fi -# -# Mapregsql -# -if test "$enable_mapregsql" = "yes" ; then - CFLAGS="$CFLAGS -DMAPREGSQL" -fi - - # # Debug # diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 49353125c..ffd70d3d8 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -533,7 +533,7 @@ nothing - A permanent variable attached to the character, the default names starting with 'l' if you want full backward compatibility. "$" - A global permanent variable. They are stored in "save\mapreg.txt" or database table `mapreg`, - depending on server type and the MAPREGSQL compilation flag. + depending on server type. "$@" - A global temporary variable. This is important for scripts which are called with no RID attached, that is, not triggered by a specific character object. diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 61e41797e..f78cb6207 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -18,13 +18,15 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \ storage.o skill.o atcommand.o charcommand.o battle.o \ intif.o trade.o party.o vending.o guild.o pet.o \ log.o mail.o date.o unit.o mercenary.o quest.o -MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) -MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) +MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) \ + obj_txt/mapreg_txt.o +MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \ + obj_sql/mapreg_sql.o MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ chat.h itemdb.h mob.h script.h path.h \ storage.h skill.h atcommand.h charcommand.h battle.h \ intif.h trade.h party.h vending.h guild.h pet.h \ - log.h mail.h date.h unit.h mercenary.h quest.h + log.h mail.h date.h unit.h mercenary.h quest.h mapreg.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/map/map.c b/src/map/map.c index 0d82094cf..36db8ebb2 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -32,6 +32,7 @@ #include "unit.h" #include "battle.h" #include "script.h" +#include "mapreg.h" #include "guild.h" #include "pet.h" #include "mercenary.h" @@ -2932,9 +2933,6 @@ int map_config_read(char *cfgName) if (strcmpi(w1, "charhelp_txt") == 0) strcpy(charhelp_txt, w2); else - if (strcmpi(w1, "mapreg_txt") == 0) - strcpy(mapreg_txt, w2); - else if(strcmpi(w1,"map_cache_file") == 0) strncpy(map_cache_file,w2,255); else @@ -3034,6 +3032,9 @@ int inter_config_read(char *cfgName) if(strcmpi(w1,"log_db_db")==0) strcpy(log_db_db, w2); #endif + else + if( mapreg_config_read(w1,w2) ) + continue; //support the import command, just like any other config else if(strcmpi(w1,"import")==0) diff --git a/src/map/mapreg.h b/src/map/mapreg.h new file mode 100644 index 000000000..d5fadafc5 --- /dev/null +++ b/src/map/mapreg.h @@ -0,0 +1,17 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _MAPREG_H_ +#define _MAPREG_H_ + +void mapreg_reload(void); +void mapreg_final(void); +void mapreg_init(void); +bool mapreg_config_read(const char* w1, const char* w2); + +int mapreg_readreg(int uid); +char* mapreg_readregstr(int uid); +bool mapreg_setreg(int uid, int val); +bool mapreg_setregstr(int uid, const char* str); + +#endif /* _MAPREG_H_ */ diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c new file mode 100644 index 000000000..401367611 --- /dev/null +++ b/src/map/mapreg_sql.c @@ -0,0 +1,242 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "map.h" // mmysql_handle +#include "script.h" +#include +#include + +static DBMap* mapreg_db = NULL; // int var_id -> int value +static DBMap* mapregstr_db = NULL; // int var_id -> char* value + +static char mapreg_table[32] = "mapreg"; +static bool mapreg_dirty = false; +#define MAPREG_AUTOSAVE_INTERVAL (300*1000) + + +/// Looks up the value of an integer variable using its uid. +int mapreg_readreg(int uid) +{ + return (int)idb_get(mapreg_db, uid); +} + +/// Looks up the value of a string variable using its uid. +char* mapreg_readregstr(int uid) +{ + return (char*)idb_get(mapregstr_db, uid); +} + +/// Modifies the value of an integer variable. +bool mapreg_setreg(int uid, int val) +{ + int num = uid & 0x00ffffff; + int i = uid & 0xff000000 >> 24; + const char* name = get_str(num); + + if( val != 0 ) + { + if( idb_put(mapreg_db,uid,(void*)val) ) + ; // already exists, delay write + else + if( name[1] == '@' ) + ; // nothing more to do + else + {// write new wariable to database + char tmp_str[32*2+1]; + Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) ) + Sql_ShowDebug(mmysql_handle); + } + } + else // val == 0 + { + idb_remove(mapreg_db,uid); + + if( name[1] == '@' ) + ; // nothing more to do + else + {// Remove from database because it is unused. + if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + Sql_ShowDebug(mmysql_handle); + } + } + + mapreg_dirty = true; + return true; +} + +/// Modifies the value of a string variable. +bool mapreg_setregstr(int uid, const char* str) +{ + int num = uid & 0x00ffffff; + int i = uid & 0xff000000 >> 24; + const char* name = get_str(num); + + if( str == NULL || *str == 0 ) + { + if(name[1] != '@') { + if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + Sql_ShowDebug(mmysql_handle); + } + idb_remove(mapregstr_db,uid); + } + else + { + if (idb_put(mapregstr_db,uid, aStrdup(str))) + ; + else if(name[1] != '@') { //put returned null, so we must insert. + // Someone is causing a database size infinite increase here without name[1] != '@' [Lance] + char tmp_str[32*2+1]; + char tmp_str2[255*2+1]; + Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); + Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) ) + Sql_ShowDebug(mmysql_handle); + } + } + + mapreg_dirty = true; + return true; +} + +/// Loads permanent variables from database +static void script_load_mapreg(void) +{ + /* + 0 1 2 + +-------------------------+ + | varname | index | value | + +-------------------------+ + */ + SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle); + char varname[32+1]; + int index; + char value[255+1]; + uint32 length; + + if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table) + || SQL_ERROR == SqlStmt_Execute(stmt) + ) { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + return; + } + + SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], 32, &length, NULL); + SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], 255, NULL, NULL); + + while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) + { + int s = add_str(varname); + int i = index; + + if( varname[length-1] == '$' ) + idb_put(mapregstr_db, (i<<24)|s, aStrdup(value)); + else + idb_put(mapreg_db, (i<<24)|s, (void *)atoi(value)); + } + + SqlStmt_Free(stmt); + + mapreg_dirty = false; +} + +/// Saves permanent variables to database +static void script_save_mapreg(void) +{ + DBIterator* iter; + void* data; + DBKey key; + + iter = mapreg_db->iterator(mapreg_db); + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) + { + int num = key.i & 0x00ffffff; + int i = key.i & 0xff000000 >> 24; + const char* name = get_str(num); + + if( name[1] == '@' ) + continue; + + if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, (int)data, name, i) ) + Sql_ShowDebug(mmysql_handle); + } + iter->destroy(iter); + + iter = mapregstr_db->iterator(mapregstr_db); + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) + { + int num = key.i & 0x00ffffff; + int i = key.i & 0xff000000 >> 24; + const char* name = get_str(num); + char tmp_str2[2*255+1]; + + if( name[1] == '@' ) + continue; + + Sql_EscapeStringLen(mmysql_handle, tmp_str2, (char*)data, safestrnlen((char*)data, 255)); + if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, tmp_str2, name, i) ) + Sql_ShowDebug(mmysql_handle); + } + iter->destroy(iter); + + mapreg_dirty = false; +} + +static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr data) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + return 0; +} + + +void mapreg_reload(void) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + mapreg_db->clear(mapreg_db, NULL); + mapregstr_db->clear(mapregstr_db, NULL); + + script_load_mapreg(); +} + +void mapreg_final(void) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + mapreg_db->destroy(mapreg_db,NULL); + mapregstr_db->destroy(mapregstr_db,NULL); +} + +void mapreg_init(void) +{ + mapreg_db = idb_alloc(DB_OPT_BASE); + mapregstr_db = idb_alloc(DB_OPT_RELEASE_DATA); + + script_load_mapreg(); + + add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); + add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); +} + +bool mapreg_config_read(const char* w1, const char* w2) +{ + if(!strcmpi(w1, "mapreg_db")) + safestrncpy(mapreg_table, w2, sizeof(mapreg_table)); + else + return false; + + return true; +} diff --git a/src/map/mapreg_txt.c b/src/map/mapreg_txt.c new file mode 100644 index 000000000..f8cfcd6bf --- /dev/null +++ b/src/map/mapreg_txt.c @@ -0,0 +1,202 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/lock.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "script.h" +#include +#include +#include + +static DBMap* mapreg_db = NULL; // int var_id -> int value +static DBMap* mapregstr_db = NULL; // int var_id -> char* value + +static char mapreg_txt[256] = "save/mapreg.txt"; +static bool mapreg_dirty = false; +#define MAPREG_AUTOSAVE_INTERVAL (300*1000) + + +/// Looks up the value of an integer variable using its uid. +int mapreg_readreg(int uid) +{ + return (int)idb_get(mapreg_db, uid); +} + +/// Looks up the value of a string variable using its uid. +char* mapreg_readregstr(int uid) +{ + return (char*)idb_get(mapregstr_db, uid); +} + +/// Modifies the value of an integer variable. +bool mapreg_setreg(int uid, int val) +{ + if( val != 0 ) + idb_put(mapreg_db,uid,(void*)val); + else + idb_remove(mapreg_db,uid); + + mapreg_dirty = true; + return true; +} + +/// Modifies the value of a string variable. +bool mapreg_setregstr(int uid, const char* str) +{ + if( str == NULL || *str == 0 ) + idb_remove(mapregstr_db,uid); + else + idb_put(mapregstr_db,uid,aStrdup(str)); + + mapreg_dirty = true; + return true; +} + +/// Loads permanent variables from savefile +static void script_load_mapreg(void) +{ + FILE* fp; + char line[1024]; + + fp = fopen(mapreg_txt,"rt"); + if( fp == NULL ) + return; + + while( fgets(line,sizeof(line),fp) ) + { + char varname[32+1]; + char value[255+1]; + int n,s,i; + + // read name and index + if( sscanf(line, "%255[^,],%d\t%n", varname,&i,&n) != 2 && + (i = 0, sscanf(line,"%[^\t]\t%n", varname,&n) != 1) ) + continue; + + // read value + if( sscanf(line + n, "%[^\n\r]", value) != 1 ) + { + ShowError("%s: %s broken data !\n", mapreg_txt, varname); + continue; + } + + s = add_str(varname); + if( varname[strlen(varname)-1] == '$' ) + idb_put(mapregstr_db, (i<<24)|s, aStrdup(value)); + else + idb_put(mapreg_db, (i<<24)|s, (void*)atoi(value)); + } + fclose(fp); + + mapreg_dirty = false; +} + +/// Saves permanent variables to savefile +static void script_save_mapreg(void) +{ + FILE *fp; + int lock; + DBIterator* iter; + void* data; + DBKey key; + + fp = lock_fopen(mapreg_txt,&lock); + if( fp == NULL ) + { + ShowError("script_save_mapreg: Unable to lock-open file [%s]!\n", mapreg_txt); + return; + } + + iter = mapreg_db->iterator(mapreg_db); + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) + { + int num = key.i & 0x00ffffff; + int i = key.i & 0xff000000 >> 24; + const char* name = get_str(num); + + if( name[1] == '@' ) + continue; + + if( i == 0 ) + fprintf(fp, "%s\t%d\n", name, (int)data); + else + fprintf(fp, "%s,%d\t%d\n", name, i, (int)data); + } + iter->destroy(iter); + + iter = mapregstr_db->iterator(mapregstr_db); + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) + { + int num = key.i & 0x00ffffff; + int i = key.i & 0xff000000 >> 24; + const char* name = get_str(num); + + if( name[1] == '@' ) + continue; + + if( i == 0 ) + fprintf(fp, "%s\t%s\n", name, (char *)data); + else + fprintf(fp, "%s,%d\t%s\n", name, i, (char *)data); + } + iter->destroy(iter); + + lock_fclose(fp,mapreg_txt,&lock); + + mapreg_dirty = false; +} + +static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr data) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + return 0; +} + + +void mapreg_reload(void) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + mapreg_db->clear(mapreg_db, NULL); + mapregstr_db->clear(mapregstr_db, NULL); + + script_load_mapreg(); +} + +void mapreg_final(void) +{ + if( mapreg_dirty ) + script_save_mapreg(); + + mapreg_db->destroy(mapreg_db,NULL); + mapregstr_db->destroy(mapregstr_db,NULL); +} + +void mapreg_init(void) +{ + mapreg_db = idb_alloc(DB_OPT_BASE); + mapregstr_db = idb_alloc(DB_OPT_RELEASE_DATA); + + script_load_mapreg(); + + add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); + add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); +} + +bool mapreg_config_read(const char* w1, const char* w2) +{ + if(!strcmpi(w1, "mapreg_txt")) + safestrncpy(mapreg_txt, w2, sizeof(mapreg_txt)); + else + return false; + + return true; +} diff --git a/src/map/script.c b/src/map/script.c index 68828db85..f058b32c4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26,6 +26,7 @@ #include "mob.h" #include "npc.h" #include "pet.h" +#include "mapreg.h" #include "mercenary.h" //[orn] #include "intif.h" #include "skill.h" @@ -157,9 +158,10 @@ static int script_pos,script_size; #define GETVALUE(buf,i) ((int)MakeDWord(MakeWord((buf)[i],(buf)[i+1]),MakeWord((buf)[i+2],0))) #define SETVALUE(buf,i,n) ((buf)[i]=GetByte(n,0),(buf)[i+1]=GetByte(n,1),(buf)[i+2]=GetByte(n,2)) -#define GETSTRING(off) (str_buf+(off)) static char *str_buf; static int str_pos,str_size; +static int str_data_size = 0; +int str_num=LABEL_START; static struct str_data_struct { enum c_op type; int str; @@ -169,7 +171,6 @@ static struct str_data_struct { int val; int next; } *str_data = NULL; -int str_num=LABEL_START,str_data_size; // Using a prime number for SCRIPT_HASH_SIZE should give better distributions #define SCRIPT_HASH_SIZE 1021 @@ -179,11 +180,6 @@ int str_hash[SCRIPT_HASH_SIZE]; //#define SCRIPT_HASH_SDBM #define SCRIPT_HASH_ELF -static DBMap* mapreg_db=NULL; // int var_id -> int value -static DBMap* mapregstr_db=NULL; // int var_id -> char* value -static int mapreg_dirty=-1; -char mapreg_txt[256]="save/mapreg.txt"; -#define MAPREG_AUTOSAVE_INTERVAL (300*1000) static DBMap* scriptlabel_db=NULL; // const char* label_name -> int script_pos static DBMap* userfunc_db=NULL; // const char* func_name -> struct script_code* @@ -248,12 +244,6 @@ int potion_flag=0; //For use on Alchemist improved potions/Potion Pitcher. [Skot int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0; int potion_target=0; -#if !defined(TXT_ONLY) && defined(MAPREGSQL) -char mapregsql_db[32] = "mapreg"; -char mapregsql_db_varname[32] = "varname"; -char mapregsql_db_index[32] = "index"; -char mapregsql_db_value[32] = "value"; -#endif c_op get_com(unsigned char *script,int *pos); int get_num(unsigned char *script,int *pos); @@ -278,9 +268,6 @@ const char* parse_subexpr(const char* p,int limit); void push_val(struct script_stack *stack,int type,int val); int run_func(struct script_state *st); -int mapreg_setreg(int num,int val); -int mapreg_setregstr(int num,const char *str); - enum { MF_NOMEMO, //0 MF_NOTELEPORT, @@ -515,66 +502,84 @@ static unsigned int calc_hash(const char* p) return h % SCRIPT_HASH_SIZE; } + /*========================================== - * str_data‚Ì’†‚É–¼‘O‚ª‚ ‚é‚©ŒŸõ‚·‚é + * str_data manipulation functions *------------------------------------------*/ -// Šù‘¶‚̂ł ‚ê‚ΔԆA–³‚¯‚ê‚Î-1 -static int search_str(const char *p) + +/// Looks up string using the provided id. +const char* get_str(int id) +{ + Assert( id >= LABEL_START && id < str_size ); + return str_buf+str_data[id].str; +} + +/// Returns the uid of the string, or -1. +static int search_str(const char* p) { int i; - i=str_hash[calc_hash(p)]; - while(i){ - if(strcasecmp(str_buf+str_data[i].str,p)==0){ + + for( i = str_hash[calc_hash(p)]; i != 0; i = str_data[i].next ) + if( strcasecmp(get_str(i),p) == 0 ) return i; - } - i=str_data[i].next; - } + return -1; } -/*========================================== - * str_data‚É–¼‘O‚ð“o˜^ - *------------------------------------------*/ -// Šù‘¶‚̂ł ‚ê‚ΔԆA–³‚¯‚ê‚Γo˜^‚µ‚ÄV‹K”Ô† +/// Stores a copy of the string and returns its id. +/// If an identical string is already present, returns its id instead. int add_str(const char* p) { - int i; + int i, h; int len; - i=calc_hash(p); - if(str_hash[i]==0){ - str_hash[i]=str_num; - } else { - i=str_hash[i]; - for(;;){ - if(strcasecmp(str_buf+str_data[i].str,p)==0){ - return i; - } - if(str_data[i].next==0) - break; - i=str_data[i].next; + h = calc_hash(p); + + if( str_hash[h] == 0 ) + {// empty bucket, add new node here + str_hash[h] = str_num; + } + else + {// scan for end of list, or occurence of identical string + for( i = str_hash[h]; ; i = str_data[i].next ) + { + if( strcasecmp(get_str(i),p) == 0 ) + return i; // string already in list + if( str_data[i].next == 0 ) + break; // reached the end } - str_data[i].next=str_num; + + // append node to end of list + str_data[i].next = str_num; } - if(str_num>=str_data_size){ - str_data_size+=128; + + // grow list if neccessary + if( str_num >= str_data_size ) + { + str_data_size += 128; RECREATE(str_data,struct str_data_struct,str_data_size); memset(str_data + (str_data_size - 128), '\0', 128); } + len=(int)strlen(p); - while(str_pos+len+1>=str_size){ - str_size+=256; + + // grow string buffer if neccessary + while( str_pos+len+1 >= str_size ) + { + str_size += 256; RECREATE(str_buf,char,str_size); memset(str_buf + (str_size - 256), '\0', 256); } - memcpy(str_buf+str_pos,p,len+1); - str_data[str_num].type=C_NOP; - str_data[str_num].str=str_pos; - str_data[str_num].next=0; - str_data[str_num].func=NULL; - str_data[str_num].backpatch=-1; - str_data[str_num].label=-1; - str_pos+=len+1; + + safestrncpy(str_buf+str_pos, p, len+1); + str_data[str_num].type = C_NOP; + str_data[str_num].str = str_pos; + str_data[str_num].next = 0; + str_data[str_num].func = NULL; + str_data[str_num].backpatch = -1; + str_data[str_num].label = -1; + str_pos += len+1; + return str_num++; } @@ -1462,7 +1467,7 @@ const char* parse_syntax(const char* p) str_data[l].type = C_USERFUNC; set_label(l, script_pos, p); if( parse_options&SCRIPT_USE_LABEL_DB ) - strdb_put(scriptlabel_db, GETSTRING(str_data[l].str), (void*)script_pos); + strdb_put(scriptlabel_db, get_str(l), (void*)script_pos); return skip_space(p); } else @@ -1959,7 +1964,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o i=add_word(p); set_label(i,script_pos,p); if( parse_options&SCRIPT_USE_LABEL_DB ) - strdb_put(scriptlabel_db, GETSTRING(str_data[i].str), (void*)script_pos); + strdb_put(scriptlabel_db, get_str(i), (void*)script_pos); p=tmpp+1; p=skip_space(p); continue; @@ -2129,7 +2134,7 @@ void get_val(struct script_state* st, struct script_data* data) data->u.str = pc_readregstr(sd, data->u.num); break; case '$': - data->u.str = (char *)idb_get(mapregstr_db, data->u.num); + data->u.str = mapreg_readregstr(data->u.num); break; case '#': if( name[1] == '#' ) @@ -2183,7 +2188,7 @@ void get_val(struct script_state* st, struct script_data* data) data->u.num = pc_readreg(sd, data->u.num); break; case '$': - data->u.num = (int)idb_get(mapreg_db, data->u.num); + data->u.num = mapreg_readreg(data->u.num); break; case '#': if( name[1] == '#' ) @@ -3190,249 +3195,6 @@ void run_script_main(struct script_state *st) } -/*========================================== - * ƒ}ƒbƒv•Ï”‚Ì•ÏX - *------------------------------------------*/ -int mapreg_setreg(int num, int val) -{ -#if !defined(TXT_ONLY) && defined(MAPREGSQL) - int i = num >> 24; - char* name = str_buf + str_data[num&0x00ffffff].str; - - if( val != 0 ) { - if(idb_put(mapreg_db,num,(void*)val)) - ; - else if(name[1] != '@') { - char tmp_str[32*2+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%d')", mapregsql_db, mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, tmp_str, i, val) ) - Sql_ShowDebug(mmysql_handle); - } - } else { // val == 0 - if(name[1] != '@') { // Remove from database because it is unused. - if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_varname, name, mapregsql_db_index, i) ) - Sql_ShowDebug(mmysql_handle); - } - idb_remove(mapreg_db,num); - } -#else - if(val != 0) - idb_put(mapreg_db,num,(void*)val); - else - idb_remove(mapreg_db,num); -#endif - - mapreg_dirty = 1; - return 1; -} -/*========================================== - * •¶Žš—ñŒ^ƒ}ƒbƒv•Ï”‚Ì•ÏX - *------------------------------------------*/ -int mapreg_setregstr(int num, const char* str) -{ -#if !defined(TXT_ONLY) && defined(MAPREGSQL) - int i = num >> 24; - char* name = str_buf + str_data[num&0x00ffffff].str; - - if( str==NULL || *str==0 ) { - if(name[1] != '@') { - if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_varname, name, mapregsql_db_index, i) ) - Sql_ShowDebug(mmysql_handle); - } - idb_remove(mapregstr_db,num); - mapreg_dirty = 1; - return 1; - } - - if (idb_put(mapregstr_db,num, aStrdup(str))) - ; - else if(name[1] != '@') { //put returned null, so we must insert. - // Someone is causing a database size infinite increase here without name[1] != '@' [Lance] - char tmp_str[32*2+1]; - char tmp_str2[255*2+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%s')", mapregsql_db, mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, tmp_str, i, tmp_str2) ) - Sql_ShowDebug(mmysql_handle); - } -#else - if( str==NULL || *str==0 ) - idb_remove(mapregstr_db,num); - else - idb_put(mapregstr_db,num,aStrdup(str)); -#endif - - mapreg_dirty = 1; - return 1; -} - -/*========================================== - * ‰i‘±“Iƒ}ƒbƒv•Ï”‚̓ǂݞ‚Ý - *------------------------------------------*/ -static int script_load_mapreg(void) -{ -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE* fp; - char line[1024]; - - if( (fp=fopen(mapreg_txt,"rt")) == NULL ) - return -1; - - while(fgets(line,sizeof(line),fp)) - { - char buf1[256],buf2[1024]; - char* p; - int n,v,s,i; - if( sscanf(line,"%255[^,],%d\t%n",buf1,&i,&n)!=2 && - (i=0,sscanf(line,"%[^\t]\t%n",buf1,&n)!=1) ) - continue; - if( buf1[strlen(buf1)-1] == '$' ) { - if( sscanf(line + n, "%[^\n\r]", buf2) != 1 ) { - ShowError("%s: %s broken data !\n", mapreg_txt, buf1); - continue; - } - p = aStrdup(buf2); - s = add_str(buf1); - idb_put(mapregstr_db, (i<<24)|s, p); - } else { - if( sscanf(line + n, "%d", &v) != 1 ) { - ShowError("%s: %s broken data !\n", mapreg_txt, buf1); - continue; - } - s = add_str(buf1); - idb_put(mapreg_db, (i<<24)|s, (void*)v); - } - } - fclose(fp); - - mapreg_dirty = 0; - return 0; -#else - /* - 0 1 2 - +-------------------------+ - | varname | index | value | - +-------------------------+ - */ - - SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle); - char varname[32+1]; - int index; - char value[255+1]; - uint32 length; - - if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `%s`, `%s`, `%s` FROM `%s`", mapregsql_db_varname, mapregsql_db_index, mapregsql_db_value, mapregsql_db) - || SQL_ERROR == SqlStmt_Execute(stmt) - ) { - SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - return -1; - } - - SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], 32, &length, NULL); - SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], 255, NULL, NULL); - - while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) - { - if( varname[length-1] == '$' ) { - int s = add_str(varname); - int i = index; - char* p = aStrdup(value); - idb_put(mapregstr_db, (i<<24)|s, p); - } else { - int s = add_str(varname); - int i = index; - int v = atoi(value); - idb_put(mapreg_db, (i<<24)|s, (void *)v); - } - } - - SqlStmt_Free(stmt); - - mapreg_dirty = 0; - return 0; - -#endif /* TXT_ONLY */ -} -/*========================================== - * ‰i‘±“Iƒ}ƒbƒv•Ï”‚Ì‘‚«ž‚Ý - *------------------------------------------*/ -static int script_save_mapreg_intsub(DBKey key,void *data,va_list ap) -{ - int num=key.i&0x00ffffff, i=key.i>>24; - char *name=str_buf+str_data[num].str; - -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp=va_arg(ap,FILE*); - if( name[1]!='@' ) { - if(i==0) - fprintf(fp,"%s\t%d\n", name, (int)data); - else - fprintf(fp,"%s,%d\t%d\n", name, i, (int)data); - } -#else - if ( name[1] != '@') { - if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `%s`='%d' WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_value, (int)data, mapregsql_db_varname, name, mapregsql_db_index, i) ) - Sql_ShowDebug(mmysql_handle); - } -#endif - - return 0; -} - -static int script_save_mapreg_strsub(DBKey key,void *data,va_list ap) -{ - int num=key.i&0x00ffffff, i=key.i>>24; - char *name=str_buf+str_data[num].str; - -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp=va_arg(ap,FILE*); - if( name[1]!='@' ) { - if(i==0) - fprintf(fp,"%s\t%s\n", name, (char *)data); - else - fprintf(fp,"%s,%d\t%s\n", name, i, (char *)data); - } -#else - if ( name[1] != '@') { - char tmp_str2[2*255+1]; - Sql_EscapeStringLen(mmysql_handle, tmp_str2, (char*)data, safestrnlen((char*)data, 255)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `%s`='%s' WHERE `%s`='%s' AND `%s`='%d'", mapregsql_db, mapregsql_db_value, tmp_str2, mapregsql_db_varname, name, mapregsql_db_index, i) ) - Sql_ShowDebug(mmysql_handle); - } -#endif - - return 0; -} -static int script_save_mapreg(void) -{ -#if defined(TXT_ONLY) || !defined(MAPREGSQL) - FILE *fp; - int lock; - - if( (fp=lock_fopen(mapreg_txt,&lock))==NULL ) { - ShowError("script_save_mapreg: Unable to lock-open file [%s]\n",mapreg_txt); - return -1; - } - mapreg_db->foreach(mapreg_db,script_save_mapreg_intsub,fp); - mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub,fp); - lock_fclose(fp,mapreg_txt,&lock); -#else - mapreg_db->foreach(mapreg_db,script_save_mapreg_intsub); - mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub); -#endif - mapreg_dirty=0; - return 0; -} -static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr data) -{ - if(mapreg_dirty) - if (script_save_mapreg() == -1) - ShowError("Failed to save the mapreg data!\n"); - return 0; -} - int script_config_read(char *cfgName) { int i; @@ -3548,11 +3310,8 @@ int do_final_script() } #endif - if(mapreg_dirty>=0) - script_save_mapreg(); + mapreg_final(); - mapreg_db->destroy(mapreg_db,NULL); - mapregstr_db->destroy(mapregstr_db,NULL); scriptlabel_db->destroy(scriptlabel_db,NULL); userfunc_db->destroy(userfunc_db,do_final_userfunc_sub); if(sleep_db) { @@ -3578,26 +3337,16 @@ int do_final_script() *------------------------------------------*/ int do_init_script() { - mapreg_db= idb_alloc(DB_OPT_BASE); - mapregstr_db=idb_alloc(DB_OPT_RELEASE_DATA); userfunc_db=strdb_alloc(DB_OPT_DUP_KEY,0); scriptlabel_db=strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA),50); - - script_load_mapreg(); - - add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); - add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); + mapreg_init(); + return 0; } int script_reload() { - if(mapreg_dirty>=0) - script_save_mapreg(); - - mapreg_db->clear(mapreg_db, NULL); - mapregstr_db->clear(mapregstr_db, NULL); userfunc_db->clear(userfunc_db,do_final_userfunc_sub); scriptlabel_db->clear(scriptlabel_db, NULL); @@ -3614,7 +3363,7 @@ int script_reload() linkdb_final(&sleep_db); } - script_load_mapreg(); + mapreg_reload(); return 0; } diff --git a/src/map/script.h b/src/map/script.h index d4225d8f8..166d8caa6 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -4,6 +4,8 @@ #ifndef _SCRIPT_H_ #define _SCRIPT_H_ +struct map_session_data; + extern int potion_flag; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex] extern int potion_hp, potion_per_hp, potion_sp, potion_per_sp; extern int potion_target; @@ -150,7 +152,8 @@ struct DBMap* script_get_userfunc_db(void); int script_config_read(char *cfgName); int do_init_script(void); int do_final_script(void); -int add_str(const char *p); +int add_str(const char* p); +const char* get_str(int id); int script_reload(void); extern char mapreg_txt[]; diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c index a43520f20..2997771fc 100644 --- a/src/txt-converter/char-converter.c +++ b/src/txt-converter/char-converter.c @@ -283,8 +283,6 @@ int convert_init(void) fclose(fp); } - //FIXME: CONVERT MAPREG HERE! (after enforcing MAPREGSQL for sql) - return 0; } diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp index 7969d8520..28718e6db 100644 --- a/vcproj-6/map-server_sql.dsp +++ b/vcproj-6/map-server_sql.dsp @@ -303,6 +303,14 @@ SOURCE=..\src\map\map.h # End Source File # Begin Source File +SOURCE=..\src\map\mapreg.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mapreg_sql.c +# End Source File +# Begin Source File + SOURCE=..\src\map\mercenary.c # End Source File # Begin Source File diff --git a/vcproj-6/map-server_txt.dsp b/vcproj-6/map-server_txt.dsp index e8a1641c3..54ddcf42d 100644 --- a/vcproj-6/map-server_txt.dsp +++ b/vcproj-6/map-server_txt.dsp @@ -359,6 +359,14 @@ SOURCE=..\src\map\map.h # End Source File # Begin Source File +SOURCE=..\src\map\mapreg.h +# End Source File +# Begin Source File + +SOURCE=..\src\map\mapreg_txt.c +# End Source File +# Begin Source File + SOURCE=..\src\map\mercenary.h # End Source File # Begin Source File diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj index 3711234d4..019123eb3 100644 --- a/vcproj-7.1/map-server_sql.vcproj +++ b/vcproj-7.1/map-server_sql.vcproj @@ -22,7 +22,7 @@ /wd4100" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;MAPREGSQL;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="TRUE" ExceptionHandling="FALSE" @@ -94,7 +94,7 @@ OptimizeForProcessor="2" OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;MAPREGSQL;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="TRUE" RuntimeLibrary="3" DefaultCharIsUnsigned="FALSE" @@ -226,6 +226,12 @@ + + + + diff --git a/vcproj-7.1/map-server_txt.vcproj b/vcproj-7.1/map-server_txt.vcproj index 91f5990d3..9ea7574aa 100644 --- a/vcproj-7.1/map-server_txt.vcproj +++ b/vcproj-7.1/map-server_txt.vcproj @@ -226,6 +226,12 @@ + + + + diff --git a/vcproj-8/map-server_sql.vcproj b/vcproj-8/map-server_sql.vcproj index dede60841..d16eb0bd0 100644 --- a/vcproj-8/map-server_sql.vcproj +++ b/vcproj-8/map-server_sql.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;MAPREGSQL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="true" ExceptionHandling="0" @@ -133,7 +133,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;MAPREGSQL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="true" RuntimeLibrary="0" DefaultCharIsUnsigned="false" @@ -441,6 +441,14 @@ RelativePath="..\src\map\map.h" > + + + + diff --git a/vcproj-8/map-server_txt.vcproj b/vcproj-8/map-server_txt.vcproj index dbaa045c0..20f6c8d45 100644 --- a/vcproj-8/map-server_txt.vcproj +++ b/vcproj-8/map-server_txt.vcproj @@ -300,6 +300,14 @@ RelativePath="..\src\map\map.h" > + + + + diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index 7f1ffe5ef..2c905c921 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;MAPREGSQL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="true" ExceptionHandling="0" @@ -136,7 +136,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;MAPREGSQL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="true" RuntimeLibrary="0" DefaultCharIsUnsigned="false" @@ -446,6 +446,14 @@ RelativePath="..\src\map\map.h" > + + + + diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj index 51f7e76a7..0a61c1895 100644 --- a/vcproj-9/map-server_txt.vcproj +++ b/vcproj-9/map-server_txt.vcproj @@ -305,6 +305,14 @@ RelativePath="..\src\map\map.h" > + + + + -- cgit v1.2.3-70-g09d2 From e5f0d3eb45aedbf6888c0816ecb625999df8cdb6 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sun, 25 Jan 2009 16:12:20 +0000 Subject: * Changes to the configure script: - added option --enable-profiler (supports gprof) - added option --enable-64bit (don't force 32bit) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13486 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 10 +- configure | 2836 ++++++++++++++++++++++++++++++--------------------- configure.in | 101 +- 3 files changed, 1745 insertions(+), 1202 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4acb8a01a..81c7fd34e 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,12 +3,14 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2009/01/25 + * Changes to the configure script: [FlavioJS] + - added option --enable-profiler (supports gprof) + - added option --enable-64bit (don't force 32bit) 2009/01/24 - * Changed pc_spiritball_timer and pc_addspiritball: (bugreport:2705) [FlavioJS] + * Changed pc_spiritball_timer and pc_addspiritball: (bugreport:2705) - don't make assumptions about the calling order of timers - - ensure that sd->spirit_timer is is ordered by expiration time - * Changed pc_spiritball_timer to not assume that timers are called in the same order they are created. (bugreport:2705) - - the timer heap makes no garantees about the order order when timers have the same tick + - ensure that sd->spirit_timer is ordered by expiration time * Changed the variables of the mapcache structs to fixed size equivalents. * Changed all uses of struct skill_unit_group* to group_id in status_change_entry's. [FlavioJS] 2009/01/23 diff --git a/configure b/configure index d473ad2ca..f4875e755 100755 --- a/configure +++ b/configure @@ -1,10 +1,10 @@ #! /bin/sh -# From configure.in Revision: 13073 . +# From configure.in Revision: 13486 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61. +# Generated by GNU Autoconf 2.63. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -16,7 +16,7 @@ DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -38,17 +38,45 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' else - PATH_SEPARATOR=: + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' fi - rm -f conf$$.sh + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } fi # Support unset when possible. @@ -64,8 +92,6 @@ fi # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) -as_nl=' -' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -88,7 +114,7 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -101,17 +127,10 @@ PS2='> ' PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -133,7 +152,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -159,7 +178,7 @@ else as_have_required=no fi - if test $as_have_required = yes && (eval ": + if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } @@ -241,7 +260,7 @@ IFS=$as_save_IFS if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -262,7 +281,7 @@ _ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -342,10 +361,10 @@ fi if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi @@ -414,9 +433,10 @@ fi test \$exitcode = 0") || { echo No shell found that supports shell functions. - echo Please tell autoconf@gnu.org about your system, - echo including any error possibly output before this - echo message + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. } @@ -452,7 +472,7 @@ test \$exitcode = 0") || { s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -480,7 +500,6 @@ case `echo -n x` in *) ECHO_N='-n';; esac - if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -493,19 +512,22 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi @@ -530,10 +552,10 @@ else as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -615,66 +637,79 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -SET_MAKE -CC -CFLAGS -LDFLAGS -CPPFLAGS -ac_ct_CC -EXEEXT -OBJEXT -CPP -GREP -EGREP -MYSQL_CONFIG_HOME -HAVE_MYSQL -MYSQL_VERSION -MYSQL_CFLAGS -MYSQL_LIBS -HAVE_PCRE -PCRE_LIBS -PCRE_CFLAGS -DLLEXT +ac_subst_vars='LTLIBOBJS LIBOBJS -LTLIBOBJS' +DLLEXT +PCRE_CFLAGS +PCRE_LIBS +HAVE_PCRE +MYSQL_LIBS +MYSQL_CFLAGS +MYSQL_VERSION +HAVE_MYSQL +MYSQL_CONFIG_HOME +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +SET_MAKE +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_manager +enable_packetver +enable_debug +enable_profiler +enable_64bit +with_mysql +with_MYSQL_CFLAGS +with_MYSQL_LIBS +with_pcre +with_zlib +' ac_precious_vars='build_alias host_alias target_alias @@ -689,6 +724,8 @@ CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null @@ -787,13 +824,21 @@ do datarootdir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=no ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; @@ -806,13 +851,21 @@ do dvidir=$ac_optarg ;; -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -1003,22 +1056,38 @@ do ac_init_version=: ;; -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=\$ac_optarg ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=no ;; + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. @@ -1038,7 +1107,7 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { echo "$as_me: error: unrecognized option: $ac_option + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -1047,16 +1116,16 @@ Try \`$0 --help' for more information." >&2 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; @@ -1065,22 +1134,38 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi -# Be sure to have absolute directory names. +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done @@ -1095,7 +1180,7 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes @@ -1111,10 +1196,10 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 + { $as_echo "$as_me: error: working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } @@ -1122,12 +1207,12 @@ test "X$ac_ls_di" = "X$ac_pwd_ls_di" || if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X"$0" | + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1154,12 +1239,12 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. @@ -1208,9 +1293,9 @@ Configuration: Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -1220,25 +1305,25 @@ for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -1250,14 +1335,19 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin) --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see src/map/clif.h) - --enable-debug Compiles extra debug code. (disabled by default) + --enable-debug[=ARG] Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) + --enable-profiler=ARG Profilers: no, gprof (disabled by default) + --enable-64bit Don't force 32 bit. (disabled by default) 64bit + support is still being tested, not recommended for + production servers. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1297,15 +1387,17 @@ fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -1341,7 +1433,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix echo && $SHELL "$ac_srcdir/configure" --help=recursive else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1351,10 +1443,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.61 +generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1365,7 +1457,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.61. Invocation command line was +generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -1401,7 +1493,7 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" + $as_echo "PATH: $as_dir" done IFS=$as_save_IFS @@ -1436,7 +1528,7 @@ do | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; @@ -1488,11 +1580,12 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -1522,9 +1615,9 @@ _ASBOX do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - echo "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo @@ -1539,9 +1632,9 @@ _ASBOX do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - echo "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1557,8 +1650,8 @@ _ASBOX echo fi test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -1600,21 +1693,24 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" + ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi -shift -for ac_site_file +for ac_site_file in "$ac_site_file1" "$ac_site_file2" do + test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi @@ -1624,16 +1720,16 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1647,29 +1743,38 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1679,10 +1784,12 @@ echo "$as_me: current value: $ac_new_val" >&2;} fi done if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi @@ -1736,8 +1843,8 @@ if test "${enable_manager+set}" = set; then "dmalloc");; "gcollect");; "bcheck");; - *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enableval'... stopping" >&5 -echo "$as_me: error: unknown memory manager '$enableval'... stopping" >&2;} + *) { { $as_echo "$as_me:$LINENO: error: unknown memory manager '$enableval'... stopping" >&5 +$as_echo "$as_me: error: unknown memory manager '$enableval'... stopping" >&2;} { (exit 1); exit 1; }; };; esac @@ -1772,8 +1879,8 @@ if test "${enable_debug+set}" = set; then "no");; "yes");; "gdb");; - *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 -echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} + *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 +$as_echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac @@ -1784,6 +1891,50 @@ fi +# +# Profiler +# +# Check whether --enable-profiler was given. +if test "${enable_profiler+set}" = set; then + enableval=$enable_profiler; + enable_profiler="$enableval" + case $enableval in + "no");; + "gprof");; + *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-profiler=$enableval... stopping" >&5 +$as_echo "$as_me: error: invalid argument --enable-profiler=$enableval... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_profiler="no" + +fi + + + +# +# 64bit +# +# Check whether --enable-64bit was given. +if test "${enable_64bit+set}" = set; then + enableval=$enable_64bit; + enable_64bit="$enableval" + case $enableval in + "no");; + "yes");; + *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-64bit=$enableval... stopping" >&5 +$as_echo "$as_me: error: invalid argument --enable-64bit=$enableval... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_64bit="no" + +fi + + + # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # @@ -1798,8 +1949,8 @@ if test "${with_mysql+set}" = set; then require_mysql="yes" if test "$withval" != "yes" ; then if test ! -x "$withval" ; then - { { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 -echo "$as_me: error: $withval is not an executable file" >&2;} + { { $as_echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 +$as_echo "$as_me: error: $withval is not an executable file" >&2;} { (exit 1); exit 1; }; } fi MYSQL_CONFIG_HOME="$withval" @@ -1861,8 +2012,8 @@ if test "${with_pcre+set}" = set; then require_pcre="yes" if test "$withval" != "yes" ; then if test ! -d "$withval" ; then - { { echo "$as_me:$LINENO: error: $withval is not a directoy" >&5 -echo "$as_me: error: $withval is not a directoy" >&2;} + { { $as_echo "$as_me:$LINENO: error: $withval is not a directoy" >&5 +$as_echo "$as_me: error: $withval is not a directoy" >&2;} { (exit 1); exit 1; }; } fi PCRE_HOME="$withval" @@ -1902,11 +2053,12 @@ fi -{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } -set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh @@ -1923,12 +2075,12 @@ esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } SET_MAKE= else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -1940,10 +2092,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -1956,7 +2108,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -1967,11 +2119,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -1980,10 +2132,10 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -1996,7 +2148,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2007,11 +2159,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then @@ -2019,12 +2171,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC @@ -2037,10 +2185,10 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2053,7 +2201,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2064,11 +2212,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2077,10 +2225,10 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2098,7 +2246,7 @@ do continue fi ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2121,11 +2269,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2136,10 +2284,10 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2152,7 +2300,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2163,11 +2311,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2180,10 +2328,10 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -2196,7 +2344,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2207,11 +2355,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -2223,12 +2371,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC @@ -2238,44 +2382,50 @@ fi fi -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH +$as_echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` +$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF @@ -2294,27 +2444,22 @@ main () } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -# -# List of possible output files, starting from the most likely. -# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) -# only as a last resort. b.out is created by i960 compilers. -ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' -# -# The IRIX 6 linker writes into existing files which may not be -# executable, retaining their permissions. Remove them first so a -# subsequent execution test works. +{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + ac_rmfiles= for ac_file in $ac_files do case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done @@ -2325,10 +2470,11 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' @@ -2339,7 +2485,7 @@ for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most @@ -2366,25 +2512,27 @@ else ac_file='' fi -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } if test -z "$ac_file"; then - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables +$as_echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } + { (exit 77); exit 77; }; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then @@ -2393,49 +2541,53 @@ if test "$cross_compiling" != yes; then *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. +$as_echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } fi fi fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } -rm -f a.out a.exe conftest$ac_cv_exeext b.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } -{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } -{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will @@ -2444,31 +2596,33 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } fi rm -f conftest$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2491,40 +2645,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile +$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2550,20 +2707,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no @@ -2573,15 +2731,19 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } -GCC=`test $ac_compiler_gnu = yes && echo yes` +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes @@ -2608,20 +2770,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" @@ -2646,20 +2809,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag @@ -2685,20 +2849,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -2713,8 +2878,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2730,10 +2895,10 @@ else CFLAGS= fi fi -{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC @@ -2804,20 +2969,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -2833,15 +2999,15 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6; } ;; + { $as_echo "$as_me:$LINENO: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; xno) - { echo "$as_me:$LINENO: result: unsupported" >&5 -echo "${ECHO_T}unsupported" >&6; } ;; + { $as_echo "$as_me:$LINENO: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; + { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac @@ -2856,15 +3022,15 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" @@ -2896,20 +3062,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. @@ -2933,13 +3100,14 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err @@ -2947,7 +3115,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 # Broken: success on invalid input. continue else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. @@ -2972,8 +3140,8 @@ fi else ac_cv_prog_CPP=$CPP fi -{ echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6; } +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +$as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -3001,20 +3169,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. @@ -3038,13 +3207,14 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err @@ -3052,7 +3222,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 # Broken: success on invalid input. continue else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. @@ -3068,11 +3238,13 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { (exit 1); exit 1; }; }; } fi ac_ext=c @@ -3095,42 +3267,37 @@ CPPFLAGS="$CPPFLAGS -I../common" -{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Extract the first word of "grep ggrep" to use in msg output -if test -z "$GREP"; then -set dummy grep ggrep; ac_prog_name=$2 +{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else + if test -z "$GREP"; then ac_path_GREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue - # Check for GNU ac_path_GREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - echo 'GREP' >> "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` @@ -3145,74 +3312,60 @@ case `"$ac_path_GREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - - $ac_path_GREP_found && break 3 + $ac_path_GREP_found && break 3 + done done done - -done IFS=$as_save_IFS - - -fi - -GREP="$ac_cv_path_GREP" -if test -z "$GREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + if test -z "$ac_cv_path_GREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } -fi - + fi else ac_cv_path_GREP=$GREP fi - fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -echo "${ECHO_T}$ac_cv_path_GREP" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else - # Extract the first word of "egrep" to use in msg output -if test -z "$EGREP"; then -set dummy egrep; ac_prog_name=$2 -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else + if test -z "$EGREP"; then ac_path_EGREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue - # Check for GNU ac_path_EGREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - echo 'EGREP' >> "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` @@ -3227,40 +3380,31 @@ case `"$ac_path_EGREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - - $ac_path_EGREP_found && break 3 + $ac_path_EGREP_found && break 3 + done done done - -done IFS=$as_save_IFS - - -fi - -EGREP="$ac_cv_path_EGREP" -if test -z "$EGREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + if test -z "$ac_cv_path_EGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } -fi - + fi else ac_cv_path_EGREP=$EGREP fi - fi fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3287,20 +3431,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no @@ -3392,37 +3537,40 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi +rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF @@ -3444,11 +3592,11 @@ fi for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3466,20 +3614,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" @@ -3487,12 +3636,15 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_Header'}'` = yes; then +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -3500,28 +3652,78 @@ fi done -{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } + + { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else - # See if sys/param.h defines the BYTE_ORDER macro. -cat >conftest.$ac_ext <<_ACEOF + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + # Check for potential -arch flags. It is not universal unless + # there are some -arch flags. Note that *ppc* also matches + # ppc64. This check is also rather less than ideal. + case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( + *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; + esac +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include -#include + #include int main () { -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ - && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) - bogus endian macros -#endif +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif ; return 0; @@ -3533,33 +3735,34 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include -#include + #include int main () { #if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif + not big endian + #endif ; return 0; @@ -3571,20 +3774,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no @@ -3592,29 +3796,69 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - # It does not; compile a test program. -if test "$cross_compiling" = yes; then - # try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown - cat >conftest.$ac_ext <<_ACEOF + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; -void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; -void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +#include + int main () { - _ascii (); _ebcdic (); +#ifndef _BIG_ENDIAN + not big endian + #endif + ; return 0; } @@ -3625,30 +3869,101 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_bigendian=no fi -if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi -fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then + # Try to guess by grepping values from an object file. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -3667,14 +3982,14 @@ int main () { - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; ; return 0; @@ -3686,58 +4001,67 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi +rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + { { $as_echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 +$as_echo "$as_me: error: bigendian is not supported... stopping" >&2;} + { (exit 1); exit 1; }; };; #( + no) + ;; #( + universal) -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } -case $ac_cv_c_bigendian in - yes) - { { echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 -echo "$as_me: error: bigendian is not supported... stopping" >&2;} - { (exit 1); exit 1; }; } ;; - no) - ;; - *) - { echo "$as_me:$LINENO: WARNING: unable to determine endianess, only little endian is supported" >&5 -echo "$as_me: WARNING: unable to determine endianess, only little endian is supported" >&2;} +cat >>confdefs.h <<\_ACEOF +#define AC_APPLE_UNIVERSAL_BUILD 1 +_ACEOF + + ;; #( + *) + { $as_echo "$as_me:$LINENO: WARNING: unable to determine endianess, only little endian is supported" >&5 +$as_echo "$as_me: WARNING: unable to determine endianess, only little endian is supported" >&2;} ;; -esac + esac -{ echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 -echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6; } -pointers_fit_in_ints="no" -cat >conftest.$ac_ext <<_ACEOF +if test "$enable_64bit" = "no" ; then + { $as_echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 +$as_echo_n "checking whether pointers can be stored in ints (old code)... " >&6; } + pointers_fit_in_ints="no" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3758,20 +4082,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then pointers_fit_in_ints="yes" else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -3779,10 +4104,10 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test "$pointers_fit_in_ints" = "no" ; then - CFLAGS="$CFLAGS -m32" - LDFLAGS="$LDFLAGS -m32" - cat >conftest.$ac_ext <<_ACEOF + if test "$pointers_fit_in_ints" = "no" ; then + CFLAGS="$CFLAGS -m32" + LDFLAGS="$LDFLAGS -m32" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3803,20 +4128,21 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then pointers_fit_in_ints="yes (with -m32)" else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -3824,18 +4150,19 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 -echo "${ECHO_T}$pointers_fit_in_ints" >&6; } -if test "$pointers_fit_in_ints" = "no" ; then - { { echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 -echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} + fi + { $as_echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 +$as_echo "$pointers_fit_in_ints" >&6; } + if test "$pointers_fit_in_ints" = "no" ; then + { { $as_echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 +$as_echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} { (exit 1); exit 1; }; } + fi fi -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 +$as_echo_n "checking whether $CC supports -Wno-unused-parameter... " >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-unused-parameter" cat >conftest.$ac_ext <<_ACEOF @@ -3847,26 +4174,27 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$OLD_CFLAGS" @@ -3875,8 +4203,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 +$as_echo_n "checking whether $CC supports -Wno-pointer-sign... " >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-pointer-sign" cat >conftest.$ac_ext <<_ACEOF @@ -3888,26 +4216,27 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$OLD_CFLAGS" @@ -3916,8 +4245,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 -echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 +$as_echo_n "checking whether $CC supports -Wno-switch... " >&6; } OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-switch" cat >conftest.$ac_ext <<_ACEOF @@ -3929,26 +4258,27 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$OLD_CFLAGS" @@ -3966,10 +4296,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # # setrlimit - used to set the socket limit # -{ echo "$as_me:$LINENO: checking for setrlimit" >&5 -echo $ECHO_N "checking for setrlimit... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for setrlimit" >&5 +$as_echo_n "checking for setrlimit... " >&6; } if test "${ac_cv_func_setrlimit+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4022,32 +4352,36 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_func_setrlimit=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_setrlimit=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_setrlimit" >&5 -echo "${ECHO_T}$ac_cv_func_setrlimit" >&6; } -if test $ac_cv_func_setrlimit = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_setrlimit" >&5 +$as_echo "$ac_cv_func_setrlimit" >&6; } +if test "x$ac_cv_func_setrlimit" = x""yes; then CFLAGS="$CFLAGS -DHAVE_SETRLIMIT" fi @@ -4067,17 +4401,17 @@ case $enable_manager in "memwatch") CFLAGS="$CFLAGS -DMEMWATCH" if test "${ac_cv_header_memwatch_h+set}" = set; then - { echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for memwatch.h" >&5 +$as_echo_n "checking for memwatch.h... " >&6; } if test "${ac_cv_header_memwatch_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +$as_echo "$ac_cv_header_memwatch_h" >&6; } else # Is the header compilable? -{ echo "$as_me:$LINENO: checking memwatch.h usability" >&5 -echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +$as_echo_n "checking memwatch.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4093,32 +4427,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } # Is the header present? -{ echo "$as_me:$LINENO: checking memwatch.h presence" >&5 -echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +$as_echo_n "checking memwatch.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4132,70 +4467,71 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ echo "$as_me:$LINENO: checking for memwatch.h" >&5 -echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for memwatch.h" >&5 +$as_echo_n "checking for memwatch.h... " >&6; } if test "${ac_cv_header_memwatch_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_header_memwatch_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +$as_echo "$ac_cv_header_memwatch_h" >&6; } fi -if test $ac_cv_header_memwatch_h = yes; then +if test "x$ac_cv_header_memwatch_h" = x""yes; then : else - { { echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 -echo "$as_me: error: memwatch header not found... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 +$as_echo "$as_me: error: memwatch header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4205,17 +4541,17 @@ fi CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" LIBS="$LIBS -ldmalloc" if test "${ac_cv_header_dmalloc_h+set}" = set; then - { echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +$as_echo_n "checking for dmalloc.h... " >&6; } if test "${ac_cv_header_dmalloc_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +$as_echo "$ac_cv_header_dmalloc_h" >&6; } else # Is the header compilable? -{ echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 -echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +$as_echo_n "checking dmalloc.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4231,32 +4567,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } # Is the header present? -{ echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 -echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +$as_echo_n "checking dmalloc.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4270,70 +4607,71 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +$as_echo_n "checking for dmalloc.h... " >&6; } if test "${ac_cv_header_dmalloc_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_header_dmalloc_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +$as_echo "$ac_cv_header_dmalloc_h" >&6; } fi -if test $ac_cv_header_dmalloc_h = yes; then +if test "x$ac_cv_header_dmalloc_h" = x""yes; then : else - { { echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 -echo "$as_me: error: dmalloc header not found... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 +$as_echo "$as_me: error: dmalloc header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4343,17 +4681,17 @@ fi CFLAGS="$CFLAGS -DGCOLLECT" LIBS="$LIBS -lgc" if test "${ac_cv_header_gc_h+set}" = set; then - { echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for gc.h" >&5 +$as_echo_n "checking for gc.h... " >&6; } if test "${ac_cv_header_gc_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +$as_echo "$ac_cv_header_gc_h" >&6; } else # Is the header compilable? -{ echo "$as_me:$LINENO: checking gc.h usability" >&5 -echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking gc.h usability" >&5 +$as_echo_n "checking gc.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4369,32 +4707,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } # Is the header present? -{ echo "$as_me:$LINENO: checking gc.h presence" >&5 -echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking gc.h presence" >&5 +$as_echo_n "checking gc.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4408,70 +4747,71 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ echo "$as_me:$LINENO: checking for gc.h" >&5 -echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for gc.h" >&5 +$as_echo_n "checking for gc.h... " >&6; } if test "${ac_cv_header_gc_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_header_gc_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +$as_echo "$ac_cv_header_gc_h" >&6; } fi -if test $ac_cv_header_gc_h = yes; then +if test "x$ac_cv_header_gc_h" = x""yes; then : else - { { echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 -echo "$as_me: error: gcollect header not found... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 +$as_echo "$as_me: error: gcollect header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4508,6 +4848,20 @@ case $enable_debug in esac +# +# Profiler +# +case $enable_profiler in + "no") + # default value + ;; + "gprof") + CFLAGS="$CFLAGS -pg" + LDFLAGS="$LDFLAGS -pg" + ;; +esac + + # # zlib library (required) # @@ -4516,10 +4870,10 @@ if test -n "${ZLIB_HOME}" ; then CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" fi -{ echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 -echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 +$as_echo_n "checking for inflateEnd in -lz... " >&6; } if test "${ac_cv_lib_z_inflateEnd+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" @@ -4551,33 +4905,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_z_inflateEnd=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_z_inflateEnd=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 -echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6; } -if test $ac_cv_lib_z_inflateEnd = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 +$as_echo "$ac_cv_lib_z_inflateEnd" >&6; } +if test "x$ac_cv_lib_z_inflateEnd" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF @@ -4585,23 +4943,23 @@ _ACEOF LIBS="-lz $LIBS" else - { { echo "$as_me:$LINENO: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&5 -echo "$as_me: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&5 +$as_echo "$as_me: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&2;} { (exit 1); exit 1; }; } fi if test "${ac_cv_header_zlib_h+set}" = set; then - { echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for zlib.h" >&5 +$as_echo_n "checking for zlib.h... " >&6; } if test "${ac_cv_header_zlib_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +$as_echo "$ac_cv_header_zlib_h" >&6; } else # Is the header compilable? -{ echo "$as_me:$LINENO: checking zlib.h usability" >&5 -echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking zlib.h usability" >&5 +$as_echo_n "checking zlib.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4617,32 +4975,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } # Is the header present? -{ echo "$as_me:$LINENO: checking zlib.h presence" >&5 -echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking zlib.h presence" >&5 +$as_echo_n "checking zlib.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4656,70 +5015,71 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for zlib.h" >&5 +$as_echo_n "checking for zlib.h... " >&6; } if test "${ac_cv_header_zlib_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_header_zlib_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +$as_echo "$ac_cv_header_zlib_h" >&6; } fi -if test $ac_cv_header_zlib_h = yes; then +if test "x$ac_cv_header_zlib_h" = x""yes; then : else - { { echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 -echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 +$as_echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4730,10 +5090,10 @@ fi # math library (required) # -{ echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 -echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 +$as_echo_n "checking for sqrt in -lm... " >&6; } if test "${ac_cv_lib_m_sqrt+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" @@ -4765,33 +5125,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_m_sqrt=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_sqrt=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 -echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6; } -if test $ac_cv_lib_m_sqrt = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 +$as_echo "$ac_cv_lib_m_sqrt" >&6; } +if test "x$ac_cv_lib_m_sqrt" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -4799,8 +5163,8 @@ _ACEOF LIBS="-lm $LIBS" else - { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 -echo "$as_me: error: math library not found... stopping" >&2;} + { { $as_echo "$as_me:$LINENO: error: math library not found... stopping" >&5 +$as_echo "$as_me: error: math library not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4810,10 +5174,10 @@ fi # clock_gettime (rt on Debian) # -{ echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 -echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 +$as_echo_n "checking for clock_gettime in -lrt... " >&6; } if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" @@ -4845,33 +5209,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_rt_clock_gettime=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_rt_clock_gettime=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 -echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6; } -if test $ac_cv_lib_rt_clock_gettime = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 +$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } +if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF @@ -4890,16 +5258,16 @@ if test "$want_mysql" = "no" ; then MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" - { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 -echo "$as_me: ignoring MySQL (optional)" >&6;} + { $as_echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 +$as_echo "$as_me: ignoring MySQL (optional)" >&6;} else if test -z "$MYSQL_CONFIG_HOME"; then # Extract the first word of "mysql_config", so it can be a program name with args. set dummy mysql_config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else case $MYSQL_CONFIG_HOME in [\\/]* | ?:[\\/]*) @@ -4914,7 +5282,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4927,11 +5295,11 @@ esac fi MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME if test -n "$MYSQL_CONFIG_HOME"; then - { echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 -echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6; } + { $as_echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 +$as_echo "$MYSQL_CONFIG_HOME" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -4951,10 +5319,10 @@ fi MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - { echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 -echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 +$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmysqlclient $LIBS" @@ -4986,48 +5354,52 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_mysqlclient_mysql_init=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_mysqlclient_mysql_init=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 -echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6; } -if test $ac_cv_lib_mysqlclient_mysql_init = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 +$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } +if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then HAVE_MYSQL="yes" fi if test "${ac_cv_header_mysql_h+set}" = set; then - { echo "$as_me:$LINENO: checking for mysql.h" >&5 -echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for mysql.h" >&5 +$as_echo_n "checking for mysql.h... " >&6; } if test "${ac_cv_header_mysql_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 -echo "${ECHO_T}$ac_cv_header_mysql_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +$as_echo "$ac_cv_header_mysql_h" >&6; } else # Is the header compilable? -{ echo "$as_me:$LINENO: checking mysql.h usability" >&5 -echo $ECHO_N "checking mysql.h usability... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking mysql.h usability" >&5 +$as_echo_n "checking mysql.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5043,32 +5415,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } # Is the header present? -{ echo "$as_me:$LINENO: checking mysql.h presence" >&5 -echo $ECHO_N "checking mysql.h presence... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking mysql.h presence" >&5 +$as_echo_n "checking mysql.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5082,66 +5455,67 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { echo "$as_me:$LINENO: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: mysql.h: proceeding with the compiler's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: mysql.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { echo "$as_me:$LINENO: WARNING: mysql.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: mysql.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: mysql.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: mysql.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: mysql.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: mysql.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: mysql.h: in the future, the compiler will take precedence" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: mysql.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: mysql.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: mysql.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: mysql.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: mysql.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: mysql.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ echo "$as_me:$LINENO: checking for mysql.h" >&5 -echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for mysql.h" >&5 +$as_echo_n "checking for mysql.h... " >&6; } if test "${ac_cv_header_mysql_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_cv_header_mysql_h=$ac_header_preproc fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 -echo "${ECHO_T}$ac_cv_header_mysql_h" >&6; } +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +$as_echo "$ac_cv_header_mysql_h" >&6; } fi -if test $ac_cv_header_mysql_h = yes; then +if test "x$ac_cv_header_mysql_h" = x""yes; then : else HAVE_MYSQL="" @@ -5151,21 +5525,21 @@ fi CPPFLAGS="$MYSQL_OLD_CPPFLAGS" LDFLAGS="$MYSQL_OLD_LDFLAGS" - { echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 -echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 +$as_echo_n "checking MySQL library (optional)... " >&6; } if test "$HAVE_MYSQL" = "yes" ; then - { echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 -echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6; } + { $as_echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +$as_echo "yes ($MYSQL_VERSION)" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } if test "$require_mysql" = "yes" ; then - { { echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 -echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} + { { $as_echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 +$as_echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } else - { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 -echo "$as_me: disabling MySQL (optional)" >&6;} + { $as_echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 +$as_echo "$as_me: disabling MySQL (optional)" >&6;} MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" @@ -5187,14 +5561,14 @@ PCRE_LIBS="" PCRE_CFLAGS="" if test "$want_pcre" = "no" ; then - { echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 -echo "$as_me: ignoring PCRE (optional)" >&6;} + { $as_echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 +$as_echo "$as_me: ignoring PCRE (optional)" >&6;} else if test -z "$PCRE_HOME" ; then - { echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 -echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 +$as_echo_n "checking for pcre_study in -lpcre... " >&6; } if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" @@ -5226,33 +5600,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_pcre_pcre_study=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pcre_pcre_study=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6; } -if test $ac_cv_lib_pcre_pcre_study = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 +$as_echo "$ac_cv_lib_pcre_pcre_study" >&6; } +if test "x$ac_cv_lib_pcre_pcre_study" = x""yes; then HAVE_PCRE="yes" fi @@ -5262,10 +5640,10 @@ fi else PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" - { echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 -echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +$as_echo_n "checking for pcre_compile in -lpcre... " >&6; } if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" @@ -5297,33 +5675,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then ac_cv_lib_pcre_pcre_compile=yes else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pcre_pcre_compile=no fi +rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 -echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6; } -if test $ac_cv_lib_pcre_pcre_compile = yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +$as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } +if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then HAVE_PCRE="yes" fi @@ -5334,21 +5716,21 @@ fi test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" fi fi - { echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 -echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6; } + { $as_echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 +$as_echo_n "checking PCRE library (optional)... " >&6; } if test "$HAVE_PCRE" = "yes" ; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } if test "$require_pcre" = "yes" ; then - { { echo "$as_me:$LINENO: error: PCRE not found or incompatible (requested)" >&5 -echo "$as_me: error: PCRE not found or incompatible (requested)" >&2;} + { { $as_echo "$as_me:$LINENO: error: PCRE not found or incompatible (requested)" >&5 +$as_echo "$as_me: error: PCRE not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } else - { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 -echo "$as_me: disabling PCRE (optional)" >&6;} + { $as_echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 +$as_echo "$as_me: disabling PCRE (optional)" >&6;} fi fi fi @@ -5361,11 +5743,11 @@ fi # # Host specific stuff # -{ echo "$as_me:$LINENO: checking host OS" >&5 -echo $ECHO_N "checking host OS... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking host OS" >&5 +$as_echo_n "checking host OS... " >&6; } host_os="`uname`" -{ echo "$as_me:$LINENO: result: $host_os" >&5 -echo "${ECHO_T}$host_os" >&6; } +{ $as_echo "$as_me:$LINENO: result: $host_os" >&5 +$as_echo "$host_os" >&6; } fd_setsize="" DLLEXT=".so" case $host_os in @@ -5389,19 +5771,19 @@ CYGWIN*) esac -{ echo "$as_me:$LINENO: checking for MinGW" >&5 -echo $ECHO_N "checking for MinGW... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for MinGW" >&5 +$as_echo_n "checking for MinGW... " >&6; } if test -n "`$CC --version | grep -i mingw`" ; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } CPPFLAGS="$CPPFLAGS -DMINGW" if test -z "$fd_setsize" ; then CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" fi LIBS="$LIBS -lws2_32" else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } fi @@ -5434,11 +5816,12 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -5471,12 +5854,12 @@ echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -5493,6 +5876,12 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g @@ -5522,7 +5911,7 @@ ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -5534,12 +5923,14 @@ LTLIBOBJS=$ac_ltlibobjs + : ${CONFIG_STATUS=./config.status} +ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -5552,7 +5943,7 @@ ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## @@ -5562,7 +5953,7 @@ DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -5584,17 +5975,45 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' else - PATH_SEPARATOR=: + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' fi - rm -f conf$$.sh + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } fi # Support unset when possible. @@ -5610,8 +6029,6 @@ fi # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) -as_nl=' -' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -5634,7 +6051,7 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -5647,17 +6064,10 @@ PS2='> ' PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -5679,7 +6089,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -5730,7 +6140,7 @@ $as_unset CDPATH s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -5758,7 +6168,6 @@ case `echo -n x` in *) ECHO_N='-n';; esac - if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -5771,19 +6180,22 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi @@ -5808,10 +6220,10 @@ else as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -5834,7 +6246,7 @@ exec 6>&1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.61. Invocation command line was +generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5847,26 +6259,33 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q` _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. -Usage: $0 [OPTIONS] [FILE]... +Usage: $0 [OPTION]... [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages + -q, --quiet, --silent + do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE Configuration files: $config_files @@ -5874,23 +6293,23 @@ $config_files Report bugs to ." _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.61, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2006 Free Software Foundation, Inc. +Copyright (C) 2008 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' +test -n "\$AWK" || AWK=awk _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do @@ -5912,21 +6331,24 @@ do -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; + $as_echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; + $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 + -*) { $as_echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -5945,30 +6367,32 @@ if $ac_cs_silent; then fi _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + exec "\$@" fi _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - echo "$ac_log" + $as_echo "$ac_log" } >&5 _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets @@ -5985,8 +6409,8 @@ do "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done @@ -6025,124 +6449,145 @@ $debug || (umask 077 && mkdir "$tmp") } || { - echo "$me: cannot create a temporary directory in ." >&2 + $as_echo "$as_me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -# -# Set up the sed scripts for CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then -_ACEOF +ac_cr=' +' +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -SHELL!$SHELL$ac_delim -PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim -PACKAGE_NAME!$PACKAGE_NAME$ac_delim -PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim -PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim -PACKAGE_STRING!$PACKAGE_STRING$ac_delim -PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim -exec_prefix!$exec_prefix$ac_delim -prefix!$prefix$ac_delim -program_transform_name!$program_transform_name$ac_delim -bindir!$bindir$ac_delim -sbindir!$sbindir$ac_delim -libexecdir!$libexecdir$ac_delim -datarootdir!$datarootdir$ac_delim -datadir!$datadir$ac_delim -sysconfdir!$sysconfdir$ac_delim -sharedstatedir!$sharedstatedir$ac_delim -localstatedir!$localstatedir$ac_delim -includedir!$includedir$ac_delim -oldincludedir!$oldincludedir$ac_delim -docdir!$docdir$ac_delim -infodir!$infodir$ac_delim -htmldir!$htmldir$ac_delim -dvidir!$dvidir$ac_delim -pdfdir!$pdfdir$ac_delim -psdir!$psdir$ac_delim -libdir!$libdir$ac_delim -localedir!$localedir$ac_delim -mandir!$mandir$ac_delim -DEFS!$DEFS$ac_delim -ECHO_C!$ECHO_C$ac_delim -ECHO_N!$ECHO_N$ac_delim -ECHO_T!$ECHO_T$ac_delim -LIBS!$LIBS$ac_delim -build_alias!$build_alias$ac_delim -host_alias!$host_alias$ac_delim -target_alias!$target_alias$ac_delim -SET_MAKE!$SET_MAKE$ac_delim -CC!$CC$ac_delim -CFLAGS!$CFLAGS$ac_delim -LDFLAGS!$LDFLAGS$ac_delim -CPPFLAGS!$CPPFLAGS$ac_delim -ac_ct_CC!$ac_ct_CC$ac_delim -EXEEXT!$EXEEXT$ac_delim -OBJEXT!$OBJEXT$ac_delim -CPP!$CPP$ac_delim -GREP!$GREP$ac_delim -EGREP!$EGREP$ac_delim -MYSQL_CONFIG_HOME!$MYSQL_CONFIG_HOME$ac_delim -HAVE_MYSQL!$HAVE_MYSQL$ac_delim -MYSQL_VERSION!$MYSQL_VERSION$ac_delim -MYSQL_CFLAGS!$MYSQL_CFLAGS$ac_delim -MYSQL_LIBS!$MYSQL_LIBS$ac_delim -HAVE_PCRE!$HAVE_PCRE$ac_delim -PCRE_LIBS!$PCRE_LIBS$ac_delim -PCRE_CFLAGS!$PCRE_CFLAGS$ac_delim -DLLEXT!$DLLEXT$ac_delim -LIBOBJS!$LIBOBJS$ac_delim -LTLIBOBJS!$LTLIBOBJS$ac_delim -_ACEOF + . ./conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done +rm -f conf$$subs.sh -ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` -if test -n "$ac_eof"; then - ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` - ac_eof=`expr $ac_eof + 1` -fi +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} -cat >>$CONFIG_STATUS <<_ACEOF -cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACAWK _ACEOF -sed ' -s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g -s/^/s,@/; s/!/@,|#_!!_#|/ -:n -t n -s/'"$ac_delim"'$/,g/; t -s/$/\\/; p -N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n -' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF -:end -s/|#_!!_#|//g -CEOF$ac_eof +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } _ACEOF - # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty @@ -6158,19 +6603,21 @@ s/^[^=]*=[ ]*$// }' fi -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" -for ac_tag in :F $CONFIG_FILES +eval set X " :F $CONFIG_FILES " +shift +for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; @@ -6199,26 +6646,38 @@ echo "$as_me: error: Invalid tag $ac_tag." >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac - ac_file_inputs="$ac_file_inputs $ac_f" + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + ac_file_inputs="$ac_file_inputs '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; + *:-:* | *:-) cat >"$tmp/stdin" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; esac ;; esac @@ -6228,7 +6687,7 @@ $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | +$as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -6254,7 +6713,7 @@ echo X"$ac_file" | as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -6263,7 +6722,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -6284,17 +6743,17 @@ echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -6330,12 +6789,13 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= -case `sed -n '/datarootdir/ { +ac_sed_dataroot=' +/datarootdir/ { p q } @@ -6344,13 +6804,14 @@ case `sed -n '/datarootdir/ { /@infodir@/p /@localedir@/p /@mandir@/p -' $ac_file_inputs` in +' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g @@ -6364,15 +6825,16 @@ _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub $extrasub _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t +s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t @@ -6381,21 +6843,28 @@ s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; @@ -6410,6 +6879,11 @@ _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save +test $ac_write_fail = 0 || + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. @@ -6431,4 +6905,8 @@ if test "$no_create" != yes; then # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi diff --git a/configure.in b/configure.in index d0d15e0ca..c881f5610 100644 --- a/configure.in +++ b/configure.in @@ -56,9 +56,11 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [debug], AC_HELP_STRING( - [--enable-debug], - [Compiles extra debug code. (disabled by default)], - [(available options: yes, no, gdb)] + [--enable-debug@<:@=ARG@:>@], + [ + Compiles extra debug code. (disabled by default) + (available options: yes, no, gdb) + ] ), [ enable_debug="$enableval" @@ -73,6 +75,51 @@ AC_ARG_ENABLE( ) +# +# Profiler +# +AC_ARG_ENABLE( + [profiler], + AC_HELP_STRING( + [--enable-profiler=ARG], + [Profilers: no, gprof (disabled by default)] + ), + [ + enable_profiler="$enableval" + case $enableval in + "no");; + "gprof");; + *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);; + esac + ], + [enable_profiler="no"] +) + + +# +# 64bit +# +AC_ARG_ENABLE( + [64bit], + AC_HELP_STRING( + [--enable-64bit], + [ + Don't force 32 bit. (disabled by default) + 64bit support is still being tested, not recommended for production servers. + ] + ), + [ + enable_64bit="$enableval" + case $enableval in + "no");; + "yes");; + *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);; + esac + ], + [enable_64bit="no"] +) + + # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # @@ -205,25 +252,27 @@ AC_C_BIGENDIAN( ) -AC_MSG_CHECKING([whether pointers can be stored in ints (old code)]) -pointers_fit_in_ints="no" -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])], - [pointers_fit_in_ints="yes"], - [] -) -if test "$pointers_fit_in_ints" = "no" ; then - CFLAGS="$CFLAGS -m32" - LDFLAGS="$LDFLAGS -m32" +if test "$enable_64bit" = "no" ; then + AC_MSG_CHECKING([whether pointers can be stored in ints (old code)]) + pointers_fit_in_ints="no" AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])], - [pointers_fit_in_ints="yes (with -m32)"], + [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])], + [pointers_fit_in_ints="yes"], [] ) -fi -AC_MSG_RESULT($pointers_fit_in_ints) -if test "$pointers_fit_in_ints" = "no" ; then - AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping]) + if test "$pointers_fit_in_ints" = "no" ; then + CFLAGS="$CFLAGS -m32" + LDFLAGS="$LDFLAGS -m32" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])], + [pointers_fit_in_ints="yes (with -m32)"], + [] + ) + fi + AC_MSG_RESULT($pointers_fit_in_ints) + if test "$pointers_fit_in_ints" = "no" ; then + AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping]) + fi fi @@ -334,6 +383,20 @@ case $enable_debug in esac +# +# Profiler +# +case $enable_profiler in + "no") + # default value + ;; + "gprof") + CFLAGS="$CFLAGS -pg" + LDFLAGS="$LDFLAGS -pg" + ;; +esac + + # # zlib library (required) # -- cgit v1.2.3-70-g09d2 From 09b5ddd71e1daa21c8e186207f7f3d1a4e3b11ed Mon Sep 17 00:00:00 2001 From: Yommy Date: Tue, 16 Mar 2010 21:42:14 +0000 Subject: added --enable-rdtsc configure option to enhance timer performance, especially in virtualized environments; default disabled - credits to sirius_black git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14265 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 6669 +++++++++++++++++++++++----------------------------- configure.in | 37 + src/common/timer.c | 45 + 3 files changed, 2962 insertions(+), 3789 deletions(-) (limited to 'configure') diff --git a/configure b/configure index f4875e755..70a12eb59 100755 --- a/configure +++ b/configure @@ -1,83 +1,26 @@ #! /bin/sh # From configure.in Revision: 13486 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63. +# Generated by GNU Autoconf 2.59. # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh +# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -87,60 +30,33 @@ else fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - # Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done +$as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -148,391 +64,157 @@ fi # Name of the executable. -as_me=`$as_basename -- "$0" || +as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi -test \$exitcode = 0) || { (exit 1); exit 1; } + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - case $as_dir in + for as_base in sh bash ksh sh5; do + case $as_dir in /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - + if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop - s/-\n.*// + s,-$,, + s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno # Exit status is that of the last command. exit } -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then + +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links as_ln_s='cp -p' + else + as_ln_s='ln -s' fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null +rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -541,28 +223,7 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -571,27 +232,39 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH -exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` +exec 6>&1 + # # Initializations. # ac_default_prefix=/usr/local -ac_clean_files= ac_config_libobj_dir=. -LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= @@ -604,128 +277,46 @@ ac_unique_file="src/common/cbasetypes.h" # Factoring default headers for most tests. ac_includes_default="\ #include -#ifdef HAVE_SYS_TYPES_H +#if HAVE_SYS_TYPES_H # include #endif -#ifdef HAVE_SYS_STAT_H +#if HAVE_SYS_STAT_H # include #endif -#ifdef STDC_HEADERS +#if STDC_HEADERS # include # include #else -# ifdef HAVE_STDLIB_H +# if HAVE_STDLIB_H # include # endif #endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif -#ifdef HAVE_STRINGS_H +#if HAVE_STRINGS_H # include #endif -#ifdef HAVE_INTTYPES_H +#if HAVE_INTTYPES_H # include +#else +# if HAVE_STDINT_H +# include +# endif #endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H +#if HAVE_UNISTD_H # include #endif" -ac_subst_vars='LTLIBOBJS -LIBOBJS -DLLEXT -PCRE_CFLAGS -PCRE_LIBS -HAVE_PCRE -MYSQL_LIBS -MYSQL_CFLAGS -MYSQL_VERSION -HAVE_MYSQL -MYSQL_CONFIG_HOME -EGREP -GREP -CPP -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -SET_MAKE -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS' ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_manager -enable_packetver -enable_debug -enable_profiler -enable_64bit -with_mysql -with_MYSQL_CFLAGS -with_MYSQL_LIBS -with_pcre -with_zlib -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - # Initialize some variables set by options. ac_init_help= ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null @@ -748,48 +339,34 @@ x_libraries=NONE # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' +datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' +infodir='${prefix}/info' +mandir='${prefix}/man' ac_prev= -ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option + eval "$ac_prev=\$ac_option" ac_prev= continue fi - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -811,61 +388,33 @@ do --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad) + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) datadir=$ac_optarg ;; - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; esac - eval enable_$ac_useropt=\$ac_optarg ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -892,12 +441,6 @@ do -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -922,16 +465,13 @@ do | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -996,16 +536,6 @@ do | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -1056,38 +586,26 @@ do ac_init_version=: ;; -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; esac - eval with_$ac_useropt=\$ac_optarg ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -1107,7 +625,7 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option + -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -1116,16 +634,17 @@ Try \`$0 --help' for more information." >&2 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; @@ -1134,39 +653,31 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix do - eval ac_val=\$$ac_var - # Remove trailing slashes. + eval ac_val=$`echo $ac_var` case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac - # Be sure to have absolute directory names. +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -1180,7 +691,7 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes @@ -1193,76 +704,74 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then + if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } + fi fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP # # Report the --help message. @@ -1291,11 +800,14 @@ Configuration: -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] +_ACEOF + + cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -1305,25 +817,18 @@ for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF @@ -1335,15 +840,23 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin) --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see src/map/clif.h) - --enable-debug[=ARG] Compiles extra debug code. (disabled by default) + --enable-debug[=ARG] + Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) + --enable-rdtsc Uses rdtsc as timing source (disabled by default) + Enable it when you've timing issues. (For example: + in conjunction with XEN or Other Virtualization + mechanisms) Note: Please ensure that you've disabled + dynamic CPU-Frequencys, such as power saving + options. (On the most modern Dedicated Servers + cpufreq is preconfigured, see your distribution's + manual how to disable it) --enable-profiler=ARG Profilers: no, gprof (disabled by default) --enable-64bit Don't force 32 bit. (disabled by default) 64bit support is still being tested, not recommended for @@ -1352,14 +865,15 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-mysql[=ARG] use MySQL client library, optionally specify the + --with-mysql[=ARG] + use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found) --with-MYSQL_CFLAGS=ARG specify MYSQL_CFLAGS manually (instead of using "mysql_config --include") --with-MYSQL_LIBS=ARG specify MYSQL_LIBS manually (instead of using "mysql_config --libs") - --with-pcre[=ARG] use PCRE library, optionally specify the full path + --with-pcre[=ARG] use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found) --with-zlib=DIR root directory path of zlib installation (defaults @@ -1372,97 +886,126 @@ Some influential environment variables: CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF -ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. + ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue + test -d $ac_dir || continue ac_builddir=. -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi case $srcdir in - .) # We are building in place. + .) # No --srcdir option. We are building in place. ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir done fi -test -n "$ac_init_help" && exit $ac_status +test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -configure -generated by GNU Autoconf 2.63 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit + exit 0 fi -cat >config.log <<_ACEOF +exec 5>config.log +cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF -exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -1481,7 +1024,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -1493,9 +1036,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" + echo "PATH: $as_dir" done -IFS=$as_save_IFS } >&5 @@ -1517,6 +1059,7 @@ _ACEOF ac_configure_args= ac_configure_args0= ac_configure_args1= +ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1527,8 +1070,8 @@ do -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; @@ -1549,7 +1092,9 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " ;; esac done @@ -1560,8 +1105,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1574,35 +1119,20 @@ trap 'exit_status=$? _ASBOX echo # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done +{ (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; - esac | - sort -) + esac; +} echo cat <<\_ASBOX @@ -1613,28 +1143,22 @@ _ASBOX echo for ac_var in $ac_subst_vars do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## +## ------------- ## +## Output files. ## +## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi @@ -1646,24 +1170,26 @@ _ASBOX ## ----------- ## _ASBOX echo - cat confdefs.h + sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status -' 0 + ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h # Predefined preprocessor variables. @@ -1693,24 +1219,18 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi @@ -1720,61 +1240,54 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1784,15 +1297,19 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + @@ -1809,32 +1326,28 @@ fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_files="$ac_config_files Makefile src/common/Makefile" + ac_config_files="$ac_config_files Makefile src/common/Makefile" -ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" + ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" -ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" + ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" -ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" + ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" # # Memory managers # -# Check whether --enable-manager was given. +# Check whether --enable-manager or --disable-manager was given. if test "${enable_manager+set}" = set; then - enableval=$enable_manager; + enableval="$enable_manager" + enable_manager="$enableval" case $enableval in "no");; @@ -1843,105 +1356,118 @@ if test "${enable_manager+set}" = set; then "dmalloc");; "gcollect");; "bcheck");; - *) { { $as_echo "$as_me:$LINENO: error: unknown memory manager '$enableval'... stopping" >&5 -$as_echo "$as_me: error: unknown memory manager '$enableval'... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enableval'... stopping" >&5 +echo "$as_me: error: unknown memory manager '$enableval'... stopping" >&2;} { (exit 1); exit 1; }; };; esac else enable_manager="builtin" -fi - +fi; # # packetver # -# Check whether --enable-packetver was given. +# Check whether --enable-packetver or --disable-packetver was given. if test "${enable_packetver+set}" = set; then - enableval=$enable_packetver; enable_packetver="$enableval" + enableval="$enable_packetver" + enable_packetver="$enableval" else enable_packetver="" -fi - +fi; # # debug # -# Check whether --enable-debug was given. +# Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then - enableval=$enable_debug; + enableval="$enable_debug" + enable_debug="$enableval" case $enableval in "no");; "yes");; "gdb");; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 -$as_echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac else enable_debug="no" -fi +fi; + +# +# RDTSC as Tick Source +# +# Check whether --enable-rdtsc or --disable-rdtsc was given. +if test "${enable_rdtsc+set}" = set; then + enableval="$enable_rdtsc" + enable_rdtsc=1 + +else + enable_rdtsc=0 +fi; # # Profiler # -# Check whether --enable-profiler was given. +# Check whether --enable-profiler or --disable-profiler was given. if test "${enable_profiler+set}" = set; then - enableval=$enable_profiler; + enableval="$enable_profiler" + enable_profiler="$enableval" case $enableval in "no");; "gprof");; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-profiler=$enableval... stopping" >&5 -$as_echo "$as_me: error: invalid argument --enable-profiler=$enableval... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-profiler=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-profiler=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac else enable_profiler="no" -fi - +fi; # # 64bit # -# Check whether --enable-64bit was given. +# Check whether --enable-64bit or --disable-64bit was given. if test "${enable_64bit+set}" = set; then - enableval=$enable_64bit; + enableval="$enable_64bit" + enable_64bit="$enableval" case $enableval in "no");; "yes");; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument --enable-64bit=$enableval... stopping" >&5 -$as_echo "$as_me: error: invalid argument --enable-64bit=$enableval... stopping" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-64bit=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-64bit=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac else enable_64bit="no" -fi - +fi; # # Enable/disable MySql and optionally specify the path to mysql_config (optional library) # -# Check whether --with-mysql was given. +# Check whether --with-mysql or --without-mysql was given. if test "${with_mysql+set}" = set; then - withval=$with_mysql; + withval="$with_mysql" + if test "$withval" = "no" ; then want_mysql="no" else @@ -1949,8 +1475,8 @@ if test "${with_mysql+set}" = set; then require_mysql="yes" if test "$withval" != "yes" ; then if test ! -x "$withval" ; then - { { $as_echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 -$as_echo "$as_me: error: $withval is not an executable file" >&2;} + { { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 +echo "$as_me: error: $withval is not an executable file" >&2;} { (exit 1); exit 1; }; } fi MYSQL_CONFIG_HOME="$withval" @@ -1960,51 +1486,51 @@ $as_echo "$as_me: error: $withval is not an executable file" >&2;} else want_mysql="yes" require_mysql="no" -fi - +fi; # # Manual MYSQL_CFLAGS (optional) # -# Check whether --with-MYSQL_CFLAGS was given. +# Check whether --with-MYSQL_CFLAGS or --without-MYSQL_CFLAGS was given. if test "${with_MYSQL_CFLAGS+set}" = set; then - withval=$with_MYSQL_CFLAGS; + withval="$with_MYSQL_CFLAGS" + manual_MYSQL_CFLAGS="yes" MYSQL_CFLAGS="$withval" else manual_MYSQL_CFLAGS="no" -fi - +fi; # # Manual MYSQL_LIBS (optional) # -# Check whether --with-MYSQL_LIBS was given. +# Check whether --with-MYSQL_LIBS or --without-MYSQL_LIBS was given. if test "${with_MYSQL_LIBS+set}" = set; then - withval=$with_MYSQL_LIBS; + withval="$with_MYSQL_LIBS" + manual_MYSQL_LIBS="yes" MYSQL_LIBS="$withval" else manual_MYSQL_LIBS="no" -fi - +fi; # # Enable/disable PCRE and optionally specify the path (optional library) # -# Check whether --with-pcre was given. +# Check whether --with-pcre or --without-pcre was given. if test "${with_pcre+set}" = set; then - withval=$with_pcre; + withval="$with_pcre" + if test "$withval" = "no" ; then want_pcre="no" else @@ -2012,8 +1538,8 @@ if test "${with_pcre+set}" = set; then require_pcre="yes" if test "$withval" != "yes" ; then if test ! -d "$withval" ; then - { { $as_echo "$as_me:$LINENO: error: $withval is not a directoy" >&5 -$as_echo "$as_me: error: $withval is not a directoy" >&2;} + { { echo "$as_me:$LINENO: error: $withval is not a directoy" >&5 +echo "$as_me: error: $withval is not a directoy" >&2;} { (exit 1); exit 1; }; } fi PCRE_HOME="$withval" @@ -2023,17 +1549,17 @@ $as_echo "$as_me: error: $withval is not a directoy" >&2;} else want_pcre="yes" require_pcre="no" -fi - +fi; # # Specify the path of the zlib library (required library) # -# Check whether --with-zlib was given. +# Check whether --with-zlib or --without-zlib was given. if test "${with_zlib+set}" = set; then - withval=$with_zlib; + withval="$with_zlib" + test -n "$withval" && ZLIB_HOME="$withval" else @@ -2042,8 +1568,7 @@ else test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr -fi - +fi; @@ -2053,34 +1578,32 @@ fi -{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF -SHELL = /bin/sh all: - @echo '@@@%%%=$(MAKE)=@@@%%%' + @echo 'ac_maketemp="$(MAKE)"' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi rm -f conftest.make fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 SET_MAKE= else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -2092,10 +1615,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2106,36 +1629,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -2146,49 +1667,38 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi + CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2199,36 +1709,76 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2240,18 +1790,17 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -2269,25 +1818,24 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe + for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2298,40 +1846,38 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl.exe + for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -2342,90 +1888,58 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - test -n "$ac_ct_CC" && break done - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi + CC=$ac_ct_CC fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } + { (exit 1); exit 1; }; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF @@ -2444,150 +1958,111 @@ main () } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { (ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link_default") 2>&5 +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext break;; * ) break;; esac done -test "$ac_cv_exeext" = no && ac_cv_exeext= - else - ac_file='' -fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables +echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } + { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 -# Check that the compiler produces executables we can run. If not, either +# Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. +echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } + { (exit 1); exit 1; }; } fi fi fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either +# Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will @@ -2596,33 +2071,32 @@ $as_echo "$ac_try_echo") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext break;; * ) break;; esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } + { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2640,48 +2114,39 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>&5 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } + { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2702,54 +2167,50 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_compiler_gnu=no +ac_compiler_gnu=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2765,121 +2226,38 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_prog_cc_g=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2895,12 +2273,12 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then - $as_echo_n "(cached) " >&6 +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_c89=no + ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2934,17 +2312,12 @@ static char *f (char * (*g) (char **, int), char **p, ...) /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get + as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ + that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2959,80 +2332,227 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - fi - -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break +rm -f conftest.err conftest.$ac_objext done -rm -f conftest.$ac_ext +rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false @@ -3057,35 +2577,35 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers + # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3095,34 +2615,34 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done @@ -3140,8 +2660,8 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 -$as_echo "$CPP" >&6; } +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -3164,35 +2684,35 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers + # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3202,34 +2722,34 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done @@ -3238,13 +2758,11 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } + { (exit 1); exit 1; }; } fi ac_ext=c @@ -3266,239 +2784,172 @@ CPPFLAGS="$CPPFLAGS -I../common" - -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done -done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done -done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then - $as_echo_n "(cached) " >&6 +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include -#include -#include +#include +#include int main () { +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include +#include +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes else - ac_cv_header_stdc=no -fi -rm -f conftest* + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_c_bigendian=no fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include - +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes fi -rm -f conftest* - +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3506,800 +2957,624 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); } _ACEOF rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - : + ac_cv_c_bigendian=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -ac_cv_header_stdc=no +ac_cv_c_bigendian=yes fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - - fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + { { echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 +echo "$as_me: error: bigendian is not supported... stopping" >&2;} + { (exit 1); exit 1; }; } ;; + no) + ;; + *) + { echo "$as_me:$LINENO: WARNING: unable to determine endianess, only little endian is supported" >&5 +echo "$as_me: WARNING: unable to determine endianess, only little endian is supported" >&2;} + ;; +esac -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF +if test "$enable_64bit" = "no" ; then + echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 +echo $ECHO_N "checking whether pointers can be stored in ints (old code)... $ECHO_C" >&6 + pointers_fit_in_ints="no" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1]; +int +main () +{ -#include <$ac_header> + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + pointers_fit_in_ints="yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_Header=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF fi - -done - - - - { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -$as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_c_bigendian=unknown - # See if we're dealing with a universal compiler. - cat >conftest.$ac_ext <<_ACEOF +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$pointers_fit_in_ints" = "no" ; then + CFLAGS="$CFLAGS -m32" + LDFLAGS="$LDFLAGS -m32" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#ifndef __APPLE_CC__ - not a universal capable compiler - #endif - typedef int dummy; +static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1]; +int +main () +{ + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - - # Check for potential -arch flags. It is not universal unless - # there are some -arch flags. Note that *ppc* also matches - # ppc64. This check is also rather less than ideal. - case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( - *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; - esac + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + pointers_fit_in_ints="yes (with -m32)" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + fi + echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 +echo "${ECHO_T}$pointers_fit_in_ints" >&6 + if test "$pointers_fit_in_ints" = "no" ; then + { { echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 +echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} + { (exit 1); exit 1; }; } + fi fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test $ac_cv_c_bigendian = unknown; then - # See if sys/param.h defines the BYTE_ORDER macro. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - #include -int -main () -{ -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ - && LITTLE_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} +echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-unused-parameter... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-unused-parameter" +cat >conftest.$ac_ext <<_ACEOF +int foo; _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - # It does; now see whether it defined to BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - #include + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif - ; - return 0; -} + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + +echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-pointer-sign... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-pointer-sign" +cat >conftest.$ac_ext <<_ACEOF +int foo; _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_c_bigendian=yes + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) - bogus endian macros - #endif - ; - return 0; -} +echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 +echo $ECHO_N "checking whether $CC supports -Wno-switch... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wno-switch" +cat >conftest.$ac_ext <<_ACEOF +int foo; _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - # It does; now see whether it defined to _BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + + +############################################################################### +# Check for libraries and header files. +# + + +# +# setrlimit - used to set the socket limit +# +echo "$as_me:$LINENO: checking for setrlimit" >&5 +echo $ECHO_N "checking for setrlimit... $ECHO_C" >&6 +if test "${ac_cv_func_setrlimit+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +/* Define setrlimit to an innocuous variant, in case declares setrlimit. + For example, HP-UX 11i declares gettimeofday. */ +#define setrlimit innocuous_setrlimit + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char setrlimit (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef setrlimit + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char setrlimit (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_setrlimit) || defined (__stub___setrlimit) +choke me +#else +char (*f) () = setrlimit; +#endif +#ifdef __cplusplus +} +#endif int main () { -#ifndef _BIG_ENDIAN - not big endian - #endif - +return f != setrlimit; ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_c_bigendian=yes + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_setrlimit=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_c_bigendian=no +ac_cv_func_setrlimit=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_setrlimit" >&5 +echo "${ECHO_T}$ac_cv_func_setrlimit" >&6 +if test $ac_cv_func_setrlimit = yes; then + CFLAGS="$CFLAGS -DHAVE_SETRLIMIT" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# +# Memory manager +# +case $enable_manager in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' fi - if test $ac_cv_c_bigendian = unknown; then - # Compile a test program. - if test "$cross_compiling" = yes; then - # Try to guess by grepping values from an object file. - cat >conftest.$ac_ext <<_ACEOF +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short int ascii_mm[] = - { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; - short int ascii_ii[] = - { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; - int use_ascii (int i) { - return ascii_mm[i] + ascii_ii[i]; - } - short int ebcdic_ii[] = - { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; - short int ebcdic_mm[] = - { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; - int use_ebcdic (int i) { - return ebcdic_mm[i] + ebcdic_ii[i]; - } - extern int foo; +#include +#include +#include +#include int main () { -return use_ascii (foo) == use_ebcdic (foo); + ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then - ac_cv_c_bigendian=yes - fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi - fi -else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - +ac_cv_header_stdc=no fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; +#include - ; - return 0; -} _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=no +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + ac_cv_header_stdc=no fi +rm -f conftest* - - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -$as_echo "$ac_cv_c_bigendian" >&6; } - case $ac_cv_c_bigendian in #( - yes) - { { $as_echo "$as_me:$LINENO: error: bigendian is not supported... stopping" >&5 -$as_echo "$as_me: error: bigendian is not supported... stopping" >&2;} - { (exit 1); exit 1; }; };; #( - no) - ;; #( - universal) - -cat >>confdefs.h <<\_ACEOF -#define AC_APPLE_UNIVERSAL_BUILD 1 -_ACEOF - - ;; #( - *) - { $as_echo "$as_me:$LINENO: WARNING: unable to determine endianess, only little endian is supported" >&5 -$as_echo "$as_me: WARNING: unable to determine endianess, only little endian is supported" >&2;} - ;; - esac - - -if test "$enable_64bit" = "no" ; then - { $as_echo "$as_me:$LINENO: checking whether pointers can be stored in ints (old code)" >&5 -$as_echo_n "checking whether pointers can be stored in ints (old code)... " >&6; } - pointers_fit_in_ints="no" - cat >conftest.$ac_ext <<_ACEOF +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1]; -int -main () -{ +#include - ; - return 0; -} _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - pointers_fit_in_ints="yes" +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + ac_cv_header_stdc=no +fi +rm -f conftest* fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$pointers_fit_in_ints" = "no" ; then - CFLAGS="$CFLAGS -m32" - LDFLAGS="$LDFLAGS -m32" - cat >conftest.$ac_ext <<_ACEOF +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1]; +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { - - ; - return 0; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - pointers_fit_in_ints="yes (with -m32)" + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - - +( exit $ac_status ) +ac_cv_header_stdc=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - { $as_echo "$as_me:$LINENO: result: $pointers_fit_in_ints" >&5 -$as_echo "$pointers_fit_in_ints" >&6; } - if test "$pointers_fit_in_ints" = "no" ; then - { { $as_echo "$as_me:$LINENO: error: pointers cannot be stored in ints, required for old code... stopping" >&5 -$as_echo "$as_me: error: pointers cannot be stored in ints, required for old code... stopping" >&2;} - { (exit 1); exit 1; }; } - fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - - -{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-unused-parameter" >&5 -$as_echo_n "checking whether $CC supports -Wno-unused-parameter... " >&6; } -OLD_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-unused-parameter" -cat >conftest.$ac_ext <<_ACEOF -int foo; -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - -{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-pointer-sign" >&5 -$as_echo_n "checking whether $CC supports -Wno-pointer-sign... " >&6; } -OLD_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-pointer-sign" -cat >conftest.$ac_ext <<_ACEOF -int foo; -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - -{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wno-switch" >&5 -$as_echo_n "checking whether $CC supports -Wno-switch... " >&6; } -OLD_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-switch" -cat >conftest.$ac_ext <<_ACEOF -int foo; +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +fi - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" +# On IRIX 5.3, sys/types and inttypes.h are conflicting. -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -############################################################################### -# Check for libraries and header files. -# -# -# setrlimit - used to set the socket limit -# -{ $as_echo "$as_me:$LINENO: checking for setrlimit" >&5 -$as_echo_n "checking for setrlimit... " >&6; } -if test "${ac_cv_func_setrlimit+set}" = set; then - $as_echo_n "(cached) " >&6 + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4307,111 +3582,65 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define setrlimit to an innocuous variant, in case declares setrlimit. - For example, HP-UX 11i declares gettimeofday. */ -#define setrlimit innocuous_setrlimit - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char setrlimit (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef setrlimit - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char setrlimit (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_setrlimit || defined __stub___setrlimit -choke me -#endif +$ac_includes_default -int -main () -{ -return setrlimit (); - ; - return 0; -} +#include <$ac_header> _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_setrlimit=yes + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_func_setrlimit=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +eval "$as_ac_Header=no" fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_setrlimit" >&5 -$as_echo "$ac_cv_func_setrlimit" >&6; } -if test "x$ac_cv_func_setrlimit" = x""yes; then - CFLAGS="$CFLAGS -DHAVE_SETRLIMIT" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF +fi +done -# -# Memory manager -# -case $enable_manager in - "no") - CFLAGS="$CFLAGS -DNO_MEMMGR" - ;; - "builtin") - # enabled by default - ;; - "memwatch") - CFLAGS="$CFLAGS -DMEMWATCH" - if test "${ac_cv_header_memwatch_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for memwatch.h" >&5 -$as_echo_n "checking for memwatch.h... " >&6; } if test "${ac_cv_header_memwatch_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -$as_echo "$ac_cv_header_memwatch_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking memwatch.h usability" >&5 -$as_echo_n "checking memwatch.h usability... " >&6; } +echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4422,38 +3651,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ $as_echo "$as_me:$LINENO: checking memwatch.h presence" >&5 -$as_echo_n "checking memwatch.h presence... " >&6; } +echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4462,76 +3694,83 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} - + { echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ $as_echo "$as_me:$LINENO: checking for memwatch.h" >&5 -$as_echo_n "checking for memwatch.h... " >&6; } +echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6 if test "${ac_cv_header_memwatch_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_memwatch_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 -$as_echo "$ac_cv_header_memwatch_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6 fi -if test "x$ac_cv_header_memwatch_h" = x""yes; then +if test $ac_cv_header_memwatch_h = yes; then : else - { { $as_echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 -$as_echo "$as_me: error: memwatch header not found... stopping" >&2;} + { { echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 +echo "$as_me: error: memwatch header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4541,17 +3780,17 @@ fi CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" LIBS="$LIBS -ldmalloc" if test "${ac_cv_header_dmalloc_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -$as_echo_n "checking for dmalloc.h... " >&6; } + echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -$as_echo "$ac_cv_header_dmalloc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 -$as_echo_n "checking dmalloc.h usability... " >&6; } +echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4562,38 +3801,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ $as_echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 -$as_echo_n "checking dmalloc.h presence... " >&6; } +echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4602,76 +3844,83 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} - + { echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ $as_echo "$as_me:$LINENO: checking for dmalloc.h" >&5 -$as_echo_n "checking for dmalloc.h... " >&6; } +echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dmalloc_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 -$as_echo "$ac_cv_header_dmalloc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 fi -if test "x$ac_cv_header_dmalloc_h" = x""yes; then +if test $ac_cv_header_dmalloc_h = yes; then : else - { { $as_echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 -$as_echo "$as_me: error: dmalloc header not found... stopping" >&2;} + { { echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 +echo "$as_me: error: dmalloc header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4681,17 +3930,17 @@ fi CFLAGS="$CFLAGS -DGCOLLECT" LIBS="$LIBS -lgc" if test "${ac_cv_header_gc_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for gc.h" >&5 -$as_echo_n "checking for gc.h... " >&6; } + echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 if test "${ac_cv_header_gc_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -$as_echo "$ac_cv_header_gc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6 else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking gc.h usability" >&5 -$as_echo_n "checking gc.h usability... " >&6; } +echo "$as_me:$LINENO: checking gc.h usability" >&5 +echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4702,38 +3951,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ $as_echo "$as_me:$LINENO: checking gc.h presence" >&5 -$as_echo_n "checking gc.h presence... " >&6; } +echo "$as_me:$LINENO: checking gc.h presence" >&5 +echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4742,76 +3994,83 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} - + { echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ $as_echo "$as_me:$LINENO: checking for gc.h" >&5 -$as_echo_n "checking for gc.h... " >&6; } +echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6 if test "${ac_cv_header_gc_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_gc_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 -$as_echo "$ac_cv_header_gc_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6 fi -if test "x$ac_cv_header_gc_h" = x""yes; then +if test $ac_cv_header_gc_h = yes; then : else - { { $as_echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 -$as_echo "$as_me: error: gcollect header not found... stopping" >&2;} + { { echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 +echo "$as_me: error: gcollect header not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -4848,6 +4107,19 @@ case $enable_debug in esac +# +# RDTSC +# +case $enable_rdtsc in + 0) + #default value + ;; + 1) + CFLAGS="$CFLAGS -DENABLE_RDTSC" + ;; +esac + + # # Profiler # @@ -4870,10 +4142,10 @@ if test -n "${ZLIB_HOME}" ; then CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" fi -{ $as_echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 -$as_echo_n "checking for inflateEnd in -lz... " >&6; } +echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5 +echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6 if test "${ac_cv_lib_z_inflateEnd+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" @@ -4884,58 +4156,57 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char inflateEnd (); int main () { -return inflateEnd (); +inflateEnd (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_z_inflateEnd=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_z_inflateEnd=no +ac_cv_lib_z_inflateEnd=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 -$as_echo "$ac_cv_lib_z_inflateEnd" >&6; } -if test "x$ac_cv_lib_z_inflateEnd" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5 +echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6 +if test $ac_cv_lib_z_inflateEnd = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF @@ -4943,23 +4214,23 @@ _ACEOF LIBS="-lz $LIBS" else - { { $as_echo "$as_me:$LINENO: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&5 -$as_echo "$as_me: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { { echo "$as_me:$LINENO: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" >&2;} { (exit 1); exit 1; }; } fi if test "${ac_cv_header_zlib_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for zlib.h" >&5 -$as_echo_n "checking for zlib.h... " >&6; } + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -$as_echo "$ac_cv_header_zlib_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking zlib.h usability" >&5 -$as_echo_n "checking zlib.h usability... " >&6; } +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4970,38 +4241,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ $as_echo "$as_me:$LINENO: checking zlib.h presence" >&5 -$as_echo_n "checking zlib.h presence... " >&6; } +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5010,76 +4284,83 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} - + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ $as_echo "$as_me:$LINENO: checking for zlib.h" >&5 -$as_echo_n "checking for zlib.h... " >&6; } +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 if test "${ac_cv_header_zlib_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_zlib_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -$as_echo "$ac_cv_header_zlib_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 fi -if test "x$ac_cv_header_zlib_h" = x""yes; then +if test $ac_cv_header_zlib_h = yes; then : else - { { $as_echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 -$as_echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} + { { echo "$as_me:$LINENO: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&5 +echo "$as_me: error: zlib header not found, please specify the correct path with --with-zlib=DIR... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -5090,10 +4371,10 @@ fi # math library (required) # -{ $as_echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 -$as_echo_n "checking for sqrt in -lm... " >&6; } +echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 +echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_sqrt+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" @@ -5104,58 +4385,57 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char sqrt (); int main () { -return sqrt (); +sqrt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_m_sqrt=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_m_sqrt=no +ac_cv_lib_m_sqrt=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 -$as_echo "$ac_cv_lib_m_sqrt" >&6; } -if test "x$ac_cv_lib_m_sqrt" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 +echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6 +if test $ac_cv_lib_m_sqrt = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -5163,8 +4443,8 @@ _ACEOF LIBS="-lm $LIBS" else - { { $as_echo "$as_me:$LINENO: error: math library not found... stopping" >&5 -$as_echo "$as_me: error: math library not found... stopping" >&2;} + { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 +echo "$as_me: error: math library not found... stopping" >&2;} { (exit 1); exit 1; }; } fi @@ -5174,10 +4454,10 @@ fi # clock_gettime (rt on Debian) # -{ $as_echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 -$as_echo_n "checking for clock_gettime in -lrt... " >&6; } +echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 +echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6 if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" @@ -5188,58 +4468,57 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char clock_gettime (); int main () { -return clock_gettime (); +clock_gettime (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_rt_clock_gettime=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_rt_clock_gettime=no +ac_cv_lib_rt_clock_gettime=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 -$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } -if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 +echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6 +if test $ac_cv_lib_rt_clock_gettime = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF @@ -5258,16 +4537,16 @@ if test "$want_mysql" = "no" ; then MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" - { $as_echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 -$as_echo "$as_me: ignoring MySQL (optional)" >&6;} + { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 +echo "$as_me: ignoring MySQL (optional)" >&6;} else if test -z "$MYSQL_CONFIG_HOME"; then # Extract the first word of "mysql_config", so it can be a program name with args. set dummy mysql_config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_MYSQL_CONFIG_HOME+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MYSQL_CONFIG_HOME in [\\/]* | ?:[\\/]*) @@ -5280,29 +4559,28 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MYSQL_CONFIG_HOME="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done -IFS=$as_save_IFS test -z "$ac_cv_path_MYSQL_CONFIG_HOME" && ac_cv_path_MYSQL_CONFIG_HOME="no" ;; esac fi MYSQL_CONFIG_HOME=$ac_cv_path_MYSQL_CONFIG_HOME + if test -n "$MYSQL_CONFIG_HOME"; then - { $as_echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 -$as_echo "$MYSQL_CONFIG_HOME" >&6; } + echo "$as_me:$LINENO: result: $MYSQL_CONFIG_HOME" >&5 +echo "${ECHO_T}$MYSQL_CONFIG_HOME" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - fi if test "$MYSQL_CONFIG_HOME" != "no" ; then @@ -5319,10 +4597,10 @@ fi MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - { $as_echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 -$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } + echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 +echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6 if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmysqlclient $LIBS" @@ -5333,73 +4611,72 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char mysql_init (); int main () { -return mysql_init (); +mysql_init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_mysqlclient_mysql_init=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_mysqlclient_mysql_init=no +ac_cv_lib_mysqlclient_mysql_init=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 -$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } -if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 +echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6 +if test $ac_cv_lib_mysqlclient_mysql_init = yes; then HAVE_MYSQL="yes" fi if test "${ac_cv_header_mysql_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for mysql.h" >&5 -$as_echo_n "checking for mysql.h... " >&6; } + echo "$as_me:$LINENO: checking for mysql.h" >&5 +echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6 if test "${ac_cv_header_mysql_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 -$as_echo "$ac_cv_header_mysql_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +echo "${ECHO_T}$ac_cv_header_mysql_h" >&6 else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking mysql.h usability" >&5 -$as_echo_n "checking mysql.h usability... " >&6; } +echo "$as_me:$LINENO: checking mysql.h usability" >&5 +echo $ECHO_N "checking mysql.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5410,38 +4687,41 @@ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no +ac_header_compiler=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? -{ $as_echo "$as_me:$LINENO: checking mysql.h presence" >&5 -$as_echo_n "checking mysql.h presence... " >&6; } +echo "$as_me:$LINENO: checking mysql.h presence" >&5 +echo $ECHO_N "checking mysql.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5450,72 +4730,79 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi - rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: mysql.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: mysql.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: mysql.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: mysql.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: mysql.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: mysql.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: mysql.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: mysql.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: mysql.h: in the future, the compiler will take precedence" >&2;} - + { echo "$as_me:$LINENO: WARNING: mysql.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: mysql.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: mysql.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: mysql.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: mysql.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: mysql.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: mysql.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: mysql.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 ;; esac -{ $as_echo "$as_me:$LINENO: checking for mysql.h" >&5 -$as_echo_n "checking for mysql.h... " >&6; } +echo "$as_me:$LINENO: checking for mysql.h" >&5 +echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6 if test "${ac_cv_header_mysql_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_mysql_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 -$as_echo "$ac_cv_header_mysql_h" >&6; } +echo "$as_me:$LINENO: result: $ac_cv_header_mysql_h" >&5 +echo "${ECHO_T}$ac_cv_header_mysql_h" >&6 fi -if test "x$ac_cv_header_mysql_h" = x""yes; then +if test $ac_cv_header_mysql_h = yes; then : else HAVE_MYSQL="" @@ -5525,21 +4812,21 @@ fi CPPFLAGS="$MYSQL_OLD_CPPFLAGS" LDFLAGS="$MYSQL_OLD_LDFLAGS" - { $as_echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 -$as_echo_n "checking MySQL library (optional)... " >&6; } + echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 +echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6 if test "$HAVE_MYSQL" = "yes" ; then - { $as_echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 -$as_echo "yes ($MYSQL_VERSION)" >&6; } + echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 if test "$require_mysql" = "yes" ; then - { { $as_echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 -$as_echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} + { { echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 +echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } else - { $as_echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 -$as_echo "$as_me: disabling MySQL (optional)" >&6;} + { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 +echo "$as_me: disabling MySQL (optional)" >&6;} MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" @@ -5561,14 +4848,14 @@ PCRE_LIBS="" PCRE_CFLAGS="" if test "$want_pcre" = "no" ; then - { $as_echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 -$as_echo "$as_me: ignoring PCRE (optional)" >&6;} + { echo "$as_me:$LINENO: ignoring PCRE (optional)" >&5 +echo "$as_me: ignoring PCRE (optional)" >&6;} else if test -z "$PCRE_HOME" ; then - { $as_echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 -$as_echo_n "checking for pcre_study in -lpcre... " >&6; } + echo "$as_me:$LINENO: checking for pcre_study in -lpcre" >&5 +echo $ECHO_N "checking for pcre_study in -lpcre... $ECHO_C" >&6 if test "${ac_cv_lib_pcre_pcre_study+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" @@ -5579,58 +4866,57 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char pcre_study (); int main () { -return pcre_study (); +pcre_study (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_pcre_pcre_study=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pcre_pcre_study=no +ac_cv_lib_pcre_pcre_study=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 -$as_echo "$ac_cv_lib_pcre_pcre_study" >&6; } -if test "x$ac_cv_lib_pcre_pcre_study" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_study" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_study" >&6 +if test $ac_cv_lib_pcre_pcre_study = yes; then HAVE_PCRE="yes" fi @@ -5640,10 +4926,10 @@ fi else PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib" PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include" - { $as_echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 -$as_echo_n "checking for pcre_compile in -lpcre... " >&6; } + echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6 if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" @@ -5654,58 +4940,57 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ +/* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ char pcre_compile (); int main () { -return pcre_compile (); +pcre_compile (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lib_pcre_pcre_compile=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pcre_pcre_compile=no +ac_cv_lib_pcre_pcre_compile=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ +rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 -$as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } -if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then +echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6 +if test $ac_cv_lib_pcre_pcre_compile = yes; then HAVE_PCRE="yes" fi @@ -5716,21 +5001,21 @@ fi test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include" fi fi - { $as_echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 -$as_echo_n "checking PCRE library (optional)... " >&6; } + echo "$as_me:$LINENO: checking PCRE library (optional)" >&5 +echo $ECHO_N "checking PCRE library (optional)... $ECHO_C" >&6 if test "$HAVE_PCRE" = "yes" ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 if test "$require_pcre" = "yes" ; then - { { $as_echo "$as_me:$LINENO: error: PCRE not found or incompatible (requested)" >&5 -$as_echo "$as_me: error: PCRE not found or incompatible (requested)" >&2;} + { { echo "$as_me:$LINENO: error: PCRE not found or incompatible (requested)" >&5 +echo "$as_me: error: PCRE not found or incompatible (requested)" >&2;} { (exit 1); exit 1; }; } else - { $as_echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 -$as_echo "$as_me: disabling PCRE (optional)" >&6;} + { echo "$as_me:$LINENO: disabling PCRE (optional)" >&5 +echo "$as_me: disabling PCRE (optional)" >&6;} fi fi fi @@ -5743,11 +5028,11 @@ fi # # Host specific stuff # -{ $as_echo "$as_me:$LINENO: checking host OS" >&5 -$as_echo_n "checking host OS... " >&6; } +echo "$as_me:$LINENO: checking host OS" >&5 +echo $ECHO_N "checking host OS... $ECHO_C" >&6 host_os="`uname`" -{ $as_echo "$as_me:$LINENO: result: $host_os" >&5 -$as_echo "$host_os" >&6; } +echo "$as_me:$LINENO: result: $host_os" >&5 +echo "${ECHO_T}$host_os" >&6 fd_setsize="" DLLEXT=".so" case $host_os in @@ -5771,19 +5056,19 @@ CYGWIN*) esac -{ $as_echo "$as_me:$LINENO: checking for MinGW" >&5 -$as_echo_n "checking for MinGW... " >&6; } +echo "$as_me:$LINENO: checking for MinGW" >&5 +echo $ECHO_N "checking for MinGW... $ECHO_C" >&6 if test -n "`$CC --version | grep -i mingw`" ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 CPPFLAGS="$CPPFLAGS -DMINGW" if test -z "$fd_setsize" ; then CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096" fi LIBS="$LIBS -lws2_32" else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi @@ -5807,59 +5092,39 @@ _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. +# So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - +{ (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( + ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; - esac | - sort -) | + esac; +} | sed ' - /^ac_cv_env_/b end t clear - :clear + : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + echo "not updating unwritable cache $cache_file" fi fi rm -f confcache @@ -5868,54 +5133,63 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, +# take arguments), then we branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} +cat >confdef2opt.sed <<\_ACEOF t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -5923,14 +5197,12 @@ LTLIBOBJS=$ac_ltlibobjs - : ${CONFIG_STATUS=./config.status} -ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -5940,81 +5212,25 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -6024,60 +5240,33 @@ else fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - # Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done +$as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -6085,122 +5274,159 @@ fi # Name of the executable. -as_me=`$as_basename -- "$0" || +as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` -# CDPATH. -$as_unset CDPATH + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop - s/-\n.*// + s,-$,, + s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno # Exit status is that of the last command. exit } -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then + +if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links as_ln_s='cp -p' + else + as_ln_s='ln -s' fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null +rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -6209,28 +5435,7 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -6239,14 +5444,31 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + exec 6>&1 -# Save the log message, to keep $[0] and so on meaningful, and to +# Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + This file was extended by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6254,106 +5476,124 @@ generated by GNU Autoconf 2.63. Invocation command line was CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 _ACEOF -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi -_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet, --silent - do not print progress messages + -V, --version print version number, then exit + -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE Configuration files: $config_files Report bugs to ." - _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk +srcdir=$srcdir _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; - *) + -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; esac case $ac_option in # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; + *) ac_config_targets="$ac_config_targets $1" ;; esac shift @@ -6367,55 +5607,39 @@ if $ac_cs_silent; then fi _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Handling of arguments. + + +cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; - "src/char/Makefile") CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; - "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; - "src/ladmin/Makefile") CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; - "src/char_sql/Makefile") CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; - "src/txt-converter/Makefile") CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; - "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; - "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; - "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; - - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/common/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; + "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; + "src/ladmin/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; + "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; + "src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; + "src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; + "src/plugins/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; + "src/tool/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done - # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -6425,465 +5649,336 @@ if $ac_need_defaults; then fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, +# simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. +# Create a temporary directory, and hook for its removal unless debugging. $debug || { - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } + # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) } || { - $as_echo "$as_me: cannot create a temporary directory in ." >&2 + echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=' -' -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\).*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\).*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" +# +# CONFIG_FILES section. +# -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@MYSQL_CONFIG_HOME@,$MYSQL_CONFIG_HOME,;t t +s,@HAVE_MYSQL@,$HAVE_MYSQL,;t t +s,@MYSQL_VERSION@,$MYSQL_VERSION,;t t +s,@MYSQL_CFLAGS@,$MYSQL_CFLAGS,;t t +s,@MYSQL_LIBS@,$MYSQL_LIBS,;t t +s,@HAVE_PCRE@,$HAVE_PCRE,;t t +s,@PCRE_LIBS@,$PCRE_LIBS,;t t +s,@PCRE_CFLAGS@,$PCRE_CFLAGS,;t t +s,@DLLEXT@,$DLLEXT,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; - esac - ;; +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - ac_dir=`$as_dirname -- "$ac_file" || + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } + ac_builddir=. -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi case $srcdir in - .) # We are building in place. + .) # No --srcdir option. We are building in place. ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } _ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub $extrasub _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - ;; - - - - esac +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi -done # for ac_tag +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save -test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. @@ -6905,8 +6000,4 @@ if test "$no_create" != yes; then # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi diff --git a/configure.in b/configure.in index c881f5610..4892ee141 100644 --- a/configure.in +++ b/configure.in @@ -74,6 +74,30 @@ AC_ARG_ENABLE( [enable_debug="no"] ) +# +# RDTSC as Tick Source +# +AC_ARG_ENABLE( + [rdtsc], + AC_HELP_STRING( + [--enable-rdtsc], + [ + Uses rdtsc as timing source (disabled by default) + Enable it when you've timing issues. + + (For example: in conjunction with XEN or Other Virtualization mechanisms) + + Note: + Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options. + (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual + how to disable it) + ] + ), + [ + enable_rdtsc=1 + ], + [enable_rdtsc=0] +) # # Profiler @@ -383,6 +407,19 @@ case $enable_debug in esac +# +# RDTSC +# +case $enable_rdtsc in + 0) + #default value + ;; + 1) + CFLAGS="$CFLAGS -DENABLE_RDTSC" + ;; +esac + + # # Profiler # diff --git a/src/common/timer.c b/src/common/timer.c index 143d2ddce..190e41eaf 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -100,11 +100,52 @@ char* search_timer_func_list(TimerFunc func) * Get tick time *----------------------------*/ +#if defined(ENABLE_RDTSC) +static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0; + +static __inline uint64 _rdtsc(){ + register union{ + uint64 qw; + uint32 dw[2]; + } t; + + asm volatile("rdtsc":"=a"(t.dw[0]), "=d"(t.dw[1]) ); + + return t.qw; +} + +static void rdtsc_calibrate(){ + uint64 t1, t2; + int32 i; + + ShowStatus("Calibrating Timer Source, please wait... "); + + RDTSC_CLOCK = 0; + + for(i = 0; i < 5; i++){ + t1 = _rdtsc(); + usleep(1000000); //1000 MS + t2 = _rdtsc(); + RDTSC_CLOCK += (t2 - t1) / 1000; + } + RDTSC_CLOCK /= 5; + + RDTSC_BEGINTICK = _rdtsc(); + + ShowMessage(" done. (Frequency: %u Mhz)\n", (uint32)(RDTSC_CLOCK/1000) ); +} + +#endif + /// platform-abstracted tick retrieval static unsigned int tick(void) { #if defined(WIN32) return GetTickCount(); +#elif defined(ENABLE_RDTSC) + // + return (unsigned int)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); + // #elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) /* posix compliant */) || (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 500005 /* FreeBSD >= 5.1.0 */) struct timespec tval; clock_gettime(CLOCK_MONOTONIC, &tval); @@ -368,6 +409,10 @@ unsigned long get_uptime(void) void timer_init(void) { +#if defined(ENABLE_RDTSC) + rdtsc_calibrate(); +#endif + time(&start_time); } -- cgit v1.2.3-70-g09d2 From 129002e2da0595c164839a2ea7d07aab1b806e69 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Thu, 13 Jan 2011 11:42:12 +0000 Subject: * Removed ladmin (remote administration tool), all related support code and the checkversion.pl tool with it's support code, which was shared with ladmin (topic:262934, related bugreport:1147, bugreport:1889, r9408 and r9610). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14667 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + Makefile.in | 13 +- conf/Changelog.txt | 2 + conf/import-tmpl/ladmin_conf.txt | 0 conf/ladmin_athena.conf | 31 - conf/login_athena.conf | 10 - configure | 3 +- configure.in | 2 +- eAthena-10.sln | 12 - eAthena-8.sln | 12 - eAthena-9.sln | 12 - readme/features.html | 1 - src/char/char.c | 130 -- src/char_sql/char.c | 16 - src/ladmin/Makefile.in | 45 - src/ladmin/ladmin.c | 3074 ------------------------------------ src/ladmin/ladmin.h | 9 - src/login/Makefile.in | 2 +- src/login/admin.c | 857 ---------- src/login/login.c | 51 +- src/login/login.h | 4 - src/map/chrif.c | 31 +- tools/checkversion.pl | 85 - vcproj-10/ladmin.vcxproj | 149 -- vcproj-10/login-server_sql.vcxproj | 1 - vcproj-10/login-server_txt.vcxproj | 1 - vcproj-6/login-server_sql.dsp | 4 - vcproj-6/login-server_txt.dsp | 4 - vcproj-7.1/login-server_sql.vcproj | 3 - vcproj-7.1/login-server_txt.vcproj | 3 - vcproj-8/ladmin.vcproj | 285 ---- vcproj-8/login-server_sql.vcproj | 4 - vcproj-8/login-server_txt.vcproj | 4 - vcproj-9/ladmin.vcproj | 290 ---- vcproj-9/login-server_sql.vcproj | 4 - vcproj-9/login-server_txt.vcproj | 4 - 36 files changed, 12 insertions(+), 5147 deletions(-) delete mode 100644 conf/import-tmpl/ladmin_conf.txt delete mode 100644 conf/ladmin_athena.conf delete mode 100644 src/ladmin/Makefile.in delete mode 100644 src/ladmin/ladmin.c delete mode 100644 src/ladmin/ladmin.h delete mode 100644 src/login/admin.c delete mode 100755 tools/checkversion.pl delete mode 100644 vcproj-10/ladmin.vcxproj delete mode 100644 vcproj-8/ladmin.vcproj delete mode 100644 vcproj-9/ladmin.vcproj (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 733ca5485..5041c57c2 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,7 @@ Date Added 2011/01/13 + * Removed ladmin (remote administration tool), all related support code and the checkversion.pl tool with it's support code, which was shared with ladmin (topic:262934, related bugreport:1147, bugreport:1889, r9408 and r9610). [Ai4rei] * Fixed chrif-packet processing considering free/unused packet IDs incorrectly as variable length packets (-1 = variable length, 0 = disabled packet). [Ai4rei] * Added support for creating account through the console-plugin on login-server (replaces ladmin functionality unavailable through atcommands). [Ai4rei] * Reformatting and minor cleanups to console-plugin related code. [Ai4rei] diff --git a/Makefile.in b/Makefile.in index 2afeda0f5..5b51affa4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql ladmin tools converters plugins import save + ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters plugins import save SQL_DEPENDS=common_sql login_sql char_sql map_sql import save COMMON_SQL_DEPENDS= LOGIN_SQL_DEPENDS=common_sql @@ -10,7 +10,7 @@ ifeq ($(HAVE_MYSQL),yes) MAP_SQL_DEPENDS=common_sql CONVERTERS_DEPENDS=common_sql else - ALL_DEPENDS=common login char map ladmin tools plugins import save + ALL_DEPENDS=common login char map tools plugins import save SQL_DEPENDS=needs_mysql COMMON_SQL_DEPENDS=needs_mysql LOGIN_SQL_DEPENDS=needs_mysql @@ -25,7 +25,7 @@ endif login login_sql \ char char_sql \ map map_sql \ - ladmin tools converters plugins addons import save \ + tools converters plugins addons import save \ clean help all: $(ALL_DEPENDS) @@ -60,9 +60,6 @@ map: common map_sql: $(MAP_SQL_DEPENDS) @$(MAKE) -C src/map sql -ladmin: common - @$(MAKE) -C src/ladmin - tools: @$(MAKE) -C src/tool @@ -96,7 +93,6 @@ clean: @$(MAKE) -C src/char $@ @$(MAKE) -C src/char_sql $@ @$(MAKE) -C src/map $@ - @$(MAKE) -C src/ladmin $@ @$(MAKE) -C src/plugins $@ @$(MAKE) -C src/tool $@ @$(MAKE) -C src/txt-converter $@ @@ -112,7 +108,6 @@ help: @echo "'char_sql' - builds char server (SQL version)" @echo "'map' - builds map server (TXT version)" @echo "'map_sql' - builds map server (SQL version)" - @echo "'ladmin' - builds remote administration tool" @echo "'tools' - builds all the tools in src/tools" @echo "'converters' - builds the login/char converters" @echo "'plugins' - builds all the plugins in src/plugins" @@ -148,7 +143,6 @@ install: conf/%.conf conf/%.txt $(shell mv npc /opt/eathena/etc/eathena/npc) $(shell mv log/* /opt/eathena/var/log/eathena/) $(shell cp *-server* /opt/eathena/bin/) - $(shell cp ladmin /opt/eathena/bin/) $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) @@ -159,7 +153,6 @@ bin-clean: $(shell rm /opt/eathena/bin/login-server*) $(shell rm /opt/eathena/bin/char-server*) $(shell rm /opt/eathena/bin/map-server*) - $(shell rm /opt/eathena/bin/ladmin) uninstall: $(shell read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue.") diff --git a/conf/Changelog.txt b/conf/Changelog.txt index fd6148e37..8061c8929 100644 --- a/conf/Changelog.txt +++ b/conf/Changelog.txt @@ -1,5 +1,7 @@ Date Added +2011/01/13 + * Rev. 14667 Removed ladmin settings (ladmin_athena.conf) and login-server settings for ladmin (login_athena.conf) (topic:262934). [Ai4rei] 2010/12/30 * Rev. 14643 Updated mapcache up to 2010-12-01. Adds Bifrost, Dewata and Malangdo maps. [Ai4rei] 2010/12/12 diff --git a/conf/import-tmpl/ladmin_conf.txt b/conf/import-tmpl/ladmin_conf.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/conf/ladmin_athena.conf b/conf/ladmin_athena.conf deleted file mode 100644 index 5c4257af7..000000000 --- a/conf/ladmin_athena.conf +++ /dev/null @@ -1,31 +0,0 @@ -// Athena Ladmin configuration file. - -// Login Server IP -login_ip:127.0.0.1 -// Login Server Port -login_port: 6900 - -// Administrative password, used to connect remotely to server. -// NOTICE: If you enable remote administration, you should change its value for security -admin_pass: admin - -// Encoding type of the password -// 0: not encoded -// 1: key+password -// 2: password+key -passenc: 2 - -// Log Filename. All operations done by the software are logged in this file. -ladmin_log_filename: log/ladmin.log - -// Indicate how to display date in logs, to players, etc. -// 0: 31-12-2004 23:59:59 -// 1: 12-31-2004 23:59:59 -// 2: 2004-31-12 23:59:59 -// 3: 2004-12-31 23:59:59 (default) -date_format: 3 - -//If redirected output contains escape sequences (color codes) -stdout_with_ansisequence: no - -import: conf/import/ladmin_conf.txt diff --git a/conf/login_athena.conf b/conf/login_athena.conf index cf7883cfa..7f1f40d4b 100644 --- a/conf/login_athena.conf +++ b/conf/login_athena.conf @@ -35,16 +35,6 @@ stdout_with_ansisequence: no //Example: "console_silent: 7" Hides information, status and notice messages (1+2+4) console_silent: 0 -// Whether remote administration is enabled or disabled -admin_state: no - -// Administrative password, used by ladmin to connect remotely to server. -// NOTICE: you should change this value for security if you use ladmin. -admin_pass: admin - -// Indicate the IP/host that the server accepts for remote administration. -admin_allowed_host: 127.0.0.1 - // Console Commands // Allow for console commands to be used on/off // This prevents usage of >& log.file diff --git a/configure b/configure index 70a12eb59..3a5c7274c 100755 --- a/configure +++ b/configure @@ -1333,7 +1333,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_files="$ac_config_files Makefile src/common/Makefile" - ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile src/ladmin/Makefile" + ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" @@ -5628,7 +5628,6 @@ do "src/common/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; - "src/ladmin/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ladmin/Makefile" ;; "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; "src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; "src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; diff --git a/configure.in b/configure.in index 4892ee141..bf3c97374 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ AC_REVISION($Revision$) AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) -AC_CONFIG_FILES([src/char/Makefile src/login/Makefile src/ladmin/Makefile]) +AC_CONFIG_FILES([src/char/Makefile src/login/Makefile]) AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) diff --git a/eAthena-10.sln b/eAthena-10.sln index a372960d3..991395305 100644 --- a/eAthena-10.sln +++ b/eAthena-10.sln @@ -14,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-10 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-10\mapcache.vcxproj", "{D356871D-58E1-450B-967A-E7E9646175AF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ladmin", "vcproj-10\ladmin.vcxproj", "{D356871D-58E1-450B-967A-E8E9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-10\txt-converter-login.vcxproj", "{D356871D-58E1-450B-967A-E9E9646175AF}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-10\txt-converter-char.vcxproj", "{D356871D-58E1-450B-967A-EAE9646175AF}" @@ -102,16 +100,6 @@ Global {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 diff --git a/eAthena-8.sln b/eAthena-8.sln index 1afd083d4..b06382a1b 100644 --- a/eAthena-8.sln +++ b/eAthena-8.sln @@ -14,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-8\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-8\mapcache.vcproj", "{D356871D-58E1-450B-967A-E7E9646175AF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ladmin", "vcproj-8\ladmin.vcproj", "{D356871D-58E1-450B-967A-E8E9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-8\txt-converter-login.vcproj", "{D356871D-58E1-450B-967A-E9E9646175AF}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-8\txt-converter-char.vcproj", "{D356871D-58E1-450B-967A-EAE9646175AF}" @@ -108,16 +106,6 @@ Global {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 diff --git a/eAthena-9.sln b/eAthena-9.sln index 2a9201785..555af8e10 100644 --- a/eAthena-9.sln +++ b/eAthena-9.sln @@ -14,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-9\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-9\mapcache.vcproj", "{D356871D-58E1-450B-967A-E7E9646175AF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ladmin", "vcproj-9\ladmin.vcproj", "{D356871D-58E1-450B-967A-E8E9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-9\txt-converter-login.vcproj", "{D356871D-58E1-450B-967A-E9E9646175AF}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-9\txt-converter-char.vcproj", "{D356871D-58E1-450B-967A-EAE9646175AF}" @@ -108,16 +106,6 @@ Global {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E8E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 diff --git a/readme/features.html b/readme/features.html index aeffbab23..99b183c79 100644 --- a/readme/features.html +++ b/readme/features.html @@ -109,7 +109,6 @@ so we will focus mainly on stability for the time being, not new features.
  • 2-2 Jobs (Alternate 2nd Jobs)
  • Super Novice (Alternate 1st Job)
  • WoE (War of Emperium)
  • -
  • Remote administration of accounts (ladmin)
  • Weddings
  • Pet equipped mobs
  • Management of day/night
  • diff --git a/src/char/char.c b/src/char/char.c index c0788f64e..f1b430150 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2176,72 +2176,6 @@ int parse_fromlogin(int fd) } break; - case 0x2726: // Request to send a broadcast message (no answer) - if (RFIFOREST(fd) < 8 || RFIFOREST(fd) < (8 + RFIFOL(fd,4))) - return 0; - if (RFIFOL(fd,4) < 1) - char_log("Receiving a message for broadcast, but message is void.\n"); - else - { - // at least 1 map-server - ARR_FIND( 0, MAX_MAP_SERVERS, i, server[i].fd >= 0 ); - if (i == MAX_MAP_SERVERS) - char_log("'ladmin': Receiving a message for broadcast, but no map-server is online.\n"); - else { - unsigned char buf[128]; - char message[4096]; // +1 to add a null terminated if not exist in the packet - int lp; - char *p; - memset(message, '\0', sizeof(message)); - memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4)); - message[sizeof(message)-1] = '\0'; - remove_control_chars(message); - // remove all first spaces - p = message; - while(p[0] == ' ') - p++; - // if message is only composed of spaces - if (p[0] == '\0') - char_log("Receiving a message for broadcast, but message is only a lot of spaces.\n"); - // else send message to all map-servers - else { - if (RFIFOW(fd,2) == 0) { - char_log("'ladmin': Receiving a message for broadcast (message (in yellow): %s)\n", - message); - lp = 4; - } else { - char_log("'ladmin': Receiving a message for broadcast (message (in blue): %s)\n", - message); - lp = 8; - } - // split message to max 80 char - while(p[0] != '\0') { // if not finish - if (p[0] == ' ') // jump if first char is a space - p++; - else { - char split[80]; - char* last_space; - sscanf(p, "%79[^\t]", split); // max 79 char, any char (\t is control char and control char was removed before) - split[sizeof(split)-1] = '\0'; // last char always \0 - if ((last_space = strrchr(split, ' ')) != NULL) { // searching space from end of the string - last_space[0] = '\0'; // replace it by NULL to have correct length of split - p++; // to jump the new NULL - } - p += strlen(split); - // send broadcast to all map-servers - WBUFW(buf,0) = 0x3800; - WBUFW(buf,2) = lp + strlen(split) + 1; - WBUFL(buf,4) = 0x65756c62; // only write if in blue (lp = 8) - memcpy(WBUFP(buf,lp), split, strlen(split) + 1); - mapif_sendall(buf, WBUFW(buf,2)); - } - } - } - } - } - RFIFOSKIP(fd,8 + RFIFOL(fd,4)); - break; - // reply to an account_reg2 registry request case 0x2729: if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) @@ -2256,54 +2190,6 @@ int parse_fromlogin(int fd) } break; - // Account deletion notification (from login-server) - case 0x2730: - if (RFIFOREST(fd) < 6) - return 0; - // Deletion of all characters of the account - for(i = 0; i < char_num; i++) { - if (char_dat[i].status.account_id == RFIFOL(fd,2)) { - char_delete(&char_dat[i].status); - if (i < char_num - 1) { - memcpy(&char_dat[i], &char_dat[char_num-1], sizeof(struct character_data)); - // if moved character owns to deleted account, check again it's character - if (char_dat[i].status.account_id == RFIFOL(fd,2)) { - i--; - // Correct moved character reference in the character's owner by [Yor] - } else { - int j, k; - struct char_session_data *sd2; - for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && - sd2->account_id == char_dat[char_num-1].status.account_id) { - for (k = 0; k < MAX_CHARS; k++) { - if (sd2->found_char[k] == char_num-1) { - sd2->found_char[k] = i; - break; - } - } - break; - } - } - } - } - char_num--; - } - } - // Deletion of the storage - inter_storage_delete(RFIFOL(fd,2)); - // send to all map-servers to disconnect the player - { - unsigned char buf[6]; - WBUFW(buf,0) = 0x2b13; - WBUFL(buf,2) = RFIFOL(fd,2); - mapif_sendall(buf, 6); - } - // disconnect player if online on char-server - disconnect_player(RFIFOL(fd,2)); - RFIFOSKIP(fd,6); - break; - // State change of account/ban notification (from login-server) case 0x2731: if (RFIFOREST(fd) < 11) @@ -3750,22 +3636,6 @@ int parse_char(int fd) } return 0; // avoid processing of followup packets here - // Athena info get - case 0x7530: - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_INTER | ATHENA_SERVER_CHAR; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - - RFIFOSKIP(fd,2); - break; - // unknown packet received default: ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL)); diff --git a/src/char_sql/char.c b/src/char_sql/char.c index fd012e419..d8c710dd5 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3429,22 +3429,6 @@ int parse_char(int fd) } return 0; // avoid processing of followup packets here - // Athena info get - case 0x7530: - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_INTER | ATHENA_SERVER_CHAR; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - - RFIFOSKIP(fd,2); - break; - // unknown packet received default: ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL)); diff --git a/src/ladmin/Makefile.in b/src/ladmin/Makefile.in deleted file mode 100644 index 4703dded1..000000000 --- a/src/ladmin/Makefile.in +++ /dev/null @@ -1,45 +0,0 @@ - -COMMON_OBJ = ../common/obj_all/minicore.o ../common/obj_all/minisocket.o ../common/obj_all/timer.o \ - ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/strlib.o \ - ../common/obj_all/utils.o ../common/obj_all/md5calc.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ - ../common/utils.h ../common/md5calc.h ../common/cbasetypes.h - -LADMIN_OBJ = obj_all/ladmin.o -LADMIN_H = ladmin.h - -@SET_MAKE@ - -##################################################################### -.PHONY : all ladmin clean help - -all: ladmin - -ladmin: obj_all $(LADMIN_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../ladmin@EXEEXT@ $(LADMIN_OBJ) $(COMMON_OBJ) @LIBS@ - -clean: - rm -rf *.o obj_all ../../ladmin@EXEEXT@ - -help: - @echo "possible targets are 'ladmin' 'all' 'clean' 'help'" - @echo "'ladmin' - remote administration tool" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" - -##################################################################### - -obj_all: - -mkdir obj_all - -obj_all/%.o: %.c $(LADMIN_H) $(COMMON_H) - @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -# missing common object files -../common/obj_all/%.o: - @$(MAKE) -C ../common txt - -../common/obj_all/mini%.o: - @$(MAKE) -C ../common txt diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c deleted file mode 100644 index d7a78c119..000000000 --- a/src/ladmin/ladmin.c +++ /dev/null @@ -1,3074 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -/////////////////////////////////////////////////////////////////////////// -// EAthena login-server remote administration tool -/////////////////////////////////////////////////////////////////////////// - -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/version.h" -#include "../common/mmo.h" -#include "../common/md5calc.h" -#include "../common/showmsg.h" -#include "ladmin.h" - -#include -#include -#include -#include -#include -#include -#include // str* -#include // valist - - -//-------------------------------INSTRUCTIONS------------------------------ -// Set the variables below: -// IP of the login server. -// Port where the login-server listens incoming packets. -// Password of administration (same of config_athena.conf). -// IMPORTANT: -// Be sure that you authorize remote administration in login-server -// (see login_athena.conf, 'admin_state' parameter) -//------------------------------------------------------------------------- -char loginserverip[16] = "127.0.0.1"; // IP of login-server -int loginserverport = 6900; // Port of login-server -char loginserveradminpassword[24] = "admin"; // Administration password -int passenc = 0; // Encoding type of the password -char ladmin_log_filename[1024] = "log/ladmin.log"; -char date_format[32] = "%Y-%m-%d %H:%M:%S"; - -//------------------------------------------------------------------------- -// LIST of COMMANDs that you can type at the prompt: -// To use these commands you can only type only the first letters. -// You must type a minimum of letters (you can not type 'a', -// because ladmin doesn't know if it's for 'aide' or for 'add') -// q <= quit, li <= list, pass <= passwd, etc. -// -// Note: every time you must give a account_name, you can use "" or '' (spaces can be included) -// -// aide/help/? -// Display the description of the commands -// aide/help/? [command] -// Display the description of the specified command -// -// add -// Create an account with the default email (a@a.com). -// Concerning the sex, only the first letter is used (F or M). -// The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail. -// When the password is omitted, the input is done without displaying of the pressed keys. -// add testname Male testpass -// -// ban/banish yyyy/mm/dd hh:mm:ss -// Changes the final date of a banishment of an account. -// Like banset, but is at end. -// -// banadd -// Adds or substracts time from the final date of a banishment of an account. -// Modifier is done as follows: -// Adjustment value (-1, 1, +1, etc...) -// Modified element: -// a or y: year -// m: month -// j or d: day -// h: hour -// mn: minute -// s: second -// banadd testname +1m-2mn1s-6y -// this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. -// NOTE: If you modify the final date of a non-banished account, -// you fix the final date to (actual time +- adjustments) -// -// banset yyyy/mm/dd [hh:mm:ss] -// Changes the final date of a banishment of an account. -// Default time [hh:mm:ss]: 23:59:59. -// banset 0 -// Set a non-banished account (0 = unbanished). -// -// block -// Set state 5 (You have been blocked by the GM Team) to an account. -// Like state 5. -// -// check -// Check the validity of a password for an account -// NOTE: Server will never send back a password. -// It's the only method you have to know if a password is correct. -// The other method is to have a ('physical') access to the accounts file. -// -// create -// Like the 'add' command, but with e-mail moreover. -// create testname Male my@mail.com testpass -// -// del -// Remove an account. -// This order requires confirmation. After confirmation, the account is deleted. -// -// email -// Modify the e-mail of an account. -// -// getcount -// Give the number of players online on all char-servers. -// -// gm [GM_level] -// Modify the GM level of an account. -// Default value remove GM level (GM level = 0). -// gm testname 80 -// -// id -// Give the id of an account. -// -// info -// Display complete information of an account. -// -// kami -// Sends a broadcast message on all map-server (in yellow). -// kamib -// Sends a broadcast message on all map-server (in blue). -// -// list/ls [start_id [end_id]] -// Display a list of accounts. -// 'start_id', 'end_id': indicate end and start identifiers. -// Research by name is not possible with this command. -// list 10 9999999 -// -// listBan/lsBan [start_id [end_id]] -// Like list/ls, but only for accounts with state or banished -// -// listGM/lsGM [start_id [end_id]] -// Like list/ls, but only for GM accounts -// -// listOK/lsOK [start_id [end_id]] -// Like list/ls, but only for accounts without state and not banished -// -// memo -// Modify the memo of an account. -// 'memo': it can have until 253 characters (with spaces or not). -// -// name -// Give the name of an account. -// -// passwd -// Change the password of an account. -// When new password is omitted, the input is done without displaying of the pressed keys. -// -// quit/end/exit -// End of the program of administration -// -// reloadGM -// Reload GM configuration file -// -// search -// Seek accounts. -// Displays the accounts whose names correspond. -// search -r/-e/--expr/--regex -// Seek accounts by regular expression. -// Displays the accounts whose names correspond. -// -// sex -// Modify the sex of an account. -// sex testname Male -// -// state -// Change the state of an account. -// 'new_state': state is the state of the packet 0x006a + 1. The possibilities are: -// 0 = Account ok 6 = Your Game's EXE file is not the latest version -// 1 = Unregistered ID 7 = You are Prohibited to log in until %s -// 2 = Incorrect Password 8 = Server is jammed due to over populated -// 3 = This ID is expired 9 = No MSG -// 4 = Rejected from Server 100 = This ID has been totally erased -// 5 = You have been blocked by the GM Team -// all other values are 'No MSG', then use state 9 please. -// 'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a) -// -// timeadd -// Adds or substracts time from the validity limit of an account. -// Modifier is done as follows: -// Adjustment value (-1, 1, +1, etc...) -// Modified element: -// a or y: year -// m: month -// j or d: day -// h: hour -// mn: minute -// s: second -// timeadd testname +1m-2mn1s-6y -// this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. -// NOTE: You can not modify a unlimited validity limit. -// If you want modify it, you want probably create a limited validity limit. -// So, at first, you must set the validity limit to a date/time. -// -// timeset yyyy/mm/dd [hh:mm:ss] -// Changes the validity limit of an account. -// Default time [hh:mm:ss]: 23:59:59. -// timeset 0 -// Gives an unlimited validity limit (0 = unlimited). -// -// unban/unbanish -// Unban an account. -// Like banset 0. -// -// unblock -// Set state 0 (Account ok) to an account. -// Like state 0. -// -// version -// Display the version of the login-server. -// -// who -// Displays complete information of an account. -// -//------------------------------------------------------------------------- - -int login_fd; -int login_ip; -int bytes_to_read = 0; // flag to know if we waiting bytes from login-server -char command[1024]; -char parameters[1024]; -int list_first, list_last, list_type, list_count; // parameter to display a list of accounts -int already_exit_function = 0; // sometimes, the exit function is called twice... so, don't log twice the message - -//------------------------------ -// Writing function of logs file -//------------------------------ -int ladmin_log(char *fmt, ...) -{ - FILE *logfp; - va_list ap; - time_t t; - char tmpstr[2048]; - - va_start(ap, fmt); - - logfp = fopen(ladmin_log_filename, "a"); - if (logfp) { - if (fmt[0] == '\0') // jump a line if no message - fprintf(logfp, "\n"); - else { - t = time(NULL); - strftime(tmpstr, 24, date_format, localtime(&t)); - sprintf(tmpstr + strlen(tmpstr), ": %s", fmt); - vfprintf(logfp, tmpstr, ap); - } - fclose(logfp); - } - - va_end(ap); - return 0; -} - -//--------------------------------------------- -// Function to return ordinal text of a number. -//--------------------------------------------- -char* makeordinal(int number) -{ - if ((number % 10) < 4 && (number % 10) != 0 && (number < 10 || number > 20)) { - if ((number % 10) == 1) - return "st"; - else if ((number % 10) == 2) - return "nd"; - else - return "rd"; - } else { - return "th"; - } -} - -//----------------------------------------------------------------------------------------- -// Function to test of the validity of an account name (return 0 if incorrect, and 1 if ok) -//----------------------------------------------------------------------------------------- -int verify_accountname(char* account_name) -{ - int i; - - for(i = 0; account_name[i]; i++) { - if (account_name[i] < 32) { - ShowMessage("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); - ladmin_log("Illegal character found in the account name (%d%s character).\n", i+1, makeordinal(i+1)); - return 0; - } - } - - if (strlen(account_name) < 4) { - ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); - return 0; - } - - if (strlen(account_name) > 23) { - ShowMessage("Account name is too long. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too long. Please input an account name of 4-23 bytes.\n"); - return 0; - } - - return 1; -} - -//---------------------------------- -// Sub-function: Input of a password -//---------------------------------- -int typepasswd(char * password) -{ - char password1[1023], password2[1023]; - int letter; - int i; - - ladmin_log("No password was given. Request to obtain a password.\n"); - - memset(password1, '\0', sizeof(password1)); - memset(password2, '\0', sizeof(password2)); - - ShowMessage("\033[1;36m Type the password > \033[0;32;42m"); - - i = 0; - while ((letter = getchar()) != '\n') - password1[i++] = letter; - - ShowMessage("\033[0m\033[1;36m Verify the password > \033[0;32;42m"); - - i = 0; - while ((letter = getchar()) != '\n') - password2[i++] = letter; - - ShowMessage("\033[0m"); - fflush(stdout); - fflush(stdin); - - if (strcmp(password1, password2) != 0) { - ShowMessage("Password verification failed. Please input same password.\n"); - ladmin_log("Password verification failed. Please input same password.\n"); - ladmin_log(" First password: %s, second password: %s.\n", password1, password2); - return 0; - } - ladmin_log("Typed password: %s.\n", password1); - strcpy(password, password1); - return 1; -} - -//------------------------------------------------------------------------------------ -// Sub-function: Test of the validity of password (return 0 if incorrect, and 1 if ok) -//------------------------------------------------------------------------------------ -int verify_password(char * password) -{ - int i; - - for(i = 0; password[i]; i++) { - if (password[i] < 32) { - ShowMessage("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); - ladmin_log("Illegal character found in the password (%d%s character).\n", i+1, makeordinal(i+1)); - return 0; - } - } - - if (strlen(password) < 4) { - ShowMessage("Account name is too short. Please input an account name of 4-23 bytes.\n"); - ladmin_log("Account name is too short. Please input an account name of 4-23 bytes.\n"); - return 0; - } - - if (strlen(password) > 23) { - ShowMessage("Password is too long. Please input a password of 4-23 bytes.\n"); - ladmin_log("Password is too long. Please input a password of 4-23 bytes.\n"); - return 0; - } - - return 1; -} - -//------------------------------------------------------------------ -// Sub-function: Check the name of a command (return complete name) -//----------------------------------------------------------------- -int check_command(char * command) -{ -// help - if (strncmp(command, "help", 1) == 0 && strncmp(command, "help", strlen(command)) == 0) - strcpy(command, "help"); -// general commands - else if (strncmp(command, "add", 2) == 0 && strncmp(command, "add", strlen(command)) == 0) // not 1 letter command: 'aide' or 'add'? - strcpy(command, "add"); - else if ((strncmp(command, "ban", 3) == 0 && strncmp(command, "ban", strlen(command)) == 0) || - (strncmp(command, "banish", 4) == 0 && strncmp(command, "banish", strlen(command)) == 0)) - strcpy(command, "ban"); - else if ((strncmp(command, "banadd", 4) == 0 && strncmp(command, "banadd", strlen(command)) == 0) || // not 1 letter command: 'ba' or 'bs'? 'banadd' or 'banset' ? - strcmp(command, "ba") == 0) - strcpy(command, "banadd"); - else if ((strncmp(command, "banset", 4) == 0 && strncmp(command, "banset", strlen(command)) == 0) || // not 1 letter command: 'ba' or 'bs'? 'banadd' or 'banset' ? - strcmp(command, "bs") == 0) - strcpy(command, "banset"); - else if (strncmp(command, "block", 2) == 0 && strncmp(command, "block", strlen(command)) == 0) - strcpy(command, "block"); - else if (strncmp(command, "check", 2) == 0 && strncmp(command, "check", strlen(command)) == 0) // not 1 letter command: 'check' or 'create'? - strcpy(command, "check"); - else if (strncmp(command, "create", 2) == 0 && strncmp(command, "create", strlen(command)) == 0) // not 1 letter command: 'check' or 'create'? - strcpy(command, "create"); - else if (strncmp(command, "delete", 1) == 0 && strncmp(command, "delete", strlen(command)) == 0) - strcpy(command, "delete"); - else if ((strncmp(command, "email", 2) == 0 && strncmp(command, "email", strlen(command)) == 0) || // not 1 letter command: 'email', 'end' or 'exit'? - (strncmp(command, "e-mail", 2) == 0 && strncmp(command, "e-mail", strlen(command)) == 0)) - strcpy(command, "email"); - else if (strncmp(command, "getcount", 2) == 0 && strncmp(command, "getcount", strlen(command)) == 0) // not 1 letter command: 'getcount' or 'gm'? - strcpy(command, "getcount"); -// else if (strncmp(command, "gm", 2) == 0 && strncmp(command, "gm", strlen(command)) == 0) // not 1 letter command: 'getcount' or 'gm'? -// strcpy(command, "gm"); -// else if (strncmp(command, "id", 2) == 0 && strncmp(command, "id", strlen(command)) == 0) // not 1 letter command: 'id' or 'info'? -// strcpy(command, "id"); - else if (strncmp(command, "info", 2) == 0 && strncmp(command, "info", strlen(command)) == 0) // not 1 letter command: 'id' or 'info'? - strcpy(command, "info"); -// else if (strncmp(command, "kami", 4) == 0 && strncmp(command, "kami", strlen(command)) == 0) // only all letters command: 'kami' or 'kamib'? -// strcpy(command, "kami"); -// else if (strncmp(command, "kamib", 5) == 0 && strncmp(command, "kamib", strlen(command)) == 0) // only all letters command: 'kami' or 'kamib'? -// strcpy(command, "kamib"); - else if ((strncmp(command, "list", 2) == 0 && strncmp(command, "list", strlen(command)) == 0) || // 'list' is default list command // not 1 letter command: 'list'? - strcmp(command, "ls") == 0) - strcpy(command, "list"); - else if ((strncmp(command, "listban", 5) == 0 && strncmp(command, "listban", strlen(command)) == 0) || - (strncmp(command, "lsban", 3) == 0 && strncmp(command, "lsban", strlen(command)) == 0) || - strcmp(command, "lb") == 0) - strcpy(command, "listban"); - else if ((strncmp(command, "listgm", 5) == 0 && strncmp(command, "listgm", strlen(command)) == 0) || - (strncmp(command, "lsgm", 3) == 0 && strncmp(command, "lsgm", strlen(command)) == 0) || - strcmp(command, "lg") == 0) - strcpy(command, "listgm"); - else if ((strncmp(command, "listok", 5) == 0 && strncmp(command, "listok", strlen(command)) == 0) || - (strncmp(command, "lsok", 3) == 0 && strncmp(command, "lsok", strlen(command)) == 0) || - strcmp(command, "lo") == 0) - strcpy(command, "listok"); - else if (strncmp(command, "memo", 1) == 0 && strncmp(command, "memo", strlen(command)) == 0) - strcpy(command, "memo"); - else if (strncmp(command, "name", 1) == 0 && strncmp(command, "name", strlen(command)) == 0) - strcpy(command, "name"); - else if ((strncmp(command, "password", 1) == 0 && strncmp(command, "password", strlen(command)) == 0) || - strcmp(command, "passwd") == 0) - strcpy(command, "password"); - else if (strncmp(command, "reloadgm", 1) == 0 && strncmp(command, "reloadgm", strlen(command)) == 0) - strcpy(command, "reloadgm"); - else if (strncmp(command, "search", 3) == 0 && strncmp(command, "search", strlen(command)) == 0) // not 1 letter command: 'search', 'state' or 'sex'? - strcpy(command, "search"); // not 2 letters command: 'search' or 'sex'? -// else if (strncmp(command, "sex", 3) == 0 && strncmp(command, "sex", strlen(command)) == 0) // not 1 letter command: 'search', 'state' or 'sex'? -// strcpy(command, "sex"); // not 2 letters command: 'search' or 'sex'? - else if (strncmp(command, "state", 2) == 0 && strncmp(command, "state", strlen(command)) == 0) // not 1 letter command: 'search', 'state' or 'sex'? - strcpy(command, "state"); - else if ((strncmp(command, "timeadd", 5) == 0 && strncmp(command, "timeadd", strlen(command)) == 0) || // not 1 letter command: 'ta' or 'ts'? 'timeadd' or 'timeset'? - strcmp(command, "ta") == 0) - strcpy(command, "timeadd"); - else if ((strncmp(command, "timeset", 5) == 0 && strncmp(command, "timeset", strlen(command)) == 0) || // not 1 letter command: 'ta' or 'ts'? 'timeadd' or 'timeset'? - strcmp(command, "ts") == 0) - strcpy(command, "timeset"); - else if ((strncmp(command, "unban", 5) == 0 && strncmp(command, "unban", strlen(command)) == 0) || - (strncmp(command, "unbanish", 4) == 0 && strncmp(command, "unbanish", strlen(command)) == 0)) - strcpy(command, "unban"); - else if (strncmp(command, "unblock", 4) == 0 && strncmp(command, "unblock", strlen(command)) == 0) - strcpy(command, "unblock"); - else if (strncmp(command, "version", 1) == 0 && strncmp(command, "version", strlen(command)) == 0) - strcpy(command, "version"); - else if (strncmp(command, "who", 1) == 0 && strncmp(command, "who", strlen(command)) == 0) - strcpy(command, "who"); -// quit - else if (strncmp(command, "quit", 1) == 0 && strncmp(command, "quit", strlen(command)) == 0) - strcpy(command, "quit"); - else if (strncmp(command, "exit", 2) == 0 && strncmp(command, "exit", strlen(command)) == 0) // not 1 letter command: 'email', 'end' or 'exit'? - strcpy(command, "exit"); - else if (strncmp(command, "end", 2) == 0 && strncmp(command, "end", strlen(command)) == 0) // not 1 letter command: 'email', 'end' or 'exit'? - strcpy(command, "end"); - - return 0; -} - -//----------------------------------------- -// Sub-function: Display commands of ladmin -//----------------------------------------- -void display_help(char* param) -{ - char command[1023]; - int i; - - memset(command, '\0', sizeof(command)); - - if (sscanf(param, "%s ", command) < 1 || strlen(command) == 0) - strcpy(command, ""); // any value that is not a command - - if (command[0] == '?') - strcpy(command, "help"); - - // lowercase for command - for (i = 0; command[i]; i++) - command[i] = TOLOWER(command[i]); - - // Analyse of the command - check_command(command); // give complete name to the command - - ladmin_log("Displaying of the commands or a command.\n"); - - if (strcmp(command, "help") == 0 ) { - ShowMessage("aide/help/?\n"); - ShowMessage(" Display the description of the commands\n"); - ShowMessage("aide/help/? [command]\n"); - ShowMessage(" Display the description of the specified command\n"); -// general commands - } else if (strcmp(command, "add") == 0) { - ShowMessage("add \n"); - ShowMessage(" Create an account with the default email (a@a.com).\n"); - ShowMessage(" Concerning the sex, only the first letter is used (F or M).\n"); - ShowMessage(" The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.\n"); - ShowMessage(" When the password is omitted,\n"); - ShowMessage(" the input is done without displaying of the pressed keys.\n"); - ShowMessage(" add testname Male testpass\n"); - } else if (strcmp(command, "ban") == 0) { - ShowMessage("ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" Changes the final date of a banishment of an account.\n"); - ShowMessage(" Like banset, but is at end.\n"); - } else if (strcmp(command, "banadd") == 0) { - ShowMessage("banadd \n"); - ShowMessage(" Adds or substracts time from the final date of a banishment of an account.\n"); - ShowMessage(" Modifier is done as follows:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ShowMessage("NOTE: If you modify the final date of a non-banished account,\n"); - ShowMessage(" you fix the final date to (actual time +- adjustments)\n"); - } else if (strcmp(command, "banset") == 0) { - ShowMessage("banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" Changes the final date of a banishment of an account.\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("banset 0\n"); - ShowMessage(" Set a non-banished account (0 = unbanished).\n"); - } else if (strcmp(command, "block") == 0) { - ShowMessage("block \n"); - ShowMessage(" Set state 5 (You have been blocked by the GM Team) to an account.\n"); - ShowMessage(" This command works like state 5.\n"); - } else if (strcmp(command, "check") == 0) { - ShowMessage("check \n"); - ShowMessage(" Check the validity of a password for an account.\n"); - ShowMessage(" NOTE: Server will never send back a password.\n"); - ShowMessage(" It's the only method you have to know if a password is correct.\n"); - ShowMessage(" The other method is to have a ('physical') access to the accounts file.\n"); - } else if (strcmp(command, "create") == 0) { - ShowMessage("create \n"); - ShowMessage(" Like the 'add' command, but with e-mail moreover.\n"); - ShowMessage(" create testname Male my@mail.com testpass\n"); - } else if (strcmp(command, "delete") == 0) { - ShowMessage("del \n"); - ShowMessage(" Remove an account.\n"); - ShowMessage(" This order requires confirmation. After confirmation, the account is deleted.\n"); - } else if (strcmp(command, "email") == 0) { - ShowMessage("email \n"); - ShowMessage(" Modify the e-mail of an account.\n"); - } else if (strcmp(command, "getcount") == 0) { - ShowMessage("getcount\n"); - ShowMessage(" Give the number of players online on all char-servers.\n"); - } else if (strcmp(command, "gm") == 0) { - ShowMessage("gm [GM_level]\n"); - ShowMessage(" Modify the GM level of an account.\n"); - ShowMessage(" Default value remove GM level (GM level = 0).\n"); - ShowMessage(" gm testname 80\n"); - } else if (strcmp(command, "id") == 0) { - ShowMessage("id \n"); - ShowMessage(" Give the id of an account.\n"); - } else if (strcmp(command, "info") == 0) { - ShowMessage("info \n"); - ShowMessage(" Display complete information of an account.\n"); - } else if (strcmp(command, "kami") == 0) { - ShowMessage("kami \n"); - ShowMessage(" Sends a broadcast message on all map-server (in yellow).\n"); - } else if (strcmp(command, "kamib") == 0) { - ShowMessage("kamib \n"); - ShowMessage(" Sends a broadcast message on all map-server (in blue).\n"); - } else if (strcmp(command, "list") == 0) { - ShowMessage("list/ls [start_id [end_id]]\n"); - ShowMessage(" Display a list of accounts.\n"); - ShowMessage(" 'start_id', 'end_id': indicate end and start identifiers.\n"); - ShowMessage(" Research by name is not possible with this command.\n"); - ShowMessage(" list 10 9999999\n"); - } else if (strcmp(command, "listban") == 0) { - ShowMessage("listBan/lsBan [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for accounts with state or banished.\n"); - } else if (strcmp(command, "listgm") == 0) { - ShowMessage("listGM/lsGM [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for GM accounts.\n"); - } else if (strcmp(command, "listok") == 0) { - ShowMessage("listOK/lsOK [start_id [end_id]]\n"); - ShowMessage(" Like list/ls, but only for accounts without state and not banished.\n"); - } else if (strcmp(command, "memo") == 0) { - ShowMessage("memo \n"); - ShowMessage(" Modify the memo of an account.\n"); - ShowMessage(" 'memo': it can have until 253 characters (with spaces or not).\n"); - } else if (strcmp(command, "name") == 0) { - ShowMessage("name \n"); - ShowMessage(" Give the name of an account.\n"); - } else if (strcmp(command, "password") == 0) { - ShowMessage("passwd \n"); - ShowMessage(" Change the password of an account.\n"); - ShowMessage(" When new password is omitted,\n"); - ShowMessage(" the input is done without displaying of the pressed keys.\n"); - } else if (strcmp(command, "reloadgm") == 0) { - ShowMessage("reloadGM\n"); - ShowMessage(" Reload GM configuration file\n"); - } else if (strcmp(command, "search") == 0) { - ShowMessage("search \n"); - ShowMessage(" Seek accounts.\n"); - ShowMessage(" Displays the accounts whose names correspond.\n"); -// ShowMessage("search -r/-e/--expr/--regex \n"); -// ShowMessage(" Seek accounts by regular expression.\n"); -// ShowMessage(" Displays the accounts whose names correspond.\n"); - } else if (strcmp(command, "sex") == 0) { - ShowMessage("sex \n"); - ShowMessage(" Modify the sex of an account.\n"); - ShowMessage(" sex testname Male\n"); - } else if (strcmp(command, "state") == 0) { - ShowMessage("state \n"); - ShowMessage(" Change the state of an account.\n"); - ShowMessage(" 'new_state': state is the state of the packet 0x006a + 1.\n"); - ShowMessage(" The possibilities are:\n"); - ShowMessage(" 0 = Account ok\n"); - ShowMessage(" 1 = Unregistered ID\n"); - ShowMessage(" 2 = Incorrect Password\n"); - ShowMessage(" 3 = This ID is expired\n"); - ShowMessage(" 4 = Rejected from Server\n"); - ShowMessage(" 5 = You have been blocked by the GM Team\n"); - ShowMessage(" 6 = Your Game's EXE file is not the latest version\n"); - ShowMessage(" 7 = You are Prohibited to log in until...\n"); - ShowMessage(" 8 = Server is jammed due to over populated\n"); - ShowMessage(" 9 = No MSG\n"); - ShowMessage(" 100 = This ID has been totally erased\n"); - ShowMessage(" all other values are 'No MSG', then use state 9 please.\n"); - ShowMessage(" 'error_message_#7': message of the code error 6\n"); - ShowMessage(" = Your are Prohibited to log in until... (packet 0x006a)\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeadd \n"); - ShowMessage(" Adds or substracts time from the validity limit of an account.\n"); - ShowMessage(" Modifier is done as follows:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ShowMessage("NOTE: You can not modify a unlimited validity limit.\n"); - ShowMessage(" If you want modify it, you want probably create a limited validity limit.\n"); - ShowMessage(" So, at first, you must set the validity limit to a date/time.\n"); - } else if (strcmp(command, "timeadd") == 0) { - ShowMessage("timeset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" Changes the validity limit of an account.\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ShowMessage("timeset 0\n"); - ShowMessage(" Gives an unlimited validity limit (0 = unlimited).\n"); - } else if (strcmp(command, "unban") == 0) { - ShowMessage("unban/unbanish \n"); - ShowMessage(" Remove the banishment of an account.\n"); - ShowMessage(" This command works like banset 0.\n"); - } else if (strcmp(command, "unblock") == 0) { - ShowMessage("unblock \n"); - ShowMessage(" Set state 0 (Account ok) to an account.\n"); - ShowMessage(" This command works like state 0.\n"); - } else if (strcmp(command, "version") == 0) { - ShowMessage("version\n"); - ShowMessage(" Display the version of the login-server.\n"); - } else if (strcmp(command, "who") == 0) { - ShowMessage("who \n"); - ShowMessage(" Displays complete information of an account.\n"); -// quit - } else if (strcmp(command, "quit") == 0 || - strcmp(command, "exit") == 0 || - strcmp(command, "end") == 0) { - ShowMessage("quit/end/exit\n"); - ShowMessage(" End of the program of administration.\n"); -// unknown command - } else { - if (strlen(command) > 0) - ShowMessage("Unknown command [%s] for help. Displaying of all commands.\n", command); - ShowMessage(" aide/help/? -- Display this help\n"); - ShowMessage(" aide/help/? [command] -- Display the help of the command\n"); - ShowMessage(" add -- Create an account with default email\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss -- Change final date of a ban\n"); - ShowMessage(" banadd/ba -- Add or substract time from the final\n"); - ShowMessage(" example: ba apple +1m-2mn1s-2y date of a banishment of an account\n"); - ShowMessage(" banset/bs yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban\n"); - ShowMessage(" banset/bs 0 -- Un-banish an account\n"); - ShowMessage(" block -- Set state 5 (blocked by the GM Team) to an account\n"); - ShowMessage(" check -- Check the validity of a password\n"); - ShowMessage(" create -- Create an account with email\n"); - ShowMessage(" del -- Remove an account\n"); - ShowMessage(" email -- Modify an email of an account\n"); - ShowMessage(" getcount -- Give the number of players online\n"); - ShowMessage(" gm [GM_level] -- Modify the GM level of an account\n"); - ShowMessage(" id -- Give the id of an account\n"); - ShowMessage(" info -- Display all information of an account\n"); - ShowMessage(" kami -- Sends a broadcast message (in yellow)\n"); - ShowMessage(" kamib -- Sends a broadcast message (in blue)\n"); - ShowMessage(" list/ls [First_id [Last_id]] -- Display a list of accounts\n"); - ShowMessage(" listBan/lsBan [First_id [Last_id] ] -- Display a list of accounts\n"); - ShowMessage(" with state or banished\n"); - ShowMessage(" listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts\n"); - ShowMessage(" listOK/lsOK [First_id [Last_id] ] -- Display a list of accounts\n"); - ShowMessage(" without state and not banished\n"); - ShowMessage(" memo -- Modify the memo of an account\n"); - ShowMessage(" name -- Give the name of an account\n"); - ShowMessage(" passwd -- Change the password of an account\n"); - ShowMessage(" quit/end/exit -- End of the program of administation\n"); - ShowMessage(" reloadGM -- Reload GM configuration file\n"); - ShowMessage(" search -- Seek accounts\n"); -// ShowMessage(" search -e/-r/--expr/--regex -- Seek accounts by regular-expression\n"); - ShowMessage(" sex -- Modify the sex of an account\n"); - ShowMessage(" state -- Change the state\n"); - ShowMessage(" timeadd/ta -- Add or substract time from the\n"); - ShowMessage(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"); - ShowMessage(" timeset/ts yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"); - ShowMessage(" timeset/ts 0 -- Give a unlimited validity limit\n"); - ShowMessage(" unban/unbanish -- Remove the banishment of an account\n"); - ShowMessage(" unblock -- Set state 0 (Account ok) to an account\n"); - ShowMessage(" version -- Gives the version of the login-server\n"); - ShowMessage(" who -- Display all information of an account\n"); - ShowMessage(" who -- Display all information of an account\n"); - ShowMessage(" Note: To use spaces in an account name, type \"\" (or ').\n"); - } -} - -//----------------------------- -// Sub-function: add an account -//----------------------------- -int addaccount(char* param, int emailflag) -{ - char name[1023], sex[1023], email[1023], password[1023]; -// int i; - WFIFOHEAD(login_fd,91); - - memset(name, '\0', sizeof(name)); - memset(sex, '\0', sizeof(sex)); - memset(email, '\0', sizeof(email)); - memset(password, '\0', sizeof(password)); - - if (emailflag == 0) { // add command - if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, sex, password) < 2 && // password can be void - sscanf(param, "'%[^']' %s %[^\r\n]", name, sex, password) < 2 && // password can be void - sscanf(param, "%s %s %[^\r\n]", name, sex, password) < 2) { // password can be void - ShowMessage("Please input an account name, a sex and a password.\n"); - ShowMessage(" add testname Male testpass\n"); - ladmin_log("Incomplete parameters to create an account ('add' command).\n"); - return 136; - } - strcpy(email, "a@a.com"); // default email - } else { // 1: create command - if (sscanf(param, "\"%[^\"]\" %s %s %[^\r\n]", name, sex, email, password) < 3 && // password can be void - sscanf(param, "'%[^']' %s %s %[^\r\n]", name, sex, email, password) < 3 && // password can be void - sscanf(param, "%s %s %s %[^\r\n]", name, sex, email, password) < 3) { // password can be void - ShowMessage("Please input an account name, a sex and a password.\n"); - ShowMessage(" create testname Male my@mail.com testpass\n"); - ladmin_log("Incomplete parameters to create an account ('create' command).\n"); - return 136; - } - } - if (verify_accountname(name) == 0) { - return 102; - } - - sex[0] = TOUPPER(sex[0]); - if (strchr("MF", sex[0]) == NULL) { - ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); - ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); - return 103; - } - - if (strlen(email) < 3) { - ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); - return 109; - } - if (strlen(email) > 39) { - ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - return 109; - } - if (e_mail_check(email) == 0) { - ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); - return 109; - } - - if (strlen(password) == 0) { - if (typepasswd(password) == 0) - return 108; - } - if (verify_password(password) == 0) - return 104; - - ladmin_log("Request to login-server to create an account.\n"); - - WFIFOW(login_fd,0) = 0x7930; - memcpy(WFIFOP(login_fd,2), name, 24); - memcpy(WFIFOP(login_fd,26), password, 24); - WFIFOB(login_fd,50) = sex[0]; - memcpy(WFIFOP(login_fd,51), email, 40); - WFIFOSET(login_fd,91); - bytes_to_read = 1; - - return 0; -} - -//--------------------------------------------------------------------------------- -// Sub-function: Add/substract time to the final date of a banishment of an account -//--------------------------------------------------------------------------------- -int banaddaccount(char* param) -{ - char name[1023], modif[1023]; - int year, month, day, hour, minute, second; - char * p_modif; - int value, i; - WFIFOHEAD(login_fd,38); - - memset(name, '\0', sizeof(name)); - memset(modif, '\0', sizeof(modif)); - year = month = day = hour = minute = second = 0; - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, modif) < 2 && - sscanf(param, "'%[^']' %[^\r\n]", name, modif) < 2 && - sscanf(param, "%s %[^\r\n]", name, modif) < 2) { - ShowMessage("Please input an account name and a modifier.\n"); - ShowMessage(" : banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("Incomplete parameters to modify the ban date/time of an account ('banadd' command).\n"); - return 136; - } - if (verify_accountname(name) == 0) { - return 102; - } - - // lowercase for modif - for (i = 0; modif[i]; i++) - modif[i] = TOLOWER(modif[i]); - p_modif = modif; - while (strlen(p_modif) > 0) { - value = atoi(p_modif); - if (value == 0) { - p_modif++; - } else { - if (p_modif[0] == '-' || p_modif[0] == '+') - p_modif++; - while (strlen(p_modif) > 0 && p_modif[0] >= '0' && p_modif[0] <= '9') { - p_modif++; - } - if (p_modif[0] == 's') { - second = value; - p_modif++; - } else if (p_modif[0] == 'm' && p_modif[1] == 'n') { - minute = value; - p_modif += 2; - } else if (p_modif[0] == 'h') { - hour = value; - p_modif++; - } else if (p_modif[0] == 'd' || p_modif[0] == 'j') { - day = value; - p_modif += 2; - } else if (p_modif[0] == 'm') { - month = value; - p_modif++; - } else if (p_modif[0] == 'y' || p_modif[0] == 'a') { - year = value; - p_modif++; - } else { - p_modif++; - } - } - } - - ShowMessage(" year: %d\n", year); - ShowMessage(" month: %d\n", month); - ShowMessage(" day: %d\n", day); - ShowMessage(" hour: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" second: %d\n", second); - - if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) { - ShowMessage("Please give an adjustment with this command:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" banadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("No adjustment isn't an adjustment ('banadd' command).\n"); - return 137; - } - if (year > 127 || year < -127) { - ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); - ladmin_log("Abnormal adjustment for the year ('banadd' command).\n"); - return 137; - } - if (month > 255 || month < -255) { - ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); - ladmin_log("Abnormal adjustment for the month ('banadd' command).\n"); - return 137; - } - if (day > 32767 || day < -32767) { - ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the days ('banadd' command).\n"); - return 137; - } - if (hour > 32767 || hour < -32767) { - ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the hours ('banadd' command).\n"); - return 137; - } - if (minute > 32767 || minute < -32767) { - ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the minutes ('banadd' command).\n"); - return 137; - } - if (second > 32767 || second < -32767) { - ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the seconds ('banadd' command).\n"); - return 137; - } - - ladmin_log("Request to login-server to modify a ban date/time.\n"); - - WFIFOW(login_fd,0) = 0x794c; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOW(login_fd,26) = (short)year; - WFIFOW(login_fd,28) = (short)month; - WFIFOW(login_fd,30) = (short)day; - WFIFOW(login_fd,32) = (short)hour; - WFIFOW(login_fd,34) = (short)minute; - WFIFOW(login_fd,36) = (short)second; - WFIFOSET(login_fd,38); - bytes_to_read = 1; - - return 0; -} - -//----------------------------------------------------------------------- -// Sub-function of sub-function banaccount, unbanaccount or bansetaccount -// Set the final date of a banishment of an account -//----------------------------------------------------------------------- -int bansetaccountsub(char* name, char* date, char* time) -{ - int year, month, day, hour, minute, second; - time_t unban_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) - struct tm *tmtime; - WFIFOHEAD(login_fd,30); - - year = month = day = hour = minute = second = 0; - unban_time = 0; - tmtime = localtime(&unban_time); // initialize - - if (verify_accountname(name) == 0) { - return 102; - } - - if (atoi(date) != 0 && - ((sscanf(date, "%d/%d/%d", &year, &month, &day) < 3 && - sscanf(date, "%d-%d-%d", &year, &month, &day) < 3 && - sscanf(date, "%d.%d.%d", &year, &month, &day) < 3) || - sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) - { - ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); - ladmin_log("Invalid format for the date/time ('banset' or 'ban' command).\n"); - return 102; - } - - if (atoi(date) == 0) { - unban_time = 0; - } else { - if (year < 70) { - year = year + 100; - } - if (year >= 1900) { - year = year - 1900; - } - if (month < 1 || month > 12) { - ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); - ladmin_log("Invalid month for the date ('banset' or 'ban' command).\n"); - return 102; - } - month = month - 1; - if (day < 1 || day > 31) { - ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); - ladmin_log("Invalid day for the date ('banset' or 'ban' command).\n"); - return 102; - } - if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) || - (month == 1 && day > 29)) { - ShowMessage("Please give a correct value for a day of this month (%d).\n", month); - ladmin_log("Invalid day for this month ('banset' or 'ban' command).\n"); - return 102; - } - if (hour < 0 || hour > 23) { - ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); - ladmin_log("Invalid hour for the time ('banset' or 'ban' command).\n"); - return 102; - } - if (minute < 0 || minute > 59) { - ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); - ladmin_log("Invalid minute for the time ('banset' or 'ban' command).\n"); - return 102; - } - if (second < 0 || second > 59) { - ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); - ladmin_log("Invalid second for the time ('banset' or 'ban' command).\n"); - return 102; - } - tmtime->tm_year = year; - tmtime->tm_mon = month; - tmtime->tm_mday = day; - tmtime->tm_hour = hour; - tmtime->tm_min = minute; - tmtime->tm_sec = second; - tmtime->tm_isdst = -1; // -1: no winter/summer time modification - unban_time = mktime(tmtime); - if (unban_time == -1) { - ShowMessage("Invalid date.\n"); - ShowMessage("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - ShowMessage("You can imput 0 instead of if you use 'banset' command.\n"); - ladmin_log("Invalid date. ('banset' or 'ban' command).\n"); - return 102; - } - } - - ladmin_log("Request to login-server to set a ban.\n"); - - WFIFOW(login_fd,0) = 0x794a; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOL(login_fd,26) = (int)unban_time; - WFIFOSET(login_fd,30); - bytes_to_read = 1; - - return 0; -} - -//--------------------------------------------------------------------- -// Sub-function: Set the final date of a banishment of an account (ban) -//--------------------------------------------------------------------- -int banaccount(char* param) -{ - char name[1023], date[1023], time[1023]; - - memset(name, '\0', sizeof(name)); - memset(date, '\0', sizeof(date)); - memset(time, '\0', sizeof(time)); - - if (sscanf(param, "%s %s \"%[^\"]\"", date, time, name) < 3 && - sscanf(param, "%s %s '%[^']'", date, time, name) < 3 && - sscanf(param, "%s %s %[^\r\n]", date, time, name) < 3) { - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); - return 136; - } - - return bansetaccountsub(name, date, time); -} - -//------------------------------------------------------------------------ -// Sub-function: Set the final date of a banishment of an account (banset) -//------------------------------------------------------------------------ -int bansetaccount(char* param) -{ - char name[1023], date[1023], time[1023]; - - memset(name, '\0', sizeof(name)); - memset(date, '\0', sizeof(date)); - memset(time, '\0', sizeof(time)); - - if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void - sscanf(param, "'%[^']' %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void - sscanf(param, "%s %s %[^\r\n]", name, date, time) < 2) { // if date = 0, time can be void - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); - return 136; - } - - if (time[0] == '\0') - strcpy(time, "23:59:59"); - - return bansetaccountsub(name, date, time); -} - -//------------------------------------------------- -// Sub-function: unbanishment of an account (unban) -//------------------------------------------------- -int unbanaccount(char* param) -{ - char name[1023]; - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(": banset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" banset 0 (0 = un-banished)\n"); - ShowMessage(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - ShowMessage(" unban/unbanish \n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a ban ('unban' command).\n"); - return 136; - } - - return bansetaccountsub(name, "0", ""); -} - -//--------------------------------------------------------- -// Sub-function: Asking to check the validity of a password -// (Note: never send back a password with login-server!! security of passwords) -//--------------------------------------------------------- -int checkaccount(char* param) -{ - char name[1023], password[1023]; - WFIFOHEAD(login_fd,50); - - memset(name, '\0', sizeof(name)); - memset(password, '\0', sizeof(password)); - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, password) < 1 && // password can be void - sscanf(param, "'%[^']' %[^\r\n]", name, password) < 1 && // password can be void - sscanf(param, "%s %[^\r\n]", name, password) < 1) { // password can be void - ShowMessage("Please input an account name.\n"); - ShowMessage(" check testname password\n"); - ladmin_log("Incomplete parameters to check the password of an account ('check' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (strlen(password) == 0) { - if (typepasswd(password) == 0) - return 134; - } - if (verify_password(password) == 0) - return 131; - - ladmin_log("Request to login-server to check a password.\n"); - - WFIFOW(login_fd,0) = 0x793a; - memcpy(WFIFOP(login_fd,2), name, 24); - memcpy(WFIFOP(login_fd,26), password, 24); - WFIFOSET(login_fd,50); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------------ -// Sub-function: Asking for deletion of an account -//------------------------------------------------ -int delaccount(char* param) -{ - char name[1023]; - char letter; - char confirm[1023]; - int i; - WFIFOHEAD(login_fd,26); - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(" del testnametodelete\n"); - ladmin_log("No name given to delete an account ('delete' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - memset(confirm, '\0', sizeof(confirm)); - while (confirm[0] != 'n' && confirm[0] != 'y') - { - ShowMessage("\033[1;36m ** Are you really sure to DELETE account [$userid]? (y/n) > \033[0m"); - fflush(stdout); - memset(confirm, '\0', sizeof(confirm)); - i = 0; - while ((letter = getchar()) != '\n') - confirm[i++] = letter; - } - - if (confirm[0] == 'n') { - ShowMessage("Deletion canceled.\n"); - ladmin_log("Deletion canceled by user ('delete' command).\n"); - return 121; - } - - ladmin_log("Request to login-server to delete an acount.\n"); - - WFIFOW(login_fd,0) = 0x7932; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOSET(login_fd,26); - bytes_to_read = 1; - - return 0; -} - -//---------------------------------------------------------- -// Sub-function: Asking to modification of an account e-mail -//---------------------------------------------------------- -int changeemail(char* param) -{ - char name[1023], email[1023]; - WFIFOHEAD(login_fd,66); - - memset(name, '\0', sizeof(name)); - memset(email, '\0', sizeof(email)); - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, email) < 2 && - sscanf(param, "'%[^']' %[^\r\n]", name, email) < 2 && - sscanf(param, "%s %[^\r\n]", name, email) < 2) { - ShowMessage("Please input an account name and an email.\n"); - ShowMessage(" email testname newemail\n"); - ladmin_log("Incomplete parameters to change the email of an account ('email' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (strlen(email) < 3) { - ShowMessage("Email is too short [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Email is too short [%s]. Please input a valid e-mail.\n", email); - return 109; - } - if (strlen(email) > 39) { - ShowMessage("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - ladmin_log("Email is too long [%s]. Please input an e-mail with 39 bytes at the most.\n", email); - return 109; - } - if (e_mail_check(email) == 0) { - ShowMessage("Invalid email [%s]. Please input a valid e-mail.\n", email); - ladmin_log("Invalid email [%s]. Please input a valid e-mail.\n", email); - return 109; - } - - ladmin_log("Request to login-server to change an email.\n"); - - WFIFOW(login_fd,0) = 0x7940; - memcpy(WFIFOP(login_fd,2), name, 24); - memcpy(WFIFOP(login_fd,26), email, 40); - WFIFOSET(login_fd,66); - bytes_to_read = 1; - - return 0; -} - -//----------------------------------------------------- -// Sub-function: Asking of the number of online players -//----------------------------------------------------- -int getlogincount(void) -{ - WFIFOHEAD(login_fd,2); - ladmin_log("Request to login-server to obtain the # of online players.\n"); - - WFIFOW(login_fd,0) = 0x7938; - WFIFOSET(login_fd,2); - bytes_to_read = 1; - - return 0; -} - -//---------------------------------------------------------- -// Sub-function: Asking to modify the GM level of an account -//---------------------------------------------------------- -int changegmlevel(char* param) -{ - char name[1023]; - int GM_level; - WFIFOHEAD(login_fd,27); - - memset(name, '\0', sizeof(name)); - GM_level = 0; - - if (sscanf(param, "\"%[^\"]\" %d", name, &GM_level) < 1 && - sscanf(param, "'%[^']' %d", name, &GM_level) < 1 && - sscanf(param, "%s %d", name, &GM_level) < 1) { - ShowMessage("Please input an account name and a GM level.\n"); - ShowMessage(" gm testname 80\n"); - ladmin_log("Incomplete parameters to change the GM level of an account ('gm' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (GM_level < 0 || GM_level > 99) { - ShowMessage("Illegal GM level [%d]. Please input a value from 0 to 99.\n", GM_level); - ladmin_log("Illegal GM level [%d]. The value can be from 0 to 99.\n", GM_level); - return 103; - } - - ladmin_log("Request to login-server to change a GM level.\n"); - - WFIFOW(login_fd,0) = 0x793e; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOB(login_fd,26) = GM_level; - WFIFOSET(login_fd,27); - bytes_to_read = 1; - - return 0; -} - -//--------------------------------------------- -// Sub-function: Asking to obtain an account id -//--------------------------------------------- -int idaccount(char* param) -{ - char name[1023]; - WFIFOHEAD(login_fd,26); - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(" id testname\n"); - ladmin_log("No name given to search an account id ('id' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - ladmin_log("Request to login-server to know an account id.\n"); - - WFIFOW(login_fd,0) = 0x7944; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOSET(login_fd,26); - bytes_to_read = 1; - - return 0; -} - -//---------------------------------------------------------------------------- -// Sub-function: Asking to displaying information about an account (by its id) -//---------------------------------------------------------------------------- -int infoaccount(int account_id) -{ - WFIFOHEAD(login_fd,6); - if (account_id < 0) { - ShowMessage("Please input a positive value for the id.\n"); - ladmin_log("Negative value was given to found the account.\n"); - return 136; - } - - ladmin_log("Request to login-server to obtain information about an account (by its id).\n"); - - WFIFOW(login_fd,0) = 0x7954; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - bytes_to_read = 1; - - return 0; -} - -//--------------------------------------- -// Sub-function: Send a broadcast message -//--------------------------------------- -int sendbroadcast(short type, char* message) -{ - int len = strlen(message); - WFIFOHEAD(login_fd,9+len); - if (len == 0) { - ShowMessage("Please input a message.\n"); - if (type == 0) { - ShowMessage(" kami a message\n"); - } else { - ShowMessage(" kamib a message\n"); - } - ladmin_log("The message is void ('kami(b)' command).\n"); - return 136; - } - len++; //+'\0' - WFIFOW(login_fd,0) = 0x794e; - WFIFOW(login_fd,2) = type; - WFIFOL(login_fd,4) = len; - memcpy(WFIFOP(login_fd,8), message, len); - WFIFOSET(login_fd,8+len); - bytes_to_read = 1; - - return 0; -} - -//-------------------------------------------------------- -// Sub-function: Asking to Displaying of the accounts list -//-------------------------------------------------------- -int listaccount(char* param, int type) -{ -//int list_first, list_last, list_type; // parameter to display a list of accounts - int i; - WFIFOHEAD(login_fd,10); - - list_type = type; - - // set default values - list_first = 0; - list_last = 0; - - if (list_type == 1) { // if listgm - // get all accounts = use default - } else if (list_type == 2) { // if search - for (i = 0; param[i]; i++) - param[i] = TOLOWER(param[i]); - // get all accounts = use default - } else if (list_type == 3) { // if listban - // get all accounts = use default - } else if (list_type == 4) { // if listok - // get all accounts = use default - } else { // if list (list_type == 0) - switch(sscanf(param, "%d %d", &list_first, &list_last)) { - case 0: - // get all accounts = use default - break; - case 1: - list_last = 0; - // use tests of the following value - default: - if (list_first < 0) - list_first = 0; - if (list_last < list_first || list_last < 0) - list_last = 0; - break; - } - } - - ladmin_log("Request to login-server to obtain the list of accounts from %d to %d.\n", list_first, list_last); - - WFIFOW(login_fd,0) = 0x7920; - WFIFOL(login_fd,2) = list_first; - WFIFOL(login_fd,6) = list_last; - WFIFOSET(login_fd,10); - bytes_to_read = 1; - - // 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 - ShowMessage("account_id GM user_name sex count state\n"); - ShowMessage("-------------------------------------------------------------------------------\n"); - list_count = 0; - - return 0; -} - -//-------------------------------------------- -// Sub-function: Asking to modify a memo field -//-------------------------------------------- -int changememo(char* param) -{ - char name[1023], memo[1023]; - WFIFOHEAD(login_fd,28+255); - - memset(name, '\0', sizeof(name)); - memset(memo, '\0', sizeof(memo)); - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, memo) < 1 && // memo can be void - sscanf(param, "'%[^']' %[^\r\n]", name, memo) < 1 && // memo can be void - sscanf(param, "%s %[^\r\n]", name, memo) < 1) { // memo can be void - ShowMessage("Please input an account name and a memo.\n"); - ShowMessage(" memo testname new memo\n"); - ladmin_log("Incomplete parameters to change the memo of an account ('email' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (strlen(memo) > 254) { - ShowMessage("Memo is too long (%lu characters).\n", (unsigned long)strlen(memo)); - ShowMessage("Please input a memo of 254 bytes at the maximum.\n"); - ladmin_log("Email is too long (%d characters). Please input a memo of 254 bytes at the maximum.\n", strlen(memo)); - return 102; - } - - ladmin_log("Request to login-server to change a memo.\n"); - - WFIFOW(login_fd,0) = 0x7942; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOW(login_fd,26) = strlen(memo); - if (strlen(memo) > 0) - memcpy(WFIFOP(login_fd,28), memo, strlen(memo)); - WFIFOSET(login_fd,28+strlen(memo)); - bytes_to_read = 1; - - return 0; -} - -//----------------------------------------------- -// Sub-function: Asking to obtain an account name -//----------------------------------------------- -int nameaccount(int id) -{ - WFIFOHEAD(login_fd,6); - if (id < 0) { - ShowMessage("Please input a positive value for the id.\n"); - ladmin_log("Negativ id given to search an account name ('name' command).\n"); - return 136; - } - - ladmin_log("Request to login-server to know an account name.\n"); - - WFIFOW(login_fd,0) = 0x7946; - WFIFOL(login_fd,2) = id; - WFIFOSET(login_fd,6); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------ -// Sub-function: Asking to modify a password -// (Note: never send back a password with login-server!! security of passwords) -//------------------------------------------ -int changepasswd(char* param) -{ - char name[1023], password[1023]; - WFIFOHEAD(login_fd,50); - - memset(name, '\0', sizeof(name)); - memset(password, '\0', sizeof(password)); - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, password) < 1 && - sscanf(param, "'%[^']' %[^\r\n]", name, password) < 1 && - sscanf(param, "%s %[^\r\n]", name, password) < 1) { - ShowMessage("Please input an account name.\n"); - ShowMessage(" passwd testname newpassword\n"); - ladmin_log("Incomplete parameters to change the password of an account ('password' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (strlen(password) == 0) { - if (typepasswd(password) == 0) - return 134; - } - if (verify_password(password) == 0) - return 131; - - ladmin_log("Request to login-server to change a password.\n"); - - WFIFOW(login_fd,0) = 0x7934; - memcpy(WFIFOP(login_fd,2), name, 24); - memcpy(WFIFOP(login_fd,26), password, 24); - WFIFOSET(login_fd,50); - bytes_to_read = 1; - - return 0; -} - -//---------------------------------------------------------------------- -// Sub-function: Request to login-server to reload GM configuration file -// this function have no answer -//---------------------------------------------------------------------- -int reloadGM(void) -{ - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x7955; - WFIFOSET(login_fd,2); - bytes_to_read = 0; - - ladmin_log("Request to reload the GM configuration file sended.\n"); - ShowMessage("Request to reload the GM configuration file sended.\n"); - ShowMessage("Check the actual GM accounts (after reloading):\n"); - listaccount(parameters, 1); // 1: to list only GM - - return 180; -} - -//----------------------------------------------------- -// Sub-function: Asking to modify the sex of an account -//----------------------------------------------------- -int changesex(char* param) -{ - char name[1023], sex[1023]; - WFIFOHEAD(login_fd,27); - - memset(name, '\0', sizeof(name)); - memset(sex, '\0', sizeof(sex)); - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, sex) < 2 && - sscanf(param, "'%[^']' %[^\r\n]", name, sex) < 2 && - sscanf(param, "%s %[^\r\n]", name, sex) < 2) { - ShowMessage("Please input an account name and a sex.\n"); - ShowMessage(" sex testname Male\n"); - ladmin_log("Incomplete parameters to change the sex of an account ('sex' command).\n"); - return 136; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - sex[0] = TOUPPER(sex[0]); - if (strchr("MF", sex[0]) == NULL) { - ShowMessage("Illegal gender [%s]. Please input M or F.\n", sex); - ladmin_log("Illegal gender [%s]. Please input M or F.\n", sex); - return 103; - } - - ladmin_log("Request to login-server to change a sex.\n"); - - WFIFOW(login_fd,0) = 0x793c; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOB(login_fd,26) = sex[0]; - WFIFOSET(login_fd,27); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------------------------------------- -// Sub-function of sub-function changestate, blockaccount or unblockaccount -// Asking to modify the state of an account -//------------------------------------------------------------------------- -int changestatesub(char* name, int state, char* error_message7) -{ - char error_message[1023]; // need to use, because we can modify error_message7 - WFIFOHEAD(login_fd,50); - - memset(error_message, '\0', sizeof(error_message)); - strncpy(error_message, error_message7, sizeof(error_message)-1); - - if ((state < 0 || state > 9) && state != 100) { // Valid values: 0: ok, or value of the 0x006a packet + 1 - ShowMessage("Please input one of these states:\n"); - ShowMessage(" 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"); - ShowMessage(" 1 = Unregistered ID 7 = You are Prohibited to log in until + message\n"); - ShowMessage(" 2 = Incorrect Password 8 = Server is jammed due to over populated\n"); - ShowMessage(" 3 = This ID is expired 9 = No MSG\n"); - ShowMessage(" 4 = Rejected from Server 100 = This ID has been totally erased\n"); - ShowMessage(" 5 = You have been blocked by the GM Team\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Invalid value for the state of an account ('state', 'block' or 'unblock' command).\n"); - return 151; - } - - if (verify_accountname(name) == 0) { - return 102; - } - - if (state != 7) { - strcpy(error_message, "-"); - } else { - if (strlen(error_message) < 1) { - ShowMessage("Error message is too short. Please input a message of 1-19 bytes.\n"); - ladmin_log("Error message is too short. Please input a message of 1-19 bytes.\n"); - return 102; - } - if (strlen(error_message) > 19) { - ShowMessage("Error message is too long. Please input a message of 1-19 bytes.\n"); - ladmin_log("Error message is too long. Please input a message of 1-19 bytes.\n"); - return 102; - } - } - - ladmin_log("Request to login-server to change a state.\n"); - - WFIFOW(login_fd,0) = 0x7936; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOL(login_fd,26) = state; - memcpy(WFIFOP(login_fd,30), error_message, 20); - WFIFOSET(login_fd,50); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------------------- -// Sub-function: Asking to modify the state of an account -//------------------------------------------------------- -int changestate(char* param) -{ - char name[1023], error_message[1023]; - int state; - - memset(name, '\0', sizeof(name)); - memset(error_message, '\0', sizeof(error_message)); - - if (sscanf(param, "\"%[^\"]\" %d %[^\r\n]", name, &state, error_message) < 2 && - sscanf(param, "'%[^']' %d %[^\r\n]", name, &state, error_message) < 2 && - sscanf(param, "%s %d %[^\r\n]", name, &state, error_message) < 2) { - ShowMessage("Please input an account name and a state.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('state' command).\n"); - return 136; - } - - return changestatesub(name, state, error_message); -} - -//------------------------------------------- -// Sub-function: Asking to unblock an account -//------------------------------------------- -int unblockaccount(char* param) -{ - char name[1023]; - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('unblock' command).\n"); - return 136; - } - - return changestatesub(name, 0, "-"); // state 0, no error message -} - -//------------------------------------------- -// Sub-function: Asking to unblock an account -//------------------------------------------- -int blockaccount(char* param) -{ - char name[1023]; - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(" state testname 5\n"); - ShowMessage(" state testname 7 end of your ban\n"); - ShowMessage(" block \n"); - ShowMessage(" unblock \n"); - ladmin_log("Incomplete parameters to change the state of an account ('block' command).\n"); - return 136; - } - - return changestatesub(name, 5, "-"); // state 5, no error message -} - -//--------------------------------------------------------------------- -// Sub-function: Add/substract time to the validity limit of an account -//--------------------------------------------------------------------- -int timeaddaccount(char* param) -{ - char name[1023], modif[1023]; - int year, month, day, hour, minute, second; - char * p_modif; - int value, i; - WFIFOHEAD(login_fd,38); - - memset(name, '\0', sizeof(name)); - memset(modif, '\0', sizeof(modif)); - year = month = day = hour = minute = second = 0; - - if (sscanf(param, "\"%[^\"]\" %[^\r\n]", name, modif) < 2 && - sscanf(param, "'%[^']' %[^\r\n]", name, modif) < 2 && - sscanf(param, "%s %[^\r\n]", name, modif) < 2) - { - ShowMessage("Please input an account name and a modifier.\n"); - ShowMessage(" : timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("Incomplete parameters to modify a limit time ('timeadd' command).\n"); - return 136; - } - if (verify_accountname(name) == 0) { - return 102; - } - - // lowercase for modif - for (i = 0; modif[i]; i++) - modif[i] = TOLOWER(modif[i]); - p_modif = modif; - while (strlen(p_modif) > 0) { - value = atoi(p_modif); - if (value == 0) { - p_modif++; - } else { - if (p_modif[0] == '-' || p_modif[0] == '+') - p_modif++; - while (strlen(p_modif) > 0 && p_modif[0] >= '0' && p_modif[0] <= '9') { - p_modif++; - } - if (p_modif[0] == 's') { - second = value; - p_modif++; - } else if (p_modif[0] == 'm' && p_modif[1] == 'n') { - minute = value; - p_modif += 2; - } else if (p_modif[0] == 'h') { - hour = value; - p_modif++; - } else if (p_modif[0] == 'd' || p_modif[0] == 'j') { - day = value; - p_modif += 2; - } else if (p_modif[0] == 'm') { - month = value; - p_modif++; - } else if (p_modif[0] == 'y' || p_modif[0] == 'a') { - year = value; - p_modif++; - } else { - p_modif++; - } - } - } - - ShowMessage(" year: %d\n", year); - ShowMessage(" month: %d\n", month); - ShowMessage(" day: %d\n", day); - ShowMessage(" hour: %d\n", hour); - ShowMessage(" minute: %d\n", minute); - ShowMessage(" second: %d\n", second); - - if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) { - ShowMessage("Please give an adjustment with this command:\n"); - ShowMessage(" Adjustment value (-1, 1, +1, etc...)\n"); - ShowMessage(" Modified element:\n"); - ShowMessage(" a or y: year\n"); - ShowMessage(" m: month\n"); - ShowMessage(" j or d: day\n"); - ShowMessage(" h: hour\n"); - ShowMessage(" mn: minute\n"); - ShowMessage(" s: second\n"); - ShowMessage(" timeadd testname +1m-2mn1s-6y\n"); - ShowMessage(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - ShowMessage(" and 6 years at the same time.\n"); - ladmin_log("No adjustment isn't an adjustment ('timeadd' command).\n"); - return 137; - } - if (year > 127 || year < -127) { - ShowMessage("Please give a correct adjustment for the years (from -127 to 127).\n"); - ladmin_log("Abnormal adjustment for the year ('timeadd' command).\n"); - return 137; - } - if (month > 255 || month < -255) { - ShowMessage("Please give a correct adjustment for the months (from -255 to 255).\n"); - ladmin_log("Abnormal adjustment for the month ('timeadd' command).\n"); - return 137; - } - if (day > 32767 || day < -32767) { - ShowMessage("Please give a correct adjustment for the days (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the days ('timeadd' command).\n"); - return 137; - } - if (hour > 32767 || hour < -32767) { - ShowMessage("Please give a correct adjustment for the hours (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the hours ('timeadd' command).\n"); - return 137; - } - if (minute > 32767 || minute < -32767) { - ShowMessage("Please give a correct adjustment for the minutes (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the minutes ('timeadd' command).\n"); - return 137; - } - if (second > 32767 || second < -32767) { - ShowMessage("Please give a correct adjustment for the seconds (from -32767 to 32767).\n"); - ladmin_log("Abnormal adjustment for the seconds ('timeadd' command).\n"); - return 137; - } - - ladmin_log("Request to login-server to modify a time limit.\n"); - - WFIFOW(login_fd,0) = 0x7950; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOW(login_fd,26) = (short)year; - WFIFOW(login_fd,28) = (short)month; - WFIFOW(login_fd,30) = (short)day; - WFIFOW(login_fd,32) = (short)hour; - WFIFOW(login_fd,34) = (short)minute; - WFIFOW(login_fd,36) = (short)second; - WFIFOSET(login_fd,38); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------------- -// Sub-function: Set a validity limit of an account -//------------------------------------------------- -int timesetaccount(char* param) -{ - char name[1023], date[1023], time[1023]; - int year, month, day, hour, minute, second; - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - struct tm *tmtime; - WFIFOHEAD(login_fd,30); - - memset(name, '\0', sizeof(name)); - memset(date, '\0', sizeof(date)); - memset(time, '\0', sizeof(time)); - year = month = day = hour = minute = second = 0; - expiration_time = 0; - tmtime = localtime(&expiration_time); // initialize - - if (sscanf(param, "\"%[^\"]\" %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void - sscanf(param, "'%[^']' %s %[^\r\n]", name, date, time) < 2 && // if date = 0, time can be void - sscanf(param, "%s %s %[^\r\n]", name, date, time) < 2) { // if date = 0, time can be void - ShowMessage("Please input an account name, a date and a hour.\n"); - ShowMessage(": timeset yyyy/mm/dd [hh:mm:ss]\n"); - ShowMessage(" timeset 0 (0 = unlimited)\n"); - ShowMessage(" Default time [hh:mm:ss]: 23:59:59.\n"); - ladmin_log("Incomplete parameters to set a limit time ('timeset' command).\n"); - return 136; - } - if (verify_accountname(name) == 0) { - return 102; - } - - if (time[0] == '\0') - strcpy(time, "23:59:59"); - - if (atoi(date) != 0 && - ((sscanf(date, "%d/%d/%d", &year, &month, &day) < 3 && - sscanf(date, "%d-%d-%d", &year, &month, &day) < 3 && - sscanf(date, "%d.%d.%d", &year, &month, &day) < 3 && - sscanf(date, "%d'%d'%d", &year, &month, &day) < 3) || - sscanf(time, "%d:%d:%d", &hour, &minute, &second) < 3)) - { - ShowMessage("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - ladmin_log("Invalid format for the date/time ('timeset' command).\n"); - return 102; - } - - if (atoi(date) == 0) { - expiration_time = 0; - } else { - if (year < 70) { - year = year + 100; - } - if (year >= 1900) { - year = year - 1900; - } - if (month < 1 || month > 12) { - ShowMessage("Please give a correct value for the month (from 1 to 12).\n"); - ladmin_log("Invalid month for the date ('timeset' command).\n"); - return 102; - } - month = month - 1; - if (day < 1 || day > 31) { - ShowMessage("Please give a correct value for the day (from 1 to 31).\n"); - ladmin_log("Invalid day for the date ('timeset' command).\n"); - return 102; - } - if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) || - (month == 1 && day > 29)) { - ShowMessage("Please give a correct value for a day of this month (%d).\n", month); - ladmin_log("Invalid day for this month ('timeset' command).\n"); - return 102; - } - if (hour < 0 || hour > 23) { - ShowMessage("Please give a correct value for the hour (from 0 to 23).\n"); - ladmin_log("Invalid hour for the time ('timeset' command).\n"); - return 102; - } - if (minute < 0 || minute > 59) { - ShowMessage("Please give a correct value for the minutes (from 0 to 59).\n"); - ladmin_log("Invalid minute for the time ('timeset' command).\n"); - return 102; - } - if (second < 0 || second > 59) { - ShowMessage("Please give a correct value for the seconds (from 0 to 59).\n"); - ladmin_log("Invalid second for the time ('timeset' command).\n"); - return 102; - } - tmtime->tm_year = year; - tmtime->tm_mon = month; - tmtime->tm_mday = day; - tmtime->tm_hour = hour; - tmtime->tm_min = minute; - tmtime->tm_sec = second; - tmtime->tm_isdst = -1; // -1: no winter/summer time modification - expiration_time = mktime(tmtime); - if (expiration_time == -1) { - ShowMessage("Invalid date.\n"); - ShowMessage("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - ladmin_log("Invalid date. ('timeset' command).\n"); - return 102; - } - } - - ladmin_log("Request to login-server to set a time limit.\n"); - - WFIFOW(login_fd,0) = 0x7948; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOL(login_fd,26) = (int)expiration_time; - WFIFOSET(login_fd,30); - bytes_to_read = 1; - - return 0; -} - -//------------------------------------------------------------------------------ -// Sub-function: Asking to displaying information about an account (by its name) -//------------------------------------------------------------------------------ -int whoaccount(char* param) -{ - char name[1023]; - WFIFOHEAD(login_fd,26); - - memset(name, '\0', sizeof(name)); - - if (strlen(param) == 0 || - (sscanf(param, "\"%[^\"]\"", name) < 1 && - sscanf(param, "'%[^']'", name) < 1 && - sscanf(param, "%[^\r\n]", name) < 1) || - strlen(name) == 0) - { - ShowMessage("Please input an account name.\n"); - ShowMessage(" who testname\n"); - ladmin_log("No name was given to found the account.\n"); - return 136; - } - if (verify_accountname(name) == 0) { - return 102; - } - - ladmin_log("Request to login-server to obtain information about an account (by its name).\n"); - - WFIFOW(login_fd,0) = 0x7952; - memcpy(WFIFOP(login_fd,2), name, 24); - WFIFOSET(login_fd,26); - bytes_to_read = 1; - - return 0; -} - -//-------------------------------------------------------- -// Sub-function: Asking of the version of the login-server -//-------------------------------------------------------- -int checkloginversion(void) -{ - WFIFOHEAD(login_fd,2); - ladmin_log("Request to login-server to obtain its version.\n"); - - WFIFOW(login_fd,0) = 0x7530; - WFIFOSET(login_fd,2); - bytes_to_read = 1; - - return 0; -} - -//--------------------------------------------- -// Prompt function -// this function wait until user type a command -// and analyse the command. -//--------------------------------------------- -int prompt(void) -{ - int i, j; - char buf[1024]; - char *p; - - // while we don't wait new packets - while (bytes_to_read == 0) { - // for help with the console colors look here: - // http://www.edoceo.com/liberum/?doc=printf-with-color - // some code explanation (used here): - // \033[2J : clear screen and go up/left (0, 0 position) - // \033[K : clear line from actual position to end of the line - // \033[0m : reset color parameter - // \033[1m : use bold for font - ShowMessage("\n"); - ShowMessage("\033[32mTo list the commands, type 'enter'.\033[0m\n"); - ShowMessage("\033[0;36mLadmin-> \033[0m"); - ShowMessage("\033[1m"); - fflush(stdout); - - // get command and parameter - memset(buf, '\0', sizeof(buf)); - fflush(stdin); - fgets(buf, sizeof(buf), stdin); - - ShowMessage("\033[0m"); - fflush(stdout); - - // remove final \n - if((p = strrchr(buf, '\n')) != NULL) - p[0] = '\0'; - // remove all control char - for (i = 0; buf[i]; i++) - if (buf[i] < 32) { - // remove cursor control. - if (buf[i] == 27 && buf[i+1] == '[' && - (buf[i+2] == 'H' || // home position (cursor) - buf[i+2] == 'J' || // clear screen - buf[i+2] == 'A' || // up 1 line - buf[i+2] == 'B' || // down 1 line - buf[i+2] == 'C' || // right 1 position - buf[i+2] == 'D' || // left 1 position - buf[i+2] == 'G')) { // center cursor (windows) - for (j = i; buf[j]; j++) - buf[j] = buf[j+3]; - } else if (buf[i] == 27 && buf[i+1] == '[' && buf[i+2] == '2' && buf[i+3] == 'J') { // clear screen - for (j = i; buf[j]; j++) - buf[j] = buf[j+4]; - } else if (buf[i] == 27 && buf[i+1] == '[' && buf[i+3] == '~' && - (buf[i+2] == '1' || // home (windows) - buf[i+2] == '2' || // insert (windows) - buf[i+2] == '3' || // del (windows) - buf[i+2] == '4' || // end (windows) - buf[i+2] == '5' || // pgup (windows) - buf[i+2] == '6')) { // pgdown (windows) - for (j = i; buf[j]; j++) - buf[j] = buf[j+4]; - } else { - // remove other control char. - for (j = i; buf[j]; j++) - buf[j] = buf[j+1]; - } - i--; - } - - // extract command name and parameters - memset(command, '\0', sizeof(command)); - memset(parameters, '\0', sizeof(parameters)); - sscanf(buf, "%1023s %[^\n]", command, parameters); - command[1023] = '\0'; - parameters[1023] = '\0'; - - // lowercase for command line - for (i = 0; command[i]; i++) - command[i] = TOLOWER(command[i]); - - if (command[0] == '?' || strlen(command) == 0) { - strcpy(buf, "help"); - strcpy(command, "help"); - } - - // Analyse of the command - check_command(command); // give complete name to the command - - if (strlen(parameters) == 0) { - ladmin_log("Command: '%s' (without parameters)\n", command, parameters); - } else { - ladmin_log("Command: '%s', parameters: '%s'\n", command, parameters); - } - - // Analyse of the command -// help - if (strcmp(command, "help") == 0 ) { - display_help(parameters); -// general commands - } else if (strcmp(command, "add") == 0) { - addaccount(parameters, 0); // 0: no email - } else if (strcmp(command, "ban") == 0) { - banaccount(parameters); - } else if (strcmp(command, "banadd") == 0) { - banaddaccount(parameters); - } else if (strcmp(command, "banset") == 0) { - bansetaccount(parameters); - } else if (strcmp(command, "block") == 0) { - blockaccount(parameters); - } else if (strcmp(command, "check") == 0) { - checkaccount(parameters); - } else if (strcmp(command, "create") == 0) { - addaccount(parameters, 1); // 1: with email - } else if (strcmp(command, "delete") == 0) { - delaccount(parameters); - } else if (strcmp(command, "email") == 0) { - changeemail(parameters); - } else if (strcmp(command, "getcount") == 0) { - getlogincount(); - } else if (strcmp(command, "gm") == 0) { - changegmlevel(parameters); - } else if (strcmp(command, "id") == 0) { - idaccount(parameters); - } else if (strcmp(command, "info") == 0) { - infoaccount(atoi(parameters)); - } else if (strcmp(command, "kami") == 0) { - sendbroadcast(0, parameters); // flag for normal - } else if (strcmp(command, "kamib") == 0) { - sendbroadcast(0x10, parameters); // flag for blue - } else if (strcmp(command, "list") == 0) { - listaccount(parameters, 0); // 0: to list all - } else if (strcmp(command, "listban") == 0) { - listaccount(parameters, 3); // 3: to list only accounts with state or bannished - } else if (strcmp(command, "listgm") == 0) { - listaccount(parameters, 1); // 1: to list only GM - } else if (strcmp(command, "listok") == 0) { - listaccount(parameters, 4); // 4: to list only accounts without state and not bannished - } else if (strcmp(command, "memo") == 0) { - changememo(parameters); - } else if (strcmp(command, "name") == 0) { - nameaccount(atoi(parameters)); - } else if (strcmp(command, "password") == 0) { - changepasswd(parameters); - } else if (strcmp(command, "reloadgm") == 0) { - reloadGM(); - } else if (strcmp(command, "search") == 0) { // no regex in C version - listaccount(parameters, 2); // 2: to list with pattern - } else if (strcmp(command, "sex") == 0) { - changesex(parameters); - } else if (strcmp(command, "state") == 0) { - changestate(parameters); - } else if (strcmp(command, "timeadd") == 0) { - timeaddaccount(parameters); - } else if (strcmp(command, "timeset") == 0) { - timesetaccount(parameters); - } else if (strcmp(command, "unban") == 0) { - unbanaccount(parameters); - } else if (strcmp(command, "unblock") == 0) { - unblockaccount(parameters); - } else if (strcmp(command, "version") == 0) { - checkloginversion(); - } else if (strcmp(command, "who") == 0) { - whoaccount(parameters); -// quit - } else if (strcmp(command, "quit") == 0 || - strcmp(command, "exit") == 0 || - strcmp(command, "end") == 0) { - ShowMessage("Bye.\n"); - exit(EXIT_SUCCESS); -// unknown command - } else { - ShowMessage("Unknown command [%s].\n", buf); - ladmin_log("Unknown command [%s].\n", buf); - } - } - - return 0; -} - -//------------------------------------------------------------- -// Function: Parse receiving informations from the login-server -//------------------------------------------------------------- -int parse_fromlogin(int fd) -{ - struct char_session_data *sd; - int id; - RFIFOHEAD(fd); - if (session[fd]->flag.eof) { - ShowMessage("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); - ladmin_log("Impossible to have a connection with the login-server [%s:%d] !\n", loginserverip, loginserverport); - do_close(fd); - exit(EXIT_FAILURE); - } - -// ShowMessage("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0)); - sd = (struct char_session_data*)session[fd]->session_data; - - while(RFIFOREST(fd) >= 2) { - switch(RFIFOW(fd,0)) { - case 0x7919: // answer of a connection request - if (RFIFOREST(fd) < 3) - return 0; - if (RFIFOB(fd,2) != 0) { - ShowMessage("Error at login:\n"); - ShowMessage(" - incorrect password,\n"); - ShowMessage(" - administration system not activated, or\n"); - ShowMessage(" - unauthorised IP.\n"); - ladmin_log("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n"); - set_eof(fd); - //bytes_to_read = 1; // not stop at prompt - return 0; - } else { - ShowMessage("Established connection.\n"); - ladmin_log("Established connection.\n"); - ShowMessage("Reading of the version of the login-server...\n"); - ladmin_log("Reading of the version of the login-server...\n"); - //bytes_to_read = 1; // unchanged - checkloginversion(); - } - RFIFOSKIP(fd,3); - break; - - case 0x01dc: // answer of a coding key request - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { - char md5str[64] = "", md5bin[32]; - WFIFOHEAD(login_fd, 20); - if (passenc == 1) { - strncpy(md5str, (const char*)RFIFOP(fd,4), RFIFOW(fd,2) - 4); - strcat(md5str, loginserveradminpassword); - } else if (passenc == 2) { - strncpy(md5str, loginserveradminpassword, sizeof(loginserveradminpassword)); - strcat(md5str, (const char*)RFIFOP(fd,4)); - } - MD5_Binary(md5str, md5bin); - WFIFOW(login_fd,0) = 0x7918; // Request for administation login (encrypted password) - WFIFOW(login_fd,2) = passenc; // Encrypted type - memcpy(WFIFOP(login_fd,4), md5bin, 16); - WFIFOSET(login_fd,20); - ShowMessage("Receiving of the MD5 key.\n"); - ladmin_log("Receiving of the MD5 key.\n"); - ShowMessage("Sending of the encrypted password...\n"); - ladmin_log("Sending of the encrypted password...\n"); - } - bytes_to_read = 1; - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - - case 0x7531: // Displaying of the version of the login-server - if (RFIFOREST(fd) < 10) - return 0; - ShowMessage(" Login-Server [%s:%d]\n", loginserverip, loginserverport); - if (((int)RFIFOB(login_fd,5)) == 0) { - ShowMessage(" eAthena version stable-%d.%d", (int)RFIFOB(login_fd,2), (int)RFIFOB(login_fd,3)); - } else { - ShowMessage(" eAthena version dev-%d.%d", (int)RFIFOB(login_fd,2), (int)RFIFOB(login_fd,3)); - } - if (((int)RFIFOB(login_fd,4)) == 0) - ShowMessage(" revision %d", (int)RFIFOB(login_fd,4)); - if (((int)RFIFOB(login_fd,6)) == 0) - ShowMessage("%d.\n", RFIFOW(login_fd,8)); - else - ShowMessage("-mod%d.\n", RFIFOW(login_fd,8)); - bytes_to_read = 0; - RFIFOSKIP(fd,10); - break; - - case 0x7921: // Displaying of the list of accounts - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - if (RFIFOW(fd,2) < 5) { - ladmin_log(" Receiving of a void accounts list.\n"); - if (list_count == 0) - ShowMessage("No account found.\n"); - else if (list_count == 1) - ShowMessage("1 account found.\n"); - else - ShowMessage("%d accounts found.\n", list_count); - bytes_to_read = 0; - } else { - int i; - WFIFOHEAD(login_fd,10); - ladmin_log(" Receiving of a accounts list.\n"); - for(i = 4; i < RFIFOW(fd,2); i += 38) { - int j; - char userid[24]; - char lower_userid[24]; - memcpy(userid, RFIFOP(fd,i + 5), sizeof(userid)); - userid[sizeof(userid)-1] = '\0'; - memset(lower_userid, '\0', sizeof(lower_userid)); - for (j = 0; userid[j]; j++) - lower_userid[j] = TOLOWER(userid[j]); - list_first = RFIFOL(fd,i) + 1; - // here are checks... - if (list_type == 0 || - (list_type == 1 && RFIFOB(fd,i+4) > 0) || - (list_type == 2 && strstr(lower_userid, parameters) != NULL) || - (list_type == 3 && RFIFOL(fd,i+34) != 0) || - (list_type == 4 && RFIFOL(fd,i+34) == 0)) { - ShowMessage("%10d ", (int)RFIFOL(fd,i)); - if (RFIFOB(fd,i+4) == 0) - ShowMessage(" "); - else - ShowMessage("%2d ", (int)RFIFOB(fd,i+4)); - ShowMessage("%-24s", userid); - if (RFIFOB(fd,i+29) == 0) - ShowMessage("%-5s ", "Femal"); - else if (RFIFOB(fd,i+29) == 1) - ShowMessage("%-5s ", "Male"); - else - ShowMessage("%-5s ", "Servr"); - ShowMessage("%6d ", (int)RFIFOL(fd,i+30)); - switch(RFIFOL(fd,i+34)) { - case 0: - ShowMessage("%-27s\n", "Account OK"); - break; - case 1: - ShowMessage("%-27s\n", "Unregistered ID"); - break; - case 2: - ShowMessage("%-27s\n", "Incorrect Password"); - break; - case 3: - ShowMessage("%-27s\n", "This ID is expired"); - break; - case 4: - ShowMessage("%-27s\n", "Rejected from Server"); - break; - case 5: - ShowMessage("%-27s\n", "Blocked by the GM Team"); // You have been blocked by the GM Team - break; - case 6: - ShowMessage("%-27s\n", "Your EXE file is too old"); // Your Game's EXE file is not the latest version - break; - case 7: - ShowMessage("%-27s\n", "Banishement or"); - ShowMessage(" Prohibited to login until...\n"); // You are Prohibited to log in until %s - break; - case 8: - ShowMessage("%-27s\n", "Server is over populated"); - break; - case 9: - ShowMessage("%-27s\n", "No MSG"); - break; - default: // 100 - ShowMessage("%-27s\n", "This ID is totally erased"); // This ID has been totally erased - break; - } - list_count++; - } - } - // asking of the following acounts - ladmin_log("Request to login-server to obtain the list of accounts from %d to %d (complement).\n", list_first, list_last); - WFIFOW(login_fd,0) = 0x7920; - WFIFOL(login_fd,2) = list_first; - WFIFOL(login_fd,6) = list_last; - WFIFOSET(login_fd,10); - bytes_to_read = 1; - } - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - - case 0x7931: // Answer of login-server about an account creation - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id != -1) { - ShowMessage("Account [%s] creation failed. Return code %d.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s] creation failed. Return code %d.\n", RFIFOP(fd,6), id); - } else { - ShowMessage("Account [%s] is successfully created.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] is successfully created.\n", RFIFOP(fd,6)); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7933: // Answer of login-server about an account deletion - if (RFIFOREST(fd) < 30) - return 0; - if (RFIFOL(fd,2) == -1) { - ShowMessage("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] deletion failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Account [%s][id: %d] is successfully DELETED.\n", RFIFOP(fd,6), RFIFOL(fd,2)); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7935: // answer of the change of an account password - if (RFIFOREST(fd) < 30) - return 0; - if (RFIFOL(fd,2) == -1) { - ShowMessage("Account [%s] password changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account password changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - ladmin_log("Account [%s][id: %d] password successfully changed.\n", RFIFOP(fd,6), (int)RFIFOL(fd,2)); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7937: // answer of the change of an account state - if (RFIFOREST(fd) < 34) - return 0; - if (RFIFOL(fd,2) == -1) { - ShowMessage("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] state changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - char tmpstr[256]; - sprintf(tmpstr, "Account [%s] state successfully changed in [", RFIFOP(fd,6)); - switch(RFIFOL(fd,30)) { - case 0: - strcat(tmpstr, "0: Account OK"); - case 1: - strcat(tmpstr, "1: Unregistered ID"); - break; - case 2: - strcat(tmpstr, "2: Incorrect Password"); - break; - case 3: - strcat(tmpstr, "3: This ID is expired"); - break; - case 4: - strcat(tmpstr, "4: Rejected from Server"); - break; - case 5: - strcat(tmpstr, "5: You have been blocked by the GM Team"); - break; - case 6: - strcat(tmpstr, "6: [Your Game's EXE file is not the latest version"); - break; - case 7: - strcat(tmpstr, "7: You are Prohibited to log in until..."); - break; - case 8: - strcat(tmpstr, "8: Server is jammed due to over populated"); - break; - case 9: - strcat(tmpstr, "9: No MSG"); - break; - default: // 100 - strcat(tmpstr, "100: This ID is totally erased"); - break; - } - strcat(tmpstr, "]"); - ShowMessage("%s\n", tmpstr); - ladmin_log("%s\n", tmpstr); - } - bytes_to_read = 0; - RFIFOSKIP(fd,34); - break; - - case 0x7939: // answer of the number of online players - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { - // Get length of the received packet - int i; - char name[20]; - ladmin_log(" Receiving of the number of online players.\n"); - // Read information of the servers - if (RFIFOW(fd,2) < 5) { - ShowMessage(" No server is connected to the login-server.\n"); - } else { - ShowMessage(" Number of online players (server: number).\n"); - // Displaying of result - for(i = 4; i < RFIFOW(fd,2); i += 32) { - memcpy(name, RFIFOP(fd,i+6), sizeof(name)); - name[sizeof(name) - 1] = '\0'; - ShowMessage(" %-20s : %5d\n", name, RFIFOW(fd,i+26)); - } - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - - case 0x793b: // answer of the check of a password - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); - ladmin_log("The account [%s] doesn't exist or the password is incorrect.\n", RFIFOP(fd,6)); - } else { - ShowMessage("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); - ladmin_log("The proposed password is correct for the account [%s][id: %d].\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x793d: // answer of the change of an account sex - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] sex changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); - ladmin_log("Account sex changing failed. The compte [%s] doesn't exist or the sex is already the good sex.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] sex successfully changed.\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x793f: // answer of the change of an account GM level - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] GM level changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist, the GM level is already the good GM level\n", RFIFOP(fd,6)); - ShowMessage("or it's impossible to modify the GM accounts file.\n"); - ladmin_log("Account GM level changing failed. The compte [%s] doesn't exist, the GM level is already the good sex or it's impossible to modify the GM accounts file.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] GM level successfully changed.\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7941: // answer of the change of an account email - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] e-mail changing failed.\n", RFIFOP(fd,6)); - ShowMessage("Account [%s] doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account e-mail changing failed. The compte [%s] doesn't exist.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] e-mail successfully changed.\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7943: // answer of the change of an account memo - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] memo changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - ShowMessage("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); - ladmin_log("Account [%s][id: %d] memo successfully changed.\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7945: // answer of an account id search - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Unable to find the account [%s] id. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - ShowMessage("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); - ladmin_log("The account [%s] have the id: %d.\n", RFIFOP(fd,6), id); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7947: // answer of an account name search - if (RFIFOREST(fd) < 30) - return 0; - id = RFIFOL(fd,2); - if (strcmp((const char*)RFIFOP(fd,6), "") == 0) { - ShowMessage("Unable to find the account [%d] name. Account doesn't exist.\n", id); - ladmin_log("Unable to find the account [%d] name. Account doesn't exist.\n", id); - } else { - ShowMessage("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); - ladmin_log("The account [id: %d] have the name: %s.\n", id, RFIFOP(fd,6)); - } - bytes_to_read = 0; - RFIFOSKIP(fd,30); - break; - - case 0x7949: // answer of an account validity limit set - if (RFIFOREST(fd) < 34) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - time_t timestamp = RFIFOL(fd,30); - if (timestamp == 0) { - ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); - ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", RFIFOP(fd,6), id); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(×tamp)); - ShowMessage("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,34); - break; - - case 0x794b: // answer of an account ban set - if (RFIFOREST(fd) < 34) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - time_t timestamp = RFIFOL(fd,30); - if (timestamp == 0) { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(×tamp)); - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,34); - break; - - case 0x794d: // answer of an account ban date/time changing - if (RFIFOREST(fd) < 34) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - time_t timestamp = RFIFOL(fd,30); - if (timestamp == 0) { - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", RFIFOP(fd,6), id); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(×tamp)); - ShowMessage("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,34); - break; - - case 0x794f: // answer of a broadcast - if (RFIFOREST(fd) < 4) - return 0; - if (RFIFOW(fd,2) == (unsigned short)-1) { - ShowMessage("Message sending failed. No online char-server.\n"); - ladmin_log("Message sending failed. No online char-server.\n"); - } else { - ShowMessage("Message successfully sended to login-server.\n"); - ladmin_log("Message successfully sended to login-server.\n"); - } - bytes_to_read = 0; - RFIFOSKIP(fd,4); - break; - - case 0x7951: // answer of an account validity limit changing - if (RFIFOREST(fd) < 34) - return 0; - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - ladmin_log("Account [%s] validity limit changing failed. Account doesn't exist.\n", RFIFOP(fd,6)); - } else { - time_t timestamp = RFIFOL(fd,30); - if (timestamp == 0) { - ShowMessage("Validity limit of the account [%s][id: %d] unchanged.\n", RFIFOP(fd,6), id); - ShowMessage("The account have an unlimited validity limit or\n"); - ShowMessage("the changing is impossible with the proposed adjustments.\n"); - ladmin_log("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n", RFIFOP(fd,6), id); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(×tamp)); - ShowMessage("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - ladmin_log("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", RFIFOP(fd,6), id, tmpstr); - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,34); - break; - - case 0x7953: // answer of a request about informations of an account (by account name/id) - if (RFIFOREST(fd) < 150 || RFIFOREST(fd) < (size_t)(150 + RFIFOW(fd,148))) - return 0; - { - char userid[24], error_message[20], lastlogin[24], last_ip[16], email[40], memo[255]; - time_t unban_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - safestrncpy(userid, (char*)RFIFOP(fd,7), sizeof(userid)); - safestrncpy(error_message, (char*)RFIFOP(fd,40), sizeof(error_message)); - safestrncpy(lastlogin, (char*)RFIFOP(fd,60), sizeof(lastlogin)); - safestrncpy(last_ip, (char*)RFIFOP(fd,84), sizeof(last_ip)); - safestrncpy(email, (char*)RFIFOP(fd,100), sizeof(email)); - expiration_time = (time_t)RFIFOL(fd,140); - unban_time = (time_t)RFIFOL(fd,144); - memset(memo, '\0', sizeof(memo)); - safestrncpy(memo, (const char*)RFIFOP(fd,150), RFIFOW(fd,148)); - id = RFIFOL(fd,2); - if (id == -1) { - ShowMessage("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); - ladmin_log("Unabled to find the account [%s]. Account doesn't exist.\n", parameters); - } else if (strlen(userid) == 0) { - ShowMessage("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); - ladmin_log("Unabled to find the account [id: %s]. Account doesn't exist.\n", parameters); - } else { - ladmin_log("Receiving information about an account.\n"); - ShowMessage("The account is set with:\n"); - if (RFIFOB(fd,6) == 0) { - ShowMessage(" Id: %d (non-GM)\n", id); - } else { - ShowMessage(" Id: %d (GM level %d)\n", id, (int)RFIFOB(fd,6)); - } - ShowMessage(" Name: '%s'\n", userid); - if (RFIFOB(fd,31) == 0) - ShowMessage(" Sex: Female\n"); - else if (RFIFOB(fd,31) == 1) - ShowMessage(" Sex: Male\n"); - else - ShowMessage(" Sex: Server\n"); - ShowMessage(" E-mail: %s\n", email); - switch(RFIFOL(fd,36)) { - case 0: ShowMessage(" State: 0 [Account OK]\n"); break; - case 1: ShowMessage(" State: 1 [Unregistered ID]\n"); break; - case 2: ShowMessage(" State: 2 [Incorrect Password]\n"); break; - case 3: ShowMessage(" State: 3 [This ID is expired]\n"); break; - case 4: ShowMessage(" State: 4 [Rejected from Server]\n"); break; - case 5: ShowMessage(" State: 5 [You have been blocked by the GM Team]\n"); break; - case 6: ShowMessage(" State: 6 [Your Game's EXE file is not the latest version]\n"); break; - case 7: ShowMessage(" State: 7 [You are Prohibited to log in until %s]\n", error_message); break; - case 8: ShowMessage(" State: 8 [Server is jammed due to over populated]\n"); break; - case 9: ShowMessage(" State: 9 [No MSG]\n"); break; - default: // 100 - ShowMessage(" State: %d [This ID is totally erased]\n", (int)RFIFOL(fd,36)); - break; - } - if (unban_time == 0) { - ShowMessage(" Banishment: not banished.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&unban_time)); - ShowMessage(" Banishment: until %s.\n", tmpstr); - } - if (RFIFOL(fd,32) > 1) - ShowMessage(" Count: %d connections.\n", (int)RFIFOL(fd,32)); - else - ShowMessage(" Count: %d connection.\n", (int)RFIFOL(fd,32)); - ShowMessage(" Last connection at: %s (ip: %s)\n", lastlogin, last_ip); - if (expiration_time == 0) { - ShowMessage(" Validity limit: unlimited.\n"); - } else { - char tmpstr[128]; - strftime(tmpstr, 24, date_format, localtime(&expiration_time)); - ShowMessage(" Validity limit: until %s.\n", tmpstr); - } - ShowMessage(" Memo: '%s'\n", memo); - } - } - bytes_to_read = 0; - RFIFOSKIP(fd,150 + RFIFOW(fd,148)); - break; - - default: - ShowMessage("Remote administration has been disconnected (unknown packet).\n"); - ladmin_log("'End of connection, unknown packet.\n"); - set_eof(fd); - return 0; - } - } - - // if we don't wait new packets, do the prompt - prompt(); - - return 0; -} - -//------------------------------------ -// Function to connect to login-server -//------------------------------------ -int Connect_login_server(void) -{ - ShowMessage("Attempt to connect to login-server...\n"); - ladmin_log("Attempt to connect to login-server...\n"); - - login_fd = make_connection(login_ip, loginserverport); - if (login_fd == -1) - { //Might not be the most elegant way to handle this, but I've never used ladmin so I dunno what else you could do. [Skotlex] - ShowMessage("Error: Failed to connect to Login Server\n"); - exit(EXIT_FAILURE); - } - session[login_fd]->flag.server = 1; - if (passenc == 0) { - WFIFOHEAD(login_fd,28); - WFIFOW(login_fd,0) = 0x7918; // Request for administation login - WFIFOW(login_fd,2) = 0; // no encrypted - memcpy(WFIFOP(login_fd,4), loginserveradminpassword, 24); - WFIFOSET(login_fd,28); - bytes_to_read = 1; - ShowMessage("Sending of the password...\n"); - ladmin_log("Sending of the password...\n"); - } else { - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x791a; // Sending request about the coding key - WFIFOSET(login_fd,2); - bytes_to_read = 1; - ShowMessage("Request about the MD5 key...\n"); - ladmin_log("Request about the MD5 key...\n"); - } - - return 0; -} - -// sends a ping packet to login server (will receive pong 0x2718) -int ping_login_server(int tid, unsigned int tick, int id, intptr data) -{ - if (login_fd > 0 && session[login_fd] != NULL) - { - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x2719; - WFIFOSET(login_fd,2); - } - return 0; -} - -//----------------------------------- -// Reading general configuration file -//----------------------------------- -int ladmin_config_read(const char *cfgName) -{ - char line[1024], w1[1024], w2[1024]; - FILE *fp; - - fp = fopen(cfgName, "r"); - if (fp == NULL) { - ShowMessage("\033[0mConfiguration file (%s) not found.\n", cfgName); - return 1; - } - - ShowMessage("\033[0m---Start reading of Ladmin configuration file (%s)\n", cfgName); - while(fgets(line, sizeof(line), fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { - remove_control_chars(w1); - remove_control_chars(w2); - - if(strcmpi(w1,"login_ip")==0) { - uint32 ipl = host2ip(w2); - if (ipl != 0) { - ip2str(ipl, loginserverip); - ShowMessage("Login server IP address: %s -> %s\n", w2, loginserverip); - } else - memcpy(loginserverip, w2, 16); - } else if (strcmpi(w1, "login_port") == 0) { - loginserverport = atoi(w2); - } else if (strcmpi(w1, "admin_pass") == 0) { - strncpy(loginserveradminpassword, w2, sizeof(loginserveradminpassword)); - loginserveradminpassword[sizeof(loginserveradminpassword)-1] = '\0'; - } else if (strcmpi(w1, "passenc") == 0) { - passenc = atoi(w2); - if (passenc < 0 || passenc > 2) - passenc = 0; - } else if (strcmpi(w1, "ladmin_log_filename") == 0) { - strncpy(ladmin_log_filename, w2, sizeof(ladmin_log_filename)); - ladmin_log_filename[sizeof(ladmin_log_filename)-1] = '\0'; - } else if (strcmpi(w1, "date_format") == 0) { - strncpy(date_format, w2, sizeof(date_format)); - } else if(strcmpi(w1,"stdout_with_ansisequence") == 0) { - stdout_with_ansisequence = config_switch(w2); - } else if (strcmpi(w1, "import") == 0) { - ladmin_config_read(w2); - } - } - } - fclose(fp); - - login_ip = str2ip(loginserverip); - - ShowMessage("---End reading of Ladmin configuration file.\n"); - - return 0; -} - -//------------------------------ -// Function called when the server -// has received a crash signal. -//------------------------------ -void do_abort(void) -{ -} - -//-------------------------------------- -// Function called at exit of the server -//-------------------------------------- -void do_final(void) -{ - if (already_exit_function == 0) { - - ShowMessage("\033[0m----End of Ladmin (normal end with closing of all files).\n"); - ladmin_log("----End of Ladmin (normal end with closing of all files).\n"); - - already_exit_function = 1; - do_close(login_fd); - } -} - -//------------------------ -// Main function of ladmin -//------------------------ -int do_init(int argc, char **argv) -{ - int next; - socket_init(); - - // read ladmin configuration - ladmin_config_read((argc > 1) ? argv[1] : LADMIN_CONF_NAME); - - ladmin_log(""); - ladmin_log("Configuration file readed.\n"); - - srand(time(NULL)); - - set_defaultparse(parse_fromlogin); - - ShowMessage("EAthena login-server administration tool.\n"); - ShowMessage("(for eAthena version %d.%d.%d.)\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION); - - ladmin_log("Ladmin is ready.\n"); - ShowMessage("Ladmin is \033[1;32mready\033[0m.\n\n"); - - Connect_login_server(); - - // keep the char-login connection alive - add_timer_func_list(ping_login_server, "ping_login_server"); - add_timer_interval(gettick() + 1000, ping_login_server, 0, 0, ((int)stall_time-2) * 1000); - - // minimalist core doesn't have sockets parsing, - // so we have to do this ourselves - while (runflag) { - next = do_timer(gettick_nocache()); - do_sockets(next); - } - - return 0; -} diff --git a/src/ladmin/ladmin.h b/src/ladmin/ladmin.h deleted file mode 100644 index 824407af7..000000000 --- a/src/ladmin/ladmin.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _LADMIN_H_ -#define _LADMIN_H_ - -#define LADMIN_CONF_NAME "conf/ladmin_athena.conf" - -#endif /* _LADMIN_H_ */ diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 611ca385b..c153d95b3 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -13,7 +13,7 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_SQL_H = ../common/sql.h -LOGIN_OBJ = login.o admin.o +LOGIN_OBJ = login.o LOGIN_TXT_OBJ = $(LOGIN_OBJ:%=obj_txt/%) \ obj_txt/account_txt.o obj_txt/ipban_txt.o obj_txt/loginlog_txt.o LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \ diff --git a/src/login/admin.c b/src/login/admin.c deleted file mode 100644 index 1e2e851ac..000000000 --- a/src/login/admin.c +++ /dev/null @@ -1,857 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/core.h" -#include "../common/socket.h" -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/version.h" -#include "../common/md5calc.h" -#include "../common/lock.h" -#include "account.h" -#include "login.h" - -#include -#include -#include -#include // for stat/lstat/fstat - -extern AccountDB* accounts; - -int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len); -bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass); -int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip); -int parse_admin(int fd); - - -bool ladmin_auth(struct login_session_data* sd, const char* ip) -{ - bool result = false; - - if( str2ip(ip) != host2ip(login_config.admin_allowed_host) ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - IP isn't authorised (ip: %s).\n", ip); - else - if( !login_config.admin_state ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (ip: %s)\n", ip); - else - if( !check_password(sd->md5key, sd->passwdenc, sd->passwd, login_config.admin_pass) ) - ShowNotice("'ladmin'-login: Connection in administration mode REFUSED - invalid password (ip: %s)\n", ip); - else - { - ShowNotice("'ladmin'-login: Connection in administration mode accepted (ip: %s)\n", ip); - session[sd->fd]->func_parse = parse_admin; - result = true; - } - - return result; -} - -//--------------------------------------- -// Packet parsing for administation login -// -// List of supported operations: -// 0x7530 - request server version (response: 0x7531) -// 0x7938 - request server list (response: 0x7939) -// 0x7920 - request entire list of accounts (response: 0x7921) -// 0x794e - request message broadcast (response: 0x794f + 0x2726) - -// 0x7930 - request account creation (response: 0x7931) -// 0x7932 - request account deletion (response: 0x7933 + 0x2730) - -// 0x7934 - request account password modification (response: 0x7935) -// 0x7936 - request account state modification (response: 0x7937 + 0x2731) -// 0x793a - request password check (response: 0x793b) -// 0x793c - request account sex modification (response: 0x793d + 0x2723) -// 0x793e - request account gm-level modification (response: 0x793f) -// 0x7940 - request account email modification (response: 0x7941) -// 0x7942 - request account memo modification (response: 0x7943) -// 0x7948 - request account expiration-time modification - absolute (response: 0x7949) -// 0x7950 - request account expiration-time modification - relative (response: 0x7951) -// 0x794a - request account unban-time modification - absolute (response: 0x794b + 0x2731) -// 0x794c - request account unban-time modification - relative (response: 0x794d + 0x2731) - -// 0x7944 - request account id lookup by name (response: 0x7945) -// 0x7946 - request account name lookup by id (response: 0x7947) -// 0x7952 - request account information lookup by name (response: 0x7953) -// 0x7954 - request account information lookup by id (response: 0x7953) -//--------------------------------------- -int parse_admin(int fd) -{ - char* account_name; - - uint32 ipl = session[fd]->client_addr; - char ip[16]; - ip2str(ipl, ip); - - if( session[fd]->flag.eof ) - { - do_close(fd); - ShowInfo("Remote administration has disconnected (session #%d).\n", fd); - return 0; - } - - while( RFIFOREST(fd) >= 2 ) - { - uint16 command = RFIFOW(fd,0); - - switch( command ) - { - - case 0x7530: // Request of the server version - ShowStatus("'ladmin': Sending of the server version (ip: %s)\n", ip); - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_LOGIN; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - RFIFOSKIP(fd,2); - break; -/* - case 0x7920: // Request of an accounts list - if (RFIFOREST(fd) < 10) - return 0; - { - int st, ed; - uint16 len; - CREATE_BUFFER(id, int, auth_num); - st = RFIFOL(fd,2); - ed = RFIFOL(fd,6); - RFIFOSKIP(fd,10); - WFIFOW(fd,0) = 0x7921; - if (st < 0) - st = 0; - if (ed > END_ACCOUNT_NUM || ed < st || ed <= 0) - ed = END_ACCOUNT_NUM; - ShowStatus("'ladmin': Sending an accounts list (ask: from %d to %d, ip: %s)\n", st, ed, ip); - // Sort before send - for(i = 0; i < auth_num; i++) { - unsigned int k; - id[i] = i; - for(j = 0; j < i; j++) { - if (auth_dat[id[i]].account_id < auth_dat[id[j]].account_id) { - for(k = i; k > j; k--) { - id[k] = id[k-1]; - } - id[j] = i; // id[i] - break; - } - } - } - // Sending accounts information - len = 4; - for(i = 0; i < auth_num && len < 30000; i++) { - int account_id = auth_dat[id[i]].account_id; // use sorted index - if (account_id >= st && account_id <= ed) { - j = id[i]; - WFIFOL(fd,len) = account_id; - WFIFOB(fd,len+4) = (unsigned char)isGM(account_id); - memcpy(WFIFOP(fd,len+5), auth_dat[j].userid, 24); - WFIFOB(fd,len+29) = auth_dat[j].sex; - WFIFOL(fd,len+30) = auth_dat[j].logincount; - if (auth_dat[j].state == 0 && auth_dat[j].unban_time != 0) // if no state and banished - WFIFOL(fd,len+34) = 7; // 6 = Your are Prohibited to log in until %s - else - WFIFOL(fd,len+34) = auth_dat[j].state; - len += 38; - } - } - WFIFOW(fd,2) = len; - WFIFOSET(fd,len); - //if (id) free(id); - DELETE_BUFFER(id); - } - break; -*/ - case 0x7930: // Request for an account creation - if (RFIFOREST(fd) < 91) - return 0; - { - struct mmo_account ma; - safestrncpy(ma.userid, (char*)RFIFOP(fd, 2), sizeof(ma.userid)); - safestrncpy(ma.pass, (char*)RFIFOP(fd,26), sizeof(ma.pass)); - ma.sex = RFIFOB(fd,50); - safestrncpy(ma.email, (char*)RFIFOP(fd,51), sizeof(ma.email)); - safestrncpy(ma.lastlogin, "-", sizeof(ma.lastlogin)); - - ShowNotice("'ladmin': Account creation request (account: %s pass: %s, sex: %c, email: %s, ip: %s)\n", ma.userid, ma.pass, ma.sex, ma.email, ip); - - WFIFOW(fd,0) = 0x7931; - WFIFOL(fd,2) = mmo_auth_new(ma.userid, ma.pass, ma.sex, ip); - safestrncpy((char*)WFIFOP(fd,6), ma.userid, 24); - WFIFOSET(fd,30); - } - RFIFOSKIP(fd,91); - break; -/* - case 0x7932: // Request for an account deletion - if (RFIFOREST(fd) < 26) - return 0; - { - struct mmo_account acc; - - char* account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - - WFIFOW(fd,0) = 0x7933; - - if( accounts->load_str(accounts, &acc, account_name) ) - { - // Char-server is notified of deletion (for characters deletion). - unsigned char buf[65535]; - WBUFW(buf,0) = 0x2730; - WBUFL(buf,2) = acc.account_id; - charif_sendallwos(-1, buf, 6); - - // send answer - memcpy(WFIFOP(fd,6), acc.userid, 24); - WFIFOL(fd,2) = acc.account_id; - - // delete account - memset(acc.userid, '\0', sizeof(acc.userid)); - auth_dat[i].account_id = -1; - mmo_auth_sync(); - } else { - WFIFOL(fd,2) = -1; - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to delete an unknown account (account: %s, ip: %s)\n", account_name, ip); - } - WFIFOSET(fd,30); - } - RFIFOSKIP(fd,26); - break; -*/ - case 0x7934: // Request to change a password - if (RFIFOREST(fd) < 50) - return 0; - { - struct mmo_account acc; - - char* account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - - WFIFOW(fd,0) = 0x7935; - - if( accounts->load_str(accounts, &acc, account_name) ) - { - WFIFOL(fd,2) = acc.account_id; - safestrncpy((char*)WFIFOP(fd,6), acc.userid, 24); - safestrncpy(acc.pass, (char*)RFIFOP(fd,26), 24); - ShowNotice("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n", acc.userid, acc.pass, ip); - - accounts->save(accounts, &acc); - } - else - { - WFIFOL(fd,2) = -1; - safestrncpy((char*)WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to modify the password of an unknown account (account: %s, ip: %s)\n", account_name, ip); - } - - WFIFOSET(fd,30); - } - RFIFOSKIP(fd,50); - break; - - case 0x7936: // Request to modify a state - if (RFIFOREST(fd) < 50) - return 0; - { - struct mmo_account acc; - - char* account_name = (char*)RFIFOP(fd,2); - uint32 state = RFIFOL(fd,26); - account_name[23] = '\0'; - - WFIFOW(fd,0) = 0x7937; - - if( accounts->load_str(accounts, &acc, account_name) ) - { - memcpy(WFIFOP(fd,6), acc.userid, 24); - WFIFOL(fd,2) = acc.account_id; - - if (acc.state == state) - ShowNotice("'ladmin': Modification of a state, but the state of the account already has this value (account: %s, received state: %d, ip: %s)\n", account_name, state, ip); - else - { - ShowNotice("'ladmin': Modification of a state (account: %s, new state: %d, ip: %s)\n", acc.userid, state, ip); - - if (acc.state == 0) { - unsigned char buf[16]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = acc.account_id; - WBUFB(buf,6) = 0; // 0: change of statut, 1: ban - WBUFL(buf,7) = state; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - acc.state = state; - accounts->save(accounts, &acc); - } - } - else - { - ShowNotice("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n", account_name, state, ip); - WFIFOL(fd,2) = -1; - memcpy(WFIFOP(fd,6), account_name, 24); - } - - WFIFOL(fd,30) = state; - WFIFOSET(fd,34); - } - RFIFOSKIP(fd,50); - break; -/* - case 0x7938: // Request for servers list and # of online players - { - uint8 server_num = 0; - ShowStatus("'ladmin': Sending of servers list (ip: %s)\n", ip); - for(i = 0; i < MAX_SERVERS; i++) { - if (server[i].fd >= 0) { - WFIFOL(fd,4+server_num*32) = htonl(server[i].ip); - WFIFOW(fd,4+server_num*32+4) = htons(server[i].port); - memcpy(WFIFOP(fd,4+server_num*32+6), server[i].name, 20); - WFIFOW(fd,4+server_num*32+26) = server[i].users; - WFIFOW(fd,4+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,4+server_num*32+30) = server[i].new_; - server_num++; - } - } - WFIFOW(fd,0) = 0x7939; - WFIFOW(fd,2) = 4 + 32 * server_num; - WFIFOSET(fd,4+32*server_num); - RFIFOSKIP(fd,2); - break; - } - - case 0x793a: // Request to password check - if (RFIFOREST(fd) < 50) - return 0; - WFIFOW(fd,0) = 0x793b; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - if( accounts->load_str(accounts, &acc, account_name) ) - { - char pass[25]; - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - memcpy(pass, RFIFOP(fd,26), 24); - pass[24] = '\0'; - remove_control_chars(pass); - if (strcmp(acc.pass, pass) == 0) { - WFIFOL(fd,2) = acc.account_id; - ShowNotice("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n", acc.userid, acc.pass, ip); - } else { - ShowNotice("'ladmin': Failure of password check (account: %s, proposed pass: %s, ip: %s)\n", acc.userid, pass, ip); - } - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to check the password of an unknown account (account: %s, ip: %s)\n", account_name, ip); - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,50); - break; - - case 0x793c: // Request to modify sex - if (RFIFOREST(fd) < 27) - return 0; - WFIFOW(fd,0) = 0x793d; - WFIFOL(fd,2) = 0xFFFFFFFF; // -1 - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - memcpy(WFIFOP(fd,6), account_name, 24); - { - char sex; - sex = RFIFOB(fd,26); - if (sex != 'F' && sex != 'M') { - if (sex > 31) - ShowNotice("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n", account_name, sex, ip); - else - ShowNotice("'ladmin': Attempt to give an invalid sex (account: %s, received sex: 'control char', ip: %s)\n", account_name, ip); - } else { - if( accounts->load_str(accounts, &acc, account_name) ) - { - memcpy(WFIFOP(fd,6), acc.userid, 24); - if (acc.sex != sex) - { - unsigned char buf[16]; - ShowNotice("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n", acc.userid, sex, ip); - - WFIFOL(fd,2) = acc.account_id; - acc.sex = sex; - accounts->save(accounts, &acc); - - // send to all char-server the change - WBUFW(buf,0) = 0x2723; - WBUFL(buf,2) = acc.account_id; - WBUFB(buf,6) = acc.sex; - charif_sendallwos(-1, buf, 7); - } else { - ShowNotice("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n", acc.userid, sex, ip); - } - } else { - ShowNotice("'ladmin': Attempt to modify the sex of an unknown account (account: %s, received sex: %c, ip: %s)\n", account_name, sex, ip); - } - } - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,27); - break; - - case 0x793e: // Request to modify GM level - if (RFIFOREST(fd) < 27) - return 0; - WFIFOW(fd,0) = 0x793f; - WFIFOL(fd,2) = 0xFFFFFFFF; // -1 - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - memcpy(WFIFOP(fd,6), account_name, 24); - { - char new_gm_level; - new_gm_level = RFIFOB(fd,26); - if( new_gm_level < 0 || new_gm_level > 99 ) - ShowNotice("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); - else - if( !accounts->load_str(accounts, &acc, account_name) ) - ShowNotice("'ladmin': Attempt to modify the GM level of an unknown account (account: %s, received GM level: %d, ip: %s)\n", account_name, (int)new_gm_level, ip); - else - { - memcpy(WFIFOP(fd,6), acc.userid, 24); - - if (isGM(acc.account_id) == new_gm_level) - ShowNotice("'ladmin': Attempt to modify of a GM level, but the GM level is already the good GM level (account: %s (%d), GM level: %d, ip: %s)\n", acc.userid, acc.account_id, (int)new_gm_level, ip); - else - { - //TODO: change level - } - } - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,27); - break; - - case 0x7940: // Request to modify e-mail - if (RFIFOREST(fd) < 66) - return 0; - WFIFOW(fd,0) = 0x7941; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - memcpy(WFIFOP(fd,6), account_name, 24); - { - char email[40]; - memcpy(email, RFIFOP(fd,26), 40); - if (e_mail_check(email) == 0) { - ShowNotice("'ladmin': Attempt to give an invalid e-mail (account: %s, ip: %s)\n", account_name, ip); - } else { - remove_control_chars(email); - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - memcpy(auth_dat[i].email, email, 40); - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Modification of an email (account: %s, new e-mail: %s, ip: %s)\n", auth_dat[i].userid, email, ip); - mmo_auth_sync(); - } else { - ShowNotice("'ladmin': Attempt to modify the e-mail of an unknown account (account: %s, received e-mail: %s, ip: %s)\n", account_name, email, ip); - } - } - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,66); - break; - - case 0x7942: // Request to modify memo field - if ((int)RFIFOREST(fd) < 28 || (int)RFIFOREST(fd) < (28 + RFIFOW(fd,26))) - return 0; - WFIFOW(fd,0) = 0x7943; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - int size_of_memo = sizeof(auth_dat[i].memo); - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - memset(auth_dat[i].memo, '\0', size_of_memo); - if (RFIFOW(fd,26) == 0) { - strncpy(auth_dat[i].memo, "-", size_of_memo); - } else if (RFIFOW(fd,26) > size_of_memo - 1) { - memcpy(auth_dat[i].memo, RFIFOP(fd,28), size_of_memo - 1); - } else { - memcpy(auth_dat[i].memo, RFIFOP(fd,28), RFIFOW(fd,26)); - } - auth_dat[i].memo[size_of_memo - 1] = '\0'; - remove_control_chars(auth_dat[i].memo); - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Modification of a memo field (account: %s, new memo: %s, ip: %s)\n", auth_dat[i].userid, auth_dat[i].memo, ip); - mmo_auth_sync(); - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to modify the memo field of an unknown account (account: %s, ip: %s)\n", account_name, ip); - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,28 + RFIFOW(fd,26)); - break; - - case 0x7944: // Request to found an account id - if (RFIFOREST(fd) < 26) - return 0; - WFIFOW(fd,0) = 0x7945; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Request (by the name) of an account id (account: %s, id: %d, ip: %s)\n", auth_dat[i].userid, auth_dat[i].account_id, ip); - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': ID request (by the name) of an unknown account (account: %s, ip: %s)\n", account_name, ip); - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,26); - break; - - case 0x7946: // Request to found an account name - if (RFIFOREST(fd) < 6) - return 0; - WFIFOW(fd,0) = 0x7947; - WFIFOL(fd,2) = RFIFOL(fd,2); - memset(WFIFOP(fd,6), '\0', 24); - for(i = 0; i < auth_num; i++) { - if (auth_dat[i].account_id == (int)RFIFOL(fd,2)) { - strncpy((char*)WFIFOP(fd,6), auth_dat[i].userid, 24); - ShowNotice("'ladmin': Request (by id) of an account name (account: %s, id: %d, ip: %s)\n", auth_dat[i].userid, RFIFOL(fd,2), ip); - break; - } - } - if (i == auth_num) { - ShowNotice("'ladmin': Name request (by id) of an unknown account (id: %d, ip: %s)\n", RFIFOL(fd,2), ip); - strncpy((char*)WFIFOP(fd,6), "", 24); - } - WFIFOSET(fd,30); - RFIFOSKIP(fd,6); - break; - - case 0x7948: // Request to change the validity limit (timestamp) (absolute value) - if (RFIFOREST(fd) < 30) - return 0; - { - time_t timestamp; - char tmpstr[2048]; - WFIFOW(fd,0) = 0x7949; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - timestamp = (time_t)RFIFOL(fd,26); - strftime(tmpstr, 24, login_config.date_format, localtime(×tamp)); - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - ShowNotice("'ladmin': Change of a validity limit (account: %s, new validity: %d (%s), ip: %s)\n", auth_dat[i].userid, timestamp, (timestamp == 0 ? "unlimited" : tmpstr), ip); - auth_dat[i].expiration_time = timestamp; - WFIFOL(fd,2) = auth_dat[i].account_id; - mmo_auth_sync(); - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to change the validity limit of an unknown account (account: %s, received validity: %d (%s), ip: %s)\n", account_name, timestamp, (timestamp == 0 ? "unlimited" : tmpstr), ip); - } - WFIFOL(fd,30) = (unsigned int)timestamp; - } - WFIFOSET(fd,34); - RFIFOSKIP(fd,30); - break; - - case 0x794a: // Request to change the final date of a banishment (timestamp) (absolute value) - if (RFIFOREST(fd) < 30) - return 0; - { - time_t timestamp; - char tmpstr[2048]; - WFIFOW(fd,0) = 0x794b; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - timestamp = (time_t)RFIFOL(fd,26); - if (timestamp <= time(NULL)) - timestamp = 0; - strftime(tmpstr, 24, login_config.date_format, localtime(×tamp)); - i = search_account_index(account_name); - if (i != -1) { - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - WFIFOL(fd,2) = auth_dat[i].account_id; - ShowNotice("'ladmin': Change of the final date of a banishment (account: %s, new final date of banishment: %d (%s), ip: %s)\n", auth_dat[i].userid, timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip); - if (auth_dat[i].unban_time != timestamp) { - if (timestamp != 0) { - unsigned char buf[16]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = auth_dat[i].account_id; - WBUFB(buf,6) = 1; // 0: change of statut, 1: ban - WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - auth_dat[i].unban_time = timestamp; - mmo_auth_sync(); - } - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to change the final date of a banishment of an unknown account (account: %s, received final date of banishment: %d (%s), ip: %s)\n", account_name, timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip); - } - WFIFOL(fd,30) = (unsigned int)timestamp; - } - WFIFOSET(fd,34); - RFIFOSKIP(fd,30); - break; - - case 0x794c: // Request to change the final date of a banishment (timestamp) (relative change) - if (RFIFOREST(fd) < 38) - return 0; - { - time_t timestamp; - struct tm *tmtime; - char tmpstr[2048]; - WFIFOW(fd,0) = 0x794d; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - WFIFOL(fd,2) = auth_dat[i].account_id; - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - if (auth_dat[i].unban_time == 0 || auth_dat[i].unban_time < time(NULL)) - timestamp = time(NULL); - else - timestamp = auth_dat[i].unban_time; - tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26); - tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28); - tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30); - tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,32); - tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,34); - tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,36); - timestamp = mktime(tmtime); - if (timestamp != -1) { - if (timestamp <= time(NULL)) - timestamp = 0; - strftime(tmpstr, 24, login_config.date_format, localtime(×tamp)); - ShowNotice("'ladmin': Adjustment of a final date of a banishment (account: %s, (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)\n", auth_dat[i].userid, (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip); - if (auth_dat[i].unban_time != timestamp) { - if (timestamp != 0) { - unsigned char buf[16]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = auth_dat[i].account_id; - WBUFB(buf,6) = 1; // 0: change of statut, 1: ban - WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - auth_dat[i].unban_time = timestamp; - mmo_auth_sync(); - } - } else { - strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].unban_time)); - ShowNotice("'ladmin': Impossible to adjust the final date of a banishment (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", auth_dat[i].userid, auth_dat[i].unban_time, (auth_dat[i].unban_time == 0 ? "no banishment" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip); - } - WFIFOL(fd,30) = (unsigned long)auth_dat[i].unban_time; - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to adjust the final date of a banishment of an unknown account (account: %s, ip: %s)\n", account_name, ip); - WFIFOL(fd,30) = 0; - } - } - WFIFOSET(fd,34); - RFIFOSKIP(fd,38); - break; - - case 0x794e: // Request to send a broadcast message - if (RFIFOREST(fd) < 8 || RFIFOREST(fd) < (8 + RFIFOL(fd,4))) - return 0; - WFIFOW(fd,0) = 0x794f; - WFIFOW(fd,2) = 0xFFFF; // WTF??? - if (RFIFOL(fd,4) < 1) { - ShowNotice("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)\n", ip); - } else { - // at least 1 char-server - for(i = 0; i < MAX_SERVERS; i++) - if (server[i].fd >= 0) - break; - if (i == MAX_SERVERS) { - ShowNotice("'ladmin': Receiving a message for broadcast, but no char-server is online (ip: %s)\n", ip); - } else { - unsigned char buf[32000]; - char message[32000]; - WFIFOW(fd,2) = 0; - memset(message, '\0', sizeof(message)); - memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4)); - message[sizeof(message)-1] = '\0'; - remove_control_chars(message); - if (RFIFOW(fd,2) == 0) - ShowNotice("'ladmin': Receiving a message for broadcast (message (in yellow): %s, ip: %s)\n", message, ip); - else - ShowNotice("'ladmin': Receiving a message for broadcast (message (in blue): %s, ip: %s)\n", message, ip); - // send same message to all char-servers (no answer) - memcpy(WBUFP(buf,0), RFIFOP(fd,0), 8 + RFIFOL(fd,4)); - WBUFW(buf,0) = 0x2726; - charif_sendallwos(-1, buf, 8 + RFIFOL(fd,4)); - } - } - WFIFOSET(fd,4); - RFIFOSKIP(fd,8 + RFIFOL(fd,4)); - break; - - case 0x7950: // Request to change the validity limite (timestamp) (relative change) - if (RFIFOREST(fd) < 38) - return 0; - { - time_t timestamp; - struct tm *tmtime; - char tmpstr[2048]; - char tmpstr2[2048]; - WFIFOW(fd,0) = 0x7951; - WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - remove_control_chars(account_name); - i = search_account_index(account_name); - if (i != -1) { - WFIFOL(fd,2) = auth_dat[i].account_id; - memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); - timestamp = auth_dat[i].expiration_time; - if (timestamp == 0 || timestamp < time(NULL)) - timestamp = time(NULL); - tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26); - tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28); - tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30); - tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,32); - tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,34); - tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,36); - timestamp = mktime(tmtime); - if (timestamp != -1) { - strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); - strftime(tmpstr2, 24, login_config.date_format, localtime(×tamp)); - ShowNotice("'ladmin': Adjustment of a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "unlimited" : tmpstr2), ip); - auth_dat[i].expiration_time = timestamp; - mmo_auth_sync(); - WFIFOL(fd,30) = (unsigned long)auth_dat[i].expiration_time; - } else { - strftime(tmpstr, 24, login_config.date_format, localtime(&auth_dat[i].expiration_time)); - ShowNotice("'ladmin': Impossible to adjust a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", auth_dat[i].userid, auth_dat[i].expiration_time, (auth_dat[i].expiration_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip); - WFIFOL(fd,30) = 0; - } - } else { - memcpy(WFIFOP(fd,6), account_name, 24); - ShowNotice("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n", account_name, ip); - WFIFOL(fd,30) = 0; - } - - WFIFOSET(fd,34); - } - RFIFOSKIP(fd,38); - break; -*/ - case 0x7952: // Request about informations of an account (by account name) - if (RFIFOREST(fd) < 26) - return 0; - { - struct mmo_account acc; - - WFIFOW(fd,0) = 0x7953; - - account_name = (char*)RFIFOP(fd,2); - account_name[23] = '\0'; - - if( accounts->load_str(accounts, &acc, account_name) ) - { - ShowNotice("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n", acc.userid, acc.account_id, ip); - WFIFOL(fd,2) = acc.account_id; - WFIFOB(fd,6) = acc.level; - safestrncpy((char*)WFIFOP(fd,7), acc.userid, 24); - WFIFOB(fd,31) = acc.sex; - WFIFOL(fd,32) = acc.logincount; - WFIFOL(fd,36) = acc.state; - safestrncpy((char*)WFIFOP(fd,40), "-", 20); // error message (removed) - safestrncpy((char*)WFIFOP(fd,60), acc.lastlogin, 24); - safestrncpy((char*)WFIFOP(fd,84), acc.last_ip, 16); - safestrncpy((char*)WFIFOP(fd,100), acc.email, 40); - WFIFOL(fd,140) = (unsigned long)acc.expiration_time; - WFIFOL(fd,144) = (unsigned long)acc.unban_time; - WFIFOW(fd,148) = 0; // previously, this was strlen(memo), and memo went afterwards - } - else - { - ShowNotice("'ladmin': Attempt to obtain information (by the name) of an unknown account (account: %s, ip: %s)\n", account_name, ip); - WFIFOL(fd,2) = -1; - safestrncpy((char*)WFIFOP(fd,7), account_name, 24); // not found - } - - WFIFOSET(fd,150); - } - RFIFOSKIP(fd,26); - break; - - case 0x7954: // Request about information of an account (by account id) - if (RFIFOREST(fd) < 6) - return 0; - { - struct mmo_account acc; - - int account_id = RFIFOL(fd,2); - - WFIFOHEAD(fd,150); - WFIFOW(fd,0) = 0x7953; - WFIFOL(fd,2) = account_id; - - if( accounts->load_num(accounts, &acc, account_id) ) - { - ShowNotice("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n", acc.userid, account_id, ip); - WFIFOB(fd,6) = acc.level; - safestrncpy((char*)WFIFOP(fd,7), acc.userid, 24); - WFIFOB(fd,31) = acc.sex; - WFIFOL(fd,32) = acc.logincount; - WFIFOL(fd,36) = acc.state; - safestrncpy((char*)WFIFOP(fd,40), "-", 20); // error message (removed) - safestrncpy((char*)WFIFOP(fd,60), acc.lastlogin, 24); - safestrncpy((char*)WFIFOP(fd,84), acc.last_ip, 16); - safestrncpy((char*)WFIFOP(fd,100), acc.email, 40); - WFIFOL(fd,140) = (unsigned long)acc.expiration_time; - WFIFOL(fd,144) = (unsigned long)acc.unban_time; - WFIFOW(fd,148) = 0; // previously, this was strlen(memo), and memo went afterwards - } - else - { - ShowNotice("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n", account_id, ip); - safestrncpy((char*)WFIFOP(fd,7), "", 24); // not found - } - - WFIFOSET(fd,150); - } - RFIFOSKIP(fd,6); - break; - - default: - ShowStatus("'ladmin': End of connection, unknown packet (ip: %s)\n", ip); - set_eof(fd); - return 0; - } - } - - return 0; -} diff --git a/src/login/login.c b/src/login/login.c index 567bbddf3..be6efb137 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -19,7 +19,6 @@ #include #include -bool ladmin_auth(struct login_session_data* sd, const char* ip); struct Login_Config login_config; int login_fd; // login server socket @@ -1224,7 +1223,7 @@ void login_auth_failed(struct login_session_data* sd, int result) //---------------------------------------------------------------------------------------- -// Default packet parsing (normal players or administation/char-server connection requests) +// Default packet parsing (normal players or char-server connection requests) //---------------------------------------------------------------------------------------- int parse_login(int fd) { @@ -1358,7 +1357,6 @@ int parse_login(int fd) break; case 0x01db: // Sending request of the coding key - case 0x791a: // Sending request of the coding key (administration packet) RFIFOSKIP(fd,2); { memset(sd->md5key, '\0', sizeof(sd->md5key)); @@ -1434,45 +1432,6 @@ int parse_login(int fd) } return 0; // processing will continue elsewhere - case 0x7530: // Server version information request - ShowStatus("Sending server version information to ip: %s\n", ip); - RFIFOSKIP(fd,2); - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_LOGIN; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - break; - - case 0x7918: // Request for administation login - if ((int)RFIFOREST(fd) < 4 || (int)RFIFOREST(fd) < ((RFIFOW(fd,2) == 0) ? 28 : 20)) - return 0; - { - int passwdenc = (int)RFIFOW(fd,2); - const char* passwd = (char*)RFIFOP(fd,4); - - if( passwdenc == 0 ) { // non encrypted password - safestrncpy(sd->passwd, passwd, NAME_LENGTH); - sd->passwdenc = 0; - } else { // encrypted password - memcpy(sd->passwd, passwd, 16); sd->passwd[16] = '\0'; // raw binary data here! - sd->passwdenc = passwdenc; - } - - RFIFOSKIP(fd, (passwdenc == 0) ? 28 : 20); - - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x7919; - WFIFOB(fd,2) = ladmin_auth(sd, ip) ? 0 : 1; - WFIFOSET(fd,3); - } - break; - default: ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, command); set_eof(fd); @@ -1578,14 +1537,6 @@ int login_config_read(const char* cfgName) login_config.ipban_cleanup_interval = (unsigned int)atoi(w2); else if(!strcmpi(w1, "ip_sync_interval")) login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes. - - else if(!strcmpi(w1, "admin_state")) - login_config.admin_state = (bool)config_switch(w2); - else if(!strcmpi(w1, "admin_pass")) - safestrncpy(login_config.admin_pass, w2, sizeof(login_config.admin_pass)); - else if(!strcmpi(w1, "admin_allowed_host")) - safestrncpy(login_config.admin_allowed_host, w2, sizeof(login_config.admin_pass)); - else if(!strcmpi(w1, "import")) login_config_read(w2); else diff --git a/src/login/login.h b/src/login/login.h index 807caaed6..f338a09e1 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -60,10 +60,6 @@ struct Login_Config { bool check_client_version; // check the clientversion set in the clientinfo ? uint32 client_version_to_connect; // the client version needed to connect (if checking is enabled) - bool admin_state; // is ladmin support enabled? - char admin_pass[24]; // security password for ladmin - char admin_allowed_host[32]; // host/ip that is allowed to connect as ladmin - bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures diff --git a/src/map/chrif.c b/src/map/chrif.c index 262214ae4..135c464c4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -38,7 +38,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff 6,-1,18, 7,-1,35,30, 0, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, F->2b07 6,30, 0, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f - 11,10,10, 6,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, F->2b15, U->2b16, U->2b17 + 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 }; @@ -71,7 +71,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free //2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them' //2b11: Outgoing, chrif_divorce -> 'tell the charserver to do divorce' //2b12: Incoming, chrif_divorceack -> 'divorce chars -//2b13: Incoming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....' +//2b13: FREE //2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY' //2b15: FREE //2b16: Outgoing, chrif_ragsrvinfo -> 'sends base / job / drop rates ....' @@ -942,32 +942,6 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) return 0; } -/*========================================== - * Disconnection of a player (account has been deleted in login-server) by [Yor] - *------------------------------------------*/ -int chrif_accountdeletion(int fd) -{ - int acc; - struct map_session_data *sd; - - acc = RFIFOL(fd,2); - if (battle_config.etc_log) - ShowNotice("chrif_accountdeletion %d.\n", acc); - sd = map_id2sd(acc); - if (acc > 0) { - if (sd != NULL) { - sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters - clif_displaymessage(sd->fd, "Your account has been deleted (disconnection)..."); - set_eof(sd->fd); // forced to disconnect for the change - map_quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] - } - } else { - if (sd != NULL) - ShowError("chrif_accountdeletion failed - player not online.\n"); - } - - return 0; -} /*========================================== * Disconnection of a player (account has been banned of has a status, from login-server) by [Yor] @@ -1426,7 +1400,6 @@ int chrif_parse(int fd) case 0x2b0d: chrif_changedsex(fd); break; case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; case 0x2b12: chrif_divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break; - case 0x2b13: chrif_accountdeletion(fd); break; case 0x2b14: chrif_accountban(fd); break; case 0x2b1b: chrif_recvfamelist(fd); break; case 0x2b1d: chrif_load_scdata(fd); break; diff --git a/tools/checkversion.pl b/tools/checkversion.pl deleted file mode 100755 index e13b7370c..000000000 --- a/tools/checkversion.pl +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/perl -w - -########################################################################## -# INFORMATION TOOL ABOUT THE SERVERS VERSION OF ATHENA -# -# By connection on a server, this software display the version of the -# designed server. -#------------------------------------------------------------------------- -# Usages: -# ./checkversion.pl IP:port -# ./checkversion.pl IP port -# perl checkversion.pl IP:port -# perl checkversion.pl IP port -# -# note: default port: 6900 -# -# When successfull, the software return the value 0. -# -########################################################################## - -#------------------------- start of configuration ------------------------ - -$connecttimeout = 10; # Connection Timeout (in seconds) - -#-------------------------- End of configuration ------------------------- - -use IO::Socket; - -unless($ARGV[0]) { - print "USAGE: $0 server_ip:port\n"; - exit(1); -} - -$server = $ARGV[0]; -$port = $ARGV[1]; -$port = $1 if ($server =~ s/:(\d+)//); -$port ||= 6900; - -# Connection to the server -my($so,$er) = (); -eval{ - $so = IO::Socket::INET->new( - PeerAddr=> $server, - PeerPort=> $port, - Proto => "tcp", - Timeout => $connecttimeout) or $er = 1; -}; - -if($er || $@) { - print "Can't not connect to server [$server:$port] !\n"; - exit(2); -} - -# Request for the server version -print $so pack("v",30000); # 0x7530 -$so->flush(); - -# Receiving of the answer of the server -if (read($so,$buf,10) < 10) { - print "Invalid answer. It isn't an athena server or it is a too old version.\n"; - exit(5); -} - -# Sending end of connection to the server -print $so pack("v",30002); # 0x7532 -$so->flush(); - -# Analyse of the answer -my($ret,$maver,$miver,$rev,$dev,$mod,$type,$mdver) = unpack("v c6 v",$buf); - -if ($ret != 30001) { # 0x7531 - print "Invalid answer. It isn't an athena server or it is a too old version.\n"; - exit(6); -} - -my(@stype) = (); -foreach $i(0..3) { - push @stype,(("login","char","inter","map")[$i]) if( $type & (1<<$i) ); -} -print " ".join("/",@stype)." server [$server:$port].\n"; -printf " Athena version %s-%d.%d", ("stable","dev")[$dev], $maver,$miver; -printf " revision %d",$rev if $rev; -printf "%s%d\n",("","-mod")[$mod],$mdver; - -exit(0); diff --git a/vcproj-10/ladmin.vcxproj b/vcproj-10/ladmin.vcxproj deleted file mode 100644 index 4865159bf..000000000 --- a/vcproj-10/ladmin.vcxproj +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-E8E9646175AF} - ladmin - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\ - $(ProjectName)\$(Configuration)\ - true - ..\ - $(ProjectName)\$(Configuration)\ - false - - - - Disabled - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;MINICORE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - false - false - true - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - - - /FIXED:NO %(AdditionalOptions) - libcmtd.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)ladmin.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;MINICORE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - true - MultiThreaded - false - - - - - Level3 - ProgramDatabase - CompileAsC - - - libcmt.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)ladmin.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)$(ProjectName).pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index e8d91e186..6570350ac 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -153,7 +153,6 @@ - diff --git a/vcproj-10/login-server_txt.vcxproj b/vcproj-10/login-server_txt.vcxproj index c82e5e30d..09bb22a38 100644 --- a/vcproj-10/login-server_txt.vcxproj +++ b/vcproj-10/login-server_txt.vcxproj @@ -144,7 +144,6 @@ - diff --git a/vcproj-6/login-server_sql.dsp b/vcproj-6/login-server_sql.dsp index 7348d3361..0a52185e1 100644 --- a/vcproj-6/login-server_sql.dsp +++ b/vcproj-6/login-server_sql.dsp @@ -207,10 +207,6 @@ SOURCE=..\src\login\account_sql.c # End Source File # Begin Source File -SOURCE=..\src\login\admin.c -# End Source File -# Begin Source File - SOURCE=..\src\login\ipban.h # End Source File # Begin Source File diff --git a/vcproj-6/login-server_txt.dsp b/vcproj-6/login-server_txt.dsp index ee54b5b76..ecb083269 100644 --- a/vcproj-6/login-server_txt.dsp +++ b/vcproj-6/login-server_txt.dsp @@ -195,10 +195,6 @@ SOURCE=..\src\login\account_txt.c # End Source File # Begin Source File -SOURCE=..\src\login\admin.c -# End Source File -# Begin Source File - SOURCE=..\src\login\ipban.h # End Source File # Begin Source File diff --git a/vcproj-7.1/login-server_sql.vcproj b/vcproj-7.1/login-server_sql.vcproj index 8c5001fa6..a86f8246b 100644 --- a/vcproj-7.1/login-server_sql.vcproj +++ b/vcproj-7.1/login-server_sql.vcproj @@ -150,9 +150,6 @@ - - diff --git a/vcproj-7.1/login-server_txt.vcproj b/vcproj-7.1/login-server_txt.vcproj index 8181e4fd5..24fc249d7 100644 --- a/vcproj-7.1/login-server_txt.vcproj +++ b/vcproj-7.1/login-server_txt.vcproj @@ -153,9 +153,6 @@ - - diff --git a/vcproj-8/ladmin.vcproj b/vcproj-8/ladmin.vcproj deleted file mode 100644 index bcca6c327..000000000 --- a/vcproj-8/ladmin.vcproj +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-8/login-server_sql.vcproj b/vcproj-8/login-server_sql.vcproj index e47f77eeb..2509f8f29 100644 --- a/vcproj-8/login-server_sql.vcproj +++ b/vcproj-8/login-server_sql.vcproj @@ -208,10 +208,6 @@ RelativePath="..\src\login\account_sql.c" >
    - - diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index 50508f5bd..35cf7639c 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -203,10 +203,6 @@ RelativePath="..\src\login\account_txt.c" > - - diff --git a/vcproj-9/ladmin.vcproj b/vcproj-9/ladmin.vcproj deleted file mode 100644 index c17252b73..000000000 --- a/vcproj-9/ladmin.vcproj +++ /dev/null @@ -1,290 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-9/login-server_sql.vcproj b/vcproj-9/login-server_sql.vcproj index f15a9cd64..4adaa8d34 100644 --- a/vcproj-9/login-server_sql.vcproj +++ b/vcproj-9/login-server_sql.vcproj @@ -213,10 +213,6 @@ RelativePath="..\src\login\account_sql.c" > - - diff --git a/vcproj-9/login-server_txt.vcproj b/vcproj-9/login-server_txt.vcproj index 82ac7669c..6c0faa66c 100644 --- a/vcproj-9/login-server_txt.vcproj +++ b/vcproj-9/login-server_txt.vcproj @@ -208,10 +208,6 @@ RelativePath="..\src\login\account_txt.c" > - - -- cgit v1.2.3-70-g09d2 From bd57369de85d0249cdc3e21102d5197c6dbb646a Mon Sep 17 00:00:00 2001 From: ai4rei Date: Wed, 16 Feb 2011 19:36:51 +0000 Subject: * Updated configure/make scripts to resolve various issues. - Added detection whether or not -fPIC switch is required when compiling shared objects (plug-ins) to resolve compile issues on 64-bit platforms (topic:208746). - Native 'strnlen' implementations are now detected and disable the one in strlib (bugreport:1261). - Define 'DB_MANUAL_CAST_TO_UNION' is now set when necessary (bugreport:1261). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14708 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 + Makefile.in | 18 ++- configure | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++- configure.in | 107 +++++++++++++++++ src/common/strlib.c | 3 +- src/common/strlib.h | 6 +- 6 files changed, 469 insertions(+), 9 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 0824bc005..5adc8f7fc 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,10 @@ Date Added +2011/02/16 + * Updated configure/make scripts to resolve various issues. [Ai4rei] + - Added detection whether or not -fPIC switch is required when compiling shared objects (plug-ins) to resolve compile issues on 64-bit platforms (topic:208746). + - Native 'strnlen' implementations are now detected and disable the one in strlib (bugreport:1261). + - Define 'DB_MANUAL_CAST_TO_UNION' is now set when necessary (bugreport:1261). 2011/02/15 * Added support for client GM command /check (related r12076). [Ai4rei] 2011/02/14 diff --git a/Makefile.in b/Makefile.in index 5b51affa4..667b79fbc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters plugins import save + ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters import save SQL_DEPENDS=common_sql login_sql char_sql map_sql import save COMMON_SQL_DEPENDS= LOGIN_SQL_DEPENDS=common_sql @@ -10,7 +10,7 @@ ifeq ($(HAVE_MYSQL),yes) MAP_SQL_DEPENDS=common_sql CONVERTERS_DEPENDS=common_sql else - ALL_DEPENDS=common login char map tools plugins import save + ALL_DEPENDS=common login char map tools import save SQL_DEPENDS=needs_mysql COMMON_SQL_DEPENDS=needs_mysql LOGIN_SQL_DEPENDS=needs_mysql @@ -19,6 +19,14 @@ else CONVERTERS_DEPENDS=needs_mysql endif +WITH_PLUGINS=@WITH_PLUGINS@ +ifeq ($(WITH_PLUGINS),yes) + ALL_DEPENDS+=plugins + PLUGIN_DEPENDS=common +else + PLUGIN_DEPENDS=no_plugins +endif + ##################################################################### .PHONY: txt sql conf \ common common_sql \ @@ -66,7 +74,7 @@ tools: converters: $(CONVERTERS_DEPENDS) @$(MAKE) -C src/txt-converter -plugins addons: common +plugins addons: $(PLUGIN_DEPENDS) @$(MAKE) -C src/plugins import: @@ -129,6 +137,10 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 +no_plugins: + @echo "Plugins disabled by the configure script" + @exit 1 + ##################################################################### # TODO diff --git a/configure b/configure index 3a5c7274c..0412b30eb 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 13486 . +# From configure.in Revision: 14708 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -311,7 +311,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP WITH_PLUGINS EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1333,7 +1333,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_files="$ac_config_files Makefile src/common/Makefile" - ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" + ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" @@ -3257,6 +3257,240 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: checking whether $CC supports -fPIC" >&5 +echo $ECHO_N "checking whether $CC supports -fPIC... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fPIC" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + compiler_supports_pic="yes" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + compiler_supports_pic="no" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$OLD_CFLAGS" + + +# +# -shared needs position independent code; some platforms emit it +# always, others need -fPIC +# +echo "$as_me:$LINENO: checking whether $CC needs -fPIC for shared objects" >&5 +echo $ECHO_N "checking whether $CC needs -fPIC for shared objects... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -shared" +WITH_PLUGINS="yes" +cat >conftest.$ac_ext <<_ACEOF + + int foo(void) + { + return 0; + } + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + if test "$compiler_supports_pic" = "yes" ; then + # Verify if -shared really fails due to lack of -fPIC or something else + CFLAGS="$CFLAGS -fPIC" + cat >conftest.$ac_ext <<_ACEOF + + int foo(void) + { + return 0; + } + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + CFLAGS="$OLD_CFLAGS -fPIC" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no, but fails for another reason" >&5 +echo "${ECHO_T}no, but fails for another reason" >&6 + { { echo "$as_me:$LINENO: error: compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" >&5 +echo "$as_me: error: compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" >&2;} + { (exit 1); exit 1; }; } + + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + else + # Disable compilation of plugins (optional), so 'make all' does not fail + echo "$as_me:$LINENO: result: yes, but unsupported" >&5 +echo "${ECHO_T}yes, but unsupported" >&6 + { echo "$as_me:$LINENO: compiler is unable to generate position independent code, disabled plugins (optional)" >&5 +echo "$as_me: compiler is unable to generate position independent code, disabled plugins (optional)" >&6;} + WITH_PLUGINS="no" + fi + + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + + +# +# DB_MANUAL_CAST_TO_UNION +# +echo "$as_me:$LINENO: checking whether $CC is able to typecast to union" >&5 +echo $ECHO_N "checking whether $CC is able to typecast to union... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF + + typedef union Foonion + { + int i; + unsigned int ui; + const char* s; + } + Foonion; + + int bar(Foonion onion) + { + return onion.i; + } + + int foo(void) + { + int i = 0; + + return bar(((Foonion)(int)i)); + } + +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + ############################################################################### # Check for libraries and header files. @@ -3362,6 +3596,104 @@ fi +# +# strnlen - string length with upper scan bound +# +echo "$as_me:$LINENO: checking for strnlen" >&5 +echo $ECHO_N "checking for strnlen... $ECHO_C" >&6 +if test "${ac_cv_func_strnlen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define strnlen to an innocuous variant, in case declares strnlen. + For example, HP-UX 11i declares gettimeofday. */ +#define strnlen innocuous_strnlen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char strnlen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef strnlen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strnlen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_strnlen) || defined (__stub___strnlen) +choke me +#else +char (*f) () = strnlen; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != strnlen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_strnlen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_strnlen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_strnlen" >&5 +echo "${ECHO_T}$ac_cv_func_strnlen" >&6 +if test $ac_cv_func_strnlen = yes; then + CFLAGS="$CFLAGS -DHAVE_STRNLEN" +fi + + # # Memory manager @@ -5725,6 +6057,7 @@ s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t +s,@WITH_PLUGINS@,$WITH_PLUGINS,;t t s,@EGREP@,$EGREP,;t t s,@MYSQL_CONFIG_HOME@,$MYSQL_CONFIG_HOME,;t t s,@HAVE_MYSQL@,$HAVE_MYSQL,;t t diff --git a/configure.in b/configure.in index bf3c97374..afc35ee3a 100644 --- a/configure.in +++ b/configure.in @@ -339,6 +339,108 @@ AC_COMPILE_IFELSE( ) +AC_MSG_CHECKING([whether $CC supports -fPIC]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fPIC" +AC_COMPILE_IFELSE( + [int foo;], + [ + AC_MSG_RESULT([yes]) + compiler_supports_pic="yes" + ], + [ + AC_MSG_RESULT([no]) + compiler_supports_pic="no" + ] +) +CFLAGS="$OLD_CFLAGS" + + +# +# -shared needs position independent code; some platforms emit it +# always, others need -fPIC +# +AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -shared" +WITH_PLUGINS="yes" +AC_LINK_IFELSE( + [ + int foo(void) + { + return 0; + } + ], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ], + [ + if test "$compiler_supports_pic" = "yes" ; then + # Verify if -shared really fails due to lack of -fPIC or something else + CFLAGS="$CFLAGS -fPIC" + AC_LINK_IFELSE( + [ + int foo(void) + { + return 0; + } + ], + [ + AC_MSG_RESULT([yes]) + CFLAGS="$OLD_CFLAGS -fPIC" + ], + [ + AC_MSG_RESULT([no, but fails for another reason]) + AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping]) + ] + ) + else + # Disable compilation of plugins (optional), so 'make all' does not fail + AC_MSG_RESULT([yes, but unsupported]) + AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)]) + WITH_PLUGINS="no" + fi + ] +) +AC_SUBST([WITH_PLUGINS]) + + +# +# DB_MANUAL_CAST_TO_UNION +# +AC_MSG_CHECKING([whether $CC is able to typecast to union]) +AC_COMPILE_IFELSE( + [ + typedef union Foonion + { + int i; + unsigned int ui; + const char* s; + } + Foonion; + + int bar(Foonion onion) + { + return onion.i; + } + + int foo(void) + { + int i = 0; + + return bar(((Foonion)(int)i)); + } + ], + [ + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION" + ] +) + ############################################################################### # Check for libraries and header files. @@ -351,6 +453,11 @@ AC_COMPILE_IFELSE( AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"]) +# +# strnlen - string length with upper scan bound +# +AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"]) + # # Memory manager diff --git a/src/common/strlib.c b/src/common/strlib.c index a0cba906c..66f281ffc 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -8,7 +8,6 @@ #include #include -#include #include @@ -241,7 +240,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) } #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char* string, size_t maxlen) diff --git a/src/common/strlib.h b/src/common/strlib.h index 23f1e191a..3f4f984cf 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -9,6 +9,10 @@ #endif #include +#define __USE_GNU // required to enable strnlen on some platforms +#include +#undef __USE_GNU + char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); int jmemescapecpy (char* pt, const char* spt, int size); @@ -24,7 +28,7 @@ const char *stristr(const char *haystack, const char *needle); char* _strtok_r(char* s1, const char* s2, char** lasts); #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) size_t strnlen (const char* string, size_t maxlen); #endif -- cgit v1.2.3-70-g09d2 From a1542fae523a304cb0d67c2b29b9a31703487628 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 20 Mar 2011 11:09:57 +0000 Subject: * Updates the to configure script. - Added check, whether or not '-Wno-pointer-sign' can actually be used (caused warnings with g++). - Math library is no longer considered required, when math functions are available without it (made configure fail on platforms, where no separate math library is present). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14749 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++ configure | 135 +++++++++++++++++++++++++++++++++++++++++++++------- configure.in | 21 +++++++- 3 files changed, 141 insertions(+), 19 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7cbdfd9f4..6d7f77baa 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,9 @@ Date Added +2011/03/20 + * Updates the to configure script. [Ai4rei] + - Added check, whether or not '-Wno-pointer-sign' can actually be used (caused warnings with g++). + - Math library is no longer considered required, when math functions are available without it (made configure fail on platforms, where no separate math library is present). 2011/03/19 * Removed leftovers of old charcommand config (follow-up to r13403). [Gepard] * Added check to ensure character `rename` status will be saved if changed. [Gepard] diff --git a/configure b/configure index 0412b30eb..5da692cf7 100755 --- a/configure +++ b/configure @@ -3196,8 +3196,57 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - echo "$as_me:$LINENO: result: yes" >&5 + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + echo "$as_me:$LINENO: checking whether $CC can actually use -Wno-pointer-sign" >&5 +echo $ECHO_N "checking whether $CC can actually use -Wno-pointer-sign... $ECHO_C" >&6 + # This option causes warnings in C++ mode + # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything + CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign" + cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 + CFLAGS="$OLD_CFLAGS -Wno-pointer-sign" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -4702,14 +4751,13 @@ fi # # math library (required) # - -echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 -echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6 -if test "${ac_cv_lib_m_sqrt+set}" = set; then +echo "$as_me:$LINENO: checking for library containing sqrt" >&5 +echo $ECHO_N "checking for library containing sqrt... $ECHO_C" >&6 +if test "${ac_cv_search_sqrt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" + ac_func_search_save_LIBS=$LIBS +ac_cv_search_sqrt=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4754,25 +4802,78 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lib_m_sqrt=yes + ac_cv_search_sqrt="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_m_sqrt=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 -echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6 -if test $ac_cv_lib_m_sqrt = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBM 1 +if test "$ac_cv_search_sqrt" = no; then + for ac_lib in m; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ - LIBS="-lm $LIBS" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sqrt (); +int +main () +{ +sqrt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_sqrt="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_sqrt" >&5 +echo "${ECHO_T}$ac_cv_search_sqrt" >&6 +if test "$ac_cv_search_sqrt" != no; then + test "$ac_cv_search_sqrt" = "none required" || LIBS="$ac_cv_search_sqrt $LIBS" else { { echo "$as_me:$LINENO: error: math library not found... stopping" >&5 diff --git a/configure.in b/configure.in index afc35ee3a..c659ad142 100644 --- a/configure.in +++ b/configure.in @@ -318,7 +318,24 @@ OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wno-pointer-sign" AC_COMPILE_IFELSE( [int foo;], - [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([yes]) + AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign]) + # This option causes warnings in C++ mode + # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything + CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign" + AC_COMPILE_IFELSE( + [int foo;], + [ + AC_MSG_RESULT([yes]) + CFLAGS="$OLD_CFLAGS -Wno-pointer-sign" + ], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ] + ) + ], [ AC_MSG_RESULT([no]) CFLAGS="$OLD_CFLAGS" @@ -555,7 +572,7 @@ AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please speci # # math library (required) # -AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])]) +AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])]) # -- cgit v1.2.3-70-g09d2 From 0f0579e6b5d547fd9be3544734c870633636816e Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 5 Apr 2011 11:11:36 +0000 Subject: * Moved detection of monotonic clock support to the configure script, which also checks, whether or not it actually works (bugreport:1003, related r11912 and r11983). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14767 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + configure | 153 +++++++++++++++++++++++++++++++++++++++++++++------- configure.in | 42 ++++++++++++++- src/common/timer.c | 2 +- 4 files changed, 177 insertions(+), 21 deletions(-) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index f7ca75961..aebf857ad 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,7 @@ Date Added 2011/04/05 + * Moved detection of monotonic clock support to the configure script, which also checks, whether or not it actually works (bugreport:1003, related r11912 and r11983). [Ai4rei] * Paying and obtaining Zeny (pc_payzeny/pc_getzeny) no longer silently reverses the effect for negative amounts, that is, getting Zeny instead of paying up and vice versa (since r8273, related r8072). [Ai4rei] 2011/03/29 * Added TargetName values to VS2010 project files to prevent MSB8012 warnings (follow-up to r14562). [Gepard] diff --git a/configure b/configure index 5da692cf7..9200993f7 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 14708 . +# From configure.in Revision: 14767 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -4884,16 +4884,15 @@ fi # -# clock_gettime (rt on Debian) +# clock_gettime (optional, rt on Debian) # - -echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 -echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6 -if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then +echo "$as_me:$LINENO: checking for library containing clock_gettime" >&5 +echo $ECHO_N "checking for library containing clock_gettime... $ECHO_C" >&6 +if test "${ac_cv_search_clock_gettime+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lrt $LIBS" + ac_func_search_save_LIBS=$LIBS +ac_cv_search_clock_gettime=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4938,28 +4937,146 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lib_rt_clock_gettime=yes + ac_cv_search_clock_gettime="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_rt_clock_gettime=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5 -echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6 -if test $ac_cv_lib_rt_clock_gettime = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBRT 1 +if test "$ac_cv_search_clock_gettime" = no; then + for ac_lib in rt; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ - LIBS="-lrt $LIBS" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char clock_gettime (); +int +main () +{ +clock_gettime (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_clock_gettime="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_clock_gettime" >&5 +echo "${ECHO_T}$ac_cv_search_clock_gettime" >&6 +if test "$ac_cv_search_clock_gettime" != no; then + test "$ac_cv_search_clock_gettime" = "none required" || LIBS="$ac_cv_search_clock_gettime $LIBS" + +fi + + + +# +# CLOCK_MONOTONIC clock for clock_gettime +# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix +# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD +# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be +# checked but some systems define them even when they do not support it +# (ref. bugreport:1003). +# +if test "$ac_cv_search_clock_gettime" != "no" ; then + echo "$as_me:$LINENO: checking whether CLOCK_MONOTONIC is supported and works" >&5 +echo $ECHO_N "checking whether CLOCK_MONOTONIC is supported and works... $ECHO_C" >&6 + if test "$cross_compiling" = yes; then + + echo "$as_me:$LINENO: result: guessing no" >&5 +echo "${ECHO_T}guessing no" >&6 + + +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + + int main(int argc, char** argv) + { + struct timespec tval; + return clock_gettime(CLOCK_MONOTONIC, &tval); + } + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK" + +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) + + # either it failed to compile (CLOCK_MONOTONIC undefined) + # or clock_gettime has returned a non-zero value + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi # diff --git a/configure.in b/configure.in index c659ad142..6407cda1b 100644 --- a/configure.in +++ b/configure.in @@ -576,9 +576,47 @@ AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stoppin # -# clock_gettime (rt on Debian) +# clock_gettime (optional, rt on Debian) # -AC_CHECK_LIB([rt], [clock_gettime]) +AC_SEARCH_LIBS([clock_gettime], [rt]) + + +# +# CLOCK_MONOTONIC clock for clock_gettime +# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix +# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD +# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be +# checked but some systems define them even when they do not support it +# (ref. bugreport:1003). +# +if test "$ac_cv_search_clock_gettime" != "no" ; then + AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works]) + AC_RUN_IFELSE( + [ + #include + #include + #include + + int main(int argc, char** argv) + { + struct timespec tval; + return clock_gettime(CLOCK_MONOTONIC, &tval); + } + ], + [ + AC_MSG_RESULT([yes]) + CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK" + ], + [ + # either it failed to compile (CLOCK_MONOTONIC undefined) + # or clock_gettime has returned a non-zero value + AC_MSG_RESULT([no]) + ], + [ + AC_MSG_RESULT([guessing no]) + ] + ) +fi # diff --git a/src/common/timer.c b/src/common/timer.c index 190e41eaf..86e148ee3 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -146,7 +146,7 @@ static unsigned int tick(void) // return (unsigned int)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); // -#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) /* posix compliant */) || (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 500005 /* FreeBSD >= 5.1.0 */) +#elif defined(HAVE_MONOTONIC_CLOCK) struct timespec tval; clock_gettime(CLOCK_MONOTONIC, &tval); return tval.tv_sec * 1000 + tval.tv_nsec / 1000000; -- cgit v1.2.3-70-g09d2 From a9492cf82f696af37f3258e19d7767f705708e63 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Mon, 27 Jun 2011 01:47:06 +0000 Subject: * Added common/random and 3rdparty/mt19937ar to project files, makefiles and configure script. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14870 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/mt19937ar/Makefile.in | 24 ++++++++++++++++++++++++ Changelog-Trunk.txt | 2 ++ Makefile.in | 32 +++++++++++++++++++++----------- configure | 4 +++- configure.in | 1 + src/char/Makefile.in | 21 ++++++++++++++------- src/char_sql/Makefile.in | 21 ++++++++++++++------- src/common/Makefile.in | 25 +++++++++++++++++-------- src/login/Makefile.in | 33 ++++++++++++++++++++++----------- src/map/Makefile.in | 30 ++++++++++++++++++++---------- vcproj-10/char-server_sql.vcxproj | 8 ++++++-- vcproj-10/char-server_txt.vcxproj | 8 ++++++-- vcproj-10/login-server_sql.vcxproj | 8 ++++++-- vcproj-10/login-server_txt.vcxproj | 8 ++++++-- vcproj-10/map-server_sql.vcxproj | 8 ++++++-- vcproj-10/map-server_txt.vcxproj | 8 ++++++-- vcproj-6/char-server_sql.dsp | 24 ++++++++++++++++++++++-- vcproj-6/char-server_txt.dsp | 24 ++++++++++++++++++++++-- vcproj-6/login-server_sql.dsp | 24 ++++++++++++++++++++++-- vcproj-6/login-server_txt.dsp | 24 ++++++++++++++++++++++-- vcproj-6/map-server_sql.dsp | 24 ++++++++++++++++++++++-- vcproj-6/map-server_txt.dsp | 24 ++++++++++++++++++++++-- vcproj-7.1/char-server_sql.vcproj | 20 ++++++++++++++++++-- vcproj-7.1/char-server_txt.vcproj | 20 ++++++++++++++++++-- vcproj-7.1/login-server_sql.vcproj | 20 ++++++++++++++++++-- vcproj-7.1/login-server_txt.vcproj | 20 ++++++++++++++++++-- vcproj-7.1/map-server_sql.vcproj | 20 ++++++++++++++++++-- vcproj-7.1/map-server_txt.vcproj | 20 ++++++++++++++++++-- vcproj-8/char-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-8/char-server_txt.vcproj | 24 ++++++++++++++++++++++-- vcproj-8/login-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-8/login-server_txt.vcproj | 24 ++++++++++++++++++++++-- vcproj-8/map-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-8/map-server_txt.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/char-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/char-server_txt.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/login-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/login-server_txt.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/map-server_sql.vcproj | 24 ++++++++++++++++++++++-- vcproj-9/map-server_txt.vcproj | 24 ++++++++++++++++++++++-- 40 files changed, 678 insertions(+), 115 deletions(-) create mode 100644 3rdparty/mt19937ar/Makefile.in (limited to 'configure') diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in new file mode 100644 index 000000000..7cae3140b --- /dev/null +++ b/3rdparty/mt19937ar/Makefile.in @@ -0,0 +1,24 @@ + +MT19937AR_OBJ = mt19937ar.o +MT19937AR_H = mt19937ar.h + +@SET_MAKE@ + +##################################################################### +.PHONY : all clean help + +all: $(MT19937AR_OBJ) + +clean: + rm -rf *.o + +help: + @echo "possible targets are 'all' 'clean' 'help'" + @echo "'all' - builds $(MT19937AR_OBJ)" + @echo "'clean' - deletes $(MT19937AR_OBJ)" + @echo "'help' - outputs this message" + +##################################################################### + +%.o: %.c $(MT19937AR_H) + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 65cc02c9d..02b9688fd 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/06/27 + *Added common/random and 3rdparty/mt19937ar to project files, makefiles and configure script. [FlavioJS] 2011/06/26 * Fixed a signed literal being assigned to an unsigned variable and other minor cleanups in malloc (bugreport:4765). [Ai4rei] * Fixed @mobinfo displaying mvp rewards with 'AegisName' although normal drops use 'Name' item db column (bugreport:4981, follow up to r6346). [Ai4rei] diff --git a/Makefile.in b/Makefile.in index 667b79fbc..ea3106317 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,15 +2,15 @@ HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters import save - SQL_DEPENDS=common_sql login_sql char_sql map_sql import save - COMMON_SQL_DEPENDS= - LOGIN_SQL_DEPENDS=common_sql - CHAR_SQL_DEPENDS=common_sql - MAP_SQL_DEPENDS=common_sql + ALL_DEPENDS=mt19937ar common common_sql login login_sql char char_sql map map_sql tools converters import save + SQL_DEPENDS=mt19937ar common_sql login_sql char_sql map_sql import save + COMMON_SQL_DEPENDS=mt19937ar + LOGIN_SQL_DEPENDS=mt19937ar common_sql + CHAR_SQL_DEPENDS=mt19937ar common_sql + MAP_SQL_DEPENDS=mt19937ar common_sql CONVERTERS_DEPENDS=common_sql else - ALL_DEPENDS=common login char map tools import save + ALL_DEPENDS=mt19937ar common login char map tools import save SQL_DEPENDS=needs_mysql COMMON_SQL_DEPENDS=needs_mysql LOGIN_SQL_DEPENDS=needs_mysql @@ -18,6 +18,10 @@ else MAP_SQL_DEPENDS=needs_mysql CONVERTERS_DEPENDS=needs_mysql endif +COMMON_TXT_DEPENDS=mt19937ar +LOGIN_TXT_DEPENDS=mt19937ar common +CHAR_TXT_DEPENDS=mt19937ar common +MAP_TXT_DEPENDS=mt19937ar common WITH_PLUGINS=@WITH_PLUGINS@ ifeq ($(WITH_PLUGINS),yes) @@ -30,6 +34,7 @@ endif ##################################################################### .PHONY: txt sql conf \ common common_sql \ + mt19937ar \ login login_sql \ char char_sql \ map map_sql \ @@ -44,25 +49,28 @@ sql: $(SQL_DEPENDS) conf: import save -common: +common: $(COMMON_TXT_DEPENDS) @$(MAKE) -C src/common txt common_sql: $(COMMON_SQL_DEPENDS) @$(MAKE) -C src/common sql -login: common +mt19937ar: + @$(MAKE) -C 3rdparty/mt19937ar + +login: $(LOGIN_TXT_DEPENDS) @$(MAKE) -C src/login txt login_sql: $(LOGIN_SQL_DEPENDS) @$(MAKE) -C src/login sql -char: common +char: $(CHAR_TXT_DEPENDS) @$(MAKE) -C src/char char_sql: $(CHAR_SQL_DEPENDS) @$(MAKE) -C src/char_sql -map: common +map: $(MAP_TXT_DEPENDS) @$(MAKE) -C src/map txt map_sql: $(MAP_SQL_DEPENDS) @@ -97,6 +105,7 @@ save: clean: @$(MAKE) -C src/common $@ + @$(MAKE) -C 3rdparty/mt19937ar $@ @$(MAKE) -C src/login $@ @$(MAKE) -C src/char $@ @$(MAKE) -C src/char_sql $@ @@ -110,6 +119,7 @@ help: @echo "possible targets are:" @echo "'common' - builds object files used in TXT servers" @echo "'common_sql' - builds object files used in SQL servers" + @echo "'mt19937ar' - builds object file of Mersenne Twister MT19937" @echo "'login' - builds login server (TXT version)" @echo "'login_sql' - builds login server (SQL version)" @echo "'char' - builds char server (TXT version)" diff --git a/configure b/configure index 9200993f7..fbc5e3a11 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 14767 . +# From configure.in Revision: 14870 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -1333,6 +1333,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_files="$ac_config_files Makefile src/common/Makefile" + ac_config_files="$ac_config_files 3rdparty/mt19937ar/Makefile" + ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" diff --git a/configure.in b/configure.in index 6407cda1b..197a4a4ed 100644 --- a/configure.in +++ b/configure.in @@ -6,6 +6,7 @@ AC_REVISION($Revision$) AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) +AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile]) AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 359e19b01..ba8f4fe64 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -3,12 +3,16 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o + ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/random.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h + ../common/mapindex.h ../common/ers.h ../common/random.h + +MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o +MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h +MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar CHAR_OBJ = obj_txt/char.o obj_txt/inter.o obj_txt/int_party.o obj_txt/int_guild.o \ obj_txt/int_storage.o obj_txt/int_status.o obj_txt/int_pet.o obj_txt/int_homun.o @@ -21,8 +25,8 @@ CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_status.h int_p all: char-server -char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ +char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) + @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ clean: rm -rf *.o obj_txt ../../char-server@EXEEXT@ @@ -39,9 +43,12 @@ help: obj_txt: -mkdir obj_txt -obj_txt/%.o: %.c $(CHAR_H) $(COMMON_H) - @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_txt/%.o: %.c $(CHAR_H) $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# missing common object files +# missing object files ../common/obj_all/%.o: @$(MAKE) -C ../common txt + +MT19937AR_OBJ: + @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in index 82c0a7c3f..a8cf8e08c 100644 --- a/src/char_sql/Makefile.in +++ b/src/char_sql/Makefile.in @@ -3,12 +3,16 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o + ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/random.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h + ../common/mapindex.h ../common/ers.h ../common/random.h + +MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o +MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h +MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_H = ../common/sql.h @@ -19,7 +23,7 @@ CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homu HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) + CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) else CHAR_SERVER_SQL_DEPENDS=needs_mysql endif @@ -32,7 +36,7 @@ endif all: char-server_sql char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @MYSQL_LIBS@ + @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@ clean: rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ @@ -53,12 +57,15 @@ needs_mysql: obj_sql: -mkdir obj_sql -obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) - @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# missing common object files +# missing object files ../common/obj_all/%.o: @$(MAKE) -C ../common sql ../common/obj_sql/%.o: @$(MAKE) -C ../common sql + +MT19937AR_OBJ: + @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/common/Makefile.in b/src/common/Makefile.in index bda9e1911..37606dde2 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -2,15 +2,19 @@ COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/plugins.o obj_all/lock.o \ obj_all/nullpo.o obj_all/malloc.o obj_all/showmsg.o obj_all/strlib.o obj_all/utils.o \ obj_all/grfio.o obj_all/mapindex.o obj_all/ers.o obj_all/md5calc.o \ - obj_all/minicore.o obj_all/minisocket.o obj_all/minimalloc.o + obj_all/minicore.o obj_all/minisocket.o obj_all/minimalloc.o obj_all/random.o COMMON_H = svnversion.h mmo.h plugin.h version.h \ core.h socket.h timer.h db.h plugins.h lock.h \ nullpo.h malloc.h showmsg.h strlib.h utils.h \ - grfio.h mapindex.h ers.h md5calc.h + grfio.h mapindex.h ers.h md5calc.h random.h COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h +MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o +MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h +MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar + HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) ALL_DEPENDS=txt sql @@ -19,6 +23,7 @@ else ALL_TARGET=txt SQL_DEPENDS=needs_mysql endif +TXT_DEPENDS=common @SET_MAKE@ @@ -27,7 +32,7 @@ endif all: $(ALL_DEPENDS) -txt: common +txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) @@ -54,16 +59,16 @@ obj_all: obj_sql: -mkdir obj_sql -common: obj_all $(COMMON_OBJ) +common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) common_sql: obj_sql $(COMMON_SQL_OBJ) -obj_all/%.o: %.c $(COMMON_H) - @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_all/mini%.o: %.c $(COMMON_H) - @CC@ @CFLAGS@ -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< @@ -80,3 +85,7 @@ else svnversion.h: @printf "\n" > svnversion.h endif + +# missing object files +MT19937AR_OBJ: + @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/login/Makefile.in b/src/login/Makefile.in index c153d95b3..fa1933964 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -3,16 +3,20 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ ../common/obj_all/strlib.o ../common/obj_all/grfio.o ../common/obj_all/mapindex.o \ - ../common/obj_all/ers.o ../common/obj_all/md5calc.o + ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_all/random.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ ../common/grfio.h ../common/mapindex.h \ - ../common/ers.h ../common/md5calc.h + ../common/ers.h ../common/md5calc.h ../common/random.h COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_SQL_H = ../common/sql.h +MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o +MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h +MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar + LOGIN_OBJ = login.o LOGIN_TXT_OBJ = $(LOGIN_OBJ:%=obj_txt/%) \ obj_txt/account_txt.o obj_txt/ipban_txt.o obj_txt/loginlog_txt.o @@ -22,10 +26,11 @@ LOGIN_H = login.h account.h ipban.h loginlog.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) + LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif +LOGIN_SERVER_TXT_DEPENDS=obj_txt $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @SET_MAKE@ @@ -63,19 +68,25 @@ obj_sql: test -d obj_sql || mkdir obj_sql #executables -login-server: $(LOGIN_TXT_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_TXT_OBJ) $(COMMON_OBJ) @LIBS@ +login-server: $(LOGIN_SERVER_TXT_DEPENDS) + @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @MYSQL_LIBS@ + @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@ # login object files -obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) - @CC@ @CFLAGS@ -DWITH_TXT @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_TXT @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) - @CC@ @CFLAGS@ -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# missing common object files +# missing object files ../common/obj_all/%.o: + @$(MAKE) -C ../common txt + +../common/obj_sql/%.o: @$(MAKE) -C ../common sql + +MT19937AR_OBJ: + @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 7070a0a9d..09e92dde2 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -3,16 +3,22 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ ../common/obj_all/nullpo.o ../common/obj_all/malloc.o ../common/obj_all/showmsg.o \ ../common/obj_all/utils.o ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/md5calc.o + ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/md5calc.o \ + ../common/obj_all/random.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ ../common/utils.h ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h ../common/md5calc.h + ../common/mapindex.h ../common/ers.h ../common/md5calc.h \ + ../common/random.h COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_SQL_H = ../common/sql.h +MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o +MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h +MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar + MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \ npc_chat.o chat.o path.o itemdb.o mob.o script.o \ storage.o skill.o atcommand.o battle.o battleground.o \ @@ -38,6 +44,7 @@ else ALL_TARGET=txt SQL_DEPENDS=needs_mysql endif +TXT_DEPENDS=map-server HAVE_PCRE=@HAVE_PCRE@ ifeq ($(HAVE_PCRE),yes) @@ -53,7 +60,7 @@ endif all: $(ALL_DEPENDS) -txt: map-server +txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) @@ -87,21 +94,24 @@ obj_sql: # executables map-server: obj_txt $(MAP_TXT_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_TXT_OBJ) $(COMMON_OBJ) @LIBS@ @PCRE_LIBS@ + @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ @PCRE_LIBS@ map-server_sql: obj_sql $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ + @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files -obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) - @CC@ @CFLAGS@ $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) - @CC@ @CFLAGS@ $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# missing common object files +# missing object files ../common/obj_all/%.o: @$(MAKE) -C ../common txt ../common/obj_sql/%.o: @$(MAKE) -C ../common sql + +MT19937AR_OBJ: + @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index aa3b130ba..f1a8e5363 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true true - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) true MultiThreaded @@ -126,6 +126,7 @@ + @@ -137,6 +138,7 @@ + @@ -157,6 +159,7 @@ + @@ -165,6 +168,7 @@ + diff --git a/vcproj-10/char-server_txt.vcxproj b/vcproj-10/char-server_txt.vcxproj index 2ecbb6ba5..3d73a14ae 100644 --- a/vcproj-10/char-server_txt.vcxproj +++ b/vcproj-10/char-server_txt.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) false false @@ -93,7 +93,7 @@ true true true - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) true MultiThreaded @@ -140,11 +140,13 @@ + + @@ -166,12 +168,14 @@ + + diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index 0bd2c5717..43dbeb351 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_SQL;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true true - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_SQL;%(PreprocessorDefinitions) true MultiThreaded @@ -145,6 +145,7 @@ + @@ -152,6 +153,7 @@ + @@ -166,12 +168,14 @@ + + diff --git a/vcproj-10/login-server_txt.vcxproj b/vcproj-10/login-server_txt.vcxproj index 138e3ee5e..f121af46a 100644 --- a/vcproj-10/login-server_txt.vcxproj +++ b/vcproj-10/login-server_txt.vcxproj @@ -49,7 +49,7 @@ Disabled - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_TXT;%(PreprocessorDefinitions) false false @@ -92,7 +92,7 @@ true true true - ..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_TXT;%(PreprocessorDefinitions) true MultiThreaded @@ -137,12 +137,14 @@ + + @@ -157,11 +159,13 @@ + + diff --git a/vcproj-10/map-server_sql.vcxproj b/vcproj-10/map-server_sql.vcxproj index 555015166..6fcb16f0f 100644 --- a/vcproj-10/map-server_sql.vcxproj +++ b/vcproj-10/map-server_sql.vcxproj @@ -50,7 +50,7 @@ Disabled - ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) false false @@ -93,7 +93,7 @@ true true true - ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) true MultiThreaded @@ -125,6 +125,7 @@ + @@ -138,6 +139,7 @@ + @@ -181,6 +183,7 @@ + @@ -191,6 +194,7 @@ + diff --git a/vcproj-10/map-server_txt.vcxproj b/vcproj-10/map-server_txt.vcxproj index a20495591..dfdf549f2 100644 --- a/vcproj-10/map-server_txt.vcxproj +++ b/vcproj-10/map-server_txt.vcxproj @@ -49,7 +49,7 @@ Disabled - ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) false false @@ -92,7 +92,7 @@ true true true - ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) + ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) true MultiThreaded @@ -169,11 +169,13 @@ + + @@ -223,12 +225,14 @@ + + diff --git a/vcproj-6/char-server_sql.dsp b/vcproj-6/char-server_sql.dsp index c87298481..f64c8d67e 100644 --- a/vcproj-6/char-server_sql.dsp +++ b/vcproj-6/char-server_sql.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "char_sql - Win32 Release" # Name "char_sql - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -157,6 +169,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-6/char-server_txt.dsp b/vcproj-6/char-server_txt.dsp index bcd522b6e..e5d9db918 100644 --- a/vcproj-6/char-server_txt.dsp +++ b/vcproj-6/char-server_txt.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "TXT_ONLY" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "TXT_ONLY" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "TXT_ONLY" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "TXT_ONLY" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "char_txt - Win32 Release" # Name "char_txt - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -165,6 +177,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-6/login-server_sql.dsp b/vcproj-6/login-server_sql.dsp index 39bed2a9b..54c953466 100644 --- a/vcproj-6/login-server_sql.dsp +++ b/vcproj-6/login-server_sql.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_SQL" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_SQL" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_SQL" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mysql\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_SQL" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "login_sql - Win32 Release" # Name "login_sql - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -165,6 +177,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-6/login-server_txt.dsp b/vcproj-6/login-server_txt.dsp index 0ed85373c..642375fb7 100644 --- a/vcproj-6/login-server_txt.dsp +++ b/vcproj-6/login-server_txt.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "login_txt - Win32 Release" # Name "login_txt - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -173,6 +185,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp index bf4249972..9246c6b17 100644 --- a/vcproj-6/map-server_sql.dsp +++ b/vcproj-6/map-server_sql.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "map_sql - Win32 Release" # Name "map_sql - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -173,6 +185,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-6/map-server_txt.dsp b/vcproj-6/map-server_txt.dsp index a79b6dcdf..00e4cf716 100644 --- a/vcproj-6/map-server_txt.dsp +++ b/vcproj-6/map-server_txt.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /D "NDEBUG" /D "TXT_ONLY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GF /c +# ADD CPP /nologo /W3 /Zi /O2 /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\mt19937ar" /D "NDEBUG" /D "TXT_ONLY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GF /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "NDEBUG" # ADD RSC /l 0x417 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /D "_DEBUG" /D "TXT_ONLY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /Gi /ZI /Od /I "..\3rdparty\msinttypes\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\mt19937ar" /D "_DEBUG" /D "TXT_ONLY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "PCRE_SUPPORT" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x405 /d "_DEBUG" # ADD RSC /l 0x417 /d "_DEBUG" @@ -84,6 +84,18 @@ LINK32=link.exe # Name "map_txt - Win32 Release" # Name "map_txt - Win32 Debug" +# Begin Group "3rdparty" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.c +# End Source File +# Begin Source File + +SOURCE=..\3rdparty\mt19937ar\mt19937ar.h +# End Source File +# End Group # Begin Group "common" # PROP Default_Filter "" @@ -181,6 +193,14 @@ SOURCE=..\src\common\plugins.h # End Source File # Begin Source File +SOURCE=..\src\common\random.c +# End Source File +# Begin Source File + +SOURCE=..\src\common\random.h +# End Source File +# Begin Source File + SOURCE=..\src\common\showmsg.c # End Source File # Begin Source File diff --git a/vcproj-7.1/char-server_sql.vcproj b/vcproj-7.1/char-server_sql.vcproj index 67b4bcb87..02ad69ff8 100644 --- a/vcproj-7.1/char-server_sql.vcproj +++ b/vcproj-7.1/char-server_sql.vcproj @@ -20,7 +20,7 @@ + + + + @@ -310,6 +316,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-7.1/char-server_txt.vcproj b/vcproj-7.1/char-server_txt.vcproj index 47b9b90b4..cf4606143 100644 --- a/vcproj-7.1/char-server_txt.vcproj +++ b/vcproj-7.1/char-server_txt.vcproj @@ -20,7 +20,7 @@ + + + + @@ -285,6 +291,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-7.1/login-server_sql.vcproj b/vcproj-7.1/login-server_sql.vcproj index a86f8246b..6ffd56f8f 100644 --- a/vcproj-7.1/login-server_sql.vcproj +++ b/vcproj-7.1/login-server_sql.vcproj @@ -19,7 +19,7 @@ + + + + @@ -269,6 +275,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-7.1/login-server_txt.vcproj b/vcproj-7.1/login-server_txt.vcproj index 24fc249d7..624bb39d7 100644 --- a/vcproj-7.1/login-server_txt.vcproj +++ b/vcproj-7.1/login-server_txt.vcproj @@ -19,7 +19,7 @@ + + + + @@ -266,6 +272,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj index 235b7ab7f..fa1b7f931 100644 --- a/vcproj-7.1/map-server_sql.vcproj +++ b/vcproj-7.1/map-server_sql.vcproj @@ -21,7 +21,7 @@ AdditionalOptions="/wd4018 /wd4100" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include" + AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="TRUE" @@ -93,7 +93,7 @@ EnableFiberSafeOptimizations="TRUE" OptimizeForProcessor="2" OptimizeForWindowsApplication="TRUE" - AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include" + AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="TRUE" RuntimeLibrary="3" @@ -428,6 +428,12 @@ + + + + @@ -468,6 +474,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-7.1/map-server_txt.vcproj b/vcproj-7.1/map-server_txt.vcproj index 44e0ee1a0..b78fe1759 100644 --- a/vcproj-7.1/map-server_txt.vcproj +++ b/vcproj-7.1/map-server_txt.vcproj @@ -21,7 +21,7 @@ AdditionalOptions="/wd4018 /wd4100" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include" + AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" GeneratePreprocessedFile="0" MinimalRebuild="TRUE" @@ -93,7 +93,7 @@ EnableFiberSafeOptimizations="TRUE" OptimizeForProcessor="2" OptimizeForWindowsApplication="TRUE" - AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include" + AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" StringPooling="TRUE" RuntimeLibrary="3" @@ -428,6 +428,12 @@ + + + + @@ -462,6 +468,16 @@ RelativePath="..\src\common\version.h"> + + + + + + diff --git a/vcproj-8/char-server_sql.vcproj b/vcproj-8/char-server_sql.vcproj index eea599498..ecee855a8 100644 --- a/vcproj-8/char-server_sql.vcproj +++ b/vcproj-8/char-server_sql.vcproj @@ -41,7 +41,7 @@ + + + + + + @@ -274,6 +286,14 @@ RelativePath="..\src\common\plugins.h" > + + + + diff --git a/vcproj-8/char-server_txt.vcproj b/vcproj-8/char-server_txt.vcproj index 3600bb9c9..da689efe5 100644 --- a/vcproj-8/char-server_txt.vcproj +++ b/vcproj-8/char-server_txt.vcproj @@ -41,7 +41,7 @@ + + + + @@ -385,6 +393,18 @@ > + + + + + + diff --git a/vcproj-8/login-server_sql.vcproj b/vcproj-8/login-server_sql.vcproj index 2509f8f29..bf2526125 100644 --- a/vcproj-8/login-server_sql.vcproj +++ b/vcproj-8/login-server_sql.vcproj @@ -41,7 +41,7 @@ + + + + @@ -365,6 +373,18 @@ > + + + + + + diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index 35cf7639c..ba298908e 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -40,7 +40,7 @@ + + + + @@ -348,6 +356,18 @@ > + + + + + + diff --git a/vcproj-8/map-server_sql.vcproj b/vcproj-8/map-server_sql.vcproj index 8a2d262d5..1f68af297 100644 --- a/vcproj-8/map-server_sql.vcproj +++ b/vcproj-8/map-server_sql.vcproj @@ -40,7 +40,7 @@ + + + + + + @@ -295,6 +307,14 @@ RelativePath="..\src\common\plugins.h" > + + + + diff --git a/vcproj-8/map-server_txt.vcproj b/vcproj-8/map-server_txt.vcproj index 9701861d1..ab7f5ab24 100644 --- a/vcproj-8/map-server_txt.vcproj +++ b/vcproj-8/map-server_txt.vcproj @@ -40,7 +40,7 @@ + + + + @@ -619,6 +627,18 @@ > + + + + + + diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 1090169e2..fd6aa7967 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -42,7 +42,7 @@ + + + + + + @@ -279,6 +291,14 @@ RelativePath="..\src\common\plugins.h" > + + + + diff --git a/vcproj-9/char-server_txt.vcproj b/vcproj-9/char-server_txt.vcproj index 7212baf6b..6eea7bbbd 100644 --- a/vcproj-9/char-server_txt.vcproj +++ b/vcproj-9/char-server_txt.vcproj @@ -42,7 +42,7 @@ + + + + @@ -390,6 +398,18 @@ > + + + + + + diff --git a/vcproj-9/login-server_sql.vcproj b/vcproj-9/login-server_sql.vcproj index 4adaa8d34..f1d1fa94e 100644 --- a/vcproj-9/login-server_sql.vcproj +++ b/vcproj-9/login-server_sql.vcproj @@ -42,7 +42,7 @@ + + + + @@ -370,6 +378,18 @@ > + + + + + + diff --git a/vcproj-9/login-server_txt.vcproj b/vcproj-9/login-server_txt.vcproj index 6c0faa66c..16cd02e84 100644 --- a/vcproj-9/login-server_txt.vcproj +++ b/vcproj-9/login-server_txt.vcproj @@ -41,7 +41,7 @@ + + + + @@ -353,6 +361,18 @@ > + + + + + + diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index e7382ccce..6d31f2340 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -41,7 +41,7 @@ + + + + + + @@ -294,6 +306,14 @@ RelativePath="..\src\common\plugins.h" > + + + + diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj index bd5d6585d..41912c95c 100644 --- a/vcproj-9/map-server_txt.vcproj +++ b/vcproj-9/map-server_txt.vcproj @@ -41,7 +41,7 @@ + + + + @@ -618,6 +626,18 @@ > + + + + + + -- cgit v1.2.3-70-g09d2 From d277092d10c486f94d159f65a37c7cd492d00652 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 16 Aug 2011 17:09:27 +0000 Subject: * Added -fno-strict-aliasing detection to configure.in (-fstrict-aliasing is added through -O2), since the code is not aliasing safe and causes warnings with gcc. - This also fixes a missing line in the pre-built configure script (since r14870). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14935 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ configure | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 16 ++++++++++++++++ 3 files changed, 68 insertions(+) (limited to 'configure') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index a8960b164..193e28b0c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,8 @@ Date Added +2011/08/16 + * Added -fno-strict-aliasing detection to configure.in (-fstrict-aliasing is added through -O2), since the code is not aliasing safe and causes warnings with gcc. [Ai4rei] + - This also fixes a missing line in the pre-built configure script (since r14870). 2011/08/11 * Fixed bonuses bAddMonsterDropItem and bAddMonsterDropItemGroup (which broke after bAddClassDropItem was added). [Skotlex] 2011/08/10 diff --git a/configure b/configure index fbc5e3a11..e26d187e8 100755 --- a/configure +++ b/configure @@ -3475,6 +3475,54 @@ rm -f conftest.err conftest.$ac_objext \ +# +# -O2 implies -fstrict-aliasing, but the code is not safe for that +# +echo "$as_me:$LINENO: checking whether $CC supports -fno-strict-aliasing" >&5 +echo $ECHO_N "checking whether $CC supports -fno-strict-aliasing... $ECHO_C" >&6 +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fno-strict-aliasing" +cat >conftest.$ac_ext <<_ACEOF +int foo; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + # # DB_MANUAL_CAST_TO_UNION # @@ -6178,6 +6226,7 @@ do # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/common/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "3rdparty/mt19937ar/Makefile" ) CONFIG_FILES="$CONFIG_FILES 3rdparty/mt19937ar/Makefile" ;; "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; diff --git a/configure.in b/configure.in index 197a4a4ed..a9e4c289a 100644 --- a/configure.in +++ b/configure.in @@ -424,6 +424,22 @@ AC_LINK_IFELSE( AC_SUBST([WITH_PLUGINS]) +# +# -O2 implies -fstrict-aliasing, but the code is not safe for that +# +AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing]) +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fno-strict-aliasing" +AC_COMPILE_IFELSE( + [int foo;], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + ] +) + + # # DB_MANUAL_CAST_TO_UNION # -- cgit v1.2.3-70-g09d2 From 415e738feb188909dea60831aef07c4fb0fe0f17 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Sun, 11 Dec 2011 21:06:25 +0000 Subject: * Merged changes up to eAthena 15032. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15065 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/pcre/include/pcre.h | 252 ++++--- 3rdparty/pcre/lib/libpcre.dll.a | Bin 19068 -> 19288 bytes 3rdparty/pcre/lib/pcre.lib | Bin 7378 -> 8298 bytes 3rdparty/pcre/pcre-7.0 | 0 3rdparty/pcre/pcre-8.20 | 0 3rdparty/zlib/include/zconf.h | 190 ++++-- 3rdparty/zlib/include/zlib.h | 1162 ++++++++++++++++++++------------- 3rdparty/zlib/lib/zdll.lib | Bin 10590 -> 13438 bytes 3rdparty/zlib/zlib-1.2.3 | 0 3rdparty/zlib/zlib-1.2.5 | 0 CMakeLists.txt | 25 - Changelog-Trunk.txt | 28 +- configure | 68 -- configure.in | 36 - db/packet_db.txt | 2 +- pcre3.dll | Bin 140288 -> 159744 bytes src/char/int_status.c | 2 +- src/common/db.c | 8 - src/common/db.h | 63 +- src/common/mmo.h | 1 + src/map/clif.h | 1 + src/map/guild.c | 4 +- vcproj-10/char-server_sql.vcxproj | 4 +- vcproj-10/char-server_txt.vcxproj | 4 +- vcproj-10/login-server_sql.vcxproj | 4 +- vcproj-10/login-server_txt.vcxproj | 4 +- vcproj-10/map-server_sql.vcxproj | 4 +- vcproj-10/map-server_txt.vcxproj | 4 +- vcproj-10/txt-converter-char.vcxproj | 4 +- vcproj-10/txt-converter-login.vcxproj | 4 +- vcproj-9/char-server_sql.vcproj | 8 +- vcproj-9/char-server_txt.vcproj | 8 +- vcproj-9/dbghelpplug.vcproj | 6 +- vcproj-9/login-server_sql.vcproj | 8 +- vcproj-9/login-server_txt.vcproj | 8 +- vcproj-9/map-server_sql.vcproj | 8 +- vcproj-9/map-server_txt.vcproj | 8 +- vcproj-9/mapcache.vcproj | 6 +- vcproj-9/plugin-console.vcproj | 89 +-- vcproj-9/plugin-pid.vcproj | 89 +-- vcproj-9/txt-converter-char.vcproj | 6 +- vcproj-9/txt-converter-login.vcproj | 6 +- zlib1.dll | Bin 59904 -> 77824 bytes 43 files changed, 1158 insertions(+), 966 deletions(-) delete mode 100644 3rdparty/pcre/pcre-7.0 create mode 100644 3rdparty/pcre/pcre-8.20 delete mode 100644 3rdparty/zlib/zlib-1.2.3 create mode 100644 3rdparty/zlib/zlib-1.2.5 (limited to 'configure') diff --git a/3rdparty/pcre/include/pcre.h b/3rdparty/pcre/include/pcre.h index e973396ba..42a109a65 100644 --- a/3rdparty/pcre/include/pcre.h +++ b/3rdparty/pcre/include/pcre.h @@ -5,7 +5,7 @@ /* This is the public header file for the PCRE library, to be #included by applications that call the PCRE functions. - Copyright (c) 1997-2006 University of Cambridge + Copyright (c) 1997-2011 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -41,44 +41,46 @@ POSSIBILITY OF SUCH DAMAGE. /* The current PCRE version information. */ -/* NOTES FOR FUTURE MAINTAINERS: Do not use numbers with leading zeros, because -they may be treated as octal constants. The PCRE_PRERELEASE feature is for -identifying release candidates. It might be defined as -RC2, for example. In -real releases, it should be defined empty. Do not change the alignment of these -statments. The code in ./configure greps out the version numbers by using "cut" -to get values from column 29 onwards. These are substituted into pcre-config -and libpcre.pc. The values are not put into configure.ac and substituted here -(which would simplify this issue) because that makes life harder for those who -cannot run ./configure. As it now stands, this file need not be edited in that -circumstance. */ - -#define PCRE_MAJOR 7 -#define PCRE_MINOR 0 -#define PCRE_PRERELEASE -#define PCRE_DATE 18-Dec-2006 - -/* Win32 uses DLL by default; it needs special stuff for exported functions -when building PCRE. */ - -#ifdef _WIN32 -# ifdef PCRE_DEFINITION -# ifdef DLL_EXPORT -# define PCRE_DATA_SCOPE __declspec(dllexport) +#define PCRE_MAJOR 8 +#define PCRE_MINOR 20 +#define PCRE_PRERELEASE +#define PCRE_DATE 2011-10-21 + +/* When an application links to a PCRE DLL in Windows, the symbols that are +imported have to be identified as such. When building PCRE, the appropriate +export setting is defined in pcre_internal.h, which includes this file. So we +don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */ + +#if defined(_WIN32) && !defined(PCRE_STATIC) +# ifndef PCRE_EXP_DECL +# define PCRE_EXP_DECL extern __declspec(dllimport) +# endif +# ifdef __cplusplus +# ifndef PCRECPP_EXP_DECL +# define PCRECPP_EXP_DECL extern __declspec(dllimport) # endif -# else -# ifndef PCRE_STATIC -# define PCRE_DATA_SCOPE extern __declspec(dllimport) +# ifndef PCRECPP_EXP_DEFN +# define PCRECPP_EXP_DEFN __declspec(dllimport) # endif # endif #endif -/* Otherwise, we use the standard "extern". */ +/* By default, we use the standard "extern" declarations. */ -#ifndef PCRE_DATA_SCOPE +#ifndef PCRE_EXP_DECL # ifdef __cplusplus -# define PCRE_DATA_SCOPE extern "C" +# define PCRE_EXP_DECL extern "C" # else -# define PCRE_DATA_SCOPE extern +# define PCRE_EXP_DECL extern +# endif +#endif + +#ifdef __cplusplus +# ifndef PCRECPP_EXP_DECL +# define PCRECPP_EXP_DECL extern +# endif +# ifndef PCRECPP_EXP_DEFN +# define PCRECPP_EXP_DEFN # endif #endif @@ -93,32 +95,45 @@ it is needed here for malloc. */ extern "C" { #endif -/* Options */ - -#define PCRE_CASELESS 0x00000001 -#define PCRE_MULTILINE 0x00000002 -#define PCRE_DOTALL 0x00000004 -#define PCRE_EXTENDED 0x00000008 -#define PCRE_ANCHORED 0x00000010 -#define PCRE_DOLLAR_ENDONLY 0x00000020 -#define PCRE_EXTRA 0x00000040 -#define PCRE_NOTBOL 0x00000080 -#define PCRE_NOTEOL 0x00000100 -#define PCRE_UNGREEDY 0x00000200 -#define PCRE_NOTEMPTY 0x00000400 -#define PCRE_UTF8 0x00000800 -#define PCRE_NO_AUTO_CAPTURE 0x00001000 -#define PCRE_NO_UTF8_CHECK 0x00002000 -#define PCRE_AUTO_CALLOUT 0x00004000 -#define PCRE_PARTIAL 0x00008000 -#define PCRE_DFA_SHORTEST 0x00010000 -#define PCRE_DFA_RESTART 0x00020000 -#define PCRE_FIRSTLINE 0x00040000 -#define PCRE_DUPNAMES 0x00080000 -#define PCRE_NEWLINE_CR 0x00100000 -#define PCRE_NEWLINE_LF 0x00200000 -#define PCRE_NEWLINE_CRLF 0x00300000 -#define PCRE_NEWLINE_ANY 0x00400000 +/* Options. Some are compile-time only, some are run-time only, and some are +both, so we keep them all distinct. However, almost all the bits in the options +word are now used. In the long run, we may have to re-use some of the +compile-time only bits for runtime options, or vice versa. */ + +#define PCRE_CASELESS 0x00000001 /* Compile */ +#define PCRE_MULTILINE 0x00000002 /* Compile */ +#define PCRE_DOTALL 0x00000004 /* Compile */ +#define PCRE_EXTENDED 0x00000008 /* Compile */ +#define PCRE_ANCHORED 0x00000010 /* Compile, exec, DFA exec */ +#define PCRE_DOLLAR_ENDONLY 0x00000020 /* Compile */ +#define PCRE_EXTRA 0x00000040 /* Compile */ +#define PCRE_NOTBOL 0x00000080 /* Exec, DFA exec */ +#define PCRE_NOTEOL 0x00000100 /* Exec, DFA exec */ +#define PCRE_UNGREEDY 0x00000200 /* Compile */ +#define PCRE_NOTEMPTY 0x00000400 /* Exec, DFA exec */ +#define PCRE_UTF8 0x00000800 /* Compile */ +#define PCRE_NO_AUTO_CAPTURE 0x00001000 /* Compile */ +#define PCRE_NO_UTF8_CHECK 0x00002000 /* Compile, exec, DFA exec */ +#define PCRE_AUTO_CALLOUT 0x00004000 /* Compile */ +#define PCRE_PARTIAL_SOFT 0x00008000 /* Exec, DFA exec */ +#define PCRE_PARTIAL 0x00008000 /* Backwards compatible synonym */ +#define PCRE_DFA_SHORTEST 0x00010000 /* DFA exec */ +#define PCRE_DFA_RESTART 0x00020000 /* DFA exec */ +#define PCRE_FIRSTLINE 0x00040000 /* Compile */ +#define PCRE_DUPNAMES 0x00080000 /* Compile */ +#define PCRE_NEWLINE_CR 0x00100000 /* Compile, exec, DFA exec */ +#define PCRE_NEWLINE_LF 0x00200000 /* Compile, exec, DFA exec */ +#define PCRE_NEWLINE_CRLF 0x00300000 /* Compile, exec, DFA exec */ +#define PCRE_NEWLINE_ANY 0x00400000 /* Compile, exec, DFA exec */ +#define PCRE_NEWLINE_ANYCRLF 0x00500000 /* Compile, exec, DFA exec */ +#define PCRE_BSR_ANYCRLF 0x00800000 /* Compile, exec, DFA exec */ +#define PCRE_BSR_UNICODE 0x01000000 /* Compile, exec, DFA exec */ +#define PCRE_JAVASCRIPT_COMPAT 0x02000000 /* Compile */ +#define PCRE_NO_START_OPTIMIZE 0x04000000 /* Compile, exec, DFA exec */ +#define PCRE_NO_START_OPTIMISE 0x04000000 /* Synonym */ +#define PCRE_PARTIAL_HARD 0x08000000 /* Exec, DFA exec */ +#define PCRE_NOTEMPTY_ATSTART 0x10000000 /* Exec, DFA exec */ +#define PCRE_UCP 0x20000000 /* Compile */ /* Exec-time and get/set-time error codes */ @@ -144,8 +159,37 @@ extern "C" { #define PCRE_ERROR_DFA_WSSIZE (-19) #define PCRE_ERROR_DFA_RECURSE (-20) #define PCRE_ERROR_RECURSIONLIMIT (-21) -#define PCRE_ERROR_NULLWSLIMIT (-22) +#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */ #define PCRE_ERROR_BADNEWLINE (-23) +#define PCRE_ERROR_BADOFFSET (-24) +#define PCRE_ERROR_SHORTUTF8 (-25) +#define PCRE_ERROR_RECURSELOOP (-26) +#define PCRE_ERROR_JIT_STACKLIMIT (-27) + +/* Specific error codes for UTF-8 validity checks */ + +#define PCRE_UTF8_ERR0 0 +#define PCRE_UTF8_ERR1 1 +#define PCRE_UTF8_ERR2 2 +#define PCRE_UTF8_ERR3 3 +#define PCRE_UTF8_ERR4 4 +#define PCRE_UTF8_ERR5 5 +#define PCRE_UTF8_ERR6 6 +#define PCRE_UTF8_ERR7 7 +#define PCRE_UTF8_ERR8 8 +#define PCRE_UTF8_ERR9 9 +#define PCRE_UTF8_ERR10 10 +#define PCRE_UTF8_ERR11 11 +#define PCRE_UTF8_ERR12 12 +#define PCRE_UTF8_ERR13 13 +#define PCRE_UTF8_ERR14 14 +#define PCRE_UTF8_ERR15 15 +#define PCRE_UTF8_ERR16 16 +#define PCRE_UTF8_ERR17 17 +#define PCRE_UTF8_ERR18 18 +#define PCRE_UTF8_ERR19 19 +#define PCRE_UTF8_ERR20 20 +#define PCRE_UTF8_ERR21 21 /* Request types for pcre_fullinfo() */ @@ -162,6 +206,11 @@ extern "C" { #define PCRE_INFO_NAMETABLE 9 #define PCRE_INFO_STUDYSIZE 10 #define PCRE_INFO_DEFAULT_TABLES 11 +#define PCRE_INFO_OKPARTIAL 12 +#define PCRE_INFO_JCHANGED 13 +#define PCRE_INFO_HASCRORLF 14 +#define PCRE_INFO_MINLENGTH 15 +#define PCRE_INFO_JIT 16 /* Request types for pcre_config(). Do not re-arrange, in order to remain compatible. */ @@ -174,6 +223,13 @@ compatible. */ #define PCRE_CONFIG_STACKRECURSE 5 #define PCRE_CONFIG_UNICODE_PROPERTIES 6 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 +#define PCRE_CONFIG_BSR 8 +#define PCRE_CONFIG_JIT 9 + +/* Request types for pcre_study(). Do not re-arrange, in order to remain +compatible. */ + +#define PCRE_STUDY_JIT_COMPILE 0x0001 /* Bit flags for the pcre_extra structure. Do not re-arrange or redefine these bits, just add new ones on the end, in order to remain compatible. */ @@ -183,12 +239,17 @@ these bits, just add new ones on the end, in order to remain compatible. */ #define PCRE_EXTRA_CALLOUT_DATA 0x0004 #define PCRE_EXTRA_TABLES 0x0008 #define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010 +#define PCRE_EXTRA_MARK 0x0020 +#define PCRE_EXTRA_EXECUTABLE_JIT 0x0040 /* Types */ struct real_pcre; /* declaration; the definition is private */ typedef struct real_pcre pcre; +struct real_pcre_jit_stack; /* declaration; the definition is private */ +typedef struct real_pcre_jit_stack pcre_jit_stack; + /* When PCRE is compiled as a C++ library, the subject pointer type can be replaced with a custom type. For conventional use, the public interface is a const char *. */ @@ -208,6 +269,8 @@ typedef struct pcre_extra { void *callout_data; /* Data passed back in callouts */ const unsigned char *tables; /* Pointer to character tables */ unsigned long int match_limit_recursion; /* Max recursive calls to match() */ + unsigned char **mark; /* For passing back a mark pointer */ + void *executable_jit; /* Contains a pointer to a compiled jit code */ } pcre_extra; /* The structure for passing out data via the pcre_callout_function. We use a @@ -230,6 +293,8 @@ typedef struct pcre_callout_block { /* ------------------- Added for Version 1 -------------------------- */ int pattern_position; /* Offset to next item in the pattern */ int next_item_length; /* Length of next item in the pattern */ + /* ------------------- Added for Version 2 -------------------------- */ + const unsigned char *mark; /* Pointer to current mark or NULL */ /* ------------------------------------------------------------------ */ } pcre_callout_block; @@ -240,52 +305,63 @@ that is triggered by the (?) regex item. For Virtual Pascal, these definitions have to take another form. */ #ifndef VPCOMPAT -PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t); -PCRE_DATA_SCOPE void (*pcre_free)(void *); -PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t); -PCRE_DATA_SCOPE void (*pcre_stack_free)(void *); -PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *); +PCRE_EXP_DECL void *(*pcre_malloc)(size_t); +PCRE_EXP_DECL void (*pcre_free)(void *); +PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t); +PCRE_EXP_DECL void (*pcre_stack_free)(void *); +PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *); #else /* VPCOMPAT */ -PCRE_DATA_SCOPE void *pcre_malloc(size_t); -PCRE_DATA_SCOPE void pcre_free(void *); -PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t); -PCRE_DATA_SCOPE void pcre_stack_free(void *); -PCRE_DATA_SCOPE int pcre_callout(pcre_callout_block *); +PCRE_EXP_DECL void *pcre_malloc(size_t); +PCRE_EXP_DECL void pcre_free(void *); +PCRE_EXP_DECL void *pcre_stack_malloc(size_t); +PCRE_EXP_DECL void pcre_stack_free(void *); +PCRE_EXP_DECL int pcre_callout(pcre_callout_block *); #endif /* VPCOMPAT */ +/* User defined callback which provides a stack just before the match starts. */ + +typedef pcre_jit_stack *(*pcre_jit_callback)(void *); + /* Exported PCRE functions */ -PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *, +PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *, const unsigned char *); -PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **, +PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **, int *, const unsigned char *); -PCRE_DATA_SCOPE int pcre_config(int, void *); -PCRE_DATA_SCOPE int pcre_copy_named_substring(const pcre *, const char *, +PCRE_EXP_DECL int pcre_config(int, void *); +PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *, int *, int, const char *, char *, int); -PCRE_DATA_SCOPE int pcre_copy_substring(const char *, int *, int, int, char *, +PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, char *, int); -PCRE_DATA_SCOPE int pcre_dfa_exec(const pcre *, const pcre_extra *, +PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *, const char *, int, int, int, int *, int , int *, int); -PCRE_DATA_SCOPE int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, +PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, int, int, int, int *, int); -PCRE_DATA_SCOPE void pcre_free_substring(const char *); -PCRE_DATA_SCOPE void pcre_free_substring_list(const char **); -PCRE_DATA_SCOPE int pcre_fullinfo(const pcre *, const pcre_extra *, int, +PCRE_EXP_DECL void pcre_free_substring(const char *); +PCRE_EXP_DECL void pcre_free_substring_list(const char **); +PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *); -PCRE_DATA_SCOPE int pcre_get_named_substring(const pcre *, const char *, +PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *, int *, int, const char *, const char **); -PCRE_DATA_SCOPE int pcre_get_stringnumber(const pcre *, const char *); -PCRE_DATA_SCOPE int pcre_get_stringtable_entries(const pcre *, const char *, +PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *); +PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *, char **, char **); -PCRE_DATA_SCOPE int pcre_get_substring(const char *, int *, int, int, +PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int, const char **); -PCRE_DATA_SCOPE int pcre_get_substring_list(const char *, int *, int, +PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int, const char ***); -PCRE_DATA_SCOPE int pcre_info(const pcre *, int *, int *); -PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void); -PCRE_DATA_SCOPE int pcre_refcount(pcre *, int); -PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **); -PCRE_DATA_SCOPE const char *pcre_version(void); +PCRE_EXP_DECL int pcre_info(const pcre *, int *, int *); +PCRE_EXP_DECL const unsigned char *pcre_maketables(void); +PCRE_EXP_DECL int pcre_refcount(pcre *, int); +PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **); +PCRE_EXP_DECL void pcre_free_study(pcre_extra *); +PCRE_EXP_DECL const char *pcre_version(void); + +/* JIT compiler related functions. */ + +PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int); +PCRE_EXP_DECL void pcre_jit_stack_free(pcre_jit_stack *); +PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *, pcre_jit_callback, void *); #ifdef __cplusplus } /* extern "C" */ diff --git a/3rdparty/pcre/lib/libpcre.dll.a b/3rdparty/pcre/lib/libpcre.dll.a index fe69e4e57..d82c1f28b 100644 Binary files a/3rdparty/pcre/lib/libpcre.dll.a and b/3rdparty/pcre/lib/libpcre.dll.a differ diff --git a/3rdparty/pcre/lib/pcre.lib b/3rdparty/pcre/lib/pcre.lib index 37b4084ef..1024ec4a5 100644 Binary files a/3rdparty/pcre/lib/pcre.lib and b/3rdparty/pcre/lib/pcre.lib differ diff --git a/3rdparty/pcre/pcre-7.0 b/3rdparty/pcre/pcre-7.0 deleted file mode 100644 index e69de29bb..000000000 diff --git a/3rdparty/pcre/pcre-8.20 b/3rdparty/pcre/pcre-8.20 new file mode 100644 index 000000000..e69de29bb diff --git a/3rdparty/zlib/include/zconf.h b/3rdparty/zlib/include/zconf.h index 03a9431c8..02ce56c43 100644 --- a/3rdparty/zlib/include/zconf.h +++ b/3rdparty/zlib/include/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. + * Copyright (C) 1995-2010 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -11,52 +11,124 @@ /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 # define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset +# define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams -# define deflateBound z_deflateBound # define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader # define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound +# define inflateUndermine z_inflateUndermine +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table # define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table # define zError z_zError +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef # define alloc_func z_alloc_func +# define charf z_charf # define free_func z_free_func +# define gzFile z_gzFile +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp # define in_func z_in_func +# define intf z_intf # define out_func z_out_func -# define Byte z_Byte # define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf # define uIntf z_uIntf +# define uLong z_uLong # define uLongf z_uLongf -# define voidpf z_voidpf # define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + #endif #if defined(__MSDOS__) && !defined(MSDOS) @@ -284,49 +356,73 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef STDC +# include /* for off_t */ +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_* and off_t */ # ifdef VMS -# include /* for off_t */ +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t # endif -# define z_off_t off_t #endif + #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif + #ifndef z_off_t # define z_off_t long #endif +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define z_off64_t off64_t +#else +# define z_off64_t z_off_t +#endif + #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ diff --git a/3rdparty/zlib/include/zlib.h b/3rdparty/zlib/include/zlib.h index 022817927..bfbba83e8 100644 --- a/3rdparty/zlib/include/zlib.h +++ b/3rdparty/zlib/include/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 + version 1.2.5, April 19th, 2010 - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,41 +37,44 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 +#define ZLIB_VERSION "1.2.5" +#define ZLIB_VERNUM 0x1250 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_SUBREVISION 0 /* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output (providing more output space) before each call. - The compressed data format used by default by the in-memory functions is + The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. - The library also supports reading and writing files in gzip (.gz) format + The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - This library can optionally read and write gzip streams in memory as well. + This library can optionally read and write gzip streams in memory as well. - The zlib format was designed to be compact and fast for use in memory + The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); @@ -126,45 +129,45 @@ typedef struct gz_header_s { typedef gz_header FAR *gz_headerp; /* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the opaque value. - zalloc must return Z_NULL if there is not enough memory for the object. + zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_PARTIAL_FLUSH 1 #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 #define Z_BLOCK 5 +#define Z_TREES 6 /* Allowed flush values; see deflate() and inflate() below for details */ #define Z_OK 0 @@ -176,8 +179,8 @@ typedef gz_header FAR *gz_headerp; #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 @@ -207,119 +210,140 @@ typedef gz_header FAR *gz_headerp; #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ + /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. */ /* ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when forced to flush. - The detailed semantics are as follows. deflate performs one or both of the + The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not + accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. + accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to + decide how much data to accumulate before producing output, in order to maximize compression. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six to avoid repeated flush markers due to avail_out == 0 on return. If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return Z_STREAM_END, then it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ @@ -328,13 +352,13 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. + This function discards any unprocessed input and does not flush any pending + output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be deallocated). */ @@ -342,10 +366,10 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - Initializes the internal stream state for decompression. The fields + Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the compression method from the zlib header and allocates all data structures accordingly; otherwise the allocation will be deferred to the first call of inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to @@ -353,95 +377,108 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. */ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce + buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. - The detailed semantics are as follows. inflate performs one or both of the + The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation + first call. So the only effect of the flush parameter in this implementation is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. + because Z_BLOCK or Z_TREES is used. If a preset dictionary is needed after this call (see inflateSetDictionary below), inflate sets strm->adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 + below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has @@ -449,27 +486,28 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. */ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. + This function discards any unprocessed input and does not flush any pending + output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a + was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ + /* Advanced functions */ /* @@ -484,55 +522,57 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int memLevel, int strategy)); - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. - The method parameter is the compression method. It must be Z_DEFLATED in + The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute an adler32 check value. - windowBits can also be greater than 15 for optional gzip encoding. Add + windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a gzip stream is being written, strm->adler is a crc32 instead of an adler32. The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. - The strategy parameter is used to tune the compression algorithm. Use the + The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, @@ -540,37 +580,37 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a + used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the adler32 value of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value + which dictionary has been used by the compressor. (The adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the adler32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not + or if the compression method is bsort). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ @@ -581,26 +621,26 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed + data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and + (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, @@ -610,18 +650,18 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. */ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, @@ -645,9 +685,10 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, @@ -655,21 +696,21 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int value)); /* deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); /* - deflateSetHeader() provides gzip header information for when a gzip + deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information @@ -682,11 +723,11 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. - If deflateSetHeader is not used, the default gzip header has text false, + If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to 255, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset(). - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ @@ -694,43 +735,50 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); - This is another version of inflateInit with an extra parameter. The + This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window + deflateInit2() was not used. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This + looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom + such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an adler32 or a crc32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments + most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. - windowBits can also be greater than 15 for optional gzip decoding. Add + windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, @@ -738,8 +786,8 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the adler32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called @@ -748,26 +796,26 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not + expected one (incorrect adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, @@ -782,18 +830,30 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and + (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. */ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, @@ -801,54 +861,87 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int value)); /* This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); /* - inflateGetHeader() requests that gzip header information be stored in the + inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. - The text, time, xflags, and os fields are filled in with the gzip header + The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max + was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. - If inflateGetHeader is not used, then the header information is simply + If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ @@ -869,9 +962,9 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. */ typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); @@ -891,15 +984,15 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then @@ -925,7 +1018,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These @@ -935,15 +1028,15 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); @@ -999,23 +1092,22 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* utility functions */ /* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. */ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. @@ -1025,11 +1117,11 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)); /* - Compresses the source buffer into the destination buffer. The level + Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the + length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough @@ -1040,22 +1132,20 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); /* compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. */ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output @@ -1063,136 +1153,199 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, */ -typedef voidp gzFile; + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); /* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); /* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. */ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* - Dynamically update the compression level or strategy. See the description + Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. */ -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); /* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). */ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); /* - Writes the given null-terminated string to the compressed file, excluding + Writes the given null-terminated string to the compressed file, excluding the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. + + gzputs returns the number of characters written, or -1 in case of error. */ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); /* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); /* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); /* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. */ -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); /* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); /* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. */ -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); /* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are + extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. - gzseek returns the resulting offset location as measured in bytes from + gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. @@ -1202,68 +1355,127 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); /* Rewinds the given file. This function is supported only for reading. - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ +/* ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + /* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. */ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); /* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. */ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); /* - Returns 1 if file is being read directly without decompression, otherwise - zero. + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); /* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. */ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); /* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. */ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); /* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ + /* checksum functions */ /* These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. + anyway because they might be useful in applications using the compression + library. */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: uLong adler = adler32(0L, Z_NULL, 0); @@ -1273,9 +1485,10 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ +/* ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); -/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of @@ -1285,9 +1498,11 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + Usage example: uLong crc = crc32(0L, Z_NULL, 0); @@ -1298,9 +1513,9 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ +/* ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); -/* Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 @@ -1339,16 +1554,57 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) + ZLIB_VERSION, sizeof(z_stream)) +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif +/* hack for buggy compilers */ #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ + struct internal_state {int dummy;}; #endif +/* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); #ifdef __cplusplus } diff --git a/3rdparty/zlib/lib/zdll.lib b/3rdparty/zlib/lib/zdll.lib index 01f4e10e6..d6ba151a0 100644 Binary files a/3rdparty/zlib/lib/zdll.lib and b/3rdparty/zlib/lib/zdll.lib differ diff --git a/3rdparty/zlib/zlib-1.2.3 b/3rdparty/zlib/zlib-1.2.3 deleted file mode 100644 index e69de29bb..000000000 diff --git a/3rdparty/zlib/zlib-1.2.5 b/3rdparty/zlib/zlib-1.2.5 new file mode 100644 index 000000000..e69de29bb diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aee569a3..51fc2e39e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,31 +195,6 @@ elseif( BIG_ENDIAN ) endif() -# -# Test typecast to union -# -message( STATUS "Check for typecast to union" ) -set( SOURCECODE - "typedef union Foonion{\n" - " int i;\n" - " unsigned int ui;\n" - " const char* s;\n" - "} Foonion;\n" - "int get_i(Foonion onion){ return onion.i; }\n" - "int main(int argc, char** argv){\n" - " int i = 0;\n" - " return get_i(((Foonion)(int)i));\n" - "}\n" - ) -CHECK_C_SOURCE_COMPILES( "${SOURCECODE}" HAVE_TYPECAST_TO_UNION ) -if( HAVE_TYPECAST_TO_UNION ) - message( STATUS "Check for typecast to union - yes" ) -else() - message( STATUS "Check for typecast to union - no" ) - set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDB_MANUAL_CAST_TO_UNION" ) -endif() - - # # Test monotonic clock # diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 8082888f6..82b4831c0 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,11 +1,33 @@ Date Added +2011-12-10 + * Updated pcre3.dll and related files from 7.0 to 8.20 (bugreport:4948). [Ai4rei] +2011-12-09 + * Updated PACKETVER and packet_db_ver to the most recent fully supported and stable client (2010-07-28aRagexeRE). [Ai4rei] +2011-12-08 + * Updated zlib1.dll and related files from 1.2.3 to 1.2.5 (bugreport:4948). [Ai4rei] +2011-12-04 + * Random procrastinating in map.c/map.h [Ai4rei] + - Rewrote command line option parser. Now reports invalid options and missing option values. + - Dropped some alternative option names. + - Renamed option --grf-path-file to --grf-path. + - Enabled option --inter-config for TXT builds as well (mapreg_txt, party_share_level, etc.). + - Fixed outdated website url in version screen. + - Replaced 'puts' with 'ShowInfo' in help screen and reformatted it a bit. + - Added explanation for option --run-once to help screen (follow up to r789). + - Fixed option --inter-config was called --sql-config in help screen (follow up to r930). + - Removed orphaned extern variable 'map_server_dns' declaration from map.h (since r7275, follow up to r7360). +2011-12-03 + * Preparation clean up in clif.h [Ai4rei] + - Synced function declarations and argument names with clif.c including whitespace. + - Removed orphaned function declarations. + - Removed include to storage.h and put it into .c files that need it instead. +2011-11-28 + * Fixed novending cell check using misleading error message (bugreport:2592, since r11572 and r14724, related r11580). [Ai4rei] + * Fixed removing item scripts through script command *setitemscript not working the way it is stated in script_commands.txt (related r9831). [Ai4rei] 2011-11-27 * Welcome to RAthena! http://rathena.org/board/topic/53704-rathena-the-fork/ -2011/11/28 - * Fixed novending cell check using misleading error message (bugreport:2592, since r11572 and r14724, related r11580). [Ai4rei] - * Fixed removing item scripts through script command *setitemscript not working the way it is stated in script_commands.txt (related r9831). [Ai4rei] 2011/11/19 * Fixed wrong damage numbers being displayed when the damage source was disguised (bugreport:5093, since r14979). [Ai4rei] 2011/11/17 diff --git a/configure b/configure index e26d187e8..606107040 100755 --- a/configure +++ b/configure @@ -3523,74 +3523,6 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# -# DB_MANUAL_CAST_TO_UNION -# -echo "$as_me:$LINENO: checking whether $CC is able to typecast to union" >&5 -echo $ECHO_N "checking whether $CC is able to typecast to union... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF - - typedef union Foonion - { - int i; - unsigned int ui; - const char* s; - } - Foonion; - - int bar(Foonion onion) - { - return onion.i; - } - - int foo(void) - { - int i = 0; - - return bar(((Foonion)(int)i)); - } - -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION" - - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - - ############################################################################### # Check for libraries and header files. # diff --git a/configure.in b/configure.in index a9e4c289a..3aff089db 100644 --- a/configure.in +++ b/configure.in @@ -440,42 +440,6 @@ AC_COMPILE_IFELSE( ) -# -# DB_MANUAL_CAST_TO_UNION -# -AC_MSG_CHECKING([whether $CC is able to typecast to union]) -AC_COMPILE_IFELSE( - [ - typedef union Foonion - { - int i; - unsigned int ui; - const char* s; - } - Foonion; - - int bar(Foonion onion) - { - return onion.i; - } - - int foo(void) - { - int i = 0; - - return bar(((Foonion)(int)i)); - } - ], - [ - AC_MSG_RESULT([yes]) - ], - [ - AC_MSG_RESULT([no]) - CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION" - ] -) - - ############################################################################### # Check for libraries and header files. # diff --git a/db/packet_db.txt b/db/packet_db.txt index a9517e0c0..fc54a6f25 100644 --- a/db/packet_db.txt +++ b/db/packet_db.txt @@ -33,7 +33,7 @@ // Main packet version of the DB to use (default = max available version) // Client detection is faster when all clients use this version. // Version 23 is the latest Sakexe (above versions are for Renewal clients) -//packet_db_ver: 23 +//packet_db_ver: 25 packet_db_ver: default diff --git a/pcre3.dll b/pcre3.dll index b5fd2a637..a1adc37f2 100644 Binary files a/pcre3.dll and b/pcre3.dll differ diff --git a/src/char/int_status.c b/src/char/int_status.c index 52b14ebbe..769d35f65 100644 --- a/src/char/int_status.c +++ b/src/char/int_status.c @@ -29,7 +29,7 @@ static void* create_scdata(DBKey key, va_list args) *------------------------------------------*/ struct scdata* status_search_scdata(int aid, int cid) { - return (struct scdata*)scdata_db->ensure(scdata_db, i2key(cid), create_scdata, aid); + return (struct scdata*)scdata_db->ensure(scdata_db, db_i2key(cid), create_scdata, aid); } /*========================================== diff --git a/src/common/db.c b/src/common/db.c index c9b124455..74c3b1f91 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -2437,14 +2437,11 @@ DBMap* db_alloc(const char *file, int line, DBType type, DBOptions options, unsi return &db->vtable; } -#ifdef DB_MANUAL_CAST_TO_UNION /** * Manual cast from 'int' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_i2key(int key) { @@ -2457,11 +2454,9 @@ DBKey db_i2key(int key) /** * Manual cast from 'unsigned int' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_ui2key(unsigned int key) { @@ -2474,11 +2469,9 @@ DBKey db_ui2key(unsigned int key) /** * Manual cast from 'const char *' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_str2key(const char *key) { @@ -2488,7 +2481,6 @@ DBKey db_str2key(const char *key) ret.str = key; return ret; } -#endif /* DB_MANUAL_CAST_TO_UNION */ /** * Initializes the database system. diff --git a/src/common/db.h b/src/common/db.h index e5515803c..d4728cbbf 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -46,8 +46,6 @@ /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * - * DB_MANUAL_CAST_TO_UNION - Define when the compiler doesn't allow casting * - * to unions. * * DBRelease - Enumeration of release options. * * DBType - Enumeration of database types. * * DBOptions - Bitfield enumeration of database options. * @@ -61,19 +59,6 @@ * DBMap - Database interface. * \*****************************************************************************/ -/** - * Define this to enable the functions that cast to unions. - * Required when the compiler doesn't support casting to unions. - * NOTE: It is recommened that the conditional tests to determine if this - * should be defined be located in the configure script or a header file - * specific for compatibility and portability issues. - * @public - * @see #db_i2key(int) - * @see #db_ui2key(unsigned int) - * @see #db_str2key(unsigned char *) - */ -//#define DB_MANUAL_CAST_TO_UNION - /** * Bitfield with what should be released by the releaser function (if the * function supports it). @@ -575,42 +560,32 @@ struct DBMap { }; //For easy access to the common functions. -#ifdef DB_MANUAL_CAST_TO_UNION -# define i2key db_i2key -# define ui2key db_ui2key -# define str2key db_str2key -#else /* not DB_MANUAL_CAST_TO_UNION */ -# define i2key(k) ((DBKey)(int)(k)) -# define ui2key(k) ((DBKey)(unsigned int)(k)) -# define str2key(k) ((DBKey)(const char *)(k)) -#endif /* not DB_MANUAL_CAST_TO_UNION */ - #define db_exists(db,k) ( (db)->exists((db),(k)) ) -#define idb_exists(db,k) ( (db)->exists((db),i2key(k)) ) -#define uidb_exists(db,k) ( (db)->exists((db),ui2key(k)) ) -#define strdb_exists(db,k) ( (db)->exists((db),str2key(k)) ) +#define idb_exists(db,k) ( (db)->exists((db),db_i2key(k)) ) +#define uidb_exists(db,k) ( (db)->exists((db),db_ui2key(k)) ) +#define strdb_exists(db,k) ( (db)->exists((db),db_str2key(k)) ) #define db_get(db,k) ( (db)->get((db),(k)) ) -#define idb_get(db,k) ( (db)->get((db),i2key(k)) ) -#define uidb_get(db,k) ( (db)->get((db),ui2key(k)) ) -#define strdb_get(db,k) ( (db)->get((db),str2key(k)) ) +#define idb_get(db,k) ( (db)->get((db),db_i2key(k)) ) +#define uidb_get(db,k) ( (db)->get((db),db_ui2key(k)) ) +#define strdb_get(db,k) ( (db)->get((db),db_str2key(k)) ) #define db_put(db,k,d) ( (db)->put((db),(k),(d)) ) -#define idb_put(db,k,d) ( (db)->put((db),i2key(k),(d)) ) -#define uidb_put(db,k,d) ( (db)->put((db),ui2key(k),(d)) ) -#define strdb_put(db,k,d) ( (db)->put((db),str2key(k),(d)) ) +#define idb_put(db,k,d) ( (db)->put((db),db_i2key(k),(d)) ) +#define uidb_put(db,k,d) ( (db)->put((db),db_ui2key(k),(d)) ) +#define strdb_put(db,k,d) ( (db)->put((db),db_str2key(k),(d)) ) #define db_remove(db,k) ( (db)->remove((db),(k)) ) -#define idb_remove(db,k) ( (db)->remove((db),i2key(k)) ) -#define uidb_remove(db,k) ( (db)->remove((db),ui2key(k)) ) -#define strdb_remove(db,k) ( (db)->remove((db),str2key(k)) ) +#define idb_remove(db,k) ( (db)->remove((db),db_i2key(k)) ) +#define uidb_remove(db,k) ( (db)->remove((db),db_ui2key(k)) ) +#define strdb_remove(db,k) ( (db)->remove((db),db_str2key(k)) ) //These are discarding the possible vargs you could send to the function, so those //that require vargs must not use these defines. #define db_ensure(db,k,f) ( (db)->ensure((db),(k),(f)) ) -#define idb_ensure(db,k,f) ( (db)->ensure((db),i2key(k),(f)) ) -#define uidb_ensure(db,k,f) ( (db)->ensure((db),ui2key(k),(f)) ) -#define strdb_ensure(db,k,f) ( (db)->ensure((db),str2key(k),(f)) ) +#define idb_ensure(db,k,f) ( (db)->ensure((db),db_i2key(k),(f)) ) +#define uidb_ensure(db,k,f) ( (db)->ensure((db),db_ui2key(k),(f)) ) +#define strdb_ensure(db,k,f) ( (db)->ensure((db),db_str2key(k),(f)) ) // Database creation and destruction macros #define idb_alloc(opt) db_alloc(__FILE__,__LINE__,DB_INT,(opt),sizeof(int)) @@ -729,37 +704,29 @@ DBReleaser db_custom_release(DBRelease which); */ DBMap* db_alloc(const char *file, int line, DBType type, DBOptions options, unsigned short maxlen); -#ifdef DB_MANUAL_CAST_TO_UNION /** * Manual cast from 'int' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_i2key(int key); /** * Manual cast from 'unsigned int' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_ui2key(unsigned int key); /** * Manual cast from 'unsigned char *' to the union DBKey. - * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_str2key(const char *key); -#endif /* DB_MANUAL_CAST_TO_UNION */ /** * Initialize the database system. diff --git a/src/common/mmo.h b/src/common/mmo.h index f8ef63390..2b39bf6d8 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -47,6 +47,7 @@ #define PACKETVER 20110609 //#define PACKETVER 20100730 #endif + // backward compatible PACKETVER 8 and 9 #if PACKETVER == 8 #undef PACKETVER diff --git a/src/map/clif.h b/src/map/clif.h index 8b6271075..def1178fd 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -6,6 +6,7 @@ #include "../common/cbasetypes.h" //#include "../common/mmo.h" +struct item; struct storage_data; struct guild_storage; //#include "map.h" diff --git a/src/map/guild.c b/src/map/guild.c index 8c5988dc8..49d92914e 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1155,7 +1155,7 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp) exp = exp * per / 100; //Otherwise tax everything. - c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); + c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, db_i2key(sd->status.char_id), create_expcache, sd); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; @@ -1174,7 +1174,7 @@ int guild_getexp(struct map_session_data *sd,int exp) if (sd->status.guild_id == 0 || guild_search(sd->status.guild_id) == NULL) return 0; - c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); + c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, db_i2key(sd->status.char_id), create_expcache, sd); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; else diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index c837f8da7..1ed50b62f 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -52,7 +52,7 @@ Disabled ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) false false @@ -95,7 +95,7 @@ true true ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/char-server_txt.vcxproj b/vcproj-10/char-server_txt.vcxproj index 0d287e5a2..ab79961a3 100644 --- a/vcproj-10/char-server_txt.vcxproj +++ b/vcproj-10/char-server_txt.vcxproj @@ -52,7 +52,7 @@ Disabled ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index 66b20780d..34f5a33af 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -52,7 +52,7 @@ Disabled ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_SQL;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;%(PreprocessorDefinitions) false false @@ -95,7 +95,7 @@ true true ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_SQL;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/login-server_txt.vcxproj b/vcproj-10/login-server_txt.vcxproj index ab2a9772f..f80d368b5 100644 --- a/vcproj-10/login-server_txt.vcxproj +++ b/vcproj-10/login-server_txt.vcxproj @@ -50,7 +50,7 @@ Disabled ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_TXT;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_TXT;%(PreprocessorDefinitions) false false @@ -93,7 +93,7 @@ true true ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;WITH_TXT;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_TXT;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/map-server_sql.vcxproj b/vcproj-10/map-server_sql.vcxproj index e6cbdcef4..daa739ba0 100644 --- a/vcproj-10/map-server_sql.vcxproj +++ b/vcproj-10/map-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/map-server_txt.vcxproj b/vcproj-10/map-server_txt.vcxproj index 272e16c57..83f16a8b5 100644 --- a/vcproj-10/map-server_txt.vcxproj +++ b/vcproj-10/map-server_txt.vcxproj @@ -50,7 +50,7 @@ Disabled ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) false false @@ -93,7 +93,7 @@ true true ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded false diff --git a/vcproj-10/txt-converter-char.vcxproj b/vcproj-10/txt-converter-char.vcxproj index 88e79604f..7064df852 100644 --- a/vcproj-10/txt-converter-char.vcxproj +++ b/vcproj-10/txt-converter-char.vcxproj @@ -52,7 +52,7 @@ Disabled ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-10/txt-converter-login.vcxproj b/vcproj-10/txt-converter-login.vcxproj index 26e87b993..06c3a8b6c 100644 --- a/vcproj-10/txt-converter-login.vcxproj +++ b/vcproj-10/txt-converter-login.vcxproj @@ -52,7 +52,7 @@ Disabled ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) false false @@ -94,7 +94,7 @@ true true ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) true MultiThreaded diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 759fd4f83..557b6e149 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -44,7 +44,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;DB_MANUAL_CAST_TO_UNION" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;FD_SETSIZE=4096" GeneratePreprocessedFile="0" ExceptionHandling="0" BasicRuntimeChecks="3" @@ -55,7 +55,7 @@ WarningLevel="3" DebugInformationFormat="4" CompileAs="1" - DisableSpecificWarnings="4800" + DisableSpecificWarnings="4800;4996" /> @@ -16,12 +17,9 @@ - - - - - - @@ -16,12 +17,9 @@ - - - - - - Date: Thu, 15 Dec 2011 02:24:20 +0000 Subject: Finished BuildBot "console error scan" stuff. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15128 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 34 ++++++++++++++++++++++++++++++++++ src/common/core.c | 2 +- src/common/core.h | 2 +- src/common/showmsg.c | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 606107040..0c088dfa1 100755 --- a/configure +++ b/configure @@ -1404,6 +1404,28 @@ else fi; +# +# debug +# +# Check whether --enable-debug or --disable-debug was given. +if test "${enable_buildbot+set}" = set; then + enableval="$enable_buildbot" + + enable_buildbot="$enableval" + case $enableval in + "no");; + "yes");; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-buildbot=$enableval... stopping" >&5 +echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_debug="no" + +fi; + + # # RDTSC as Tick Source # @@ -4469,6 +4491,18 @@ case $enable_debug in ;; esac +# +# Buildbot +# +case $enable_buildbot in + "no") + #default value + ;; + "yes") + CFLAGS="$CFLAGS -g -DBUILDBOT" + ;; +esac + # # RDTSC diff --git a/src/common/core.c b/src/common/core.c index 7a6584898..e05f5a571 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -29,7 +29,7 @@ void (*shutdown_callback)(void) = NULL; #if defined(BUILDBOT) - bool buildbotflag; + int buildbotflag = 0; #endif int runflag = CORE_ST_RUN; diff --git a/src/common/core.h b/src/common/core.h index 9dff92625..ecaa2a9d0 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -8,7 +8,7 @@ extern int arg_c; extern char **arg_v; #if defined(BUILDBOT) - extern bool buildbotflag; + extern int buildbotflag; #endif /// @see E_CORE_ST diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 812cbcf68..8492d6db7 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -694,7 +694,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) if( flag == MSG_WARNING || flag == MSG_ERROR || flag == MSG_SQL ) { - buildbotflag = true; + buildbotflag = 1; } #endif if( -- cgit v1.2.3-70-g09d2 From 9d59b6a3431095b30ab8b2e10205f8a20ab85d9b Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 21 Dec 2011 06:54:57 +0000 Subject: Fixed GCC "--enable-debug", and 2 compiler warnings that were omitted due to enable-debug being broken. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15197 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 7 +++---- src/map/clif.c | 1 - src/map/unit.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 0c088dfa1..348dcb804 100755 --- a/configure +++ b/configure @@ -1405,9 +1405,8 @@ else fi; # -# debug +# BuildBot # -# Check whether --enable-debug or --disable-debug was given. if test "${enable_buildbot+set}" = set; then enableval="$enable_buildbot" @@ -1416,12 +1415,12 @@ if test "${enable_buildbot+set}" = set; then "no");; "yes");; *) { { echo "$as_me:$LINENO: error: invalid argument --enable-buildbot=$enableval... stopping" >&5 -echo "$as_me: error: invalid argument --enable-debug=$enableval... stopping" >&2;} +echo "$as_me: error: invalid argument --enable-buildbot=$enableval... stopping" >&2;} { (exit 1); exit 1; }; };; esac else - enable_debug="no" + enable_buildbot="no" fi; diff --git a/src/map/clif.c b/src/map/clif.c index 3c1851309..a471bfc06 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13607,7 +13607,6 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) { int fail = 0; - struct npc_data *nd; nullpo_retv(sd); if( sd->state.trading || !sd->npc_shopid ) diff --git a/src/map/unit.c b/src/map/unit.c index e7f7fffce..9471f6a9d 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -462,7 +462,7 @@ int unit_run(struct block_list *bl) to_y += dir_y; } - if(to_x == bl->x && to_y == bl->y || (to_x == (bl->x+1) || to_y == (bl->y+1)) || (to_x == (bl->x-1) || to_y == (bl->y-1))) { + if( (to_x == bl->x && to_y == bl->y ) || (to_x == (bl->x+1) || to_y == (bl->y+1)) || (to_x == (bl->x-1) || to_y == (bl->y-1))) { //If you can't run forward, you must be next to a wall, so bounce back. [Skotlex] clif_status_change(bl, SI_BUMP, 1, 0, 0, 0, 0); -- cgit v1.2.3-70-g09d2 From a02514bc54c044f141520118ffd7e0b6ff5ecae2 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Thu, 19 Jan 2012 22:05:57 +0000 Subject: * Added `--enable-buildbot` to configure.in (follow-up to r15128). * Fixed TXT-removal branch configure and Makefile errors and removed TXT-only leftovers. * SQL libs are now required to configure/make TXT-removal branch. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15499 54d463be-8e91-2dee-dedb-b68131a5f0ec --- configure | 15 ++++++++------- configure.in | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 348dcb804..cc3891e63 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 14870 . +# From configure.in Revision: 15238 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -272,7 +272,7 @@ PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= -ac_unique_file="eAthena" +ac_unique_file="rAthena" ac_unique_file="src/common/cbasetypes.h" # Factoring default headers for most tests. ac_includes_default="\ @@ -849,6 +849,8 @@ Optional Features: --enable-debug[=ARG] Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) + --enable-buildbot[=ARG] + (available options: yes, no) --enable-rdtsc Uses rdtsc as timing source (disabled by default) Enable it when you've timing issues. (For example: in conjunction with XEN or Other Virtualization @@ -1405,8 +1407,9 @@ else fi; # -# BuildBot +# Buildbot # +# Check whether --enable-buildbot or --disable-buildbot was given. if test "${enable_buildbot+set}" = set; then enableval="$enable_buildbot" @@ -1424,7 +1427,6 @@ else fi; - # # RDTSC as Tick Source # @@ -4495,14 +4497,13 @@ esac # case $enable_buildbot in "no") - #default value + # default value ;; "yes") - CFLAGS="$CFLAGS -g -DBUILDBOT" + CFLAGS="$CFLAGS -DBUILDBOT" ;; esac - # # RDTSC # diff --git a/configure.in b/configure.in index 3aff089db..8872e7c8c 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT(eAthena) +AC_INIT(rAthena) AC_REVISION($Revision$) AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) @@ -75,6 +75,26 @@ AC_ARG_ENABLE( [enable_debug="no"] ) +# +# Buildbot +# +AC_ARG_ENABLE( + [buildbot], + AC_HELP_STRING( + [--enable-buildbot@<:@=ARG@:>@], + [(available options: yes, no)] + ), + [ + enable_buildbot="$enableval" + case $enableval in + "no");; + "yes");; + *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);; + esac + ], + [enable_buildbot="no"] +) + # # RDTSC as Tick Source # @@ -511,6 +531,17 @@ case $enable_debug in ;; esac +# +# Buildbot +# +case $enable_buildbot in + "no") + # default value + ;; + "yes") + CFLAGS="$CFLAGS -DBUILDBOT" + ;; +esac # # RDTSC -- cgit v1.2.3-70-g09d2 From 44d7606656a650dc43018b5c63bb56ad1f70e77c Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Fri, 20 Jan 2012 20:33:32 +0000 Subject: Merged TXT removal branch back to trunk. * TXT save engine is removed and no longer supported. * See also tid:53926, tid:57717. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15503 54d463be-8e91-2dee-dedb-b68131a5f0ec --- CMakeLists.txt | 6 - Makefile.in | 73 +- charserv.bat | 2 - conf/char_athena.conf | 6 - conf/inter_athena.conf | 31 - conf/login_athena.conf | 3 - configure | 99 +- configure.in | 88 +- logserv.bat | 2 - mapserv.bat | 2 - rAthena-10.sln | 90 - rAthena-9.sln | 90 - runserver.bat | 75 - save-tmpl/account.txt | 16 - save-tmpl/accreg.txt | 0 save-tmpl/athena.txt | 0 save-tmpl/athena_backup.txt | 0 save-tmpl/castle.txt | 34 - save-tmpl/friends.txt | 0 save-tmpl/g_storage.txt | 0 save-tmpl/guild.txt | 0 save-tmpl/homun.txt | 0 save-tmpl/mapreg.txt | 0 save-tmpl/party.txt | 0 save-tmpl/pet.txt | 0 save-tmpl/scdata.txt | 0 save-tmpl/storage.txt | 0 src/CMakeLists.txt | 7 - src/char/CMakeLists.txt | 79 +- src/char/Makefile.in | 53 +- src/char/char.c | 3477 +++++++++---------- src/char/char.h | 75 +- src/char/int_auction.c | 494 +++ src/char/int_auction.h | 12 + src/char/int_guild.c | 2377 +++++++------ src/char/int_guild.h | 40 +- src/char/int_homun.c | 526 ++- src/char/int_homun.h | 21 +- src/char/int_mail.c | 476 +++ src/char/int_mail.h | 16 + src/char/int_mercenary.c | 218 ++ src/char/int_mercenary.h | 20 + src/char/int_party.c | 761 ++-- src/char/int_party.h | 34 +- src/char/int_pet.c | 447 +-- src/char/int_pet.h | 14 +- src/char/int_quest.c | 184 + src/char/int_quest.h | 13 + src/char/int_status.c | 183 - src/char/int_status.h | 23 - src/char/int_storage.c | 501 +-- src/char/int_storage.h | 24 +- src/char/inter.c | 762 ++-- src/char/inter.h | 19 +- src/char_sql/CMakeLists.txt | 58 - src/char_sql/Makefile.in | 71 - src/char_sql/char.c | 4636 ------------------------- src/char_sql/char.h | 83 - src/char_sql/int_auction.c | 494 --- src/char_sql/int_auction.h | 12 - src/char_sql/int_guild.c | 2018 ----------- src/char_sql/int_guild.h | 40 - src/char_sql/int_homun.c | 313 -- src/char_sql/int_homun.h | 18 - src/char_sql/int_mail.c | 476 --- src/char_sql/int_mail.h | 16 - src/char_sql/int_mercenary.c | 221 -- src/char_sql/int_mercenary.h | 20 - src/char_sql/int_party.c | 870 ----- src/char_sql/int_party.h | 32 - src/char_sql/int_pet.c | 310 -- src/char_sql/int_pet.h | 21 - src/char_sql/int_quest.c | 184 - src/char_sql/int_quest.h | 13 - src/char_sql/int_storage.c | 250 -- src/char_sql/int_storage.h | 22 - src/char_sql/inter.c | 744 ---- src/char_sql/inter.h | 30 - src/login/CMakeLists.txt | 2 - src/login/Makefile.in | 22 +- src/login/account.h | 6 +- src/login/account_txt.c | 645 ---- src/login/ipban_txt.c | 50 - src/login/login.c | 5 - src/login/loginlog_txt.c | 81 - src/login/txt/CMakeLists.txt | 39 - src/map/CMakeLists.txt | 2 - src/map/Makefile.in | 8 +- src/map/atcommand.c | 10 +- src/map/chrif.c | 14 +- src/map/clif.c | 9 - src/map/clif.h | 2 - src/map/intif.c | 7 +- src/map/intif.h | 2 - src/map/itemdb.c | 4 - src/map/log.c | 23 - src/map/mail.c | 4 - src/map/map.c | 16 +- src/map/map.h | 4 - src/map/mapreg_txt.c | 202 -- src/map/mob.c | 6 - src/map/pc.c | 10 +- src/map/script.c | 26 +- src/map/txt/CMakeLists.txt | 108 - src/txt-converter/CMakeLists.txt | 17 - src/txt-converter/Makefile.in | 150 - src/txt-converter/char-converter.c | 303 -- src/txt-converter/char/CMakeLists.txt | 76 - src/txt-converter/login-converter.c | 108 - src/txt-converter/login/CMakeLists.txt | 60 - vcproj-10/char-server_sql.vcxproj | 44 +- vcproj-10/char-server_sql.vcxproj.filters | 44 +- vcproj-10/char-server_txt.vcxproj | 184 - vcproj-10/char-server_txt.vcxproj.filters | 168 - vcproj-10/login-server_txt.vcxproj | 175 - vcproj-10/login-server_txt.vcxproj.filters | 144 - vcproj-10/map-server_txt.vcxproj | 250 -- vcproj-10/map-server_txt.vcxproj.filters | 345 -- vcproj-10/txt-converter-char.vcxproj | 204 -- vcproj-10/txt-converter-char.vcxproj.filters | 156 - vcproj-10/txt-converter-login.vcxproj | 162 - vcproj-10/txt-converter-login.vcxproj.filters | 90 - vcproj-9/char-server_sql.vcproj | 44 +- vcproj-9/char-server_txt.vcproj | 417 --- vcproj-9/login-server_txt.vcproj | 380 -- vcproj-9/map-server_txt.vcproj | 681 ---- vcproj-9/txt-converter-char.vcproj | 513 --- vcproj-9/txt-converter-login.vcproj | 309 -- 128 files changed, 6263 insertions(+), 22493 deletions(-) delete mode 100755 charserv.bat delete mode 100755 logserv.bat delete mode 100755 mapserv.bat delete mode 100755 runserver.bat delete mode 100644 save-tmpl/account.txt delete mode 100644 save-tmpl/accreg.txt delete mode 100644 save-tmpl/athena.txt delete mode 100644 save-tmpl/athena_backup.txt delete mode 100644 save-tmpl/castle.txt delete mode 100644 save-tmpl/friends.txt delete mode 100644 save-tmpl/g_storage.txt delete mode 100644 save-tmpl/guild.txt delete mode 100644 save-tmpl/homun.txt delete mode 100644 save-tmpl/mapreg.txt delete mode 100644 save-tmpl/party.txt delete mode 100644 save-tmpl/pet.txt delete mode 100644 save-tmpl/scdata.txt delete mode 100644 save-tmpl/storage.txt create mode 100644 src/char/int_auction.c create mode 100644 src/char/int_auction.h create mode 100644 src/char/int_mail.c create mode 100644 src/char/int_mail.h create mode 100644 src/char/int_mercenary.c create mode 100644 src/char/int_mercenary.h create mode 100644 src/char/int_quest.c create mode 100644 src/char/int_quest.h delete mode 100644 src/char/int_status.c delete mode 100644 src/char/int_status.h delete mode 100644 src/char_sql/CMakeLists.txt delete mode 100644 src/char_sql/Makefile.in delete mode 100644 src/char_sql/char.c delete mode 100644 src/char_sql/char.h delete mode 100644 src/char_sql/int_auction.c delete mode 100644 src/char_sql/int_auction.h delete mode 100644 src/char_sql/int_guild.c delete mode 100644 src/char_sql/int_guild.h delete mode 100644 src/char_sql/int_homun.c delete mode 100644 src/char_sql/int_homun.h delete mode 100644 src/char_sql/int_mail.c delete mode 100644 src/char_sql/int_mail.h delete mode 100644 src/char_sql/int_mercenary.c delete mode 100644 src/char_sql/int_mercenary.h delete mode 100644 src/char_sql/int_party.c delete mode 100644 src/char_sql/int_party.h delete mode 100644 src/char_sql/int_pet.c delete mode 100644 src/char_sql/int_pet.h delete mode 100644 src/char_sql/int_quest.c delete mode 100644 src/char_sql/int_quest.h delete mode 100644 src/char_sql/int_storage.c delete mode 100644 src/char_sql/int_storage.h delete mode 100644 src/char_sql/inter.c delete mode 100644 src/char_sql/inter.h delete mode 100644 src/login/account_txt.c delete mode 100644 src/login/ipban_txt.c delete mode 100644 src/login/loginlog_txt.c delete mode 100644 src/login/txt/CMakeLists.txt delete mode 100644 src/map/mapreg_txt.c delete mode 100644 src/map/txt/CMakeLists.txt delete mode 100644 src/txt-converter/CMakeLists.txt delete mode 100644 src/txt-converter/Makefile.in delete mode 100644 src/txt-converter/char-converter.c delete mode 100644 src/txt-converter/char/CMakeLists.txt delete mode 100644 src/txt-converter/login-converter.c delete mode 100644 src/txt-converter/login/CMakeLists.txt delete mode 100644 vcproj-10/char-server_txt.vcxproj delete mode 100644 vcproj-10/char-server_txt.vcxproj.filters delete mode 100644 vcproj-10/login-server_txt.vcxproj delete mode 100644 vcproj-10/login-server_txt.vcxproj.filters delete mode 100644 vcproj-10/map-server_txt.vcxproj delete mode 100644 vcproj-10/map-server_txt.vcxproj.filters delete mode 100644 vcproj-10/txt-converter-char.vcxproj delete mode 100644 vcproj-10/txt-converter-char.vcxproj.filters delete mode 100644 vcproj-10/txt-converter-login.vcxproj delete mode 100644 vcproj-10/txt-converter-login.vcxproj.filters delete mode 100644 vcproj-9/char-server_txt.vcproj delete mode 100644 vcproj-9/login-server_txt.vcproj delete mode 100644 vcproj-9/map-server_txt.vcproj delete mode 100644 vcproj-9/txt-converter-char.vcproj delete mode 100644 vcproj-9/txt-converter-login.vcproj (limited to 'configure') diff --git a/CMakeLists.txt b/CMakeLists.txt index 14a244b82..b60a5de20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,7 +443,6 @@ set( DEVELOPMENT_FILES set( DEVELOPMENT_DIRECTORIES "3rdparty" "conf/import-tmpl" - "save-tmpl" "src" "vcproj-9" "vcproj-10" @@ -452,21 +451,17 @@ set( RUNTIME_FILES "${CMAKE_CURRENT_SOURCE_DIR}/athena-start" "${CMAKE_CURRENT_SOURCE_DIR}/char-server.sh" "${CMAKE_CURRENT_SOURCE_DIR}/charserv-sql.bat" - "${CMAKE_CURRENT_SOURCE_DIR}/charserv.bat" "${CMAKE_CURRENT_SOURCE_DIR}/dbghelp.dll" "${CMAKE_CURRENT_SOURCE_DIR}/libmysql.dll" "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_SOURCE_DIR}/login-server.sh" "${CMAKE_CURRENT_SOURCE_DIR}/logserv-sql.bat" - "${CMAKE_CURRENT_SOURCE_DIR}/logserv.bat" "${CMAKE_CURRENT_SOURCE_DIR}/map-server.sh" "${CMAKE_CURRENT_SOURCE_DIR}/mapserv-sql.bat" - "${CMAKE_CURRENT_SOURCE_DIR}/mapserv.bat" "${CMAKE_CURRENT_SOURCE_DIR}/notice.txt" "${CMAKE_CURRENT_SOURCE_DIR}/pcre3.dll" "${CMAKE_CURRENT_SOURCE_DIR}/readme.html" "${CMAKE_CURRENT_SOURCE_DIR}/runserver-sql.bat" - "${CMAKE_CURRENT_SOURCE_DIR}/runserver.bat" "${CMAKE_CURRENT_SOURCE_DIR}/serv.bat" "${CMAKE_CURRENT_SOURCE_DIR}/start" "${CMAKE_CURRENT_SOURCE_DIR}/zlib1.dll" @@ -511,7 +506,6 @@ endif() if( INSTALL_COMPONENT_RUNTIME ) # templates set( _TEMPLATES - "save-tmpl" "save" "conf/import-tmpl" "conf/import" ) set( INSTALL_TEMPLATES_FILE "${CMAKE_CURRENT_BINARY_DIR}/InstallTemplates.cmake" ) diff --git a/Makefile.in b/Makefile.in index ea3106317..02ca9b987 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,76 +2,56 @@ HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=mt19937ar common common_sql login login_sql char char_sql map map_sql tools converters import save - SQL_DEPENDS=mt19937ar common_sql login_sql char_sql map_sql import save + ALL_DEPENDS=common_sql login_sql char_sql map_sql tools import + SQL_DEPENDS=common_sql login_sql char_sql map_sql import COMMON_SQL_DEPENDS=mt19937ar LOGIN_SQL_DEPENDS=mt19937ar common_sql CHAR_SQL_DEPENDS=mt19937ar common_sql MAP_SQL_DEPENDS=mt19937ar common_sql CONVERTERS_DEPENDS=common_sql else - ALL_DEPENDS=mt19937ar common login char map tools import save + ALL_DEPENDS=needs_mysql SQL_DEPENDS=needs_mysql COMMON_SQL_DEPENDS=needs_mysql LOGIN_SQL_DEPENDS=needs_mysql CHAR_SQL_DEPENDS=needs_mysql MAP_SQL_DEPENDS=needs_mysql - CONVERTERS_DEPENDS=needs_mysql endif -COMMON_TXT_DEPENDS=mt19937ar -LOGIN_TXT_DEPENDS=mt19937ar common -CHAR_TXT_DEPENDS=mt19937ar common -MAP_TXT_DEPENDS=mt19937ar common WITH_PLUGINS=@WITH_PLUGINS@ ifeq ($(WITH_PLUGINS),yes) ALL_DEPENDS+=plugins - PLUGIN_DEPENDS=common + PLUGIN_DEPENDS=common_sql else PLUGIN_DEPENDS=no_plugins endif ##################################################################### -.PHONY: txt sql conf \ - common common_sql \ +.PHONY: sql \ + common_sql \ mt19937ar \ - login login_sql \ - char char_sql \ - map map_sql \ - tools converters plugins addons import save \ + login_sql \ + char_sql \ + map_sql \ + tools plugins addons \ + import \ clean help all: $(ALL_DEPENDS) -txt: common login char map import save - sql: $(SQL_DEPENDS) -conf: import save - -common: $(COMMON_TXT_DEPENDS) - @$(MAKE) -C src/common txt - common_sql: $(COMMON_SQL_DEPENDS) @$(MAKE) -C src/common sql mt19937ar: @$(MAKE) -C 3rdparty/mt19937ar -login: $(LOGIN_TXT_DEPENDS) - @$(MAKE) -C src/login txt - login_sql: $(LOGIN_SQL_DEPENDS) @$(MAKE) -C src/login sql -char: $(CHAR_TXT_DEPENDS) - @$(MAKE) -C src/char - char_sql: $(CHAR_SQL_DEPENDS) - @$(MAKE) -C src/char_sql - -map: $(MAP_TXT_DEPENDS) - @$(MAKE) -C src/map txt + @$(MAKE) -C src/char map_sql: $(MAP_SQL_DEPENDS) @$(MAKE) -C src/map sql @@ -79,12 +59,9 @@ map_sql: $(MAP_SQL_DEPENDS) tools: @$(MAKE) -C src/tool -converters: $(CONVERTERS_DEPENDS) - @$(MAKE) -C src/txt-converter - plugins addons: $(PLUGIN_DEPENDS) @$(MAKE) -C src/plugins - + import: # 1) create conf/import folder # 2) add missing files @@ -94,50 +71,30 @@ import: @for f in $$(ls conf/import-tmpl) ; do if test ! -e conf/import/$$f ; then cp conf/import-tmpl/$$f conf/import ; fi ; done @rm -rf conf/import/.svn -save: -# 1) create save folder -# 2) add missing files -# 3) remove remaining .svn folder - @echo "building save folder..." - @if test ! -d save ; then mkdir save ; fi - @for f in $$(ls save-tmpl) ; do if test ! -e save/$$f ; then cp save-tmpl/$$f save ; fi ; done - @rm -rf save/.svn - clean: @$(MAKE) -C src/common $@ @$(MAKE) -C 3rdparty/mt19937ar $@ @$(MAKE) -C src/login $@ @$(MAKE) -C src/char $@ - @$(MAKE) -C src/char_sql $@ @$(MAKE) -C src/map $@ @$(MAKE) -C src/plugins $@ @$(MAKE) -C src/tool $@ - @$(MAKE) -C src/txt-converter $@ help: - @echo "most common targets are 'all' 'txt' 'sql' 'conf' 'clean' 'help'" + @echo "most common targets are 'all' 'sql' 'conf' 'clean' 'help'" @echo "possible targets are:" - @echo "'common' - builds object files used in TXT servers" @echo "'common_sql' - builds object files used in SQL servers" @echo "'mt19937ar' - builds object file of Mersenne Twister MT19937" - @echo "'login' - builds login server (TXT version)" @echo "'login_sql' - builds login server (SQL version)" - @echo "'char' - builds char server (TXT version)" @echo "'char_sql' - builds char server (SQL version)" - @echo "'map' - builds map server (TXT version)" @echo "'map_sql' - builds map server (SQL version)" @echo "'tools' - builds all the tools in src/tools" - @echo "'converters' - builds the login/char converters" @echo "'plugins' - builds all the plugins in src/plugins" @echo "'addons'" @echo "'import' - builds conf/import folder from the template conf/import-tmpl" - @echo "'save' - builds save folder from the template save-tmpl" @echo "'all' - builds all the above targets" - @echo "'txt' - builds txt servers (targets 'common' 'login' 'char' 'map'" - @echo " 'import' and 'save')" @echo "'sql' - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'" - @echo " 'map_sql' 'import' and 'save')" - @echo "'conf' - builds templated folders/files (targets 'import' and 'save')" + @echo " 'map_sql' and 'import')" @echo "'clean' - cleans builds and objects" @echo "'help' - outputs this message" diff --git a/charserv.bat b/charserv.bat deleted file mode 100755 index b21efac35..000000000 --- a/charserv.bat +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -CALL serv.bat char-server.exe Char-Server diff --git a/conf/char_athena.conf b/conf/char_athena.conf index 4ffd47783..bc9e1ab1c 100644 --- a/conf/char_athena.conf +++ b/conf/char_athena.conf @@ -104,12 +104,6 @@ autosave_time: 60 // Display information on the console whenever characters/guilds/parties/pets are loaded/saved? save_log: yes -// Character server flatfile database -char_txt: save/athena.txt - -// Friends list flatfile database -friends_txt: save/friends.txt - // Start point, Map name followed by coordinates (x,y) start_point: new_1-1,53,111 diff --git a/conf/inter_athena.conf b/conf/inter_athena.conf index 03e39b90d..bf6c4f417 100644 --- a/conf/inter_athena.conf +++ b/conf/inter_athena.conf @@ -11,37 +11,6 @@ inter_log_filename: log/inter.log // Level range for sharing within a party party_share_level: 15 - -// TXT version options only - -// Storage flatfile database, used for Karfa storage. -storage_txt: save/storage.txt - -// Party flatfile database, for party names, members and other party info. -party_txt: save/party.txt - -// Hotkeys flatfile database, where character skill shortcuts are stored. -hotkeys_txt: save/hotkeys.txt - -// Guild flatfile database, for guild names, members, and other guild info. -guild_txt: save/guild.txt - -// Pet flatfile database, for pet names, and other pet info. -pet_txt: save/pet.txt - -// Homunculus flatfile database, for homunculus information. -homun_txt: save/homun.txt - -// Castle flatfile database, for emperium war castles, etc. -castle_txt: save/castle.txt - -// Status change flatfile database, for status changes that are saved between sessions. -scdata_txt: save/scdata.txt - -// Mapserver permanent script variables ($-type) -mapreg_txt: save/mapreg.txt - - // SQL version options only // You can specify the codepage to use in your mySQL tables here. diff --git a/conf/login_athena.conf b/conf/login_athena.conf index 7ee08881b..aab2f854c 100644 --- a/conf/login_athena.conf +++ b/conf/login_athena.conf @@ -117,9 +117,6 @@ dnsbl_servers: dnsbl.deltaanime.net account.engine: auto // Account data storage configuration -// TXT -account.txt.account_db: save/account.txt -account.txt.case_sensitive: no // SQL //account.sql.db_hostname: 127.0.0.1 //account.sql.db_port: 3306 diff --git a/configure b/configure index cc3891e63..9494bacd5 100755 --- a/configure +++ b/configure @@ -868,9 +868,8 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-mysql[=ARG] - use MySQL client library, optionally specify the - path to the mysql_config executable (by default - mysql is used if found) + optionally specify the path to the mysql_config + executable --with-MYSQL_CFLAGS=ARG specify MYSQL_CFLAGS manually (instead of using "mysql_config --include") --with-MYSQL_LIBS=ARG specify MYSQL_LIBS manually (instead of using @@ -1339,8 +1338,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" - ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile" - ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile" @@ -1486,30 +1483,22 @@ fi; # -# Enable/disable MySql and optionally specify the path to mysql_config (optional library) +# Optionally specify the path to mysql_config # # Check whether --with-mysql or --without-mysql was given. if test "${with_mysql+set}" = set; then withval="$with_mysql" - if test "$withval" = "no" ; then - want_mysql="no" - else - want_mysql="yes" - require_mysql="yes" - if test "$withval" != "yes" ; then - if test ! -x "$withval" ; then - { { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 + if test "$withval" != "no" ; then + if test ! -x "$withval" ; then + { { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5 echo "$as_me: error: $withval is not an executable file" >&2;} { (exit 1); exit 1; }; } - fi - MYSQL_CONFIG_HOME="$withval" fi + MYSQL_CONFIG_HOME="$withval" fi -else - want_mysql="yes" require_mysql="no" fi; @@ -5096,18 +5085,11 @@ fi # -# MySQL library (optional) +# MySQL library # -if test "$want_mysql" = "no" ; then - MYSQL_VERSION="" - MYSQL_CFLAGS="" - MYSQL_LIBS="" - { echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5 -echo "$as_me: ignoring MySQL (optional)" >&6;} -else - if test -z "$MYSQL_CONFIG_HOME"; then - # Extract the first word of "mysql_config", so it can be a program name with args. +if test -z "$MYSQL_CONFIG_HOME"; then + # Extract the first word of "mysql_config", so it can be a program name with args. set dummy mysql_config; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 @@ -5147,23 +5129,23 @@ else echo "${ECHO_T}no" >&6 fi - fi +fi - if test "$MYSQL_CONFIG_HOME" != "no" ; then - MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - if test "$manual_MYSQL_CFLAGS" = "no" ; then - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" - fi - if test "$manual_MYSQL_LIBS" = "no" ; then - MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - fi - else - MYSQL_VERSION="unknown" +if test "$MYSQL_CONFIG_HOME" != "no" ; then + MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" + if test "$manual_MYSQL_CFLAGS" = "no" ; then + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" fi + if test "$manual_MYSQL_LIBS" = "no" ; then + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" + fi +else + MYSQL_VERSION="unknown" +fi - MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" - MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 +MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" +MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" +echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5 echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6 if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5231,7 +5213,7 @@ if test $ac_cv_lib_mysqlclient_mysql_init = yes; then HAVE_MYSQL="yes" fi - if test "${ac_cv_header_mysql_h+set}" = set; then +if test "${ac_cv_header_mysql_h+set}" = set; then echo "$as_me:$LINENO: checking for mysql.h" >&5 echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6 if test "${ac_cv_header_mysql_h+set}" = set; then @@ -5375,29 +5357,20 @@ else fi - CPPFLAGS="$MYSQL_OLD_CPPFLAGS" - LDFLAGS="$MYSQL_OLD_LDFLAGS" +CPPFLAGS="$MYSQL_OLD_CPPFLAGS" +LDFLAGS="$MYSQL_OLD_LDFLAGS" - echo "$as_me:$LINENO: checking MySQL library (optional)" >&5 -echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6 - if test "$HAVE_MYSQL" = "yes" ; then - echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 +echo "$as_me:$LINENO: checking MySQL library (required)" >&5 +echo $ECHO_N "checking MySQL library (required)... $ECHO_C" >&6 +if test "$HAVE_MYSQL" = "yes" ; then + echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5 echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 +else + echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 - if test "$require_mysql" = "yes" ; then - { { echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5 -echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;} + { { echo "$as_me:$LINENO: error: MySQL not found or incompatible" >&5 +echo "$as_me: error: MySQL not found or incompatible" >&2;} { (exit 1); exit 1; }; } - else - { echo "$as_me:$LINENO: disabling MySQL (optional)" >&5 -echo "$as_me: disabling MySQL (optional)" >&6;} - MYSQL_VERSION="" - MYSQL_CFLAGS="" - MYSQL_LIBS="" - fi - fi fi @@ -6195,8 +6168,6 @@ do "3rdparty/mt19937ar/Makefile" ) CONFIG_FILES="$CONFIG_FILES 3rdparty/mt19937ar/Makefile" ;; "src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; "src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; - "src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;; - "src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;; "src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; "src/plugins/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;; "src/tool/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; diff --git a/configure.in b/configure.in index 8872e7c8c..3269537b2 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,6 @@ AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile]) -AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) @@ -166,29 +165,22 @@ AC_ARG_ENABLE( # -# Enable/disable MySql and optionally specify the path to mysql_config (optional library) +# Optionally specify the path to mysql_config # AC_ARG_WITH( [mysql], AC_HELP_STRING( [--with-mysql@<:@=ARG@:>@], - [use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)] + [optionally specify the path to the mysql_config executable] ), [ - if test "$withval" = "no" ; then - want_mysql="no" - else - want_mysql="yes" - require_mysql="yes" - if test "$withval" != "yes" ; then - if test ! -x "$withval" ; then - AC_MSG_ERROR([$withval is not an executable file]) - fi - MYSQL_CONFIG_HOME="$withval" + if test "$withval" != "no" ; then + if test ! -x "$withval" ; then + AC_MSG_ERROR([$withval is not an executable file]) fi + MYSQL_CONFIG_HOME="$withval" fi - ], - [want_mysql="yes" require_mysql="no"] + ] ) @@ -632,52 +624,38 @@ fi # -# MySQL library (optional) +# MySQL library # -if test "$want_mysql" = "no" ; then - MYSQL_VERSION="" - MYSQL_CFLAGS="" - MYSQL_LIBS="" - AC_MSG_NOTICE([ignoring MySQL (optional)]) -else - if test -z "$MYSQL_CONFIG_HOME"; then - AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no]) - fi +if test -z "$MYSQL_CONFIG_HOME"; then + AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no]) +fi - if test "$MYSQL_CONFIG_HOME" != "no" ; then - MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" - if test "$manual_MYSQL_CFLAGS" = "no" ; then - MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" - fi - if test "$manual_MYSQL_LIBS" = "no" ; then - MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" - fi - else - MYSQL_VERSION="unknown" +if test "$MYSQL_CONFIG_HOME" != "no" ; then + MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`" + if test "$manual_MYSQL_CFLAGS" = "no" ; then + MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`" + fi + if test "$manual_MYSQL_LIBS" = "no" ; then + MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`" fi +else + MYSQL_VERSION="unknown" +fi - MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" - MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" - AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], []) - AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""]) - CPPFLAGS="$MYSQL_OLD_CPPFLAGS" - LDFLAGS="$MYSQL_OLD_LDFLAGS" +MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS" +MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS" +AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], []) +AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""]) +CPPFLAGS="$MYSQL_OLD_CPPFLAGS" +LDFLAGS="$MYSQL_OLD_LDFLAGS" - AC_MSG_CHECKING([MySQL library (optional)]) - if test "$HAVE_MYSQL" = "yes" ; then - AC_MSG_RESULT([yes ($MYSQL_VERSION)]) - else - AC_MSG_RESULT([no]) - if test "$require_mysql" = "yes" ; then - AC_MSG_ERROR([MySQL not found or incompatible (requested)]) - else - AC_MSG_NOTICE([disabling MySQL (optional)]) - MYSQL_VERSION="" - MYSQL_CFLAGS="" - MYSQL_LIBS="" - fi - fi +AC_MSG_CHECKING([MySQL library (required)]) +if test "$HAVE_MYSQL" = "yes" ; then + AC_MSG_RESULT([yes ($MYSQL_VERSION)]) +else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([MySQL not found or incompatible]) fi AC_SUBST([HAVE_MYSQL]) diff --git a/logserv.bat b/logserv.bat deleted file mode 100755 index a36e07f17..000000000 --- a/logserv.bat +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -CALL serv.bat login-server.exe Login-Server diff --git a/mapserv.bat b/mapserv.bat deleted file mode 100755 index fc6235092..000000000 --- a/mapserv.bat +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -CALL serv.bat map-server.exe Map-Server diff --git a/rAthena-10.sln b/rAthena-10.sln index 991395305..ea8847037 100644 --- a/rAthena-10.sln +++ b/rAthena-10.sln @@ -1,11 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-10\map-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-10\login-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-10\char-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-10\char-server_sql.vcxproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-10\login-server_sql.vcxproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" @@ -14,112 +8,28 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-10 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-10\mapcache.vcxproj", "{D356871D-58E1-450B-967A-E7E9646175AF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-10\txt-converter-login.vcxproj", "{D356871D-58E1-450B-967A-E9E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-10\txt-converter-char.vcxproj", "{D356871D-58E1-450B-967A-EAE9646175AF}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Debug-sql|Win32 = Debug-sql|Win32 - Debug-txt|Win32 = Debug-txt|Win32 Release|Win32 = Release|Win32 - Release-sql|Win32 = Release-sql|Win32 - Release-txt|Win32 = Release-txt|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/rAthena-9.sln b/rAthena-9.sln index 7a1f69c67..7d8588f07 100644 --- a/rAthena-9.sln +++ b/rAthena-9.sln @@ -1,11 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-9\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-9\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-9\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-9\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-9\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" @@ -14,10 +8,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-9\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-9\mapcache.vcproj", "{D356871D-58E1-450B-967A-E7E9646175AF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-9\txt-converter-login.vcproj", "{D356871D-58E1-450B-967A-E9E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-9\txt-converter-char.vcproj", "{D356871D-58E1-450B-967A-EAE9646175AF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin-console", "vcproj-9\plugin-console.vcproj", "{73E1101A-310C-4453-8F45-FD2795ABEF15}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin-pid", "vcproj-9\plugin-pid.vcproj", "{9509E1B9-DA2B-4153-9EE0-CBCA6597F198}" @@ -25,105 +15,25 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Debug-sql|Win32 = Debug-sql|Win32 - Debug-txt|Win32 = Debug-txt|Win32 Release|Win32 = Release|Win32 - Release-sql|Win32 = Release-sql|Win32 - Release-txt|Win32 = Release-txt|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 {D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.Build.0 = Release|Win32 {73E1101A-310C-4453-8F45-FD2795ABEF15}.Debug|Win32.ActiveCfg = Debug|Win32 {73E1101A-310C-4453-8F45-FD2795ABEF15}.Debug|Win32.Build.0 = Debug|Win32 {73E1101A-310C-4453-8F45-FD2795ABEF15}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/runserver.bat b/runserver.bat deleted file mode 100755 index 553274013..000000000 --- a/runserver.bat +++ /dev/null @@ -1,75 +0,0 @@ -@echo off - -rem ----- Configuration ----- - rem Defines the server type (txt or sql). - set SERVER_TYPE=txt - rem Defines how long to wait before restarting (in seconds). - set SLEEP_TIME=15 - rem Defines whether to run all servers in one window (yes or no). - set SINGLE_WINDOW=no -rem ----- ------------- ----- - -:L_Init - set this=%0 - if %SERVER_TYPE% == txt set suffix= - if %SERVER_TYPE% == sql set suffix=_sql - if %SINGLE_WINDOW% == yes set wndswitch=/B - -:L_Main - set command=%1 - if "%command%" == "" goto L_DefaultAction - - if %command% == exec goto L_ExecServerExe - if %command% == start goto L_StartServerExe - if %command% == stop goto L_StopServerExe - if %command% == restart echo "TODO" - goto L_EOF - -:L_DefaultAction -:L_StartServer - call %this% start login-server%suffix%.exe - call %this% start char-server%suffix%.exe - call %this% start map-server%suffix%.exe - goto L_EOF - -:L_StopServer - call %this% stop login-server%suffix%.exe - call %this% stop char-server%suffix%.exe - call %this% stop map-server%suffix%.exe - goto L_EOF - -:L_StartServerExe - set filename=%2 - if "%filename%" == "" goto L_StartServer - if exist %filename% goto L_HaveExe - echo Cannot start '%filename%' because the file is missing! - goto L_EOF - - :L_HaveExe - echo Starting %filename%... - start "%filename%" %wndswitch% %this% exec %filename% - goto L_EOF - -:L_StopServerExe - set filename=%2 - if "%filename%" == "" goto L_StopServer - if exist %windir%\system32\taskkill.exe goto L_HaveTaskKill - echo The 'stop' command is not available on your system. - exit - - :L_HaveTaskKill - rem CAUTION! This will kill all processes called %filename%. - echo Stopping '%filename%'... - taskkill /F /FI "WINDOWTITLE eq %filename% - %this% exec %filename%" - taskkill /F /IM "%filename%" - goto L_EOF - -:L_ExecServerExe - %filename% - echo . - echo . - echo Server exited, restarting in %SLEEP_TIME% seconds! Press CTRL+C to abort! - ping.exe -n %SLEEP_TIME% 127.0.0.1 > nul - goto L_ExecServerExe - -:L_EOF diff --git a/save-tmpl/account.txt b/save-tmpl/account.txt deleted file mode 100644 index eadbc4c4f..000000000 --- a/save-tmpl/account.txt +++ /dev/null @@ -1,16 +0,0 @@ -20110114 -// Accounts file: here are saved all information about the accounts. -// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, birth date, repeated(register key, register value) -// where: -// sex : M or F for normal accounts, S for server accounts -// level : this account's gm level -// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1 -// unban time : 0: no ban, : banned until the date (unix timestamp) -// expiration time : 0: unlimited account, : account expires on the date (unix timestamp) -1 s1 p1 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -2 s2 p2 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -3 s3 p3 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -4 s4 p4 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -5 s5 p5 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -2000001 Test Test M a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00 -2000002 %newid% diff --git a/save-tmpl/accreg.txt b/save-tmpl/accreg.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/athena.txt b/save-tmpl/athena.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/athena_backup.txt b/save-tmpl/athena_backup.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/castle.txt b/save-tmpl/castle.txt deleted file mode 100644 index 5270d976b..000000000 --- a/save-tmpl/castle.txt +++ /dev/null @@ -1,34 +0,0 @@ -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/save-tmpl/friends.txt b/save-tmpl/friends.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/g_storage.txt b/save-tmpl/g_storage.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/guild.txt b/save-tmpl/guild.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/homun.txt b/save-tmpl/homun.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/mapreg.txt b/save-tmpl/mapreg.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/party.txt b/save-tmpl/party.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/pet.txt b/save-tmpl/pet.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/scdata.txt b/save-tmpl/scdata.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/save-tmpl/storage.txt b/save-tmpl/storage.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ec05e405..0c120f99a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,11 +3,6 @@ # setup and static libraries # add_subdirectory( common ) -if( HAVE_common_base ) - option( BUILD_TXT_SERVERS "build txt server executables" ON ) -else() - message( STATUS "Disabled txt server targets (requires common_base)" ) -endif() if( HAVE_common_sql ) option( BUILD_SQL_SERVERS "build sql server executables" ON ) else() @@ -20,8 +15,6 @@ endif() # add_subdirectory( login ) add_subdirectory( char ) -add_subdirectory( char_sql ) add_subdirectory( map ) add_subdirectory( tool ) -add_subdirectory( txt-converter ) add_subdirectory( plugins ) diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index fa1c3f366..823939393 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -2,52 +2,57 @@ # # setup # -set( TXT_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) +set( SQL_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) # -# char txt +# char sql # -if( BUILD_TXT_SERVERS ) -message( STATUS "Creating target char-server" ) -set( TXT_CHAR_HEADERS - "${TXT_CHAR_SOURCE_DIR}/char.h" - "${TXT_CHAR_SOURCE_DIR}/int_guild.h" - "${TXT_CHAR_SOURCE_DIR}/int_homun.h" - "${TXT_CHAR_SOURCE_DIR}/int_party.h" - "${TXT_CHAR_SOURCE_DIR}/int_pet.h" - "${TXT_CHAR_SOURCE_DIR}/int_status.h" - "${TXT_CHAR_SOURCE_DIR}/int_storage.h" - "${TXT_CHAR_SOURCE_DIR}/inter.h" +if( BUILD_SQL_SERVERS ) +message( STATUS "Creating target char-server_sql" ) +set( SQL_CHAR_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/char.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_auction.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_mail.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_party.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_quest.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.h" + "${CMAKE_CURRENT_SOURCE_DIR}/inter.h" ) -set( TXT_CHAR_SOURCES - "${TXT_CHAR_SOURCE_DIR}/char.c" - "${TXT_CHAR_SOURCE_DIR}/int_guild.c" - "${TXT_CHAR_SOURCE_DIR}/int_homun.c" - "${TXT_CHAR_SOURCE_DIR}/int_party.c" - "${TXT_CHAR_SOURCE_DIR}/int_pet.c" - "${TXT_CHAR_SOURCE_DIR}/int_status.c" - "${TXT_CHAR_SOURCE_DIR}/int_storage.c" - "${TXT_CHAR_SOURCE_DIR}/inter.c" +set( SQL_CHAR_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/char.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_auction.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_mail.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_party.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_quest.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.c" + "${CMAKE_CURRENT_SOURCE_DIR}/inter.c" ) -set( DEPENDENCIES common_base ) +set( DEPENDENCIES common_sql ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DTXT_ONLY" ) -set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_CHAR_HEADERS} ${TXT_CHAR_SOURCES} ) -source_group( common FILES ${COMMON_BASE_HEADERS} ) -source_group( char FILES ${TXT_CHAR_HEADERS} ${TXT_CHAR_SOURCES} ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) +set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} ) +source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) +source_group( char FILES ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} ) include_directories( ${INCLUDE_DIRS} ) -add_executable( char-server ${SOURCE_FILES} ) -add_dependencies( char-server ${DEPENDENCIES} ) -target_link_libraries( char-server ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( char-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) +add_executable( char-server_sql ${SOURCE_FILES} ) +add_dependencies( char-server_sql ${DEPENDENCIES} ) +target_link_libraries( char-server_sql ${LIBRARIES} ${DEPENDENCIES} ) +set_target_properties( char-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_charserver_txt DESCRIPTION "char-server (txt version)" DISPLAY_NAME "char-server" GROUP Runtime ) - install( TARGETS char-server + cpack_add_component( Runtime_charserver_sql DESCRIPTION "char-server (sql version)" DISPLAY_NAME "char-server_sql" GROUP Runtime ) + install( TARGETS char-server_sql DESTINATION "." - COMPONENT Runtime_charserver_txt ) + COMPONENT Runtime_charserver_sql ) endif( INSTALL_COMPONENT_RUNTIME ) -set( TARGET_LIST ${TARGET_LIST} char-server CACHE INTERNAL "" ) -message( STATUS "Creating target char-server - done" ) -endif( BUILD_TXT_SERVERS ) +message( STATUS "Creating target char-server_sql - done" ) +endif( BUILD_SQL_SERVERS ) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 1fd54b20b..e96113f0e 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -14,41 +14,58 @@ MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar -CHAR_OBJ = obj_txt/char.o obj_txt/inter.o obj_txt/int_party.o obj_txt/int_guild.o \ - obj_txt/int_storage.o obj_txt/int_status.o obj_txt/int_pet.o obj_txt/int_homun.o -CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_status.h int_pet.h int_homun.h +COMMON_SQL_OBJ = ../common/obj_sql/sql.o +COMMON_H = ../common/sql.h + +CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \ + obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o +CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h + +HAVE_MYSQL=@HAVE_MYSQL@ +ifeq ($(HAVE_MYSQL),yes) + CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) +else + CHAR_SERVER_SQL_DEPENDS=needs_mysql +endif @SET_MAKE@ ##################################################################### -.PHONY : all char-server clean help +.PHONY : all char-server_sql clean help -all: char-server +all: char-server_sql -char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) - @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ +char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) + @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj_txt ../../char-server@EXEEXT@ + rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ help: - @echo "possible targets are 'char-server' 'all' 'clean' 'help'" - @echo "'char-server' - char server (TXT version)" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" + @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" + @echo "'char-server_sql' - char server (SQL version)" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" ##################################################################### -obj_txt: - -mkdir obj_txt +needs_mysql: + @echo "MySQL not found or disabled by the configure script" + @exit 1 -obj_txt/%.o: %.c $(CHAR_H) $(COMMON_H) $(MT19937AR_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql: + -mkdir obj_sql + +obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) + @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files ../common/obj_all/%.o: - @$(MAKE) -C ../common txt + @$(MAKE) -C ../common sql + +../common/obj_sql/%.o: + @$(MAKE) -C ../common sql MT19937AR_OBJ: @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/char/char.c b/src/char/char.c index aac469c5b..cb3007ff9 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -4,7 +4,6 @@ #include "../common/cbasetypes.h" #include "../common/core.h" #include "../common/db.h" -#include "../common/lock.h" #include "../common/malloc.h" #include "../common/mapindex.h" #include "../common/mmo.h" @@ -17,10 +16,9 @@ #include "inter.h" #include "int_guild.h" #include "int_homun.h" -#include "int_pet.h" +#include "int_mercenary.h" #include "int_party.h" #include "int_storage.h" -#include "int_status.h" #include "char.h" #include @@ -34,22 +32,43 @@ // private declarations #define CHAR_CONF_NAME "conf/char_athena.conf" #define LAN_CONF_NAME "conf/subnet_athena.conf" - -char char_txt[1024] = "save/athena.txt"; -char friends_txt[1024] = "save/friends.txt"; -char hotkeys_txt[1024] = "save/hotkeys.txt"; -char char_log_filename[1024] = "log/char.log"; +#define SQL_CONF_NAME "conf/inter_athena.conf" + +char char_db[256] = "char"; +char scdata_db[256] = "sc_data"; +char cart_db[256] = "cart_inventory"; +char inventory_db[256] = "inventory"; +char charlog_db[256] = "charlog"; +char storage_db[256] = "storage"; +char interlog_db[256] = "interlog"; +char reg_db[256] = "global_reg_value"; +char skill_db[256] = "skill"; +char memo_db[256] = "memo"; +char guild_db[256] = "guild"; +char guild_alliance_db[256] = "guild_alliance"; +char guild_castle_db[256] = "guild_castle"; +char guild_expulsion_db[256] = "guild_expulsion"; +char guild_member_db[256] = "guild_member"; +char guild_position_db[256] = "guild_position"; +char guild_skill_db[256] = "guild_skill"; +char guild_storage_db[256] = "guild_storage"; +char party_db[256] = "party"; +char pet_db[256] = "pet"; +char mail_db[256] = "mail"; // MAIL SYSTEM +char auction_db[256] = "auction"; // Auctions System +char friend_db[256] = "friends"; +char hotkey_db[256] = "hotkey"; +char quest_db[256] = "quest"; // show loading/saving messages -#ifndef TXT_SQL_CONVERT int save_log = 1; -#endif -//If your code editor is having problems syntax highlighting this file, uncomment this and RECOMMENT IT BEFORE COMPILING -//#undef TXT_SQL_CONVERT -#ifndef TXT_SQL_CONVERT +static DBMap* char_db_; // int char_id -> struct mmo_charstatus* + char db_path[1024] = "db"; +int db_use_sqldbs; + struct mmo_map_server { int fd; uint32 ip; @@ -75,12 +94,10 @@ int char_maintenance = 0; bool char_new = true; int char_new_display = 0; -int email_creation = 0; // disabled by default - bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor] int char_name_option = 0; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor] char unknown_char_name[NAME_LENGTH] = "Unknown"; // Name to use when the requested name cannot be determined -#define TRIM_CHARS "\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex] +#define TRIM_CHARS "\255\xA0\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex] char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) in a character name. by [Yor] int char_per_account = 0; //Maximum charas per account (default unlimited) [Sirius] @@ -107,13 +124,10 @@ struct char_session_data { int gmlevel; uint32 version; uint8 clienttype; + char new_name[NAME_LENGTH]; char birthdate[10+1]; // YYYY-MM-DD }; -int char_id_count = START_CHAR_NUM; -struct character_data *char_dat; - -int char_num, char_max; int max_connect_user = 0; int gm_allow_level = 99; int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; @@ -132,17 +146,14 @@ struct fame_list smith_fame_list[MAX_FAME_LIST]; struct fame_list chemist_fame_list[MAX_FAME_LIST]; struct fame_list taekwon_fame_list[MAX_FAME_LIST]; +// check for exit signal +// 0 is saving complete +// other is char_id +unsigned int save_flag = 0; + // Initial position (it's possible to set it in conf file) struct point start_point = { 0, 53, 111 }; -// online players by [Yor] -char online_txt_filename[1024] = "online.txt"; -char online_html_filename[1024] = "online.html"; -int online_sorting_option = 0; // sorting option to display online players in online files -int online_display_option = 1; // display options: to know which columns must be displayed -int online_refresh_html = 20; // refresh time (in sec) of the html file in the explorer -int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it - int console = 0; //----------------------------------------------------- @@ -159,6 +170,7 @@ struct auth_node { int sex; time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) int gmlevel; + unsigned changing_mapservers : 1; }; static DBMap* auth_db; // int account_id -> struct auth_node* @@ -177,6 +189,7 @@ struct online_char_data { static DBMap* online_char_db; // int account_id -> struct online_char_data* static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); +int delete_char_sql(int char_id); static void* create_online_char_data(DBKey key, va_list args) { @@ -221,7 +234,12 @@ void set_char_charselect(int account_id) void set_char_online(int map_id, int char_id, int account_id) { struct online_char_data* character; + struct mmo_charstatus *cp; + //Update DB + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + //Check to see for online conflicts character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); if( character->char_id != -1 && character->server > -1 && character->server != map_id ) @@ -244,6 +262,10 @@ void set_char_online(int map_id, int char_id, int account_id) character->waiting_disconnect = INVALID_TIMER; } + //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it. + cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); + inter_guild_CharOnline(char_id, cp?cp->guild_id:-1); + //Notify login server if (login_fd > 0 && !session[login_fd]->flag.eof) { @@ -258,6 +280,22 @@ void set_char_offline(int char_id, int account_id) { struct online_char_data* character; + if ( char_id == -1 ) + { + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) ) + Sql_ShowDebug(sql_handle); + } + else + { + struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); + inter_guild_CharOffline(char_id, cp?cp->guild_id:-1); + if (cp) + idb_remove(char_db_,char_id); + + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + } + if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL) { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] if( character->server > -1 ) @@ -339,913 +377,904 @@ void set_all_offline(int id) WFIFOSET(login_fd,2); } -//------------------------------ -// Writing function of logs file -//------------------------------ -int char_log(char *fmt, ...) +void set_all_offline_sql(void) { - if(log_char) - { - FILE *logfp; - va_list ap; - time_t raw_time; - char tmpstr[2048]; - - va_start(ap, fmt); - - logfp = fopen(char_log_filename, "a"); - if (logfp) { - if (fmt[0] == '\0') // jump a line if no message - fprintf(logfp, "\n"); - else { - time(&raw_time); - strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&raw_time)); - sprintf(tmpstr + 19, ": %s", fmt); - vfprintf(logfp, tmpstr, ap); - } - fclose(logfp); - } - va_end(ap); - } - return 0; + //Set all players to 'OFFLINE' + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) ) + Sql_ShowDebug(sql_handle); } - -/// Find all characters for given session and update the session character cache. -int char_find_characters(struct char_session_data* sd) +static void* create_charstatus(DBKey key, va_list args) { - int i, found_num = 0; + struct mmo_charstatus *cp; + cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus)); + cp->char_id = key.i; + return cp; +} - for( i = 0; i < char_num; i++ ) - {// find character entries and save them - if( char_dat[i].status.account_id == sd->account_id ) - { - sd->found_char[found_num++] = i; - if( found_num >= MAX_CHARS ) - { - break; - } - } - } +int mmo_char_tosql(int char_id, struct mmo_charstatus* p) +{ + int i = 0; + int count = 0; + int diff = 0; + char save_status[128]; //For displaying save information. [Skotlex] + struct mmo_charstatus *cp; + int errors = 0; //If there are any errors while saving, "cp" will not be updated at the end. + StringBuf buf; - for( i = found_num; i < MAX_CHARS; i++ ) - {// fill remaining blanks - sd->found_char[i] = -1; - } + if (char_id!=p->char_id) return 0; - return found_num; -} + cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); + StringBuf_Init(&buf); + memset(save_status, 0, sizeof(save_status)); -/// Search character data from given session. -struct mmo_charstatus* search_session_character(struct char_session_data* sd, int char_id) -{ - int i; + //map inventory data + if( memcmp(p->inventory, cp->inventory, sizeof(p->inventory)) ) + { + if (!memitemdata_to_sql(p->inventory, MAX_INVENTORY, p->char_id, TABLE_INVENTORY)) + strcat(save_status, " inventory"); + else + errors++; + } - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] != -1 && char_dat[sd->found_char[i]].status.char_id == char_id ); - if( i == MAX_CHARS ) + //map cart data + if( memcmp(p->cart, cp->cart, sizeof(p->cart)) ) { - return NULL; + if (!memitemdata_to_sql(p->cart, MAX_CART, p->char_id, TABLE_CART)) + strcat(save_status, " cart"); + else + errors++; } - return &char_dat[sd->found_char[i]].status; -} + //map storage data + if( memcmp(p->storage.items, cp->storage.items, sizeof(p->storage.items)) ) + { + if (!memitemdata_to_sql(p->storage.items, MAX_STORAGE, p->account_id, TABLE_STORAGE)) + strcat(save_status, " storage"); + else + errors++; + } -//Search character data from the aid/cid givem -struct mmo_charstatus* search_character(int aid, int cid) -{ - int i; - for (i = 0; i < char_num; i++) { - if (char_dat[i].status.char_id == cid && char_dat[i].status.account_id == aid) - return &char_dat[i].status; + if ( + (p->base_exp != cp->base_exp) || (p->base_level != cp->base_level) || + (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || + (p->zeny != cp->zeny) || + (p->last_point.map != cp->last_point.map) || + (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || + (p->max_hp != cp->max_hp) || (p->hp != cp->hp) || + (p->max_sp != cp->max_sp) || (p->sp != cp->sp) || + (p->status_point != cp->status_point) || (p->skill_point != cp->skill_point) || + (p->str != cp->str) || (p->agi != cp->agi) || (p->vit != cp->vit) || + (p->int_ != cp->int_) || (p->dex != cp->dex) || (p->luk != cp->luk) || + (p->option != cp->option) || + (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || + (p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) || + (p->shield != cp->shield) || (p->head_top != cp->head_top) || + (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || + (p->rename != cp->rename) || (p->robe != cp->robe) + ) + { //Save status + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," + "`base_exp`='%u', `job_exp`='%u', `zeny`='%d'," + "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," + "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d'," + "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d'," + "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," + "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d'," + "`delete_date`='%lu',`robe`='%d'" + " WHERE `account_id`='%d' AND `char_id` = '%d'", + char_db, p->base_level, p->job_level, + p->base_exp, p->job_exp, p->zeny, + p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, + p->str, p->agi, p->vit, p->int_, p->dex, p->luk, + p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, + p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, + mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, + mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, + (unsigned long)p->delete_date, // FIXME: platform-dependent size + p->robe, + p->account_id, p->char_id) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } else + strcat(save_status, " status"); } - return NULL; -} - -struct mmo_charstatus* search_character_byname(char* character_name) -{ - int i = search_character_index(character_name); - if (i == -1) return NULL; - return &char_dat[i].status; -} -// Searches if the given character is online, and returns the fd of the -// map-server it is connected to. -int search_character_online(int aid, int cid) -{ - //Look for online character. - struct online_char_data* character; - character = (struct online_char_data*)idb_get(online_char_db, aid); - if(character && - character->char_id == cid && - character->server > -1) - return server[character->server].fd; - return -1; -} + //Values that will seldom change (to speed up saving) + if ( + (p->hair != cp->hair) || (p->hair_color != cp->hair_color) || (p->clothes_color != cp->clothes_color) || + (p->class_ != cp->class_) || + (p->partner_id != cp->partner_id) || (p->father != cp->father) || + (p->mother != cp->mother) || (p->child != cp->child) || + (p->karma != cp->karma) || (p->manner != cp->manner) || + (p->fame != cp->fame) + ) + { + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d'," + "`hair`='%d',`hair_color`='%d',`clothes_color`='%d'," + "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d'," + "`karma`='%d',`manner`='%d', `fame`='%d'" + " WHERE `account_id`='%d' AND `char_id` = '%d'", + char_db, p->class_, + p->hair, p->hair_color, p->clothes_color, + p->partner_id, p->father, p->mother, p->child, + p->karma, p->manner, p->fame, + p->account_id, p->char_id) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } else + strcat(save_status, " status2"); + } -//---------------------------------------------- -// Search an character id -// (return character index or -1 (if not found)) -// If exact character name is not found, -// the function checks without case sensitive -// and returns index if only 1 character is found -// and similar to the searched name. -//---------------------------------------------- -int search_character_index(char* character_name) -{ - int i, quantity, index; - - quantity = 0; - index = -1; - for(i = 0; i < char_num; i++) { - // Without case sensitive check (increase the number of similar character names found) - if (stricmp(char_dat[i].status.name, character_name) == 0) { - // Strict comparison (if found, we finish the function immediatly with correct value) - if (strcmp(char_dat[i].status.name, character_name) == 0) - return i; - quantity++; - index = i; - } + /* Mercenary Owner */ + if( (p->mer_id != cp->mer_id) || + (p->arch_calls != cp->arch_calls) || (p->arch_faith != cp->arch_faith) || + (p->spear_calls != cp->spear_calls) || (p->spear_faith != cp->spear_faith) || + (p->sword_calls != cp->sword_calls) || (p->sword_faith != cp->sword_faith) ) + { + if (mercenary_owner_tosql(char_id, p)) + strcat(save_status, " mercenary"); + else + errors++; } - // Here, the exact character name is not found - // We return the found index of a similar account ONLY if there is 1 similar character - if (quantity == 1) - return index; - // Exact character name is not found and 0 or more than 1 similar characters have been found ==> we say not found - return -1; -} + //memo points + if( memcmp(p->memo_point, cp->memo_point, sizeof(p->memo_point)) ) + { + char esc_mapname[NAME_LENGTH*2+1]; -/*--------------------------------------------------- - Make a data line for friends list - --------------------------------------------------*/ -int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p) -{ - int i; - char *str_p = str; - str_p += sprintf(str_p, "%d", p->char_id); + //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } - for (i=0;ifriends[i].account_id > 0 && p->friends[i].char_id > 0 && p->friends[i].name[0]) - str_p += sprintf(str_p, ",%d,%d,%s", p->friends[i].account_id, p->friends[i].char_id, p->friends[i].name); + //insert here. + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db); + for( i = 0, count = 0; i < MAX_MEMOPOINTS; ++i ) + { + if( p->memo_point[i].map ) + { + if( count ) + StringBuf_AppendStr(&buf, ","); + Sql_EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map)); + StringBuf_Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y); + ++count; + } + } + if( count ) + { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } + } + strcat(save_status, " memo"); } - str_p += '\0'; + //FIXME: is this neccessary? [ultramage] + for(i=0;iskill[i].lv != 0) && (p->skill[i].id == 0)) + p->skill[i].id = i; // Fix skill tree - return 0; -} -/*--------------------------------------------------- - Make a data line for hotkeys list - --------------------------------------------------*/ -int mmo_hotkeys_tostr(char *str, struct mmo_charstatus *p) -{ -#ifdef HOTKEY_SAVING - int i; - char *str_p = str; - str_p += sprintf(str_p, "%d", p->char_id); - for (i=0;ihotkeys[i].type, p->hotkeys[i].id, p->hotkeys[i].lv); - str_p += '\0'; -#endif - - return 0; -} - -//------------------------------------------------- -// Function to create the character line (for save) -//------------------------------------------------- -int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int reg_num) -{ - int i,j; - char *str_p = str; - - str_p += sprintf(str_p, - "%d\t%d,%d\t%s\t%d,%d,%d\t%u,%u,%d" //Up to Zeny field - "\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" //Up to Skill Point - "\t%d,%d,%d\t%d,%d,%d,%d" //Up to hom id - "\t%d,%d,%d\t%d,%d,%d,%d,%d,%d" //Up to robe - "\t%d,%d,%d\t%d,%d,%d" //last point + save point - ",%d,%d,%d,%d,%d,%lu\t", //Family info + delete date - p->char_id, p->account_id, p->slot, p->name, // - p->class_, p->base_level, p->job_level, - p->base_exp, p->job_exp, p->zeny, - p->hp, p->max_hp, p->sp, p->max_sp, - p->str, p->agi, p->vit, p->int_, p->dex, p->luk, - p->status_point, p->skill_point, - p->option, p->karma, p->manner, // - p->party_id, p->guild_id, p->pet_id, p->hom_id, - p->hair, p->hair_color, p->clothes_color, - p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, p->robe, - p->last_point.map, p->last_point.x, p->last_point.y, // - p->save_point.map, p->save_point.x, p->save_point.y, - p->partner_id,p->father,p->mother,p->child,p->fame, // - (unsigned long)p->delete_date); // FIXME: platform-dependent size - for(i = 0; i < MAX_MEMOPOINTS; i++) - if (p->memo_point[i].map) { - str_p += sprintf(str_p, "%d,%d,%d ", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y); - } - *(str_p++) = '\t'; - - for(i = 0; i < MAX_INVENTORY; i++) - if (p->inventory[i].nameid) { - str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d", - p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip, - p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute); - for(j=0; jinventory[i].card[j]); - str_p += sprintf(str_p," "); - } - *(str_p++) = '\t'; - - for(i = 0; i < MAX_CART; i++) - if (p->cart[i].nameid) { - str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d", - p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip, - p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute); - for(j=0; jcart[i].card[j]); - str_p += sprintf(str_p," "); + //skills + if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) + { + //`skill` (`char_id`, `id`, `lv`) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) + { + Sql_ShowDebug(sql_handle); + errors++; } - *(str_p++) = '\t'; - for(i = 0; i < MAX_SKILL; i++) - if (p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY) { - str_p += sprintf(str_p, "%d,%d ", p->skill[i].id, (p->skill[i].flag == SKILL_FLAG_PERMANENT) ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0); + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`) VALUES ", skill_db); + //insert here. + for( i = 0, count = 0; i < MAX_SKILL; ++i ) + { + if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) + { + if( p->skill[i].flag == SKILL_FLAG_PERMANENT && p->skill[i].lv == 0 ) + continue; + if( p->skill[i].flag != SKILL_FLAG_PERMANENT && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 ) + continue; + if( count ) + StringBuf_AppendStr(&buf, ","); + StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->skill[i].id, (p->skill[i].flag == SKILL_FLAG_PERMANENT ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0)); + ++count; + } + } + if( count ) + { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } } - *(str_p++) = '\t'; - - for(i = 0; i < reg_num; i++) - if (reg[i].str[0]) - str_p += sprintf(str_p, "%s,%s ", reg[i].str, reg[i].value); - *(str_p++) = '\t'; - *str_p = '\0'; - return 0; -} -#endif //TXT_SQL_CONVERT -//------------------------------------------------------------------------- -// Function to set the character from the line (at read of characters file) -//------------------------------------------------------------------------- -int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num) -{ - char tmp_str[3][128]; //To avoid deleting chars with too long names. - int tmp_int[256]; - unsigned int tmp_uint[2]; //To read exp.... - int next, len, i, j; - unsigned long tmp_ulong[1]; - - // initilialise character - memset(p, '\0', sizeof(struct mmo_charstatus)); - -// Char structure of version 14797 (robe) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d,%d,%d,%d,%d,%lu%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[44], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], &tmp_int[47], - &tmp_int[45], &tmp_int[35], &tmp_int[36], - &tmp_int[46], &tmp_int[37], &tmp_int[38], &tmp_int[39], - &tmp_int[40], &tmp_int[41], &tmp_int[42], &tmp_int[43], &tmp_ulong[0], &next) != 50) - { - tmp_int[47] = 0; // robe -// Char structure of version 14700 (delete date) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d,%d,%d,%d,%d,%lu%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[44], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - &tmp_int[45], &tmp_int[35], &tmp_int[36], - &tmp_int[46], &tmp_int[37], &tmp_int[38], &tmp_int[39], - &tmp_int[40], &tmp_int[41], &tmp_int[42], &tmp_int[43], &tmp_ulong[0], &next) != 49) - { - tmp_ulong[0] = 0; // delete date -// Char structure of version 1500 (homun + mapindex maps) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%d,%d,%d\t%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[44], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - &tmp_int[45], &tmp_int[35], &tmp_int[36], - &tmp_int[46], &tmp_int[37], &tmp_int[38], &tmp_int[39], - &tmp_int[40], &tmp_int[41], &tmp_int[42], &tmp_int[43], &next) != 48) - { - tmp_int[44] = 0; //Hom ID. -// Char structure of version 1488 (fame field addition) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%127[^,],%d,%d\t%127[^,],%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - tmp_str[1], &tmp_int[35], &tmp_int[36], - tmp_str[2], &tmp_int[37], &tmp_int[38], &tmp_int[39], - &tmp_int[40], &tmp_int[41], &tmp_int[42], &tmp_int[43], &next) != 47) - { - tmp_int[43] = 0; //Fame -// Char structure of version 1363 (family data addition) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%127[^,],%d,%d\t%127[^,],%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], // - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - tmp_str[1], &tmp_int[35], &tmp_int[36], // - tmp_str[2], &tmp_int[37], &tmp_int[38], &tmp_int[39], - &tmp_int[40], &tmp_int[41], &tmp_int[42], &next) != 46) - { - tmp_int[40] = 0; // father - tmp_int[41] = 0; // mother - tmp_int[42] = 0; // child -// Char structure version 1008 (marriage partner addition) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%127[^,],%d,%d\t%127[^,],%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], // - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - tmp_str[1], &tmp_int[35], &tmp_int[36], // - tmp_str[2], &tmp_int[37], &tmp_int[38], &tmp_int[39], &next) != 43) - { - tmp_int[39] = 0; // partner id -// Char structure version 384 (pet addition) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%127[^,],%d,%d\t%127[^,],%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], // - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - tmp_str[1], &tmp_int[35], &tmp_int[36], // - tmp_str[2], &tmp_int[37], &tmp_int[38], &next) != 42) - { - tmp_int[26] = 0; // pet id -// Char structure of a version 1 (original data structure) - if (sscanf(str, "%d\t%d,%d\t%127[^\t]\t%d,%d,%d\t%u,%u,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%127[^,],%d,%d\t%127[^,],%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], tmp_str[0], // - &tmp_int[3], &tmp_int[4], &tmp_int[5], - &tmp_uint[0], &tmp_uint[1], &tmp_int[8], - &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], - &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], - &tmp_int[19], &tmp_int[20], - &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], // - &tmp_int[27], &tmp_int[28], &tmp_int[29], - &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], - tmp_str[1], &tmp_int[35], &tmp_int[36], // - tmp_str[2], &tmp_int[37], &tmp_int[38], &next) != 41) - { - ShowError("Char-loading: Unrecognized character data version, info lost!\n"); - ShowDebug("Character info: %s\n", str); - return 0; + strcat(save_status, " skills"); } - } // Char structure version 384 (pet addition) - } // Char structure version 1008 (marriage partner addition) - } // Char structure of version 1363 (family data addition) - } // Char structure of version 1488 (fame field addition) - //Convert save data from string to integer for older formats - tmp_int[45] = mapindex_name2id(tmp_str[1]); - tmp_int[46] = mapindex_name2id(tmp_str[2]); - } // Char structure of version 1500 (homun + mapindex maps) - } // Char structure of version 14700 (delete date) - } // Char structure of version 14797 (robe) - - safestrncpy(p->name, tmp_str[0], NAME_LENGTH); //Overflow protection [Skotlex] - p->char_id = tmp_int[0]; - p->account_id = tmp_int[1]; - p->slot = tmp_int[2]; - p->class_ = tmp_int[3]; - p->base_level = tmp_int[4]; - p->job_level = tmp_int[5]; - p->base_exp = tmp_uint[0]; - p->job_exp = tmp_uint[1]; - p->zeny = tmp_int[8]; - p->hp = tmp_int[9]; - p->max_hp = tmp_int[10]; - p->sp = tmp_int[11]; - p->max_sp = tmp_int[12]; - p->str = tmp_int[13]; - p->agi = tmp_int[14]; - p->vit = tmp_int[15]; - p->int_ = tmp_int[16]; - p->dex = tmp_int[17]; - p->luk = tmp_int[18]; - p->status_point = tmp_int[19]; - p->skill_point = tmp_int[20]; - p->option = tmp_int[21]; - p->karma = tmp_int[22]; - p->manner = tmp_int[23]; - p->party_id = tmp_int[24]; - p->guild_id = tmp_int[25]; - p->pet_id = tmp_int[26]; - p->hair = tmp_int[27]; - p->hair_color = tmp_int[28]; - p->clothes_color = tmp_int[29]; - p->weapon = tmp_int[30]; - p->shield = tmp_int[31]; - p->head_top = tmp_int[32]; - p->head_mid = tmp_int[33]; - p->head_bottom = tmp_int[34]; - p->last_point.x = tmp_int[35]; - p->last_point.y = tmp_int[36]; - p->save_point.x = tmp_int[37]; - p->save_point.y = tmp_int[38]; - p->partner_id = tmp_int[39]; - p->father = tmp_int[40]; - p->mother = tmp_int[41]; - p->child = tmp_int[42]; - p->fame = tmp_int[43]; - p->hom_id = tmp_int[44]; - p->last_point.map = tmp_int[45]; - p->save_point.map = tmp_int[46]; - p->delete_date = tmp_ulong[0]; - p->robe = tmp_int[47]; - -#ifndef TXT_SQL_CONVERT - // Some checks - for(i = 0; i < char_num; i++) { - if (char_dat[i].status.char_id == p->char_id) { - ShowError(CL_RED"mmmo_auth_init: a character has an identical id to another.\n"); - ShowError(" character id #%d -> new character not readed.\n", p->char_id); - ShowError(" Character saved in log file."CL_RESET"\n"); - return -1; - } else if (strcmp(char_dat[i].status.name, p->name) == 0) { - ShowError(CL_RED"mmmo_auth_init: a character name already exists.\n"); - ShowError(" character name '%s' -> new character not read.\n", p->name); - ShowError(" Character saved in log file."CL_RESET"\n"); - return -2; + + diff = 0; + for(i = 0; i < MAX_FRIENDS; i++){ + if(p->friends[i].char_id != cp->friends[i].char_id || + p->friends[i].account_id != cp->friends[i].account_id){ + diff = 1; + break; } } - if (strcmpi(wisp_server_name, p->name) == 0) { - ShowWarning("mmo_auth_init: ******WARNING: character name has wisp server name.\n"); - ShowWarning(" Character name '%s' = wisp server name '%s'.\n", p->name, wisp_server_name); - ShowWarning(" Character readed. Suggestion: change the wisp server name.\n"); - char_log("mmo_auth_init: ******WARNING: character name has wisp server name: Character name '%s' = wisp server name '%s'.\n", - p->name, wisp_server_name); - } -#endif //TXT_SQL_CONVERT - if (str[next] == '\n' || str[next] == '\r') - return 1; // V‹Kƒf[ƒ^ - - next++; - - for(i = 0; str[next] && str[next] != '\t'; i++) { - //mapindex memo format - if (sscanf(str+next, "%d,%d,%d%n", &tmp_int[2], &tmp_int[0], &tmp_int[1], &len) != 3) - { //Old string-based memo format. - if (sscanf(str+next, "%[^,],%d,%d%n", tmp_str[0], &tmp_int[0], &tmp_int[1], &len) != 3) - return -3; - tmp_int[2] = mapindex_name2id(tmp_str[0]); + if(diff == 1) + { //Save friends + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + errors++; } - if (i < MAX_MEMOPOINTS) - { //Avoid overflowing (but we must also read through all saved memos) - p->memo_point[i].x = tmp_int[0]; - p->memo_point[i].y = tmp_int[1]; - p->memo_point[i].map = tmp_int[2]; + + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db); + for( i = 0, count = 0; i < MAX_FRIENDS; ++i ) + { + if( p->friends[i].char_id > 0 ) + { + if( count ) + StringBuf_AppendStr(&buf, ","); + StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->friends[i].account_id, p->friends[i].char_id); + count++; + } } - next += len; - if (str[next] == ' ') - next++; + if( count ) + { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } + } + strcat(save_status, " friends"); } - next++; - - for(i = 0; str[next] && str[next] != '\t'; i++) { - if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str[0], &len) == 8) +#ifdef HOTKEY_SAVING + // hotkeys + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db); + diff = 0; + for(i = 0; i < ARRAYLENGTH(p->hotkeys); i++){ + if(memcmp(&p->hotkeys[i], &cp->hotkeys[i], sizeof(struct hotkey))) { - p->inventory[i].id = tmp_int[0]; - p->inventory[i].nameid = tmp_int[1]; - p->inventory[i].amount = tmp_int[2]; - p->inventory[i].equip = tmp_int[3]; - p->inventory[i].identify = tmp_int[4]; - p->inventory[i].refine = tmp_int[5]; - p->inventory[i].attribute = tmp_int[6]; - - for(j = 0; j < MAX_SLOTS && tmp_str[0][0] && sscanf(tmp_str[0], ",%d%[0-9,-]",&tmp_int[0], tmp_str[0]) > 0; j++) - p->inventory[i].card[j] = tmp_int[0]; - - next += len; - if (str[next] == ' ') - next++; - } else // invalid structure - return -4; + if( diff ) + StringBuf_AppendStr(&buf, ",");// not the first hotkey + StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv); + diff = 1; + } } - next++; - - for(i = 0; str[next] && str[next] != '\t'; i++) { - if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str[0], &len) == 8) + if(diff) { + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) { - p->cart[i].id = tmp_int[0]; - p->cart[i].nameid = tmp_int[1]; - p->cart[i].amount = tmp_int[2]; - p->cart[i].equip = tmp_int[3]; - p->cart[i].identify = tmp_int[4]; - p->cart[i].refine = tmp_int[5]; - p->cart[i].attribute = tmp_int[6]; - - for(j = 0; j < MAX_SLOTS && tmp_str[0][0] && sscanf(tmp_str[0], ",%d%[0-9,-]",&tmp_int[0], tmp_str[0]) > 0; j++) - p->cart[i].card[j] = tmp_int[0]; - - next += len; - if (str[next] == ' ') - next++; - } else // invalid structure - return -5; + Sql_ShowDebug(sql_handle); + errors++; + } else + strcat(save_status, " hotkeys"); } +#endif + StringBuf_Destroy(&buf); + if (save_status[0]!='\0' && save_log) + ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status); + if (!errors) + memcpy(cp, p, sizeof(struct mmo_charstatus)); + return 0; +} - next++; +/// Saves an array of 'item' entries into the specified table. +int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch) +{ + StringBuf buf; + SqlStmt* stmt; + int i; + int j; + const char* tablename; + const char* selectoption; + struct item item; // temp storage variable + bool* flag; // bit array for inventory matching + bool found; + int errors = 0; + + switch (tableswitch) { + case TABLE_INVENTORY: tablename = inventory_db; selectoption = "char_id"; break; + case TABLE_CART: tablename = cart_db; selectoption = "char_id"; break; + case TABLE_STORAGE: tablename = storage_db; selectoption = "account_id"; break; + case TABLE_GUILD_STORAGE: tablename = guild_storage_db; selectoption = "guild_id"; break; + default: + ShowError("Invalid table name!\n"); + return 1; + } + + + // The following code compares inventory with current database values + // and performs modification/deletion/insertion only on relevant rows. + // This approach is more complicated than a trivial delete&insert, but + // it significantly reduces cpu load on the database server. + + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id); - for(i = 0; str[next] && str[next] != '\t'; i++) { - if (sscanf(str + next, "%d,%d%n", &tmp_int[0], &tmp_int[1], &len) != 2) - return -6; - p->skill[tmp_int[0]].id = tmp_int[0]; - p->skill[tmp_int[0]].lv = tmp_int[1]; - next += len; - if (str[next] == ' ') - next++; + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_ERROR == SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + StringBuf_Destroy(&buf); + return 1; } - next++; + SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL); + SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL); + for( j = 0; j < MAX_SLOTS; ++j ) + SqlStmt_BindColumn(stmt, 8+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL); + + // bit array indicating which inventory items have already been matched + flag = (bool*) aCallocA(max, sizeof(bool)); + + while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) + { + found = false; + // search for the presence of the item in the char's inventory + for( i = 0; i < max; ++i ) + { + // skip empty and already matched entries + if( items[i].nameid == 0 || flag[i] ) + continue; - for(i = 0; str[next] && str[next] != '\t' && str[next] != '\n' && str[next] != '\r'; i++) { // global_regŽÀ‘•ˆÈ‘O‚Ìathena.txtŒÝŠ·‚Ì‚½‚߈ꉞ'\n'ƒ`ƒFƒbƒN - if (sscanf(str + next, "%[^,],%[^ ] %n", reg[i].str, reg[i].value, &len) != 2) { - // because some scripts are not correct, the str can be "". So, we must check that. - // If it's, we must not refuse the character, but just this REG value. - // Character line will have something like: nov_2nd_cos,9 ,9 nov_1_2_cos_c,1 (here, ,9 is not good) - if (str[next] == ',' && sscanf(str + next, ",%[^ ] %n", reg[i].value, &len) == 1) - i--; - else - return -7; + if( items[i].nameid == item.nameid + && items[i].card[0] == item.card[0] + && items[i].card[2] == item.card[2] + && items[i].card[3] == item.card[3] + ) { //They are the same item. + ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] ); + if( j == MAX_SLOTS && + items[i].amount == item.amount && + items[i].equip == item.equip && + items[i].identify == item.identify && + items[i].refine == item.refine && + items[i].attribute == item.attribute && + items[i].expire_time == item.expire_time ) + ; //Do nothing. + else + { + // update all fields. + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u'", + tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); + StringBuf_Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); + + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } + } + + found = flag[i] = true; //Item dealt with, + break; //skip to next item in the db. + } + } + if( !found ) + {// Item not present in inventory, remove it. + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) ) + { + Sql_ShowDebug(sql_handle); + errors++; + } } - next += len; - if (str[next] == ' ') - next++; } - *reg_num = i; + SqlStmt_Free(stmt); - return 1; -} + StringBuf_Clear(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`", tablename, selectoption); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_AppendStr(&buf, ") VALUES "); -//--------------------------------- -// Function to read friend list -//--------------------------------- -int parse_friend_txt(struct mmo_charstatus *p) -{ - char line[1024], temp[1024]; - int pos = 0, count = 0, next; - int i,len; - FILE *fp; + found = false; + // insert non-matched items into the db as new items + for( i = 0; i < max; ++i ) + { + // skip empty and already matched entries + if( items[i].nameid == 0 || flag[i] ) + continue; - // Open the file and look for the ID - fp = fopen(friends_txt, "r"); + if( found ) + StringBuf_AppendStr(&buf, ","); + else + found = true; - if(fp == NULL) - return -1; - - while(fgets(line, sizeof(line), fp)) + StringBuf_Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u'", + id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", '%d'", items[i].card[j]); + StringBuf_AppendStr(&buf, ")"); + } + + if( found && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) { - if(line[0] == '/' && line[1] == '/') - continue; - if (sscanf(line, "%d%n",&i, &pos) < 1 || i != p->char_id) - continue; //Not this line... - //Read friends - len = strlen(line); - next = pos; - for (count = 0; next < len && count < MAX_FRIENDS; count++) - { //Read friends. - if (sscanf(line+next, ",%d,%d,%23[^,^\n]%n",&p->friends[count].account_id,&p->friends[count].char_id, p->friends[count].name, &pos) < 3) - { //Invalid friend? - memset(&p->friends[count], 0, sizeof(p->friends[count])); - break; - } - next+=pos; - //What IF the name contains a comma? while the next field is not a - //number, we assume it belongs to the current name. [Skotlex] - //NOTE: Of course, this will fail if someone sets their name to something like - //Bob,2005 but... meh, it's the problem of parsing a text file (encasing it in " - //won't do as quotes are also valid name chars!) - while(next < len && sscanf(line+next, ",%23[^,^\n]%n", temp, &pos) > 0) - { - if (atoi(temp)) //We read the next friend, just continue. - break; - //Append the name. - next+=pos; - i = strlen(p->friends[count].name); - if (i + strlen(temp) +1 < NAME_LENGTH) - { - p->friends[count].name[i] = ','; - strcpy(p->friends[count].name+i+1, temp); - } - } //End Guess Block - } //Friend's for. - break; //Found friends. + Sql_ShowDebug(sql_handle); + errors++; } - fclose(fp); - return count; + + StringBuf_Destroy(&buf); + aFree(flag); + + return errors; } -//--------------------------------- -// Function to read hotkey list -//--------------------------------- -int parse_hotkey_txt(struct mmo_charstatus *p) +int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p); + +//===================================================================================================== +// Loads the basic character rooster for the given account. Returns total buffer used. +int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) { -#ifdef HOTKEY_SAVING - char line[1024]; - int pos = 0, count = 0, next; - int i,len; - int type, id, lv; - FILE *fp; + SqlStmt* stmt; + struct mmo_charstatus p; + int j = 0, i; + char last_map[MAP_NAME_LENGTH_EXT]; - // Open the file and look for the ID - fp = fopen(hotkeys_txt, "r"); - if(fp == NULL) - return -1; - - while(fgets(line, sizeof(line), fp)) + stmt = SqlStmt_Malloc(sql_handle); + if( stmt == NULL ) { - if(line[0] == '/' && line[1] == '/') + SqlStmt_ShowDebug(stmt); + return 0; + } + memset(&p, 0, sizeof(p)); + + // read char data + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT " + "`char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," + "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," + "`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`," + "`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`," + "`robe`" + " FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p.rename, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL) + ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + return 0; + } + for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SqlStmt_NextRow(stmt); i++ ) + { + if( p.delete_date && p.delete_date < time(NULL) ) { + delete_char_sql(p.char_id); + i--; continue; - if (sscanf(line, "%d%n",&i, &pos) < 1 || i != p->char_id) - continue; //Not this line... - //Read hotkeys - len = strlen(line); - next = pos; - for (count = 0; next < len && count < MAX_HOTKEYS; count++) - { - if (sscanf(line+next, ",%d,%d,%d%n",&type,&id,&lv, &pos) < 3) - //Invalid entry? - break; - p->hotkeys[count].type = type; - p->hotkeys[count].id = id; - p->hotkeys[count].lv = lv; - next+=pos; } - break; //Found hotkeys. + p.last_point.map = mapindex_name2id(last_map); + sd->found_char[i] = p.char_id; + j += mmo_char_tobuf(WBUFP(buf, j), &p); } - fclose(fp); - return count; -#else - return 0; -#endif -} + for( ; i < MAX_CHARS; i++ ) + sd->found_char[i] = -1; + memset(sd->new_name,0,sizeof(sd->new_name)); + SqlStmt_Free(stmt); + return j; +} -#ifndef TXT_SQL_CONVERT -//--------------------------------- -// Function to read characters file -//--------------------------------- -int mmo_char_init(void) +//===================================================================================================== +int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) { - char line[65536]; - int ret, line_count; - FILE* fp; + int i,j; + char t_msg[128] = ""; + struct mmo_charstatus* cp; + StringBuf buf; + SqlStmt* stmt; + char last_map[MAP_NAME_LENGTH_EXT]; + char save_map[MAP_NAME_LENGTH_EXT]; + char point_map[MAP_NAME_LENGTH_EXT]; + struct point tmp_point; + struct item tmp_item; + struct s_skill tmp_skill; + struct s_friend tmp_friend; +#ifdef HOTKEY_SAVING + struct hotkey tmp_hotkey; + int hotkey_num; +#endif - char_num = 0; - char_max = 0; - char_dat = NULL; + memset(p, 0, sizeof(struct mmo_charstatus)); + + if (save_log) ShowInfo("Char load request (%d)\n", char_id); - fp = fopen(char_txt, "r"); + stmt = SqlStmt_Malloc(sql_handle); + if( stmt == NULL ) + { + SqlStmt_ShowDebug(stmt); + return 0; + } - if (fp == NULL) { - ShowError("Characters file not found: %s.\n", char_txt); - char_log("Characters file not found: %s.\n", char_txt); - char_log("Id for the next created character: %d.\n", char_id_count); + // read char data + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT " + "`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," + "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," + "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`hair`," + "`hair_color`,`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`," + "`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`" + " FROM `%s` WHERE `char_id`=? LIMIT 1", char_db) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p->hair, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p->shield, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_INT, &p->partner_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_INT, &p->father, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_INT, &p->mother, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_INT, &p->child, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_INT, &p->fame, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_SHORT, &p->rename, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT, &p->robe, 0, NULL, NULL) + ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); return 0; } + if( SQL_ERROR == SqlStmt_NextRow(stmt) ) + { + ShowError("Requested non-existant character id: %d!\n", char_id); + SqlStmt_Free(stmt); + return 0; + } + p->last_point.map = mapindex_name2id(last_map); + p->save_point.map = mapindex_name2id(save_map); - line_count = 0; - while(fgets(line, sizeof(line), fp)) + strcat(t_msg, " status"); + + if (!load_everything) // For quick selection of data when displaying the char menu { - int i, j; - line_count++; + SqlStmt_Free(stmt); + return 1; + } - if (line[0] == '/' && line[1] == '/') - continue; + //read memo data + //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + { + tmp_point.map = mapindex_name2id(point_map); + memcpy(&p->memo_point[i], &tmp_point, sizeof(tmp_point)); + } + strcat(t_msg, " memo"); + + //read inventory + //`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); + for( i = 0; i < MAX_SLOTS; ++i ) + StringBuf_Printf(&buf, ", `card%d`", i); + StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY); + + if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < MAX_SLOTS; ++i ) + if( SQL_ERROR == SqlStmt_BindColumn(stmt, 8+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + for( i = 0; i < MAX_INVENTORY && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + memcpy(&p->inventory[i], &tmp_item, sizeof(tmp_item)); + + strcat(t_msg, " inventory"); + + //read cart + //`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) + StringBuf_Clear(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART); + + if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < MAX_SLOTS; ++i ) + if( SQL_ERROR == SqlStmt_BindColumn(stmt, 8+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + for( i = 0; i < MAX_CART && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + memcpy(&p->cart[i], &tmp_item, sizeof(tmp_item)); + strcat(t_msg, " cart"); + + //read storage + storage_fromsql(p->account_id, &p->storage); + strcat(t_msg, " storage"); + + //read skill + //`skill` (`char_id`, `id`, `lv`) + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_USHORT, &tmp_skill.lv, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + tmp_skill.flag = SKILL_FLAG_PERMANENT; + + for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + { + if( tmp_skill.id < ARRAYLENGTH(p->skill) ) + memcpy(&p->skill[tmp_skill.id], &tmp_skill, sizeof(tmp_skill)); + else + ShowWarning("mmo_char_fromsql: ignoring invalid skill (id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", tmp_skill.id, tmp_skill.lv, p->name, p->account_id, p->char_id); + } + strcat(t_msg, " skills"); + + //read friends + //`friends` (`char_id`, `friend_account`, `friend_id`) + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + memcpy(&p->friends[i], &tmp_friend, sizeof(tmp_friend)); + strcat(t_msg, " friends"); - j = 0; - if (sscanf(line, "%d\t%%newid%%%n", &i, &j) == 1 && j > 0) { - if (char_id_count < i) - char_id_count = i; - continue; - } +#ifdef HOTKEY_SAVING + //read hotkeys + //`hotkey` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl` + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) + { + if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS ) + memcpy(&p->hotkeys[hotkey_num], &tmp_hotkey, sizeof(tmp_hotkey)); + else + ShowWarning("mmo_char_fromsql: ignoring invalid hotkey (hotkey=%d,type=%u,id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", hotkey_num, tmp_hotkey.type, tmp_hotkey.id, tmp_hotkey.lv, p->name, p->account_id, p->char_id); + } + strcat(t_msg, " hotkeys"); +#endif - if (char_num >= char_max) { - char_max += 256; - char_dat = (struct character_data*)aRealloc(char_dat, sizeof(struct character_data) * char_max); - if (!char_dat) { - ShowFatalError("Out of memory: mmo_char_init (realloc of char_dat).\n"); - char_log("Out of memory: mmo_char_init (realloc of char_dat).\n"); - exit(EXIT_FAILURE); - } - } + /* Mercenary Owner DataBase */ + mercenary_owner_fromsql(char_id, p); + strcat(t_msg, " mercenary"); - ret = mmo_char_fromstr(line, &char_dat[char_num].status, char_dat[char_num].global, &char_dat[char_num].global_num); - // Initialize friends list - parse_friend_txt(&char_dat[char_num].status); // Grab friends for the character - // Initialize hotkey list - parse_hotkey_txt(&char_dat[char_num].status); // Grab hotkeys for the character - - if (ret > 0) { // negative value or zero for errors - if (char_dat[char_num].status.char_id >= char_id_count) - char_id_count = char_dat[char_num].status.char_id + 1; - char_num++; - } else { - ShowError("mmo_char_init: in characters file, unable to read the line #%d.\n", line_count); - ShowError(" -> Character saved in log file.\n"); - switch (ret) { - case -1: - char_log("Duplicate character id in the next character line (character not readed):\n"); - break; - case -2: - char_log("Duplicate character name in the next character line (character not readed):\n"); - break; - case -3: - char_log("Invalid memo point structure in the next character line (character not readed):\n"); - break; - case -4: - char_log("Invalid inventory item structure in the next character line (character not readed):\n"); - break; - case -5: - char_log("Invalid cart item structure in the next character line (character not readed):\n"); - break; - case -6: - char_log("Invalid skill structure in the next character line (character not readed):\n"); - break; - case -7: - char_log("Invalid register structure in the next character line (character not readed):\n"); - break; - default: // 0 - char_log("Unabled to get a character in the next line - Basic structure of line (before inventory) is incorrect (character not readed):\n"); - break; - } - char_log("%s", line); - } - } - fclose(fp); + if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly! + SqlStmt_Free(stmt); + StringBuf_Destroy(&buf); - if (char_num == 0) { - ShowNotice("mmo_char_init: No character found in %s.\n", char_txt); - char_log("mmo_char_init: No character found in %s.\n", char_txt); - } else if (char_num == 1) { - ShowStatus("mmo_char_init: 1 character read in %s.\n", char_txt); - char_log("mmo_char_init: 1 character read in %s.\n", char_txt); - } else { - ShowStatus("mmo_char_init: %d characters read in %s.\n", char_num, char_txt); - char_log("mmo_char_init: %d characters read in %s.\n", char_num, char_txt); + cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); + memcpy(cp, p, sizeof(struct mmo_charstatus)); + return 1; +} + +//========================================================================================================== +int mmo_char_sql_init(void) +{ + ShowInfo("Begin Initializing.......\n"); + char_db_= idb_alloc(DB_OPT_RELEASE_DATA); + + if(char_per_account == 0){ + ShowStatus("Chars per Account: 'Unlimited'.......\n"); + }else{ + ShowStatus("Chars per Account: '%d'.......\n", char_per_account); } - char_log("Id for the next created character: %d.\n", char_id_count); + //the 'set offline' part is now in check_login_conn ... + //if the server connects to loginserver + //it will dc all off players + //and send the loginserver the new state.... + + // Force all users offline in sql when starting char-server + // (useful when servers crashs and don't clean the database) + set_all_offline_sql(); + + ShowInfo("Finished initilizing.......\n"); return 0; } -//--------------------------------------------------------- -// Function to save characters in files (speed up by [Yor]) -//--------------------------------------------------------- -void mmo_char_sync(void) +//----------------------------------- +// Function to change chararcter's names +//----------------------------------- +int rename_char_sql(struct char_session_data *sd, int char_id) { - char line[65536],f_line[1024]; - int i, j, k; - int lock; - FILE *fp,*f_fp; - CREATE_BUFFER(id, int, char_num); - - // Sorting before save (by [Yor]) - for(i = 0; i < char_num; i++) { - id[i] = i; - for(j = 0; j < i; j++) { - if ((char_dat[i].status.account_id < char_dat[id[j]].status.account_id) || - // if same account id, we sort by slot. - (char_dat[i].status.account_id == char_dat[id[j]].status.account_id && - char_dat[i].status.slot < char_dat[id[j]].status.slot)) { - for(k = i; k > j; k--) - id[k] = id[k-1]; - id[j] = i; // id[i] - break; - } - } - } + struct mmo_charstatus char_dat; + char esc_name[NAME_LENGTH*2+1]; - // Data save - fp = lock_fopen(char_txt, &lock); - if (fp == NULL) { - ShowWarning("Server cannot save characters.\n"); - char_log("WARNING: Server cannot save characters.\n"); - } else { - for(i = 0; i < char_num; i++) { - mmo_char_tostr(line, &char_dat[id[i]].status, char_dat[id[i]].global, char_dat[id[i]].global_num); // use of sorted index - fprintf(fp, "%s\n", line); - } - fprintf(fp, "%d\t%%newid%%\n", char_id_count); - lock_fclose(fp, char_txt, &lock); - } + if( sd->new_name[0] == 0 ) // Not ready for rename + return 2; + + if( !mmo_char_fromsql(char_id, &char_dat, false) ) // Only the short data is needed. + return 2; - // Friends List data save (davidsiaw) - f_fp = lock_fopen(friends_txt, &lock); - for(i = 0; i < char_num; i++) { - mmo_friends_list_data_str(f_line, &char_dat[id[i]].status); - fprintf(f_fp, "%s\n", f_line); - } + if( char_dat.rename == 0 ) + return 1; - lock_fclose(f_fp, friends_txt, &lock); + Sql_EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH)); -#ifdef HOTKEY_SAVING - // Hotkey List data save (Skotlex) - f_fp = lock_fopen(hotkeys_txt, &lock); - for(i = 0; i < char_num; i++) { - mmo_hotkeys_tostr(f_line, &char_dat[id[i]].status); - fprintf(f_fp, "%s\n", f_line); + // check if the char exist + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) ) + { + Sql_ShowDebug(sql_handle); + return 4; } - lock_fclose(f_fp, hotkeys_txt, &lock); -#endif + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) ) + { + Sql_ShowDebug(sql_handle); + return 3; + } - DELETE_BUFFER(id); + // Change character's name into guild_db. + if( char_dat.guild_id ) + inter_guild_charname_changed(char_dat.guild_id, sd->account_id, char_id, sd->new_name); - return; -} + safestrncpy(char_dat.name, sd->new_name, NAME_LENGTH); + memset(sd->new_name,0,sizeof(sd->new_name)); + + // log change + if( log_char ) + { + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + "VALUES (NOW(), '%s', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')", + charlog_db, "change char name", sd->account_id, char_dat.slot, esc_name) ) + Sql_ShowDebug(sql_handle); + } -//---------------------------------------------------- -// Function to save (in a periodic way) datas in files -//---------------------------------------------------- -int mmo_char_sync_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - if (save_log) - ShowInfo("Saving all files...\n"); - mmo_char_sync(); - inter_save(); return 0; } -int check_char_name(char * name) +int check_char_name(char * name, char * esc_name) { int i; // check length of character name if( name[0] == '\0' ) return -2; // empty character name - + /** + * The client does not allow you to create names with less than 4 characters, however, + * the use of WPE can bypass this, and this fixes the exploit. + **/ + if( strlen( name ) < 4 ) + return -2; // check content of character name if( remove_control_chars(name) ) return -2; // control chars in name @@ -1267,17 +1296,18 @@ int check_char_name(char * name) if( strchr(char_name_letters, name[i]) != NULL ) return -2; } - - // check name (already in use?) - if( name_ignoring_case ) - { - ARR_FIND( 0, char_num, i, strncmp(char_dat[i].status.name, name, NAME_LENGTH) == 0 ); - } - else - { - ARR_FIND( 0, char_num, i, strncmpi(char_dat[i].status.name, name, NAME_LENGTH) == 0 ); + if( name_ignoring_case ) { + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) { + Sql_ShowDebug(sql_handle); + return -2; + } + } else { + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) { + Sql_ShowDebug(sql_handle); + return -2; + } } - if( i < char_num ) + if( Sql_NumRows(sql_handle) > 0 ) return -1; // name already exists return 0; @@ -1286,15 +1316,17 @@ int check_char_name(char * name) //----------------------------------- // Function to create a new character //----------------------------------- -int make_new_char(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) +int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) { char name[NAME_LENGTH]; - int i, flag; - + char esc_name[NAME_LENGTH*2+1]; + int char_id, flag; + safestrncpy(name, name_, NAME_LENGTH); normalize_name(name,TRIM_CHARS); + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); - flag = check_char_name(name); + flag = check_char_name(name,esc_name); if( flag < 0 ) return flag; @@ -1307,471 +1339,226 @@ int make_new_char(struct char_session_data* sd, char* name_, int str, int agi, i // check the number of already existing chars in this account if( char_per_account != 0 ) { - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == -1 ); - - if( i >= char_per_account ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d'", char_db, sd->account_id) ) + Sql_ShowDebug(sql_handle); + if( Sql_NumRows(sql_handle) >= char_per_account ) return -2; // character account limit exceeded } // check char slot - ARR_FIND( 0, char_num, i, char_dat[i].status.account_id == sd->account_id && char_dat[i].status.slot == slot ); - if( i < char_num ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d' LIMIT 1", char_db, sd->account_id, slot) ) + Sql_ShowDebug(sql_handle); + if( Sql_NumRows(sql_handle) > 0 ) return -2; // slot already in use - if (char_num >= char_max) { - char_max += 256; - RECREATE(char_dat, struct character_data, char_max); - if (!char_dat) { - ShowFatalError("Out of memory: make_new_char (realloc of char_dat).\n"); - char_log("Out of memory: make_new_char (realloc of char_dat).\n"); - exit(EXIT_FAILURE); - } + // validation success, log result + if (log_char) { + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" + "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + charlog_db, "make new char", sd->account_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) ) + Sql_ShowDebug(sql_handle); } - // validation success, log result - char_log("make new char: account: %d, slot %d, name: %s, stats: %d/%d/%d/%d/%d/%d, hair: %d, hair color: %d.\n", - sd->account_id, slot, name, str, agi, vit, int_, dex, luk, hair_style, hair_color); - - i = char_num; - memset(&char_dat[i], 0, sizeof(struct character_data)); - - char_dat[i].status.char_id = char_id_count++; - char_dat[i].status.account_id = sd->account_id; - char_dat[i].status.slot = slot; - safestrncpy(char_dat[i].status.name,name,NAME_LENGTH); - char_dat[i].status.class_ = 0; - char_dat[i].status.base_level = 1; - char_dat[i].status.job_level = 1; - char_dat[i].status.base_exp = 0; - char_dat[i].status.job_exp = 0; - char_dat[i].status.zeny = start_zeny; - char_dat[i].status.str = str; - char_dat[i].status.agi = agi; - char_dat[i].status.vit = vit; - char_dat[i].status.int_ = int_; - char_dat[i].status.dex = dex; - char_dat[i].status.luk = luk; - char_dat[i].status.max_hp = 40 * (100 + char_dat[i].status.vit) / 100; - char_dat[i].status.max_sp = 11 * (100 + char_dat[i].status.int_) / 100; - char_dat[i].status.hp = char_dat[i].status.max_hp; - char_dat[i].status.sp = char_dat[i].status.max_sp; - char_dat[i].status.status_point = 0; - char_dat[i].status.skill_point = 0; - char_dat[i].status.option = 0; - char_dat[i].status.karma = 0; - char_dat[i].status.manner = 0; - char_dat[i].status.party_id = 0; - char_dat[i].status.guild_id = 0; - char_dat[i].status.hair = hair_style; - char_dat[i].status.hair_color = hair_color; - char_dat[i].status.clothes_color = 0; - char_dat[i].status.inventory[0].nameid = start_weapon; // Knife - char_dat[i].status.inventory[0].amount = 1; - char_dat[i].status.inventory[0].identify = 1; - char_dat[i].status.inventory[1].nameid = start_armor; // Cotton Shirt - char_dat[i].status.inventory[1].amount = 1; - char_dat[i].status.inventory[1].identify = 1; - char_dat[i].status.weapon = 0; // W_FIST - char_dat[i].status.shield = 0; - char_dat[i].status.head_top = 0; - char_dat[i].status.head_mid = 0; - char_dat[i].status.head_bottom = 0; - memcpy(&char_dat[i].status.last_point, &start_point, sizeof(start_point)); - memcpy(&char_dat[i].status.save_point, &start_point, sizeof(start_point)); - char_num++; - - ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, i, slot, name); - mmo_char_sync(); - return i; + //Insert the new char entry to the database + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`," + "`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES (" + "'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')", + char_db, sd->account_id , slot, esc_name, start_zeny, str, agi, vit, int_, dex, luk, + (40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color, + mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) ) + { + Sql_ShowDebug(sql_handle); + return -2; //No, stop the procedure! + } + //Retrieve the newly auto-generated char id + char_id = (int)Sql_LastInsertId(sql_handle); + //Give the char the default items + if (start_weapon > 0) { //add Start Weapon (Knife?) + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_weapon, 1, 1) ) + Sql_ShowDebug(sql_handle); + } + if (start_armor > 0) { //Add default armor (cotton shirt?) + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_armor, 1, 1) ) + Sql_ShowDebug(sql_handle); + } + + ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, slot, name); + return char_id; } -//---------------------------------------------------- -// This function return the name of the job (by [Yor]) -//---------------------------------------------------- -char * job_name(int class_) +/*----------------------------------------------------------------------------------------------------------*/ +/* Divorce Players */ +/*----------------------------------------------------------------------------------------------------------*/ +int divorce_char_sql(int partner_id1, int partner_id2) { - switch (class_) { - case JOB_NOVICE: return "Novice"; - case JOB_SWORDMAN: return "Swordsman"; - case JOB_MAGE: return "Mage"; - case JOB_ARCHER: return "Archer"; - case JOB_ACOLYTE: return "Acolyte"; - case JOB_MERCHANT: return "Merchant"; - case JOB_THIEF: return "Thief"; - case JOB_KNIGHT: return "Knight"; - case JOB_PRIEST: return "Priest"; - case JOB_WIZARD: return "Wizard"; - case JOB_BLACKSMITH: return "Blacksmith"; - case JOB_HUNTER: return "Hunter"; - case JOB_ASSASSIN: return "Assassin"; - case JOB_KNIGHT2: return "Peco-Knight"; - case JOB_CRUSADER: return "Crusader"; - case JOB_MONK: return "Monk"; - case JOB_SAGE: return "Sage"; - case JOB_ROGUE: return "Rogue"; - case JOB_ALCHEMIST: return "Alchemist"; - case JOB_BARD: return "Bard"; - case JOB_DANCER: return "Dancer"; - case JOB_CRUSADER2: return "Peco-Crusader"; - case JOB_WEDDING: return "Wedding"; - case JOB_SUPER_NOVICE: return "Super Novice"; - case JOB_GUNSLINGER: return "Gunslinger"; - case JOB_NINJA: return "Ninja"; - case JOB_XMAS: return "Christmas"; - case JOB_NOVICE_HIGH: return "Novice High"; - case JOB_SWORDMAN_HIGH: return "Swordsman High"; - case JOB_MAGE_HIGH: return "Mage High"; - case JOB_ARCHER_HIGH: return "Archer High"; - case JOB_ACOLYTE_HIGH: return "Acolyte High"; - case JOB_MERCHANT_HIGH: return "Merchant High"; - case JOB_THIEF_HIGH: return "Thief High"; - case JOB_LORD_KNIGHT: return "Lord Knight"; - case JOB_HIGH_PRIEST: return "High Priest"; - case JOB_HIGH_WIZARD: return "High Wizard"; - case JOB_WHITESMITH: return "Whitesmith"; - case JOB_SNIPER: return "Sniper"; - case JOB_ASSASSIN_CROSS: return "Assassin Cross"; - case JOB_LORD_KNIGHT2: return "Peko Knight"; - case JOB_PALADIN: return "Paladin"; - case JOB_CHAMPION: return "Champion"; - case JOB_PROFESSOR: return "Professor"; - case JOB_STALKER: return "Stalker"; - case JOB_CREATOR: return "Creator"; - case JOB_CLOWN: return "Clown"; - case JOB_GYPSY: return "Gypsy"; - case JOB_PALADIN2: return "Peko Paladin"; - case JOB_BABY: return "Baby Novice"; - case JOB_BABY_SWORDMAN: return "Baby Swordsman"; - case JOB_BABY_MAGE: return "Baby Mage"; - case JOB_BABY_ARCHER: return "Baby Archer"; - case JOB_BABY_ACOLYTE: return "Baby Acolyte"; - case JOB_BABY_MERCHANT: return "Baby Merchant"; - case JOB_BABY_THIEF: return "Baby Thief"; - case JOB_BABY_KNIGHT: return "Baby Knight"; - case JOB_BABY_PRIEST: return "Baby Priest"; - case JOB_BABY_WIZARD: return "Baby Wizard"; - case JOB_BABY_BLACKSMITH: return "Baby Blacksmith"; - case JOB_BABY_HUNTER: return "Baby Hunter"; - case JOB_BABY_ASSASSIN: return "Baby Assassin"; - case JOB_BABY_KNIGHT2: return "Baby Peco Knight"; - case JOB_BABY_CRUSADER: return "Baby Crusader"; - case JOB_BABY_MONK: return "Baby Monk"; - case JOB_BABY_SAGE: return "Baby Sage"; - case JOB_BABY_ROGUE: return "Baby Rogue"; - case JOB_BABY_ALCHEMIST: return "Baby Alchemist"; - case JOB_BABY_BARD: return "Baby Bard"; - case JOB_BABY_DANCER: return "Baby Dancer"; - case JOB_BABY_CRUSADER2: return "Baby Peco Crusader"; - case JOB_SUPER_BABY: return "Super Baby"; - case JOB_TAEKWON: return "Taekwon"; - case JOB_STAR_GLADIATOR: return "Star Gladiator"; - case JOB_STAR_GLADIATOR2: return "Flying Star Gladiator"; - case JOB_SOUL_LINKER: return "Soul Linker"; - } - return "Unknown Job"; + unsigned char buf[64]; + + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) ) + Sql_ShowDebug(sql_handle); + + WBUFW(buf,0) = 0x2b12; + WBUFL(buf,2) = partner_id1; + WBUFL(buf,6) = partner_id2; + mapif_sendall(buf,10); + + return 0; } -static int create_online_files_sub(DBKey key, void* data, va_list va) +/*----------------------------------------------------------------------------------------------------------*/ +/* Delete char - davidsiaw */ +/*----------------------------------------------------------------------------------------------------------*/ +/* Returns 0 if successful + * Returns < 0 for error + */ +int delete_char_sql(int char_id) { - struct online_char_data *character; - int* players; - int *id; - int j,k,l; - character = (struct online_char_data*) data; - players = va_arg(va, int*); - id = va_arg(va, int*); - - // check if map-server is online - if (character->server == -1 || character->char_id == -1) { //Character not currently online. + char name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped. + int account_id, party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id; + char* data; + size_t len; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + ShowError("delete_char_sql: Unable to fetch character data, deletion aborted.\n"); + Sql_FreeResult(sql_handle); return -1; } - - j = character->server; - if (server[j].fd < 0) { - server[j].users = 0; - return -1; + + Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 1, &data, NULL); account_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); party_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); father_id = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data); + + Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH)); + Sql_FreeResult(sql_handle); + + //check for config char del condition [Lupus] + // TODO: Move this out to packet processing (0x68/0x1fb). + if( ( char_del_level > 0 && base_level >= char_del_level ) + || ( char_del_level < 0 && base_level <= -char_del_level ) + ) { + ShowInfo("Char deletion aborted: %s, BaseLevel: %i\n", name, base_level); + return -1; } - // search position of character in char_dat and sort online characters. - for(j = 0; j < char_num; j++) { - if (char_dat[j].status.char_id != character->char_id) - continue; - id[*players] = j; - // use sorting option - switch (online_sorting_option) { - case 1: // by name (without case sensitive) - for(k = 0; k < *players; k++) - if (stricmp(char_dat[j].status.name, char_dat[id[k]].status.name) < 0 || - // if same name, we sort with case sensitive. - (stricmp(char_dat[j].status.name, char_dat[id[k]].status.name) == 0 && - strcmp(char_dat[j].status.name, char_dat[id[k]].status.name) < 0)) { - for(l = *players; l > k; l--) - id[l] = id[l-1]; - id[k] = j; // id[*players] - break; - } - break; - case 2: // by zeny - for(k = 0; k < *players; k++) - if (char_dat[j].status.zeny < char_dat[id[k]].status.zeny || - // if same number of zenys, we sort by name. - (char_dat[j].status.zeny == char_dat[id[k]].status.zeny && - stricmp(char_dat[j].status.name, char_dat[id[k]].status.name) < 0)) { - for(l = *players; l > k; l--) - id[l] = id[l-1]; - id[k] = j; // id[*players] - break; - } - break; - case 3: // by base level - for(k = 0; k < *players; k++) - if (char_dat[j].status.base_level < char_dat[id[k]].status.base_level || - // if same base level, we sort by base exp. - (char_dat[j].status.base_level == char_dat[id[k]].status.base_level && - char_dat[j].status.base_exp < char_dat[id[k]].status.base_exp)) { - for(l = *players; l > k; l--) - id[l] = id[l-1]; - id[k] = j; // id[*players] - break; - } - break; - case 4: // by job (and job level) - for(k = 0; k < *players; k++) - if (char_dat[j].status.class_ < char_dat[id[k]].status.class_ || - // if same job, we sort by job level. - (char_dat[j].status.class_ == char_dat[id[k]].status.class_ && - char_dat[j].status.job_level < char_dat[id[k]].status.job_level) || - // if same job and job level, we sort by job exp. - (char_dat[j].status.class_ == char_dat[id[k]].status.class_ && - char_dat[j].status.job_level == char_dat[id[k]].status.job_level && - char_dat[j].status.job_exp < char_dat[id[k]].status.job_exp)) { - for(l = *players; l > k; l--) - id[l] = id[l-1]; - id[k] = j; // id[*players] - break; - } - break; - case 5: // by location map name - { - const char *map1, *map2; - map1 = mapindex_id2name(char_dat[j].status.last_point.map); - - for(k = 0; k < *players; k++) { - map2 = mapindex_id2name(char_dat[id[k]].status.last_point.map); - if (!map1 || !map2 || //Avoid sorting if either one failed to resolve. - stricmp(map1, map2) < 0 || - // if same map name, we sort by name. - (stricmp(map1, map2) == 0 && - stricmp(char_dat[j].status.name, char_dat[id[k]].status.name) < 0)) { - for(l = *players; l > k; l--) - id[l] = id[l-1]; - id[k] = j; // id[*players] - break; - } - } - } - break; - default: // 0 or invalid value: no sorting - break; - } - (*players)++; - break; + + /* Divorce [Wizputer] */ + if( partner_id ) + divorce_char_sql(char_id, partner_id); + + /* De-addopt [Zephyrus] */ + if( father_id || mother_id ) + { // Char is Baby + unsigned char buf[64]; + + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) ) + Sql_ShowDebug(sql_handle); + + WBUFW(buf,0) = 0x2b25; + WBUFL(buf,2) = father_id; + WBUFL(buf,6) = mother_id; + WBUFL(buf,10) = char_id; // Baby + mapif_sendall(buf,14); } - return 0; -} -//------------------------------------------------------------- -// Function to create the online files (txt and html). by [Yor] -//------------------------------------------------------------- -void create_online_files(void) -{ - unsigned int k, j; // for loop with strlen comparing - int i, l; // for loops - int players; // count the number of players - FILE *fp; // for the txt file - FILE *fp2; // for the html file - char temp[256]; // to prepare what we must display - time_t time_server; // for number of seconds - struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ... - int id[4096]; - - if (online_display_option == 0) // we display nothing, so return - return; - // Get number of online players, id of each online players, and verify if a server is offline - players = 0; - online_char_db->foreach(online_char_db, create_online_files_sub, &players, &id); - - // write files - fp = fopen(online_txt_filename, "w"); - if (fp != NULL) { - fp2 = fopen(online_html_filename, "w"); - if (fp2 != NULL) { - // get time - time(&time_server); // get time in seconds since 1/1/1970 - datetime = localtime(&time_server); // convert seconds in structure - strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like sprintf, but only for date/time (05 dec 2003 15:12:52) - // write heading - fprintf(fp2, "\n"); - fprintf(fp2, " \n", online_refresh_html); // update on client explorer every x seconds - fprintf(fp2, " \n"); - fprintf(fp2, " Online Players on %s\n", server_name); - fprintf(fp2, " \n"); - fprintf(fp2, " \n"); - fprintf(fp2, "

    Online Players on %s (%s):

    \n", server_name, temp); - fprintf(fp, "Online Players on %s (%s):\n", server_name, temp); - fprintf(fp, "\n"); - - for (i = 0; i < players; i++) { - // if it's the first player - if (i == 0) { - j = 0; // count the number of characters for the txt version and to set the separate line - fprintf(fp2, " \n"); - fprintf(fp2, " \n"); - if ((online_display_option & 1) || (online_display_option & 64)) { - fprintf(fp2, " \n"); - if (online_display_option & 64) { - fprintf(fp, "Name "); // 30 - j += 30; - } else { - fprintf(fp, "Name "); // 25 - j += 25; - } - } - if ((online_display_option & 6) == 6) { - fprintf(fp2, " \n"); - fprintf(fp, "Job Levels "); // 27 - j += 27; - } else if (online_display_option & 2) { - fprintf(fp2, " \n"); - fprintf(fp, "Job "); // 19 - j += 19; - } else if (online_display_option & 4) { - fprintf(fp2, " \n"); - fprintf(fp, " Levels "); // 8 - j += 8; - } - if (online_display_option & 24) { // 8 or 16 - fprintf(fp2, " \n"); - if (online_display_option & 16) { - fprintf(fp, "Location ( x , y ) "); // 23 - j += 23; - } else { - fprintf(fp, "Location "); // 13 - j += 13; - } - } - if (online_display_option & 32) { - fprintf(fp2, " \n"); - fprintf(fp, " Zenys "); // 16 - j += 16; - } - fprintf(fp2, " \n"); - fprintf(fp, "\n"); - for (k = 0; k < j; k++) - fprintf(fp, "-"); - fprintf(fp, "\n"); - } - fprintf(fp2, " \n"); - // get id of the character (more speed) - j = id[i]; - // displaying the character name - if ((online_display_option & 1) || (online_display_option & 64)) { // without/with 'GM' display - safestrncpy(temp, char_dat[j].status.name, sizeof(temp)); - //l = isGM(char_dat[j].status.account_id); - l = 0; //FIXME: how to get the gm level? - if (online_display_option & 64) { - if (l >= online_gm_display_min_level) - fprintf(fp, "%-24s (GM) ", temp); - else - fprintf(fp, "%-24s ", temp); - } else - fprintf(fp, "%-24s ", temp); - // name of the character in the html (no < >, because that create problem in html code) - fprintf(fp2, " \n"); - } - // displaying of the job - if (online_display_option & 6) { - char * jobname = job_name(char_dat[j].status.class_); - if ((online_display_option & 6) == 6) { - fprintf(fp2, " \n", jobname, char_dat[j].status.base_level, char_dat[j].status.job_level); - fprintf(fp, "%-18s %3d/%3d ", jobname, char_dat[j].status.base_level, char_dat[j].status.job_level); - } else if (online_display_option & 2) { - fprintf(fp2, " \n", jobname); - fprintf(fp, "%-18s ", jobname); - } else if (online_display_option & 4) { - fprintf(fp2, " \n", char_dat[j].status.base_level, char_dat[j].status.job_level); - fprintf(fp, "%3d/%3d ", char_dat[j].status.base_level, char_dat[j].status.job_level); - } - } - // displaying of the map - if (online_display_option & 24) { // 8 or 16 - // prepare map name - safestrncpy(temp, mapindex_id2name(char_dat[j].status.last_point.map), sizeof(temp)); - // write map name - if (online_display_option & 16) { // map-name AND coordinates - fprintf(fp2, " \n", temp, char_dat[j].status.last_point.x, char_dat[j].status.last_point.y); - fprintf(fp, "%-12s (%3d,%3d) ", temp, char_dat[j].status.last_point.x, char_dat[j].status.last_point.y); - } else { - fprintf(fp2, " \n", temp); - fprintf(fp, "%-12s ", temp); - } - } - // displaying nimber of zenys - if (online_display_option & 32) { - // write number of zenys - if (char_dat[j].status.zeny == 0) { // if no zeny - fprintf(fp2, " \n"); - fprintf(fp, " no zeny "); - } else { - fprintf(fp2, " \n", char_dat[j].status.zeny); - fprintf(fp, "%13d z ", char_dat[j].status.zeny); - } - } - fprintf(fp, "\n"); - fprintf(fp2, " \n"); - } - // If we display at least 1 player - if (players > 0) { - fprintf(fp2, "
    NameJob (levels)JobLevelsLocationzenys
    "); - if ((online_display_option & 64) && l >= online_gm_display_min_level) - fprintf(fp2, ""); - for (k = 0; k < strlen(temp); k++) { - switch(temp[k]) { - case '<': // < - fprintf(fp2, "<"); - break; - case '>': // > - fprintf(fp2, ">"); - break; - default: - fprintf(fp2, "%c", temp[k]); - break; - }; - } - if ((online_display_option & 64) && l >= online_gm_display_min_level) - fprintf(fp2, " (GM)"); - fprintf(fp2, "%s %d/%d%s%d/%d%s (%d, %d)%sno zeny%d z
    \n"); - fprintf(fp, "\n"); - } + //Make the character leave the party [Skotlex] + if (party_id) + inter_party_leave(party_id, account_id, char_id); - // Displaying number of online players - if (players == 0) { - fprintf(fp2, "

    No user is online.

    \n"); - fprintf(fp, "No user is online.\n"); - } else if (players == 1) { - fprintf(fp2, "

    %d user is online.

    \n", players); - fprintf(fp, "%d user is online.\n", players); - } else { - fprintf(fp2, "

    %d users are online.

    \n", players); - fprintf(fp, "%d users are online.\n", players); - } - fprintf(fp2, " \n"); - fprintf(fp2, "\n"); - fclose(fp2); - } - fclose(fp); + /* delete char's pet */ + //Delete the hatched pet if you have one... + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incuvate` = '0'", pet_db, char_id) ) + Sql_ShowDebug(sql_handle); + + //Delete all pets that are stored in eggs (inventory + cart) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* remove homunculus */ + if( hom_id ) + mapif_homunculus_delete(hom_id); + + /* remove mercenary data */ + mercenary_owner_delete(char_id); + + /* delete char's friends list */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* delete char from other's friend list */ + //NOTE: Won't this cause problems for people who are already online? [Skotlex] + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) ) + Sql_ShowDebug(sql_handle); + +#ifdef HOTKEY_SAVING + /* delete hotkeys */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) ) + Sql_ShowDebug(sql_handle); +#endif + + /* delete inventory */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* delete cart inventory */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* delete memo areas */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* delete character registry */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* delete skills */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) ) + Sql_ShowDebug(sql_handle); + +#ifdef ENABLE_SC_SAVING + /* status changes */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); +#endif + + if (log_char) { + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')", + charlog_db, account_id, 0, char_id, esc_name) ) + Sql_ShowDebug(sql_handle); } - return; + /* delete character */ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + + /* No need as we used inter_guild_leave [Skotlex] + // Also delete info from guildtables. + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) ) + Sql_ShowDebug(sql_handle); + */ + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + mapif_parse_BreakGuild(0,guild_id); + else if( guild_id ) + inter_guild_leave(guild_id, account_id, char_id);// Leave your guild. + return 0; } //--------------------------------------------------------------------- @@ -1828,7 +1615,10 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed; WBUFW(buf,52) = p->class_; WBUFW(buf,54) = p->hair; - WBUFW(buf,56) = p->option&0x20 ? 0 : p->weapon; //When the weapon is sent and your option is riding, the client crashes on login!? + + //When the weapon is sent and your option is riding, the client crashes on login!? + WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon; + WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); WBUFW(buf,62) = p->head_bottom; @@ -1861,14 +1651,17 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) WBUFL(buf,128) = p->robe; offset += 4; #endif -#if PACKETVER >= 20110928 - WBUFL(buf,132) = 0; // change slot feature (0 = disabled, otherwise enabled) - offset += 4; -#endif -#if PACKETVER >= 20111025 - WBUFL(buf,136) = 0; // unknown purpose (0 = disabled, otherwise displays "Add-Ons" sidebar) - offset += 4; +#if PACKETVER != 20111116 //2011-11-16 wants 136, ask gravity. + #if PACKETVER >= 20110928 + WBUFL(buf,132) = 0; // change slot feature (0 = disabled, otherwise enabled) + offset += 4; + #endif + #if PACKETVER >= 20111025 + WBUFL(buf,136) = 0; // unknown purpose (0 = disabled, otherwise displays "Add-Ons" sidebar) + offset += 4; + #endif #endif + return 106+offset; } @@ -1877,15 +1670,16 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) //---------------------------------------- int mmo_char_send006b(int fd, struct char_session_data* sd) { - int i, j, found_num, offset = 0; + int j, offset = 0; #if PACKETVER >= 20100413 offset += 3; #endif - found_num = char_find_characters(sd); + if (save_log) + ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); j = 24 + offset; // offset - WFIFOHEAD(fd,j + found_num*MAX_CHAR_BUF); + WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF); WFIFOW(fd,0) = 0x6b; #if PACKETVER >= 20100413 WFIFOB(fd,4) = MAX_CHARS; // Max slots. @@ -1893,80 +1687,75 @@ int mmo_char_send006b(int fd, struct char_session_data* sd) WFIFOB(fd,6) = MAX_CHARS; // Premium slots. #endif memset(WFIFOP(fd,4 + offset), 0, 20); // unknown bytes - for(i = 0; i < found_num; i++) - j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status); + j+=mmo_chars_fromsql(sd, WFIFOP(fd,j)); WFIFOW(fd,2) = j; // packet len WFIFOSET(fd,j); return 0; } -// —£¥(char휎ž‚ÉŽg—p) -int char_divorce(struct mmo_charstatus *cs) +int char_married(int pl1, int pl2) { - if (cs == NULL) - return 0; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; - if (cs->partner_id > 0){ - int i, j; - for(i = 0; i < char_num; i++) { - if (char_dat[i].status.char_id == cs->partner_id && char_dat[i].status.partner_id == cs->char_id) { - cs->partner_id = 0; - char_dat[i].status.partner_id = 0; - for(j = 0; j < MAX_INVENTORY; j++) - { - if (char_dat[i].status.inventory[j].nameid == WEDDING_RING_M || char_dat[i].status.inventory[j].nameid == WEDDING_RING_F) - memset(&char_dat[i].status.inventory[j], 0, sizeof(char_dat[i].status.inventory[0])); - if (cs->inventory[j].nameid == WEDDING_RING_M || cs->inventory[j].nameid == WEDDING_RING_F) - memset(&cs->inventory[j], 0, sizeof(cs->inventory[0])); - } - return 0; - } + Sql_GetData(sql_handle, 0, &data, NULL); + if( pl2 == atoi(data) ) + { + Sql_FreeResult(sql_handle); + return 1; } } + Sql_FreeResult(sql_handle); return 0; } -int char_married(int pl1, int pl2) -{ - return (char_dat[pl1].status.char_id == char_dat[pl2].status.partner_id && char_dat[pl2].status.char_id == char_dat[pl1].status.partner_id); -} - int char_child(int parent_id, int child_id) { - return (char_dat[parent_id].status.child == char_dat[child_id].status.char_id && - ((char_dat[parent_id].status.char_id == char_dat[child_id].status.father) || - (char_dat[parent_id].status.char_id == char_dat[child_id].status.mother))); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + if( child_id == atoi(data) ) + { + Sql_FreeResult(sql_handle); + return 1; + } + } + Sql_FreeResult(sql_handle); + return 0; } int char_family(int cid1, int cid2, int cid3) { - int i, idx1 = -1, idx2 =-1;//, idx3 =-1; - for(i = 0; i < char_num && (idx1 == -1 || idx2 == -1/* || idx3 == 1*/); i++) - { - if (char_dat[i].status.char_id == cid1) - idx1 = i; - if (char_dat[i].status.char_id == cid2) - idx2 = i; -// if (char_dat[i].status.char_id == cid2) -// idx3 = i; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) ) + Sql_ShowDebug(sql_handle); + else while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int charid; + int partnerid; + int childid; + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); charid = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); childid = atoi(data); + + if( (cid1 == charid && ((cid2 == partnerid && cid3 == childid ) || (cid2 == childid && cid3 == partnerid))) || + (cid1 == partnerid && ((cid2 == charid && cid3 == childid ) || (cid2 == childid && cid3 == charid ))) || + (cid1 == childid && ((cid2 == charid && cid3 == partnerid) || (cid2 == partnerid && cid3 == charid ))) ) + { + Sql_FreeResult(sql_handle); + return childid; + } } - if (idx1 == -1 || idx2 == -1/* || idx3 == -1*/) - return 0; //Some character not found?? - - //Unless the dbs are corrupted, these 3 checks should suffice, even though - //we could do a lot more checks and force cross-reference integrity. - if(char_dat[idx1].status.partner_id == cid2 && - char_dat[idx1].status.child == cid3) - return cid3; //cid1/cid2 parents. cid3 child. - - if(char_dat[idx1].status.partner_id == cid3 && - char_dat[idx1].status.child == cid2) - return cid2; //cid1/cid3 parents. cid2 child. - - if(char_dat[idx2].status.partner_id == cid3 && - char_dat[idx2].status.child == cid1) - return cid1; //cid2/cid3 parents. cid1 child. + Sql_FreeResult(sql_handle); return 0; } @@ -1984,45 +1773,6 @@ void disconnect_player(int account_id) set_eof(i); } -// ƒLƒƒƒ‰íœ‚É”º‚¤ƒf[ƒ^íœ -static int char_delete(struct mmo_charstatus *cs) -{ - int j; - - // ƒyƒbƒgíœ - if (cs->pet_id) - inter_pet_delete(cs->pet_id); - if (cs->hom_id) - inter_homun_delete(cs->hom_id); - for (j = 0; j < MAX_INVENTORY; j++) - if (cs->inventory[j].card[0] == (short)0xff00) - inter_pet_delete(MakeDWord(cs->inventory[j].card[1],cs->inventory[j].card[2])); - for (j = 0; j < MAX_CART; j++) - if (cs->cart[j].card[0] == (short)0xff00) - inter_pet_delete( MakeDWord(cs->cart[j].card[1],cs->cart[j].card[2]) ); - // ƒMƒ‹ƒh’E‘Þ - if (cs->guild_id) - inter_guild_leave(cs->guild_id, cs->account_id, cs->char_id); - // ƒp[ƒeƒB[’E‘Þ - if (cs->party_id) - inter_party_leave(cs->party_id, cs->account_id, cs->char_id); - // —£¥ - if (cs->partner_id){ - // —£¥î•ñ‚ðmap‚É’Ê’m - unsigned char buf[10]; - WBUFW(buf,0) = 0x2b12; - WBUFL(buf,2) = cs->char_id; - WBUFL(buf,6) = cs->partner_id; - mapif_sendall(buf,10); - // —£¥ - char_divorce(cs); - } -#ifdef ENABLE_SC_SAVING - status_delete_scdata(cs->account_id, cs->char_id); -#endif - return 0; -} - static void char_auth_ok(int fd, struct char_session_data *sd) { struct online_char_data* character; @@ -2085,6 +1835,7 @@ void loginif_reset(void) /// Checks the conditions for the server to stop. +/// Releases the cookie when all characters are saved. /// If all the conditions are met, it stops the core loop. void loginif_check_shutdown(void) { @@ -2107,7 +1858,7 @@ void loginif_on_ready(void) int i; loginif_check_shutdown(); - + //Send online accounts to login server. send_accounts_tologin(INVALID_TIMER, gettick(), 0, 0); @@ -2122,7 +1873,7 @@ int parse_fromlogin(int fd) { struct char_session_data* sd = NULL; int i; - + // only process data from the login-server if( fd != login_fd ) { @@ -2157,7 +1908,7 @@ int parse_fromlogin(int fd) //printf("connect login server error : %d\n", RFIFOB(fd,2)); ShowError("Can not connect to login-server.\n"); ShowError("The server communication passwords (default s1/p1) are probably invalid.\n"); - ShowError("Also, please make sure your accounts file (default: accounts.txt) has the correct communication username/passwords and the gender of the account is S.\n"); + ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n"); ShowError("The communication passwords are set in map_athena.conf and char_athena.conf\n"); set_eof(fd); return 0; @@ -2213,22 +1964,21 @@ int parse_fromlogin(int fd) ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) ); if( i < fd_max ) { + int server_id; memcpy(sd->email, RFIFOP(fd,6), 40); sd->expiration_time = (time_t)RFIFOL(fd,46); sd->gmlevel = RFIFOB(fd,50); safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate)); - + ARR_FIND( 0, ARRAYLENGTH(server), server_id, server[server_id].fd > 0 && server[server_id].map[0] ); // continued from char_auth_ok... - if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level ) - { + if( server_id == ARRAYLENGTH(server) || //server not online, bugreport:2359 + ( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level ) ) { // refuse connection (over populated) WFIFOHEAD(i,3); WFIFOW(i,0) = 0x6c; WFIFOW(i,2) = 0; WFIFOSET(i,3); - } - else - { + } else { // send characters to player mmo_char_send006b(i, sd); #if PACKETVER >= 20110309 @@ -2258,7 +2008,6 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 7) return 0; { - int j; unsigned char buf[7]; int acc = RFIFOL(fd,2); @@ -2267,57 +2016,65 @@ int parse_fromlogin(int fd) if( acc > 0 ) {// TODO: Is this even possible? + int char_id[MAX_CHARS]; + int class_[MAX_CHARS]; + int guild_id[MAX_CHARS]; + int num; + char* data; + struct auth_node* node = (struct auth_node*)idb_get(auth_db, acc); if( node != NULL ) node->sex = sex; - ARR_FIND( 0, char_num, i, char_dat[i].status.account_id == acc ); - if( i < char_num ) + // get characters + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + Sql_GetData(sql_handle, 0, &data, NULL); char_id[i] = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); class_[i] = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); guild_id[i] = atoi(data); + } + num = i; + for( i = 0; i < num; ++i ) { - int jobclass = char_dat[i].status.class_; - char_dat[i].status.sex = sex; - if (jobclass == JOB_BARD || jobclass == JOB_DANCER || - jobclass == JOB_CLOWN || jobclass == JOB_GYPSY || - jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) { + if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER || + class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY || + class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER || + class_[i] == JOB_WANDERER || class_[i] == JOB_WANDERER_T || + class_[i] == JOB_MINSTREL || class_[i] == JOB_MINSTREL_T ) + { // job modification - if (jobclass == JOB_BARD || jobclass == JOB_DANCER) { - char_dat[i].status.class_ = (sex) ? JOB_BARD : JOB_DANCER; - } else if (jobclass == JOB_CLOWN || jobclass == JOB_GYPSY) { - char_dat[i].status.class_ = (sex) ? JOB_CLOWN : JOB_GYPSY; - } else if (jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) { - char_dat[i].status.class_ = (sex) ? JOB_BABY_BARD : JOB_BABY_DANCER; - } - // remove specifical skills of classes 19, 4020 and 4042 - for(j = 315; j <= 322; j++) { - if (char_dat[i].status.skill[j].id > 0 && char_dat[i].status.skill[j].flag == SKILL_FLAG_PERMANENT) { - char_dat[i].status.skill_point += char_dat[i].status.skill[j].lv; - char_dat[i].status.skill[j].id = 0; - char_dat[i].status.skill[j].lv = 0; - } - } - // remove specifical skills of classes 20, 4021 and 4043 - for(j = 323; j <= 330; j++) { - if (char_dat[i].status.skill[j].id > 0 && char_dat[i].status.skill[j].flag == SKILL_FLAG_PERMANENT) { - char_dat[i].status.skill_point += char_dat[i].status.skill[j].lv; - char_dat[i].status.skill[j].id = 0; - char_dat[i].status.skill[j].lv = 0; - } - } + if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ) + class_[i] = (sex ? JOB_BARD : JOB_DANCER); + else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ) + class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY); + else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ) + class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER); + else if( class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER ) + class_[i] = (sex ? JOB_MINSTREL : JOB_WANDERER); + else if( class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T ) + class_[i] = (sex ? JOB_MINSTREL_T : JOB_WANDERER_T); + // remove specifical skills of classes 19,20 4020,4021 and 4042,4043 + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `skill_point` = `skill_point` +" + " (SELECT SUM(lv) FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330' AND `lv` > '0')" + " WHERE `char_id` = '%d'", + char_db, skill_db, char_id[i], char_id[i]) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'", skill_db, char_id[i]) ) + Sql_ShowDebug(sql_handle); } // to avoid any problem with equipment and invalid sex, equipment is unequiped. - for (j = 0; j < MAX_INVENTORY; j++) { - if (char_dat[i].status.inventory[j].nameid && char_dat[i].status.inventory[j].equip) - char_dat[i].status.inventory[j].equip = 0; - } - char_dat[i].status.weapon = 0; - char_dat[i].status.shield = 0; - char_dat[i].status.head_top = 0; - char_dat[i].status.head_mid = 0; - char_dat[i].status.head_bottom = 0; - - if (char_dat[i].status.guild_id) //If there is a guild, update the guild_member data [Skotlex] - inter_guild_sex_changed(char_dat[i].status.guild_id, acc, char_dat[i].status.char_id, sex); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'", inventory_db, char_id[i]) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', `head_bottom`='0' WHERE `char_id`='%d'", char_db, class_[i], char_id[i]) ) + Sql_ShowDebug(sql_handle); + + if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex] + inter_guild_sex_changed(guild_id[i], acc, char_id[i], sex); } + Sql_FreeResult(sql_handle); + // disconnect player if online on char-server disconnect_player(acc); } @@ -2495,124 +2252,62 @@ int save_accreg2(unsigned char* buf, int len) return 0; } -//Receive Registry information for a character. -int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int buf_len) -{ - int i,j,p,len; - for (i = 0; i < char_num; i++) { - if (char_dat[i].status.account_id == account_id && char_dat[i].status.char_id == char_id) - break; - } - if(i >= char_num) //Character not found? - return 1; - for(j=0,p=0;j= char_num){ //Character not found? Sent empty packet. - WFIFOW(fd,2)=13; - }else{ - for (p=13,j = 0; j < char_dat[i].global_num; j++) { - if (char_dat[i].global[j].str[0]) { - p+= sprintf((char*)WFIFOP(fd,p), "%s", char_dat[i].global[j].str)+1; //We add 1 to consider the '\0' in place. - p+= sprintf((char*)WFIFOP(fd,p), "%s", char_dat[i].global[j].value)+1; - } - } - WFIFOW(fd,2)=p; - } - WFIFOSET(fd,WFIFOW(fd,2)); - return 0; -} - void char_read_fame_list(void) { - int i, j, k; - struct fame_list fame_item; - CREATE_BUFFER(id, int, char_num); - - for(i = 0; i < char_num; i++) { - id[i] = i; - for(j = 0; j < i; j++) { - if (char_dat[i].status.fame > char_dat[id[j]].status.fame) { - for(k = i; k > j; k--) - id[k] = id[k-1]; - id[j] = i; // id[i] - break; - } - } - } + int i; + char* data; + size_t len; // Empty ranking lists memset(smith_fame_list, 0, sizeof(smith_fame_list)); memset(chemist_fame_list, 0, sizeof(chemist_fame_list)); memset(taekwon_fame_list, 0, sizeof(taekwon_fame_list)); // Build Blacksmith ranking list - for (i = 0, j = 0; i < char_num && j < fame_list_size_smith; i++) { - if (char_dat[id[i]].status.fame && ( - char_dat[id[i]].status.class_ == JOB_BLACKSMITH || - char_dat[id[i]].status.class_ == JOB_WHITESMITH || - char_dat[id[i]].status.class_ == JOB_BABY_BLACKSMITH)) - { - fame_item.id = char_dat[id[i]].status.char_id; - fame_item.fame = char_dat[id[i]].status.fame; - safestrncpy(fame_item.name, char_dat[id[i]].status.name, NAME_LENGTH); - - memcpy(&smith_fame_list[j],&fame_item,sizeof(struct fame_list)); - j++; - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, fame_list_size_smith) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + smith_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + smith_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH)); } // Build Alchemist ranking list - for (i = 0, j = 0; i < char_num && j < fame_list_size_chemist; i++) { - if (char_dat[id[i]].status.fame && ( - char_dat[id[i]].status.class_ == JOB_ALCHEMIST || - char_dat[id[i]].status.class_ == JOB_CREATOR || - char_dat[id[i]].status.class_ == JOB_BABY_ALCHEMIST)) - { - fame_item.id = char_dat[id[i]].status.char_id; - fame_item.fame = char_dat[id[i]].status.fame; - safestrncpy(fame_item.name, char_dat[id[i]].status.name, NAME_LENGTH); - - memcpy(&chemist_fame_list[j],&fame_item,sizeof(struct fame_list)); - - j++; - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, fame_list_size_chemist) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + chemist_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + chemist_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH)); } // Build Taekwon ranking list - for (i = 0, j = 0; i < char_num && j < fame_list_size_taekwon; i++) { - if (char_dat[id[i]].status.fame && - char_dat[id[i]].status.class_ == JOB_TAEKWON) - { - fame_item.id = char_dat[id[i]].status.char_id; - fame_item.fame = char_dat[id[i]].status.fame; - safestrncpy(fame_item.name, char_dat[id[i]].status.name, NAME_LENGTH); - - memcpy(&taekwon_fame_list[j],&fame_item,sizeof(struct fame_list)); - - j++; - } + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) ) + Sql_ShowDebug(sql_handle); + for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + // char_id + Sql_GetData(sql_handle, 0, &data, NULL); + taekwon_fame_list[i].id = atoi(data); + // fame + Sql_GetData(sql_handle, 1, &data, &len); + taekwon_fame_list[i].fame = atoi(data); + // name + Sql_GetData(sql_handle, 2, &data, &len); + memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH)); } - DELETE_BUFFER(id); + Sql_FreeResult(sql_handle); } // Send map-servers the fame ranking lists @@ -2666,12 +2361,15 @@ void char_update_fame_list(int type, int index, int fame) //Returns 1 on found, 0 on not found (buffer is filled with Unknown char name) int char_loadName(int char_id, char* name) { - int j; + char* data; + size_t len; - ARR_FIND( 0, char_num, j, char_dat[j].status.char_id == char_id ); - if( j < char_num ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) { - safestrncpy(name, char_dat[j].status.name, NAME_LENGTH); + Sql_GetData(sql_handle, 0, &data, &len); + safestrncpy(name, data, NAME_LENGTH); return 1; } else @@ -2721,8 +2419,9 @@ void mapif_server_reset(int id) WBUFW(buf,2) = j * 4 + 10; mapif_sendallwos(fd, buf, WBUFW(buf,2)); } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo` WHERE `index`='%d'", server[id].fd) ) + Sql_ShowDebug(sql_handle); online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server. - create_online_files(); mapif_server_destroy(id); mapif_server_init(id); } @@ -2775,9 +2474,7 @@ int parse_frommap(int fd) ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n", id, j, CONVIP(server[id].ip), server[id].port); ShowStatus("Map-server %d loading complete.\n", id); - char_log("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d. Map-server %d loading complete.\n", - id, j, CONVIP(server[id].ip), server[id].port, id); - + // send name for wisp to player WFIFOHEAD(fd, 3 + NAME_LENGTH); WFIFOW(fd,0) = 0x2afb; @@ -2792,7 +2489,6 @@ int parse_frommap(int fd) int x; if (j == 0) { ShowWarning("Map-server %d has NO maps.\n", id); - char_log("WARNING: Map-server %d has NO maps.\n", id); } else { // Transmitting maps information to the other map-servers WBUFW(buf,0) = 0x2b04; @@ -2829,23 +2525,48 @@ int parse_frommap(int fd) { #ifdef ENABLE_SC_SAVING int aid, cid; - struct scdata *data; aid = RFIFOL(fd,2); cid = RFIFOL(fd,6); - data = status_search_scdata(aid, cid); - if (data->count > 0) - { //Deliver status change data. - WFIFOHEAD(fd,14 + data->count*sizeof(struct status_change_data)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", + scdata_db, aid, cid) ) + { + Sql_ShowDebug(sql_handle); + break; + } + if( Sql_NumRows(sql_handle) > 0 ) + { + struct status_change_data scdata; + int count; + char* data; + + WFIFOHEAD(fd,14+50*sizeof(struct status_change_data)); WFIFOW(fd,0) = 0x2b1d; - WFIFOW(fd,2) = 14 + data->count*sizeof(struct status_change_data); WFIFOL(fd,4) = aid; WFIFOL(fd,8) = cid; - WFIFOW(fd,12) = data->count; - for (i = 0; i < data->count; i++) - memcpy(WFIFOP(fd,14+i*sizeof(struct status_change_data)), &data->data[i], sizeof(struct status_change_data)); - WFIFOSET(fd, WFIFOW(fd,2)); - status_delete_scdata(aid, cid); //Data sent, so it needs be discarded now. + for( count = 0; count < 50 && SQL_SUCCESS == Sql_NextRow(sql_handle); ++count ) + { + Sql_GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); scdata.tick = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data); + memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data)); + } + if (count >= 50) + ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid); + if (count > 0) + { + WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data); + WFIFOW(fd,12) = count; + WFIFOSET(fd,WFIFOW(fd,2)); + + //Clear the data once loaded. + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) ) + Sql_ShowDebug(sql_handle); + } } + Sql_FreeResult(sql_handle); #endif RFIFOSKIP(fd, 10); } @@ -2894,7 +2615,7 @@ int parse_frommap(int fd) return 0; { int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2); - struct mmo_charstatus* cs; + struct online_char_data* character; if (size - 13 != sizeof(struct mmo_charstatus)) { @@ -2902,10 +2623,17 @@ int parse_frommap(int fd) RFIFOSKIP(fd,size); break; } - if( ( cs = search_character(aid, cid) ) != NULL ) + //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect + if (RFIFOB(fd,12) || ( + (character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL && + character->char_id == cid)) { - memcpy(cs, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); - storage_save(cs->account_id, &cs->storage); + struct mmo_charstatus char_dat; + memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); + mmo_char_tosql(cid, &char_dat); + } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off. + ShowError("parse_from_map (save-char): Received data for non-existant/offline character (%d:%d).\n", aid, cid); + set_char_online(id, cid, aid); } if (RFIFOB(fd,12)) @@ -2932,7 +2660,7 @@ int parse_frommap(int fd) uint32 login_id2 = RFIFOL(fd,10); uint32 ip = RFIFOL(fd,14); RFIFOSKIP(fd,18); - + if( runflag != CHARSERVER_ST_RUNNING ) { WFIFOHEAD(fd,7); @@ -2968,19 +2696,25 @@ int parse_frommap(int fd) break; case 0x2b05: // request "change map server" - if (RFIFOREST(fd) < 35) + if (RFIFOREST(fd) < 39) return 0; { int map_id, map_fd = -1; struct online_char_data* data; struct mmo_charstatus* char_data; + struct mmo_charstatus char_dat; map_id = search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port. if (map_id >= 0) map_fd = server[map_id].fd; - - char_data = search_character(RFIFOL(fd,2), RFIFOL(fd,14)); - + //Char should just had been saved before this packet, so this should be safe. [Skotlex] + char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); + if (char_data == NULL) + { //Really shouldn't happen. + mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true); + char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); + } + if( runflag == CHARSERVER_ST_RUNNING && session_isActive(map_fd) && char_data ) @@ -3000,8 +2734,10 @@ int parse_frommap(int fd) node->login_id1 = RFIFOL(fd,6); node->login_id2 = RFIFOL(fd,10); node->sex = RFIFOB(fd,30); - node->expiration_time = 0; // FIXME + node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing) node->ip = ntohl(RFIFOL(fd,31)); + node->gmlevel = RFIFOL(fd,35); + node->changing_mapservers = 1; idb_put(auth_db, RFIFOL(fd,2), node); data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); @@ -3024,6 +2760,22 @@ int parse_frommap(int fd) } break; + case 0x2b07: // Remove RFIFOL(fd,6) (friend_id) from RFIFOL(fd,2) (char_id) friend list [Ind] + if (RFIFOREST(fd) < 10) + return 0; + { + int char_id, friend_id; + char_id = RFIFOL(fd,2); + friend_id = RFIFOL(fd,6); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1", + friend_db, char_id, friend_id) ) { + Sql_ShowDebug(sql_handle); + break; + } + RFIFOSKIP(fd,10); + } + break; + case 0x2b08: // char name request if (RFIFOREST(fd) < 6) return 0; @@ -3054,7 +2806,7 @@ int parse_frommap(int fd) return 0; { int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - char character_name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1]; int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request) const char* name = (char*)RFIFOP(fd,6); // name of the target character @@ -3067,19 +2819,26 @@ int parse_frommap(int fd) short second = RFIFOW(fd,42); RFIFOSKIP(fd,44); - safestrncpy(character_name, name, NAME_LENGTH); - i = search_character_index(character_name); - if( i < 0 ) + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) + Sql_ShowDebug(sql_handle); + else + if( Sql_NumRows(sql_handle) == 0 ) { result = 1; // 1-player not found } else + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + Sql_ShowDebug(sql_handle); + //FIXME: set proper result value? + else { char name[NAME_LENGTH]; int account_id; + char* data; - account_id = char_dat[i].status.account_id; - safestrncpy(name, char_dat[i].status.name, NAME_LENGTH); + Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name)); if( login_fd <= 0 ) result = 3; // 3-login-server offline @@ -3130,6 +2889,8 @@ int parse_frommap(int fd) } } + Sql_FreeResult(sql_handle); + // send answer if a player ask, not if the server ask if( acc != -1 && type != 5) { // Don't send answer for changesex WFIFOHEAD(fd,34); @@ -3196,11 +2957,28 @@ int parse_frommap(int fd) } break; + // Divorce chars + case 0x2b11: + if( RFIFOREST(fd) < 10 ) + return 0; + + divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6)); + RFIFOSKIP(fd,10); + break; + case 0x2b16: // Receive rates [Wizputer] if( RFIFOREST(fd) < 14 ) return 0; - // Txt doesn't need this packet, so just skip it + { + char esc_server_name[sizeof(server_name)*2+1]; + + Sql_EscapeString(sql_handle, esc_server_name, server_name); + + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'", + fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) ) + Sql_ShowDebug(sql_handle); RFIFOSKIP(fd,14); + } break; case 0x2b17: // Character disconnected set online 0 [Wizputer] @@ -3236,20 +3014,31 @@ int parse_frommap(int fd) { #ifdef ENABLE_SC_SAVING int count, aid, cid; - struct scdata *data; aid = RFIFOL(fd, 4); cid = RFIFOL(fd, 8); count = RFIFOW(fd, 12); - data = status_search_scdata(aid, cid); - if (data->count != count) + if( count > 0 ) { - data->count = count; - data->data = (struct status_change_data*)aRealloc(data->data, count*sizeof(struct status_change_data)); + struct status_change_data data; + StringBuf buf; + int i; + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db); + for( i = 0; i < count; ++i ) + { + memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); + if( i > 0 ) + StringBuf_AppendStr(&buf, ", "); + StringBuf_Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid, + data.type, data.tick, data.val1, data.val2, data.val3, data.val4); + } + if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + StringBuf_Destroy(&buf); } - for (i = 0; i < count; i++) - memcpy (&data->data[i], RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); #endif RFIFOSKIP(fd, RFIFOW(fd, 2)); } @@ -3274,6 +3063,7 @@ int parse_frommap(int fd) uint32 ip; struct auth_node* node; struct mmo_charstatus* cd; + struct mmo_charstatus char_dat; account_id = RFIFOL(fd,2); char_id = RFIFOL(fd,6); @@ -3283,10 +3073,15 @@ int parse_frommap(int fd) RFIFOSKIP(fd,19); node = (struct auth_node*)idb_get(auth_db, account_id); - cd = search_character(account_id, char_id); + cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); + if( cd == NULL ) + { //Really shouldn't happen. + mmo_char_fromsql(char_id, &char_dat, true); + cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); + } if( runflag == CHARSERVER_ST_RUNNING && cd != NULL && - node != NULL && + node != NULL && node->account_id == account_id && node->char_id == char_id && node->login_id1 == login_id1 && @@ -3295,16 +3090,16 @@ int parse_frommap(int fd) {// auth ok cd->sex = sex; - WFIFOHEAD(fd,24 + sizeof(struct mmo_charstatus)); + WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus)); WFIFOW(fd,0) = 0x2afd; - WFIFOW(fd,2) = 24 + sizeof(struct mmo_charstatus); + WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus); WFIFOL(fd,4) = account_id; WFIFOL(fd,8) = node->login_id1; WFIFOL(fd,12) = node->login_id2; WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" WFIFOL(fd,20) = node->gmlevel; - storage_load(cd->account_id, &cd->storage); //FIXME: storage is used as a temp buffer here - memcpy(WFIFOP(fd,24), cd, sizeof(struct mmo_charstatus)); + WFIFOB(fd,24) = node->changing_mapservers; + memcpy(WFIFOP(fd,25), cd, sizeof(struct mmo_charstatus)); WFIFOSET(fd, WFIFOW(fd,2)); // only use the auth once and mark user online @@ -3460,18 +3255,31 @@ void char_delete2_cancel_ack(int fd, int char_id, uint32 result) static void char_delete2_req(int fd, struct char_session_data* sd) {// CH: <0827>.W .L - int char_id; - struct mmo_charstatus* cs; + int char_id, i, guild_id, party_id; + char* data; + time_t delete_date; char_id = RFIFOL(fd,2); - if( ( cs = search_session_character(sd, char_id) ) == NULL ) + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); + if( i == MAX_CHARS ) {// character not found char_delete2_ack(fd, char_id, 3, 0); return; } - if( cs->delete_date ) + if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `guild_id`,`party_id`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_ShowDebug(sql_handle); + char_delete2_ack(fd, char_id, 3, 0); + return; + } + + Sql_GetData(sql_handle, 0, &data, NULL); guild_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); party_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); delete_date = strtoul(data, NULL, 10); + + if( delete_date ) {// character already queued for deletion char_delete2_ack(fd, char_id, 0, 0); return; @@ -3481,13 +3289,13 @@ static void char_delete2_req(int fd, struct char_session_data* sd) // Aegis imposes these checks probably to avoid dead member // entries in guilds/parties, otherwise they are not required. // TODO: Figure out how these are enforced during waiting. - if( cs->guild_id ) + if( guild_id ) {// character in guild char_delete2_ack(fd, char_id, 4, 0); return; } - if( cs->party_id ) + if( party_id ) {// character in party char_delete2_ack(fd, char_id, 5, 0); return; @@ -3495,17 +3303,26 @@ static void char_delete2_req(int fd, struct char_session_data* sd) */ // success - cs->delete_date = time(NULL)+char_del_delay; + delete_date = time(NULL)+char_del_delay; + + if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) ) + { + Sql_ShowDebug(sql_handle); + char_delete2_ack(fd, char_id, 3, 0); + return; + } - char_delete2_ack(fd, char_id, 1, cs->delete_date); + char_delete2_ack(fd, char_id, 1, delete_date); } static void char_delete2_accept(int fd, struct char_session_data* sd) {// CH: <0829>.W .L .6B char birthdate[8+1]; - int char_id, i; - struct mmo_charstatus* cs; + int char_id, i, k; + unsigned int base_level; + char* data; + time_t delete_date; char_id = RFIFOL(fd,2); @@ -3522,15 +3339,24 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) birthdate[7] = RFIFOB(fd,11); birthdate[8] = 0; - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] != -1 && char_dat[sd->found_char[i]].status.char_id == char_id ); + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); if( i == MAX_CHARS ) {// character not found char_delete2_accept_ack(fd, char_id, 3); return; } - cs = &char_dat[sd->found_char[i]].status; - if( !cs->delete_date || cs->delete_date>time(NULL) ) + if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) ) + {// data error + Sql_ShowDebug(sql_handle); + char_delete2_accept_ack(fd, char_id, 3); + return; + } + + Sql_GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10); + + if( !delete_date || delete_date>time(NULL) ) {// not queued or delay not yet passed char_delete2_accept_ack(fd, char_id, 4); return; @@ -3542,49 +3368,25 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) return; } - if( ( char_del_level > 0 && cs->base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && cs->base_level <= (unsigned int)(-char_del_level) ) ) + if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) ) {// character level config restriction char_delete2_accept_ack(fd, char_id, 2); return; } // success - char_delete(cs); - - // drop character entry - if( --char_num > 0 && sd->found_char[i] != char_num ) + if( delete_char_sql(char_id) < 0 ) { - int s, c; - - // move the last entry to the place of the deleted character - memcpy(&char_dat[sd->found_char[i]], &char_dat[char_num], sizeof(struct mmo_charstatus)); - - // scan currently online accounts, if the moved character - // entry requires an update of the cached character list - for( s = 0; s < fd_max; s++ ) - { - struct char_session_data* osd; - - if( session[s] && ( osd = (struct char_session_data*)session[s]->session_data ) != NULL && osd->account_id == char_dat[char_num].status.account_id ) - { - for( c = 0; c < MAX_CHARS; c++ ) - { - if( osd->found_char[c] == char_num ) - { - osd->found_char[c] = sd->found_char[i]; - break; - } - } - break; - } - } - - // wipe the last entry - memset(&char_dat[char_num], 0, sizeof(struct mmo_charstatus)); + char_delete2_accept_ack(fd, char_id, 3); + return; } // refresh character list cache - char_find_characters(sd); + for(k = i; k < MAX_CHARS-1; k++) + { + sd->found_char[k] = sd->found_char[k+1]; + } + sd->found_char[MAX_CHARS-1] = -1; char_delete2_accept_ack(fd, char_id, 1); } @@ -3592,12 +3394,12 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) static void char_delete2_cancel(int fd, struct char_session_data* sd) {// CH: <082b>.W .L - int char_id; - struct mmo_charstatus* cs; + int char_id, i; char_id = RFIFOL(fd,2); - if( ( cs = search_session_character(sd, char_id) ) == NULL ) + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); + if( i == MAX_CHARS ) {// character not found char_delete2_cancel_ack(fd, char_id, 2); return; @@ -3606,7 +3408,12 @@ static void char_delete2_cancel(int fd, struct char_session_data* sd) // there is no need to check, whether or not the character was // queued for deletion, as the client prints an error message by // itself, if it was not the case (@see char_delete2_cancel_ack) - cs->delete_date = 0; + if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + char_delete2_cancel_ack(fd, char_id, 2); + return; + } char_delete2_cancel_ack(fd, char_id, 1); } @@ -3732,37 +3539,46 @@ int parse_char(int fd) case 0x66: FIFOSD_CHECK(3); { + struct mmo_charstatus char_dat; struct mmo_charstatus *cd; + char* data; + int char_id; uint32 subnet_map_ip; struct auth_node* node; int slot = RFIFOB(fd,2); RFIFOSKIP(fd,3); - // if we activated email creation and email is default email - if (email_creation != 0 && strcmp(sd->email, "a@a.com") == 0 && login_fd > 0) { // to modify an e-mail, login-server must be online - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; // 00 = Incorrect Email address - WFIFOSET(fd,3); - break; - } - // otherwise, load the character - ARR_FIND( 0, MAX_CHARS, ch, sd->found_char[ch] >= 0 && char_dat[sd->found_char[ch]].status.slot == slot ); - if (ch == MAX_CHARS) + if ( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot) + || SQL_SUCCESS != Sql_NextRow(sql_handle) + || SQL_SUCCESS != Sql_GetData(sql_handle, 0, &data, NULL) ) { //Not found?? May be forged packet. + Sql_ShowDebug(sql_handle); + Sql_FreeResult(sql_handle); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x6c; WFIFOB(fd,2) = 0; // rejected from server WFIFOSET(fd,3); break; } - cd = &char_dat[sd->found_char[ch]].status; - char_log("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s.\n", sd->account_id, slot, cd->name); + char_id = atoi(data); + Sql_FreeResult(sql_handle); + mmo_char_fromsql(char_id, &char_dat, true); + + //Have to switch over to the DB instance otherwise data won't propagate [Kevin] + cd = (struct mmo_charstatus *)idb_get(char_db_, char_id); cd->sex = sd->sex; - ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, cd->name); + if (log_char) { + char esc_name[NAME_LENGTH*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')", + charlog_db, sd->account_id, slot, esc_name) ) + Sql_ShowDebug(sql_handle); + } + ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name); // searching map server i = search_mapserver(cd->last_point.map, -1, -1); @@ -3846,6 +3662,9 @@ int parse_char(int fd) node->gmlevel = sd->gmlevel; node->ip = ipl; idb_put(auth_db, sd->account_id, node); + + set_char_online(-2,node->char_id,sd->account_id); + } break; @@ -3857,7 +3676,7 @@ int parse_char(int fd) if( !char_new ) //turn character creation on/off [Kevin] i = -2; else - i = make_new_char(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35)); + i = make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35)); //'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3) if (i < 0) @@ -3874,17 +3693,20 @@ int parse_char(int fd) else { int len; + // retrieve data + struct mmo_charstatus char_dat; + mmo_char_fromsql(i, &char_dat, false); //Only the short data is needed. // send to player WFIFOHEAD(fd,2+MAX_CHAR_BUF); WFIFOW(fd,0) = 0x6d; - len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status); + len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat); WFIFOSET(fd,len); // add new entry to the chars list ARR_FIND( 0, MAX_CHARS, ch, sd->found_char[ch] == -1 ); if( ch < MAX_CHARS ) - sd->found_char[ch] = i; // position of the new char in the char_dat[] array + sd->found_char[ch] = i; // the char_id of the new char } RFIFOSKIP(fd,37); @@ -3898,56 +3720,17 @@ int parse_char(int fd) if (cmd == 0x1fb) FIFOSD_CHECK(56); { int cid = RFIFOL(fd,2); - struct mmo_charstatus* cs = NULL; ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); memcpy(email, RFIFOP(fd,6), 40); - RFIFOSKIP(fd,( cmd == 0x68 ) ? 46 : 56); - - if (e_mail_check(email) == 0) - safestrncpy(email, "a@a.com", sizeof(email)); // default e-mail - - // BEGIN HACK: "change email using the char deletion 'confirm email' menu" - // if we activated email creation and email is default email - if (email_creation != 0 && strcmp(sd->email, "a@a.com") == 0 && login_fd > 0) { // to modify an e-mail, login-server must be online - // if sended email is incorrect e-mail - if (strcmp(email, "a@a.com") == 0) { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; // 00 = Incorrect Email address - WFIFOSET(fd,3); - break; - } - // we change the packet to set it like selection. - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] != -1 && char_dat[sd->found_char[i]].status.char_id == cid ); - if( i < MAX_CHARS ) - { - // we save new e-mail - memcpy(sd->email, email, 40); - // we send new e-mail to login-server ('online' login-server is checked before) - WFIFOHEAD(login_fd,46); - WFIFOW(login_fd,0) = 0x2715; - WFIFOL(login_fd,2) = sd->account_id; - memcpy(WFIFOP(login_fd, 6), email, 40); - WFIFOSET(login_fd,46); - - // change value to put new packet (char selection) - RFIFOSKIP(fd,-3); //FIXME: Will this work? Messing with the received buffer is ugly anyway... - RFIFOW(fd,0) = 0x66; - RFIFOB(fd,2) = char_dat[sd->found_char[i]].status.slot; - // not send packet, it's modify of actual packet - } else { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; // 00 = Incorrect Email address - WFIFOSET(fd,3); - } - break; - } - // END HACK - - // otherwise, we delete the character - if (strcmpi(email, sd->email) != 0) { // if it's an invalid email + RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56); + + // Check if e-mail is correct + if(strcmpi(email, sd->email) && //email does not matches and + ( + strcmp("a@a.com", sd->email) || //it is not default email, or + (strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default + )) { //Fail WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x70; WFIFOB(fd,2) = 0; // 00 = Incorrect Email address @@ -3956,7 +3739,7 @@ int parse_char(int fd) } // check if this char exists - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] != -1 && char_dat[sd->found_char[i]].status.char_id == cid ); + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); if( i == MAX_CHARS ) { // Such a character does not exist in the account WFIFOHEAD(fd,3); @@ -3966,45 +3749,22 @@ int parse_char(int fd) break; } - // deletion process - cs = &char_dat[sd->found_char[i]].status; - - //check for config char del condition [Lupus] - if( ( char_del_level > 0 && cs->base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && cs->base_level <= (unsigned int)(-char_del_level) ) ) - { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 1; // This character cannot be deleted. - WFIFOSET(fd,3); - break; - } - - char_delete(cs); - if (sd->found_char[i] != char_num - 1) { - int j, k; - struct char_session_data *sd2; - memcpy(&char_dat[sd->found_char[i]], &char_dat[char_num-1], sizeof(struct mmo_charstatus)); - // Correct moved character reference in the character's owner - for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && - sd2->account_id == char_dat[char_num-1].status.account_id) { - for (k = 0; k < MAX_CHARS; k++) { - if (sd2->found_char[k] == char_num-1) { - sd2->found_char[k] = sd->found_char[i]; - break; - } - } - break; - } - } - } - char_num--; - // remove char from list and compact it for(ch = i; ch < MAX_CHARS-1; ch++) sd->found_char[ch] = sd->found_char[ch+1]; sd->found_char[MAX_CHARS-1] = -1; - + + /* Delete character */ + if(delete_char_sql(cid)<0){ + //can't delete the char + //either SQL error or can't delete by some CONFIG conditions + //del fail + WFIFOHEAD(fd,3); + WFIFOW(fd, 0) = 0x70; + WFIFOB(fd, 2) = 0; + WFIFOSET(fd, 3); + break; + } /* Char successfully deleted.*/ WFIFOHEAD(fd,2); WFIFOW(fd,0) = 0x6f; @@ -4025,8 +3785,32 @@ int parse_char(int fd) case 0x28d: FIFOSD_CHECK(34); { - //not implemented + int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6); + char name[NAME_LENGTH]; + char esc_name[NAME_LENGTH*2+1]; + safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH); RFIFOSKIP(fd,34); + + if( aid != sd->account_id ) + break; + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); + if( i == MAX_CHARS ) + break; + + normalize_name(name,TRIM_CHARS); + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); + if( !check_char_name(name,esc_name) ) + { + i = 1; + safestrncpy(sd->new_name, name, NAME_LENGTH); + } + else + i = 0; + + WFIFOHEAD(fd, 4); + WFIFOW(fd,0) = 0x28e; + WFIFOW(fd,2) = i; + WFIFOSET(fd,4); } break; //Confirm change name. @@ -4039,8 +3823,19 @@ int parse_char(int fd) // 4: Another user is using this character name, so please select another one. FIFOSD_CHECK(6); { - //not implemented + int i; + int cid = RFIFOL(fd,2); RFIFOSKIP(fd,6); + + ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); + if( i == MAX_CHARS ) + break; + i = rename_char_sql(sd, cid); + + WFIFOHEAD(fd, 4); + WFIFOW(fd,0) = 0x290; + WFIFOW(fd,2) = i; + WFIFOSET(fd,4); } break; @@ -4237,9 +4032,6 @@ int broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data) WBUFL(buf,2) = users; mapif_sendall(buf,6); - // refresh online files (txt and html) - create_online_files(); - return 0; } @@ -4409,9 +4201,86 @@ int char_lan_config_read(const char *lancfgName) fclose(fp); return 0; } -#endif //TXT_SQL_CONVERT -int char_config_read(const char *cfgName) +void sql_config_read(const char* cfgName) +{ + char line[1024], w1[1024], w2[1024]; + FILE* fp; + + ShowInfo("Reading file %s...\n", cfgName); + + if ((fp = fopen(cfgName, "r")) == NULL) { + ShowError("file not found: %s\n", cfgName); + return; + } + + while(fgets(line, sizeof(line), fp)) + { + if(line[0] == '/' && line[1] == '/') + continue; + + if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + continue; + + if(!strcmpi(w1,"char_db")) + safestrncpy(char_db, w2, sizeof(char_db)); + else if(!strcmpi(w1,"scdata_db")) + safestrncpy(scdata_db, w2, sizeof(scdata_db)); + else if(!strcmpi(w1,"cart_db")) + safestrncpy(cart_db, w2, sizeof(cart_db)); + else if(!strcmpi(w1,"inventory_db")) + safestrncpy(inventory_db, w2, sizeof(inventory_db)); + else if(!strcmpi(w1,"charlog_db")) + safestrncpy(charlog_db, w2, sizeof(charlog_db)); + else if(!strcmpi(w1,"storage_db")) + safestrncpy(storage_db, w2, sizeof(storage_db)); + else if(!strcmpi(w1,"reg_db")) + safestrncpy(reg_db, w2, sizeof(reg_db)); + else if(!strcmpi(w1,"skill_db")) + safestrncpy(skill_db, w2, sizeof(skill_db)); + else if(!strcmpi(w1,"interlog_db")) + safestrncpy(interlog_db, w2, sizeof(interlog_db)); + else if(!strcmpi(w1,"memo_db")) + safestrncpy(memo_db, w2, sizeof(memo_db)); + else if(!strcmpi(w1,"guild_db")) + safestrncpy(guild_db, w2, sizeof(guild_db)); + else if(!strcmpi(w1,"guild_alliance_db")) + safestrncpy(guild_alliance_db, w2, sizeof(guild_alliance_db)); + else if(!strcmpi(w1,"guild_castle_db")) + safestrncpy(guild_castle_db, w2, sizeof(guild_castle_db)); + else if(!strcmpi(w1,"guild_expulsion_db")) + safestrncpy(guild_expulsion_db, w2, sizeof(guild_expulsion_db)); + else if(!strcmpi(w1,"guild_member_db")) + safestrncpy(guild_member_db, w2, sizeof(guild_member_db)); + else if(!strcmpi(w1,"guild_skill_db")) + safestrncpy(guild_skill_db, w2, sizeof(guild_skill_db)); + else if(!strcmpi(w1,"guild_position_db")) + safestrncpy(guild_position_db, w2, sizeof(guild_position_db)); + else if(!strcmpi(w1,"guild_storage_db")) + safestrncpy(guild_storage_db, w2, sizeof(guild_storage_db)); + else if(!strcmpi(w1,"party_db")) + safestrncpy(party_db, w2, sizeof(party_db)); + else if(!strcmpi(w1,"pet_db")) + safestrncpy(pet_db, w2, sizeof(pet_db)); + else if(!strcmpi(w1,"mail_db")) + safestrncpy(mail_db, w2, sizeof(mail_db)); + else if(!strcmpi(w1,"auction_db")) + safestrncpy(auction_db, w2, sizeof(auction_db)); + else if(!strcmpi(w1,"friend_db")) + safestrncpy(friend_db, w2, sizeof(friend_db)); + else if(!strcmpi(w1,"hotkey_db")) + safestrncpy(hotkey_db, w2, sizeof(hotkey_db)); + else if(!strcmpi(w1,"quest_db")) + safestrncpy(quest_db,w2,sizeof(quest_db)); + //support the import command, just like any other config + else if(!strcmpi(w1,"import")) + sql_config_read(w2); + } + fclose(fp); + ShowInfo("Done reading %s.\n", cfgName); +} + +int char_config_read(const char* cfgName) { char line[1024], w1[1024], w2[1024]; FILE* fp = fopen(cfgName, "r"); @@ -4437,7 +4306,6 @@ int char_config_read(const char *cfgName) } else if(strcmpi(w1,"console_silent")==0){ ShowInfo("Console Silent Setting: %d\n", atoi(w2)); msg_silent = atoi(w2); -#ifndef TXT_SQL_CONVERT } else if(strcmpi(w1,"stdout_with_ansisequence")==0){ stdout_with_ansisequence = config_switch(w2); } else if (strcmpi(w1, "userid") == 0) { @@ -4482,18 +4350,6 @@ int char_config_read(const char *cfgName) char_new = (bool)atoi(w2); } else if (strcmpi(w1, "char_new_display") == 0) { char_new_display = atoi(w2); - } else if (strcmpi(w1, "email_creation") == 0) { - email_creation = config_switch(w2); - } else if (strcmpi(w1, "scdata_txt") == 0) { //By Skotlex - safestrncpy(scdata_txt, w2, sizeof(scdata_txt)); -#endif - } else if (strcmpi(w1, "char_txt") == 0) { - safestrncpy(char_txt, w2, sizeof(char_txt)); - } else if (strcmpi(w1, "friends_txt") == 0) { //By davidsiaw - safestrncpy(friends_txt, w2, sizeof(friends_txt)); - } else if (strcmpi(w1, "hotkeys_txt") == 0) { //By davidsiaw - safestrncpy(hotkeys_txt, w2, sizeof(hotkeys_txt)); -#ifndef TXT_SQL_CONVERT } else if (strcmpi(w1, "max_connect_user") == 0) { max_connect_user = atoi(w2); if (max_connect_user < 0) @@ -4535,8 +4391,6 @@ int char_config_read(const char *cfgName) } else if (strcmpi(w1, "unknown_char_name") == 0) { safestrncpy(unknown_char_name, w2, sizeof(unknown_char_name)); unknown_char_name[NAME_LENGTH-1] = '\0'; - } else if (strcmpi(w1, "char_log_filename") == 0) { - safestrncpy(char_log_filename, w2, sizeof(char_log_filename)); } else if (strcmpi(w1, "name_ignoring_case") == 0) { name_ignoring_case = (bool)config_switch(w2); } else if (strcmpi(w1, "char_name_option") == 0) { @@ -4549,23 +4403,6 @@ int char_config_read(const char *cfgName) char_del_level = atoi(w2); } else if (strcmpi(w1, "char_del_delay") == 0) { char_del_delay = atoi(w2); -// online files options - } else if (strcmpi(w1, "online_txt_filename") == 0) { - safestrncpy(online_txt_filename, w2, sizeof(online_txt_filename)); - } else if (strcmpi(w1, "online_html_filename") == 0) { - safestrncpy(online_html_filename, w2, sizeof(online_html_filename)); - } else if (strcmpi(w1, "online_sorting_option") == 0) { - online_sorting_option = atoi(w2); - } else if (strcmpi(w1, "online_display_option") == 0) { - online_display_option = atoi(w2); - } else if (strcmpi(w1, "online_gm_display_min_level") == 0) { // minimum GM level to display 'GM' when we want to display it - online_gm_display_min_level = atoi(w2); - if (online_gm_display_min_level < 5) // send online file every 5 seconds to player is enough - online_gm_display_min_level = 5; - } else if (strcmpi(w1, "online_refresh_html") == 0) { - online_refresh_html = atoi(w2); - if (online_refresh_html < 1) - online_refresh_html = 1; } else if(strcmpi(w1,"db_path")==0) { safestrncpy(db_path, w2, sizeof(db_path)); } else if (strcmpi(w1, "console") == 0) { @@ -4590,7 +4427,6 @@ int char_config_read(const char *cfgName) } } else if (strcmpi(w1, "guild_exp_rate") == 0) { guild_exp_rate = atoi(w2); -#endif //TXT_SQL_CONVERT } else if (strcmpi(w1, "import") == 0) { char_config_read(w2); } @@ -4601,41 +4437,36 @@ int char_config_read(const char *cfgName) return 0; } -#ifndef TXT_SQL_CONVERT void do_final(void) { ShowStatus("Terminating...\n"); - mmo_char_sync(); - inter_save(); set_all_offline(-1); + set_all_offline_sql(); + + inter_final(); + flush_fifos(); do_final_mapif(); do_final_loginif(); - // write online players files with no player - online_char_db->clear(online_char_db, NULL); - create_online_files(); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo`") ) + Sql_ShowDebug(sql_handle); + char_db_->destroy(char_db_, NULL); online_char_db->destroy(online_char_db, NULL); auth_db->destroy(auth_db, NULL); - - if(char_dat) aFree(char_dat); - + if( char_fd != -1 ) { do_close(char_fd); char_fd = -1; } -#ifdef ENABLE_SC_SAVING - status_final(); -#endif - inter_final(); + Sql_Free(sql_handle); mapindex_final(); - char_log("----End of char-server (normal end with closing of all files).\n"); ShowStatus("Finished.\n"); } @@ -4679,28 +4510,24 @@ int do_init(int argc, char **argv) char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]); char_lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME); + sql_config_read(SQL_CONF_NAME); if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) { ShowError("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); - ShowNotice("Please edit your save/account.txt file to create a proper inter-server user/password (gender 'S')\n"); + ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); ShowNotice("And then change the user/password to use in conf/char_athena.conf (or conf/import/char_conf.txt)\n"); } ShowInfo("Finished reading the char-server configuration.\n"); - // a newline in the log... - char_log(""); - char_log("The char-server starting...\n"); - + inter_init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server ÃʱâÈ­ + ShowInfo("Finished reading the inter-server configuration.\n"); + ShowInfo("Initializing char server.\n"); auth_db = idb_alloc(DB_OPT_RELEASE_DATA); online_char_db = idb_alloc(DB_OPT_RELEASE_DATA); - mmo_char_init(); + mmo_char_sql_init(); char_read_fame_list(); //Read fame lists. -#ifdef ENABLE_SC_SAVING - status_init(); -#endif - inter_init_txt((argc > 2) ? argv[2] : inter_cfgName); // inter server ‰Šú‰» ShowInfo("char server initialized.\n"); if ((naddr_ != 0) && (!login_ip || !char_ip)) @@ -4736,18 +4563,32 @@ int do_init(int argc, char **argv) add_timer_func_list(online_data_cleanup, "online_data_cleanup"); add_timer_interval(gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); - // periodic flush of all saved data to disk - add_timer_func_list(mmo_char_sync_timer, "mmo_char_sync_timer"); - add_timer_interval(gettick() + 1000, mmo_char_sync_timer, 0, 0, autosave_interval); - if( console ) { //##TODO invoke a CONSOLE_START plugin event } + //Cleaning the tables for NULL entrys @ startup [Sirius] + //Chardb clean + ShowInfo("Cleaning the '%s' table...\n", char_db); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) ) + Sql_ShowDebug(sql_handle); + + //guilddb clean + ShowInfo("Cleaning the '%s' table...\n", guild_db); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) ) + Sql_ShowDebug(sql_handle); + + //guildmemberdb clean + ShowInfo("Cleaning the '%s' table...\n", guild_member_db); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) ) + Sql_ShowDebug(sql_handle); + + ShowInfo("End of char server initilization function.\n"); + set_defaultparse(parse_char); + ShowInfo("open port %d.....\n",char_port); char_fd = make_listen_bind(bind_ip, char_port); - char_log("The char-server is ready (Server is listening on the port %d).\n", char_port); ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); if( runflag != CORE_ST_STOP ) @@ -4758,5 +4599,3 @@ int do_init(int argc, char **argv) return 0; } - -#endif //TXT_SQL_CONVERT diff --git a/src/char/char.h b/src/char/char.h index bb1a530f0..73c2f9f72 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -1,62 +1,81 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_H_ -#define _CHAR_H_ +#ifndef _CHAR_SQL_H_ +#define _CHAR_SQL_H_ #include "../common/core.h" // CORE_ST_LAST -#include "../common/mmo.h" -#ifndef TXT_SQL_CONVERT enum E_CHARSERVER_ST { CHARSERVER_ST_RUNNING = CORE_ST_LAST, CHARSERVER_ST_SHUTDOWN, CHARSERVER_ST_LAST }; -#endif + +struct mmo_charstatus; #define MAX_MAP_SERVERS 30 #define DEFAULT_AUTOSAVE_INTERVAL 300*1000 -struct character_data { - struct mmo_charstatus status; - int global_num; - struct global_reg global[GLOBAL_REG_NUM]; +enum { + TABLE_INVENTORY, + TABLE_CART, + TABLE_STORAGE, + TABLE_GUILD_STORAGE, }; -struct mmo_charstatus* search_character(int aid, int cid); -struct mmo_charstatus* search_character_byname(char* character_name); -int search_character_index(char* character_name); -char* search_character_name(int index); -int search_character_online(int aid, int cid); +int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch); -int mapif_sendall(unsigned char *buf, unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len); -int mapif_send(int fd,unsigned char *buf, unsigned int len); +int mapif_sendall(unsigned char *buf,unsigned int len); +int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); +int mapif_send(int fd,unsigned char *buf,unsigned int len); int char_married(int pl1,int pl2); int char_child(int parent_id, int child_id); -int char_family(int cid1, int cid2, int cid3); - -int char_log(char *fmt, ...); +int char_family(int pl1,int pl2,int pl3); int request_accreg2(int account_id, int char_id); -int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int len); -int save_accreg2(unsigned char *buf, int len); -int char_account_reg_reply(int fd,int account_id,int char_id); +int save_accreg2(unsigned char* buf, int len); extern int char_name_option; extern char char_name_letters[]; +extern bool char_gm_read; extern int autosave_interval; +extern int save_log; extern char db_path[]; +extern char char_db[256]; +extern char scdata_db[256]; +extern char cart_db[256]; +extern char inventory_db[256]; +extern char charlog_db[256]; +extern char storage_db[256]; +extern char interlog_db[256]; +extern char reg_db[256]; +extern char skill_db[256]; +extern char memo_db[256]; +extern char guild_db[256]; +extern char guild_alliance_db[256]; +extern char guild_castle_db[256]; +extern char guild_expulsion_db[256]; +extern char guild_member_db[256]; +extern char guild_position_db[256]; +extern char guild_skill_db[256]; +extern char guild_storage_db[256]; +extern char party_db[256]; +extern char pet_db[256]; +extern char mail_db[256]; +extern char auction_db[256]; +extern char quest_db[256]; + +extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] + extern int guild_exp_rate; extern int log_inter; + //Exported for use in the TXT-SQL converter. -extern char char_txt[]; -int char_config_read(const char *cfgName); -int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num); -int parse_friend_txt(struct mmo_charstatus *p); +int mmo_char_tosql(int char_id, struct mmo_charstatus *p); +void sql_config_read(const char *cfgName); -#endif /* _CHAR_H_ */ +#endif /* _CHAR_SQL_H_ */ diff --git a/src/char/int_auction.c b/src/char/int_auction.c new file mode 100644 index 000000000..04e321062 --- /dev/null +++ b/src/char/int_auction.c @@ -0,0 +1,494 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/db.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_mail.h" +#include "int_auction.h" + +#include +#include +#include + +static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* + +void auction_delete(struct auction_data *auction); +static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data); + +static int auction_count(int char_id, bool buy) +{ + int i = 0; + struct auction_data *auction; + DBIterator* iter; + DBKey key; + + iter = auction_db_->iterator(auction_db_); + for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) + { + if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) ) + i++; + } + iter->destroy(iter); + + return i; +} + +void auction_save(struct auction_data *auction) +{ + int j; + StringBuf buf; + SqlStmt* stmt; + + if( !auction ) + return; + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "UPDATE `%s` SET `seller_id` = '%d', `seller_name` = ?, `buyer_id` = '%d', `buyer_name` = ?, `price` = '%d', `buynow` = '%d', `hours` = '%d', `timestamp` = '%lu', `nameid` = '%d', `item_name` = ?, `type` = '%d', `refine` = '%d', `attribute` = '%d'", + auction_db, auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute); + for( j = 0; j < MAX_SLOTS; j++ ) + StringBuf_Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]); + StringBuf_Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id); + + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + } + + SqlStmt_Free(stmt); + StringBuf_Destroy(&buf); +} + +unsigned int auction_create(struct auction_data *auction) +{ + int j; + StringBuf buf; + SqlStmt* stmt; + + if( !auction ) + return false; + + auction->timestamp = time(NULL) + (auction->hours * 3600); + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`", auction_db); + for( j = 0; j < MAX_SLOTS; j++ ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%d',?,'%d','%d','%d'", + auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute); + for( j = 0; j < MAX_SLOTS; j++ ) + StringBuf_Printf(&buf, ",'%d'", auction->item.card[j]); + StringBuf_AppendStr(&buf, ")"); + + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + auction->auction_id = 0; + } + else + { + struct auction_data *auction_; + unsigned int tick = auction->hours * 3600000; + + auction->item.amount = 1; + auction->item.identify = 1; + auction->item.expire_time = 0; + + auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt); + auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0); + ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name); + + CREATE(auction_, struct auction_data, 1); + memcpy(auction_, auction, sizeof(struct auction_data)); + idb_put(auction_db_, auction_->auction_id, auction_); + } + + SqlStmt_Free(stmt); + StringBuf_Destroy(&buf); + + return auction->auction_id; +} + +static void mapif_Auction_message(int char_id, unsigned char result) +{ + unsigned char buf[74]; + + WBUFW(buf,0) = 0x3854; + WBUFL(buf,2) = char_id; + WBUFL(buf,6) = result; + mapif_sendall(buf,7); +} + +static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) +{ + struct auction_data *auction; + if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) + { + if( auction->buyer_id ) + { + mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item); + mapif_Auction_message(auction->buyer_id, 6); // You have won the auction + mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL); + } + else + mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item); + + ShowInfo("Auction End: id %u.\n", auction->auction_id); + + auction->auction_end_timer = INVALID_TIMER; + auction_delete(auction); + } + + return 0; +} + +void auction_delete(struct auction_data *auction) +{ + unsigned int auction_id = auction->auction_id; + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) ) + Sql_ShowDebug(sql_handle); + + if( auction->auction_end_timer != INVALID_TIMER ) + delete_timer(auction->auction_end_timer, auction_end_timer); + + idb_remove(auction_db_, auction_id); +} + +void inter_auctions_fromsql(void) +{ + int i; + struct auction_data *auction; + struct item *item; + char *data; + StringBuf buf; + unsigned int tick = gettick(), endtick; + time_t now = time(NULL); + + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`," + "`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`"); + for( i = 0; i < MAX_SLOTS; i++ ) + StringBuf_Printf(&buf, ",`card%d`", i); + StringBuf_Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", auction_db); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Destroy(&buf); + + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + CREATE(auction, struct auction_data, 1); + Sql_GetData(sql_handle, 0, &data, NULL); auction->auction_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); auction->seller_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 5, &data, NULL); auction->price = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); auction->buynow = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); auction->hours = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); auction->timestamp = atoi(data); + + item = &auction->item; + Sql_GetData(sql_handle, 9, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH); + Sql_GetData(sql_handle,11, &data, NULL); auction->type = atoi(data); + + Sql_GetData(sql_handle,12, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data); + + item->identify = 1; + item->amount = 1; + item->expire_time = 0; + + for( i = 0; i < MAX_SLOTS; i++ ) + { + Sql_GetData(sql_handle, 14 + i, &data, NULL); + item->card[i] = atoi(data); + } + + if( auction->timestamp > now ) + endtick = ((unsigned int)(auction->timestamp - now) * 1000) + tick; + else + endtick = tick + 10000; // 10 Second's to process ended auctions + + auction->auction_end_timer = add_timer(endtick, auction_end_timer, auction->auction_id, 0); + idb_put(auction_db_, auction->auction_id, auction); + } + + Sql_FreeResult(sql_handle); +} + +static void mapif_Auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf) +{ + int len = (sizeof(struct auction_data) * count) + 12; + + WFIFOHEAD(fd, len); + WFIFOW(fd,0) = 0x3850; + WFIFOW(fd,2) = len; + WFIFOL(fd,4) = char_id; + WFIFOW(fd,8) = count; + WFIFOW(fd,10) = pages; + memcpy(WFIFOP(fd,12), buf, len - 12); + WFIFOSET(fd,len); +} + +static void mapif_parse_Auction_requestlist(int fd) +{ + char searchtext[NAME_LENGTH]; + int char_id = RFIFOL(fd,4), len = sizeof(struct auction_data); + int price = RFIFOL(fd,10); + short type = RFIFOW(fd,8), page = max(1,RFIFOW(fd,14)); + unsigned char buf[5 * sizeof(struct auction_data)]; + DBIterator* iter; + DBKey key; + struct auction_data *auction; + short i = 0, j = 0, pages = 1; + + memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH); + + iter = auction_db_->iterator(auction_db_); + for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) + { + if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) || + (type == 1 && auction->type != IT_WEAPON) || + (type == 2 && auction->type != IT_CARD) || + (type == 3 && auction->type != IT_ETC) || + (type == 4 && !strstr(auction->item_name, searchtext)) || + (type == 5 && auction->price > price) || + (type == 6 && auction->seller_id != char_id) || + (type == 7 && auction->buyer_id != char_id) ) + continue; + + i++; + if( i > 5 ) + { // Counting Pages of Total Results (5 Results per Page) + pages++; + i = 1; // First Result of This Page + } + + if( page != pages ) + continue; // This is not the requested Page + + memcpy(WBUFP(buf, j * len), auction, len); + j++; // Found Results + } + iter->destroy(iter); + + mapif_Auction_sendlist(fd, char_id, j, pages, buf); +} + +static void mapif_Auction_register(int fd, struct auction_data *auction) +{ + int len = sizeof(struct auction_data) + 4; + + WFIFOHEAD(fd,len); + WFIFOW(fd,0) = 0x3851; + WFIFOW(fd,2) = len; + memcpy(WFIFOP(fd,4), auction, sizeof(struct auction_data)); + WFIFOSET(fd,len); +} + +static void mapif_parse_Auction_register(int fd) +{ + struct auction_data auction; + if( RFIFOW(fd,2) != sizeof(struct auction_data) + 4 ) + return; + + memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data)); + if( auction_count(auction.seller_id, false) < 5 ) + auction.auction_id = auction_create(&auction); + + mapif_Auction_register(fd, &auction); +} + +static void mapif_Auction_cancel(int fd, int char_id, unsigned char result) +{ + WFIFOHEAD(fd,7); + WFIFOW(fd,0) = 0x3852; + WFIFOL(fd,2) = char_id; + WFIFOB(fd,6) = result; + WFIFOSET(fd,7); +} + +static void mapif_parse_Auction_cancel(int fd) +{ + int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); + struct auction_data *auction; + + if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) + { + mapif_Auction_cancel(fd, char_id, 1); // Bid Number is Incorrect + return; + } + + if( auction->seller_id != char_id ) + { + mapif_Auction_cancel(fd, char_id, 2); // You cannot end the auction + return; + } + + if( auction->buyer_id > 0 ) + { + mapif_Auction_cancel(fd, char_id, 3); // An auction with at least one bidder cannot be canceled + return; + } + + mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction canceled.", 0, &auction->item); + auction_delete(auction); + + mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled +} + +static void mapif_Auction_close(int fd, int char_id, unsigned char result) +{ + WFIFOHEAD(fd,7); + WFIFOW(fd,0) = 0x3853; + WFIFOL(fd,2) = char_id; + WFIFOB(fd,6) = result; + WFIFOSET(fd,7); +} + +static void mapif_parse_Auction_close(int fd) +{ + int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); + struct auction_data *auction; + + if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) + { + mapif_Auction_close(fd, char_id, 2); // Bid Number is Incorrect + return; + } + + if( auction->seller_id != char_id ) + { + mapif_Auction_close(fd, char_id, 1); // You cannot end the auction + return; + } + + if( auction->buyer_id == 0 ) + { + mapif_Auction_close(fd, char_id, 1); // You cannot end the auction + return; + } + + // Send Money to Seller + mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction closed.", auction->price, NULL); + // Send Item to Buyer + mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Auction winner.", 0, &auction->item); + mapif_Auction_message(auction->buyer_id, 6); // You have won the auction + auction_delete(auction); + + mapif_Auction_close(fd, char_id, 0); // You have ended the auction +} + +static void mapif_Auction_bid(int fd, int char_id, int bid, unsigned char result) +{ + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x3855; + WFIFOL(fd,2) = char_id; + WFIFOL(fd,6) = bid; // To Return Zeny + WFIFOB(fd,10) = result; + WFIFOSET(fd,11); +} + +static void mapif_parse_Auction_bid(int fd) +{ + int char_id = RFIFOL(fd,4), bid = RFIFOL(fd,12); + unsigned int auction_id = RFIFOL(fd,8); + struct auction_data *auction; + + if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id ) + { + mapif_Auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction + return; + } + + if( auction_count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id ) + { + mapif_Auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time + return; + } + + if( auction->buyer_id > 0 ) + { // Send Money back to the previous Buyer + if( auction->buyer_id != char_id ) + { + mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Someone has placed a higher bid.", auction->price, NULL); + mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction + } + else + mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have placed a higher bid.", auction->price, NULL); + } + + auction->buyer_id = char_id; + safestrncpy(auction->buyer_name, (char*)RFIFOP(fd,16), NAME_LENGTH); + auction->price = bid; + + if( bid >= auction->buynow ) + { // Automatic won the auction + mapif_Auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction + + mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have won the auction.", 0, &auction->item); + mapif_Auction_message(char_id, 6); // You have won the auction + mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->buynow, NULL); + + auction_delete(auction); + return; + } + + auction_save(auction); + + mapif_Auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction +} + +/*========================================== + * Packets From Map Server + *------------------------------------------*/ +int inter_auction_parse_frommap(int fd) +{ + switch(RFIFOW(fd,0)) + { + case 0x3050: mapif_parse_Auction_requestlist(fd); break; + case 0x3051: mapif_parse_Auction_register(fd); break; + case 0x3052: mapif_parse_Auction_cancel(fd); break; + case 0x3053: mapif_parse_Auction_close(fd); break; + case 0x3055: mapif_parse_Auction_bid(fd); break; + default: + return 0; + } + return 1; +} + +int inter_auction_sql_init(void) +{ + auction_db_ = idb_alloc(DB_OPT_RELEASE_DATA); + inter_auctions_fromsql(); + + return 0; +} + +void inter_auction_sql_final(void) +{ + auction_db_->destroy(auction_db_,NULL); + + return; +} diff --git a/src/char/int_auction.h b/src/char/int_auction.h new file mode 100644 index 000000000..bf26b152c --- /dev/null +++ b/src/char/int_auction.h @@ -0,0 +1,12 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _INT_AUCTION_SQL_H_ +#define _INT_AUCTION_SQL_H_ + +int inter_auction_parse_frommap(int fd); + +int inter_auction_sql_init(void); +void inter_auction_sql_final(void); + +#endif /* _INT_AUCTION_SQL_H_ */ diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 31cceeff0..2ce6d6141 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -6,381 +6,634 @@ #include "../common/malloc.h" #include "../common/socket.h" #include "../common/db.h" -#include "../common/lock.h" #include "../common/showmsg.h" #include "../common/strlib.h" +#include "../common/timer.h" #include "char.h" #include "inter.h" -#include "int_storage.h" #include "int_guild.h" #include #include #include -char guild_txt[1024] = "save/guild.txt"; -char castle_txt[1024] = "save/castle.txt"; +#define GS_MEMBER_UNMODIFIED 0x00 +#define GS_MEMBER_MODIFIED 0x01 +#define GS_MEMBER_NEW 0x02 -#ifndef TXT_SQL_CONVERT -static DBMap* guild_db; // int guild_id -> struct guild* -static DBMap* castle_db; // int castle_id -> struct guild_castle* +#define GS_POSITION_UNMODIFIED 0x00 +#define GS_POSITION_MODIFIED 0x01 -static int guild_newid = 10000; +// LSB = 0 => Alliance, LSB = 1 => Opposition +#define GUILD_ALLIANCE_TYPE_MASK 0x01 +#define GUILD_ALLIANCE_REMOVE 0x08 + +static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + +//Guild cache +static DBMap* guild_db_; // int guild_id -> struct guild* + +struct guild_castle castles[MAX_GUILDCASTLE]; static unsigned int guild_exp[100]; -int mapif_guild_broken(int guild_id, int flag); +int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes); +int mapif_guild_broken(int guild_id,int flag); static bool guild_check_empty(struct guild *g); int guild_calcinfo(struct guild *g); -int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len); -int mapif_guild_info(int fd, struct guild *g); -int guild_break_sub(DBKey key, void *data, va_list ap); +int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len); +int mapif_guild_info(int fd,struct guild *g); +int guild_break_sub(int key,void *data,va_list ap); +int inter_guild_tosql(struct guild *g,int flag); -/// serializes the guild data structure into the provided string -int inter_guild_tostr(char* str, struct guild* g) +static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) { - int i, c, len; + static int last_id = 0; //To know in which guild we were. + int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving. + DBIterator* iter; + DBKey key; + struct guild* g; - // save guild base info - len = sprintf(str, "%d\t%s\t%s\t%d,%d,%"PRIu64",%d,%d\t%s#\t%s#\t", - g->guild_id, g->name, g->master, g->guild_lv, g->max_member, g->exp, g->skill_point, 0, g->mes1, g->mes2); + if( last_id == 0 ) //Save the first guild in the list. + state = 1; - // save guild member info - for(i = 0; i < g->max_member; i++) + iter = guild_db_->iterator(guild_db_); + for( g = (struct guild*)iter->first(iter,&key); iter->exists(iter); g = (struct guild*)iter->next(iter,&key) ) { - struct guild_member *m = &g->member[i]; - len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%"PRIu64",%d,%d\t%s\t", - m->account_id, m->char_id, - m->hair, m->hair_color, m->gender, - m->class_, m->lv, m->exp, m->exp_payper, m->position, - ((m->account_id > 0) ? m->name : "-")); - } - - // save guild position info - for(i = 0; i < MAX_GUILDPOSITION; i++) { - struct guild_position *p = &g->position[i]; - len += sprintf(str + len, "%d,%d\t%s#\t", p->mode, p->exp_mode, p->name); - } + if( state == 0 && g->guild_id == last_id ) + state++; //Save next guild in the list. + else + if( state == 1 && g->save_flag&GS_MASK ) + { + inter_guild_tosql(g, g->save_flag&GS_MASK); + g->save_flag &= ~GS_MASK; - // save guild emblem - len += sprintf(str + len, "%d,%d,", g->emblem_len, g->emblem_id); - for(i = 0; i < g->emblem_len; i++) { - len += sprintf(str + len, "%02x", (unsigned char)(g->emblem_data[i])); - } - len += sprintf(str + len, "$\t"); + //Some guild saved. + last_id = g->guild_id; + state++; + } - // save guild alliance info - c = 0; - for(i = 0; i < MAX_GUILDALLIANCE; i++) - if (g->alliance[i].guild_id > 0) - c++; - len += sprintf(str + len, "%d\t", c); - for(i = 0; i < MAX_GUILDALLIANCE; i++) { - struct guild_alliance *a = &g->alliance[i]; - if (a->guild_id > 0) - len += sprintf(str + len, "%d,%d\t%s\t", a->guild_id, a->opposition, a->name); + if( g->save_flag == GS_REMOVE ) + {// Nothing to save, guild is ready for removal. + if (save_log) + ShowInfo("Guild Unloaded (%d - %s)\n", g->guild_id, g->name); + db_remove(guild_db_, key); + } } + iter->destroy(iter); - // save guild expulsion info - c = 0; - for(i = 0; i < MAX_GUILDEXPULSION; i++) - if (g->expulsion[i].account_id > 0) - c++; - len += sprintf(str + len, "%d\t", c); - for(i = 0; i < MAX_GUILDEXPULSION; i++) { - struct guild_expulsion *e = &g->expulsion[i]; - if (e->account_id > 0) - len += sprintf(str + len, "%d,%d,%d,%d\t%s\t%s\t%s#\t", - e->account_id, 0, 0, 0, e->name, "#", e->mes ); - } + if( state != 2 ) //Reached the end of the guild db without saving. + last_id = 0; //Reset guild saved, return to beginning. - // save guild skill info - for(i = 0; i < MAX_GUILDSKILL; i++) { - len += sprintf(str + len, "%d,%d ", g->skill[i].id, g->skill[i].lv); - } - len += sprintf(str + len, "\t"); + state = guild_db_->size(guild_db_); + if( state < 1 ) state = 1; //Calculate the time slot for the next save. + add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0); + return 0; +} +int inter_guild_removemember_tosql(int account_id, int char_id) +{ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) ) + Sql_ShowDebug(sql_handle); return 0; } -#endif //TXT_SQL_CONVERT -/// parses the guild data string into a guild data structure -int inter_guild_fromstr(char* str, struct guild* g) +// Save guild into sql +int inter_guild_tosql(struct guild *g,int flag) { - int i, c; - char *pstr; - - memset(g, 0, sizeof(struct guild)); - - {// load guild base info - int guildid; - char name[256]; // only 24 used - char master[256]; // only 24 used - int guildlv; - int max_member; - uint64 exp; - int skpoint; - char mes1[256]; // only 60 used - char mes2[256]; // only 120 used - int len; - - if( sscanf(str, "%d\t%[^\t]\t%[^\t]\t%d,%d,%"SCNu64",%d,%*d\t%[^\t]\t%[^\t]\t%n", - &guildid, name, master, &guildlv, &max_member, &exp, &skpoint, mes1, mes2, &len) < 9 ) - return 1; - - // remove '#' - mes1[strlen(mes1)-1] = '\0'; - mes2[strlen(mes2)-1] = '\0'; - - g->guild_id = guildid; - g->guild_lv = guildlv; - g->max_member = max_member; - g->exp = exp; - g->skill_point = skpoint; - safestrncpy(g->name, name, sizeof(g->name)); - safestrncpy(g->master, master, sizeof(g->master)); - safestrncpy(g->mes1, mes1, sizeof(g->mes1)); - safestrncpy(g->mes2, mes2, sizeof(g->mes2)); - - str+= len; - } - - {// load guild member info - int accountid; - int charid; - int hair, hair_color, gender; - int class_, lv; - uint64 exp; - int exp_payper; - int position; - char name[256]; // only 24 used - int len; - int i; + // Table guild (GS_BASIC_MASK) + // GS_EMBLEM `emblem_len`,`emblem_id`,`emblem_data` + // GS_CONNECT `connect_member`,`average_lv` + // GS_MES `mes1`,`mes2` + // GS_LEVEL `guild_lv`,`max_member`,`exp`,`next_exp`,`skill_point` + // GS_BASIC `name`,`master`,`char_id` + + // GS_MEMBER `guild_member` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) + // GS_POSITION `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) + // GS_ALLIANCE `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`) + // GS_EXPULSION `guild_expulsion` (`guild_id`,`account_id`,`name`,`mes`) + // GS_SKILL `guild_skill` (`guild_id`,`id`,`lv`) + + // temporary storage for str convertion. They must be twice the size of the + // original string to ensure no overflows will occur. [Skotlex] + char t_info[256]; + char esc_name[NAME_LENGTH*2+1]; + char esc_master[NAME_LENGTH*2+1]; + char new_guild = 0; + int i=0; + + if (g->guild_id<=0 && g->guild_id != -1) return 0; + +#ifdef NOISY + ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag); +#endif + + Sql_EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH)); + Sql_EscapeStringLen(sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH)); + *t_info = '\0'; + + // Insert a new guild the guild + if (flag&GS_BASIC && g->guild_id == -1) + { + strcat(t_info, " guild_create"); - for( i = 0; i < g->max_member; i++ ) + // Create a new guild + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " + "(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " + "VALUES ('%s', '%s', '%d', '%d', '%d', '%d')", + guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) + { + Sql_ShowDebug(sql_handle); + if (g->guild_id == -1) + return 0; //Failed to create guild! + } + else { - struct guild_member* m = &g->member[i]; - if (sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%"SCNu64",%d,%d\t%[^\t]\t%n", - &accountid, &charid, &hair, &hair_color, &gender, - &class_, &lv, &exp, &exp_payper, &position, - name, &len) < 11) - return 1; - - m->account_id = accountid; - m->char_id = charid; - m->hair = hair; - m->hair_color = hair_color; - m->gender = gender; - m->class_ = class_; - m->lv = lv; - m->exp = exp; - m->exp_payper = exp_payper; - m->position = position; - safestrncpy(m->name, name, NAME_LENGTH); - - str+= len; + g->guild_id = (int)Sql_LastInsertId(sql_handle); + new_guild = 1; } } - {// load guild position info - int mode, exp_mode; - char name[256]; // only 24 used - int len; - int i = 0; - int j; + // If we need an update on an existing guild or more update on the new guild + if (((flag & GS_BASIC_MASK) && !new_guild) || ((flag & (GS_BASIC_MASK & ~GS_BASIC)) && new_guild)) + { + StringBuf buf; + bool add_comma = false; - while (sscanf(str, "%d,%d%n", &mode, &exp_mode, &j) == 2 && str[j] == '\t') + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "UPDATE `%s` SET ", guild_db); + + if (flag & GS_EMBLEM) { - struct guild_position *p = &g->position[i]; - if (sscanf(str, "%d,%d\t%[^\t]\t%n", &mode, &exp_mode, name, &len) < 3) - return 1; + char emblem_data[sizeof(g->emblem_data)*2+1]; + char* pData = emblem_data; + + strcat(t_info, " emblem"); + // Convert emblem_data to hex + //TODO: why not use binary directly? [ultramage] + for(i=0; iemblem_len; i++){ + *pData++ = dataToHex[(g->emblem_data[i] >> 4) & 0x0F]; + *pData++ = dataToHex[g->emblem_data[i] & 0x0F]; + } + *pData = 0; + StringBuf_Printf(&buf, "`emblem_len`=%d, `emblem_id`=%d, `emblem_data`='%s'", g->emblem_len, g->emblem_id, emblem_data); + add_comma = true; + } + if (flag & GS_BASIC) + { + strcat(t_info, " basic"); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`name`='%s', `master`='%s', `char_id`=%d", esc_name, esc_master, g->member[0].char_id); + } + if (flag & GS_CONNECT) + { + strcat(t_info, " connect"); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`connect_member`=%d, `average_lv`=%d", g->connect_member, g->average_lv); + } + if (flag & GS_MES) + { + char esc_mes1[sizeof(g->mes1)*2+1]; + char esc_mes2[sizeof(g->mes2)*2+1]; - p->mode = mode; - p->exp_mode = exp_mode; - name[strlen(name)-1] = 0; - safestrncpy(p->name, name, NAME_LENGTH); + strcat(t_info, " mes"); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + Sql_EscapeStringLen(sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1))); + Sql_EscapeStringLen(sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2))); + StringBuf_Printf(&buf, "`mes1`='%s', `mes2`='%s'", esc_mes1, esc_mes2); + } + if (flag & GS_LEVEL) + { + strcat(t_info, " level"); + if( add_comma ) + StringBuf_AppendStr(&buf, ", "); + else + add_comma = true; + StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); + } + StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "%s", StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + StringBuf_Destroy(&buf); + } - i++; - str+= len; + if (flag&GS_MEMBER) + { + struct guild_member *m; + + strcat(t_info, " members"); + // Update only needed players + for(i=0;imax_member;i++){ + m = &g->member[i]; + if (!m->modified) + continue; + if(m->account_id) { + //Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO + Sql_EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) " + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%"PRIu64"','%d','%d','%d','%s')", + guild_member_db, g->guild_id, m->account_id, m->char_id, + m->hair, m->hair_color, m->gender, + m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) ) + Sql_ShowDebug(sql_handle); + if (m->modified & GS_MEMBER_NEW) + { + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'", + char_db, g->guild_id, m->char_id) ) + Sql_ShowDebug(sql_handle); + } + m->modified = GS_MEMBER_UNMODIFIED; + } } } - {// load guild emblem - int emblemlen; - int emblemid; - char emblem[4096]; - int len; - - emblemid = 0; - if( sscanf(str, "%d,%d,%[^\t]\t%n", &emblemlen, &emblemid, emblem, &len) < 3 ) - if( sscanf(str, "%d,%[^\t]\t%n", &emblemlen, emblem, &len) < 2 ) //! pre-svn format - return 1; - - g->emblem_len = emblemlen; - g->emblem_id = emblemid; - for(i = 0, pstr = emblem; i < g->emblem_len; i++, pstr += 2) { - int c1 = pstr[0], c2 = pstr[1], x1 = 0, x2 = 0; - if (c1 >= '0' && c1 <= '9') x1 = c1 - '0'; - if (c1 >= 'a' && c1 <= 'f') x1 = c1 - 'a' + 10; - if (c1 >= 'A' && c1 <= 'F') x1 = c1 - 'A' + 10; - if (c2 >= '0' && c2 <= '9') x2 = c2 - '0'; - if (c2 >= 'a' && c2 <= 'f') x2 = c2 - 'a' + 10; - if (c2 >= 'A' && c2 <= 'F') x2 = c2 - 'A' + 10; - g->emblem_data[i] = (x1<<4) | x2; + if (flag&GS_POSITION){ + strcat(t_info, " positions"); + //printf("- Insert guild %d to guild_position\n",g->guild_id); + for(i=0;iposition[i]; + if (!p->modified) + continue; + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')", + guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) ) + Sql_ShowDebug(sql_handle); + p->modified = GS_POSITION_UNMODIFIED; } + } - str+= len; + if (flag&GS_ALLIANCE) + { + // Delete current alliances + // NOTE: no need to do it on both sides since both guilds in memory had + // their info changed, not to mention this would also mess up oppositions! + // [Skotlex] + //if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) ) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) ) + { + Sql_ShowDebug(sql_handle); + } + else + { + //printf("- Insert guild %d to guild_alliance\n",g->guild_id); + for(i=0;ialliance[i]; + if(a->guild_id>0) + { + Sql_EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) " + "VALUES ('%d','%d','%d','%s')", + guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) ) + Sql_ShowDebug(sql_handle); + } + } + } } - {// load guild alliance info - int guildid; - int opposition; - char name[256]; // only 24 used - int len; + if (flag&GS_EXPULSION){ + strcat(t_info, " expulsions"); + //printf("- Insert guild %d to guild_expulsion\n",g->guild_id); + for(i=0;iexpulsion[i]; + if(e->account_id>0){ + char esc_mes[sizeof(e->mes)*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH)); + Sql_EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes))); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) " + "VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) ) + Sql_ShowDebug(sql_handle); + } + } + } - if (sscanf(str, "%d\t%n", &c, &len) < 1) - return 1; - str+= len; + if (flag&GS_SKILL){ + strcat(t_info, " skills"); + //printf("- Insert guild %d to guild_skill\n",g->guild_id); + for(i=0;iskill[i].id>0 && g->skill[i].lv>0){ + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')", + guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) ) + Sql_ShowDebug(sql_handle); + } + } + } - for(i = 0; i < c; i++) - { - struct guild_alliance* a = &g->alliance[i]; - if (sscanf(str, "%d,%d\t%[^\t]\t%n", &guildid, &opposition, name, &len) < 3) - return 1; + if (save_log) + ShowInfo("Saved guild (%d - %s):%s\n",g->guild_id,g->name,t_info); + return 1; +} - a->guild_id = guildid; - a->opposition = opposition; - safestrncpy(a->name, name, NAME_LENGTH); +// Read guild from sql +struct guild * inter_guild_fromsql(int guild_id) +{ + struct guild *g; + char* data; + size_t len; + char* p; + int i; - str+= len; - } + if( guild_id <= 0 ) + return NULL; + + g = (struct guild*)idb_get(guild_db_, guild_id); + if( g ) + return g; + +#ifdef NOISY + ShowInfo("Guild load request (%d)...\n", guild_id); +#endif + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` " + "FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", guild_db, char_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + return NULL; } - {// load guild expulsion info - int accountid; - char name[256]; // only 24 used - char message[256]; // only 40 used - int len; - int i; + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + return NULL;// Guild does not exists. - if (sscanf(str, "%d\t%n", &c, &len) < 1) - return 1; - str+= len; + CREATE(g, struct guild, 1); - for(i = 0; i < c; i++) - { - struct guild_expulsion *e = &g->expulsion[i]; - if (sscanf(str, "%d,%*d,%*d,%*d\t%[^\t]\t%*[^\t]\t%[^\t]\t%n", &accountid, name, message, &len) < 3) - return 1; + g->guild_id = guild_id; + Sql_GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data); + if( g->max_member > MAX_GUILD ) + { // Fix reduction of MAX_GUILD [PoW] + ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD); + g->max_member = MAX_GUILD; + } + Sql_GetData(sql_handle, 5, &data, NULL); g->average_lv = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10); + Sql_GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data); + Sql_GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1))); + Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2))); + Sql_GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data); + Sql_GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data); + Sql_GetData(sql_handle, 13, &data, &len); + // convert emblem data from hexadecimal to binary + //TODO: why not store it in the db as binary directly? [ultramage] + for( i = 0, p = g->emblem_data; i < g->emblem_len; ++i, ++p ) + { + if( *data >= '0' && *data <= '9' ) + *p = *data - '0'; + else if( *data >= 'a' && *data <= 'f' ) + *p = *data - 'a' + 10; + else if( *data >= 'A' && *data <= 'F' ) + *p = *data - 'A' + 10; + *p <<= 4; + ++data; + + if( *data >= '0' && *data <= '9' ) + *p |= *data - '0'; + else if( *data >= 'a' && *data <= 'f' ) + *p |= *data - 'a' + 10; + else if( *data >= 'A' && *data <= 'F' ) + *p |= *data - 'A' + 10; + ++data; + } - e->account_id = accountid; - safestrncpy(e->name, name, sizeof(e->name)); - message[strlen(message)-1] = 0; // remove '#' - safestrncpy(e->mes, message, sizeof(e->mes)); + // load guild member info + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` " + "FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + aFree(g); + return NULL; + } + for( i = 0; i < g->max_member && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_member* m = &g->member[i]; + + Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); m->hair = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); m->hair_color = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); m->gender = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); m->class_ = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); m->lv = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10); + Sql_GetData(sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); m->online = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); m->position = atoi(data); + if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW] + m->position = MAX_GUILDPOSITION - 1; + Sql_GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); + m->modified = GS_MEMBER_UNMODIFIED; + } - str+= len; - } + //printf("- Read guild_position %d from sql \n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + aFree(g); + return NULL; + } + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int position; + struct guild_position* p; + + Sql_GetData(sql_handle, 0, &data, NULL); position = atoi(data); + if( position < 0 || position >= MAX_GUILDPOSITION ) + continue;// invalid position + p = &g->position[position]; + Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, NULL); p->mode = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); p->exp_mode = atoi(data); + p->modified = GS_POSITION_UNMODIFIED; } - {// load guild skill info - int skillid; - int skilllv; - int len; - int i; + //printf("- Read guild_alliance %d from sql \n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + aFree(g); + return NULL; + } + for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_alliance* a = &g->alliance[i]; - for(i = 0; i < MAX_GUILDSKILL; i++) - { - if (sscanf(str, "%d,%d %n", &skillid, &skilllv, &len) < 2) - break; - g->skill[i].id = skillid; - g->skill[i].lv = skilllv; + Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH)); + } - str+= len; - } - str = strchr(str, '\t'); + //printf("- Read guild_expulsion %d from sql \n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + aFree(g); + return NULL; } + for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + struct guild_expulsion *e = &g->expulsion[i]; - return 0; -} + Sql_GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes))); + } -#ifndef TXT_SQL_CONVERT -// ƒMƒ‹ƒhéƒf[ƒ^‚Ì•¶Žš—ñ‚ւ̕ϊ· -int inter_guildcastle_tostr(char *str, struct guild_castle *gc) -{ - int len; + //printf("- Read guild_skill %d from sql \n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) ) + { + Sql_ShowDebug(sql_handle); + aFree(g); + return NULL; + } - len = sprintf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", - gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, - gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, - gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, - gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible); + for(i = 0; i < MAX_GUILDSKILL; i++) + { //Skill IDs must always be initialized. [Skotlex] + g->skill[i].id = i + GD_SKILLBASE; + } + + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + int id; + Sql_GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE; + if( id < 0 && id >= MAX_GUILDSKILL ) + continue;// invalid guild skill + Sql_GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data); + } + Sql_FreeResult(sql_handle); + + idb_put(guild_db_, guild_id, g); //Add to cache + g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long. + + if (save_log) + ShowInfo("Guild loaded (%d - %s)\n", guild_id, g->name); + return g; +} + +int inter_guildcastle_tosql(struct guild_castle *gc) +{ + // `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`) + + if (gc==NULL) return 0; + #ifdef GUILD_DEBUG +ShowDebug("Save guild_castle (%d)\n", gc->castle_id); + #endif + +// sql_query("DELETE FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, gc->castle_id); + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " + "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," + "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`)" + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", + guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, + gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible) ) + Sql_ShowDebug(sql_handle); + + memcpy(&castles[gc->castle_id],gc,sizeof(struct guild_castle)); return 0; } -#endif ///TXT_SQL_CONVERT -// ƒMƒ‹ƒhéƒf[ƒ^‚Ì•¶Žš—ñ‚©‚ç‚̕ϊ· -int inter_guildcastle_fromstr(char *str, struct guild_castle *gc) +// Read guild_castle from sql +int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) { - int castleid, guildid, economy, defense, triggerE, triggerD, nextTime, payTime, createTime, visibleC; - int guardian[8]; - int dummy; - - memset(gc, 0, sizeof(struct guild_castle)); - // structure of guild castle with the guardian hp included - if( sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", - &castleid, &guildid, &economy, &defense, &triggerE, &triggerD, &nextTime, &payTime, &createTime, &visibleC, - &guardian[0], &guardian[1], &guardian[2], &guardian[3], &guardian[4], &guardian[5], &guardian[6], &guardian[7], - &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) != 26 ) - // structure of guild castle without the hps (current one) - if( sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", - &castleid, &guildid, &economy, &defense, &triggerE, &triggerD, &nextTime, &payTime, &createTime, &visibleC, - &guardian[0], &guardian[1], &guardian[2], &guardian[3], &guardian[4], &guardian[5], &guardian[6], &guardian[7]) != 18 ) + static int castles_init=0; + char* data; + + if (gc==NULL) return 0; + if (castle_id==-1) return 0; + + if(!castles_init) + { + int i; + for(i=0;icastle_id=castle_id; + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_FreeResult(sql_handle); + return 1; //Assume empty castle. + } - gc->castle_id = castleid; - gc->guild_id = guildid; - gc->economy = economy; - gc->defense = defense; - gc->triggerE = triggerE; - gc->triggerD = triggerD; - gc->nextTime = nextTime; - gc->payTime = payTime; - gc->createTime = createTime; - gc->visibleC = visibleC; - gc->guardian[0].visible = guardian[0]; - gc->guardian[1].visible = guardian[1]; - gc->guardian[2].visible = guardian[2]; - gc->guardian[3].visible = guardian[3]; - gc->guardian[4].visible = guardian[4]; - gc->guardian[5].visible = guardian[5]; - gc->guardian[6].visible = guardian[6]; - gc->guardian[7].visible = guardian[7]; + Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); + + Sql_FreeResult(sql_handle); + memcpy(&castles[castle_id],gc,sizeof(struct guild_castle)); + + if( save_log ) + ShowInfo("Loaded Castle %d (guild %d)\n", castle_id, gc->guild_id); - return 0; + return 1; } -#ifndef TXT_SQL_CONVERT -// ƒMƒ‹ƒhŠÖ˜Aƒf[ƒ^ƒx[ƒX“ǂݞ‚Ý -int inter_guild_readdb(void) + +// Read exp_guild.txt +int inter_guild_ReadEXP(void) { int i; FILE *fp; char line[1024]; - char path[1024]; - - sprintf(path, "%s%s", db_path, "/exp_guild.txt"); - fp = fopen(path, "r"); - if (fp == NULL) { - ShowError("can't read db/exp_guild.txt\n"); + for (i=0;i<100;i++) guild_exp[i]=0; + //this is going to be discussed, temp fix + sprintf(line, "%s/pre-re/exp_guild.txt", db_path); + fp=fopen(line,"r"); + if(fp==NULL){ + ShowError("can't read %s\n", line); return 1; } - i = 0; + i=0; while(fgets(line, sizeof(line), fp) && i < 100) { - if (line[0] == '/' && line[1] == '/') + if(line[0]=='/' && line[1]=='/') continue; - guild_exp[i] = (unsigned int)atof(line); + guild_exp[i]=(unsigned int)atof(line); i++; } fclose(fp); @@ -388,171 +641,172 @@ int inter_guild_readdb(void) return 0; } -// ƒMƒ‹ƒhƒf[ƒ^‚̓ǂݞ‚Ý -int inter_guild_init() -{ - char line[16384]; - struct guild *g; - struct guild_castle *gc; - FILE *fp; - int i, j, c = 0; - inter_guild_readdb(); - - guild_db = idb_alloc(DB_OPT_RELEASE_DATA); - castle_db = idb_alloc(DB_OPT_RELEASE_DATA); - - if ((fp = fopen(guild_txt,"r")) == NULL) - return 1; - while(fgets(line, sizeof(line), fp)) - { - j = 0; - if (sscanf(line, "%d\t%%newid%%\n%n", &i, &j) == 1 && j > 0 && guild_newid <= i) { - guild_newid = i; - continue; +int inter_guild_CharOnline(int char_id, int guild_id) +{ + struct guild *g; + int i; + + if (guild_id == -1) { + //Get guild_id from the database + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; } - g = (struct guild *) aCalloc(sizeof(struct guild), 1); - if(g == NULL){ - ShowFatalError("int_guild: out of memory!\n"); - exit(EXIT_FAILURE); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); } -// memset(g, 0, sizeof(struct guild)); not needed... - if (inter_guild_fromstr(line, g) == 0 && g->guild_id > 0) { - if (g->guild_id >= guild_newid) - guild_newid = g->guild_id + 1; - idb_put(guild_db, g->guild_id, g); - guild_check_empty(g); - guild_calcinfo(g); - } else { - ShowError("int_guild: broken data [%s] line %d\n", guild_txt, c); - aFree(g); + else + { + guild_id = 0; } - c++; + Sql_FreeResult(sql_handle); + } + if (guild_id == 0) + return 0; //No guild... + + g = inter_guild_fromsql(guild_id); + if(!g) { + ShowError("Character %d's guild %d not found!\n", char_id, guild_id); + return 0; } - fclose(fp); - c = 0;//ƒJƒEƒ“ƒ^‰Šú‰» + //Member has logged in before saving, tell saver not to delete + if(g->save_flag & GS_REMOVE) + g->save_flag &= ~GS_REMOVE; - if ((fp = fopen(castle_txt, "r")) == NULL) { - return 1; + //Set member online + ARR_FIND( 0, g->max_member, i, g->member[i].char_id == char_id ); + if( i < g->max_member ) + { + g->member[i].online = 1; + g->member[i].modified = GS_MEMBER_MODIFIED; } - while(fgets(line, sizeof(line), fp)) + return 1; +} + +int inter_guild_CharOffline(int char_id, int guild_id) +{ + struct guild *g=NULL; + int online_count, i; + + if (guild_id == -1) { - gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1); - if(gc == NULL){ - ShowFatalError("int_guild: out of memory!\n"); - exit(EXIT_FAILURE); - } -// memset(gc, 0, sizeof(struct guild_castle)); No need... - if (inter_guildcastle_fromstr(line, gc) == 0) { - idb_put(castle_db, gc->castle_id, gc); - } else { - ShowError("int_guild: broken data [%s] line %d\n", castle_txt, c); - aFree(gc); + //Get guild_id from the database + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; } - c++; - } - fclose(fp); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; - if (!c) { - ShowStatus(" %s - making Default Data...\n", castle_txt); - //ƒfƒtƒHƒ‹ƒgƒf[ƒ^‚ðì¬ - for(i = 0; i < MAX_GUILDCASTLE; i++) { - gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1); - if (gc == NULL) { - ShowFatalError("int_guild: out of memory!\n"); - exit(EXIT_FAILURE); - } - gc->castle_id = i; - idb_put(castle_db, gc->castle_id, gc); + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); + } + else + { + guild_id = 0; } - ShowStatus(" %s - making done\n",castle_txt); + Sql_FreeResult(sql_handle); + } + if (guild_id == 0) + return 0; //No guild... + + //Character has a guild, set character offline and check if they were the only member online + g = inter_guild_fromsql(guild_id); + if (g == NULL) //Guild not found? return 0; + + //Set member offline + ARR_FIND( 0, g->max_member, i, g->member[i].char_id == char_id ); + if( i < g->max_member ) + { + g->member[i].online = 0; + g->member[i].modified = GS_MEMBER_MODIFIED; } - return 0; -} + online_count = 0; + for( i = 0; i < g->max_member; i++ ) + if( g->member[i].online ) + online_count++; -void inter_guild_final() -{ - castle_db->destroy(castle_db, NULL); - guild_db->destroy(guild_db, NULL); - return; + // Remove guild from memory if no players online + if( online_count == 0 ) + g->save_flag |= GS_REMOVE; + + return 1; } -struct guild *inter_guild_search(int guild_id) +// Initialize guild sql +int inter_guild_sql_init(void) { - return (struct guild*)idb_get(guild_db, guild_id); + //Initialize the guild cache + guild_db_= idb_alloc(DB_OPT_RELEASE_DATA); + + //Read exp file + inter_guild_ReadEXP(); + + add_timer_func_list(guild_save_timer, "guild_save_timer"); + add_timer(gettick() + 10000, guild_save_timer, 0, 0); + return 0; } -// ƒMƒ‹ƒhƒf[ƒ^‚̃Z[ƒu -int inter_guild_save() +static int guild_db_final(DBKey key, void *data, va_list ap) { - FILE *fp; - int lock; - DBIterator* iter; - struct guild* g; - struct guild_castle* gc; - - // save guild data - if ((fp = lock_fopen(guild_txt, &lock)) == NULL) { - ShowError("int_guild: can't write [%s] !!! data is lost !!!\n", guild_txt); + struct guild *g = (struct guild*)data; + if (g->save_flag&GS_MASK) { + inter_guild_tosql(g, g->save_flag&GS_MASK); return 1; } - - iter = guild_db->iterator(guild_db); - for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) ) - { - char line[16384]; - inter_guild_tostr(line, g); - fprintf(fp, "%s\n", line); - } - iter->destroy(iter); - -// fprintf(fp, "%d\t%%newid%%\n", guild_newid); - lock_fclose(fp, guild_txt, &lock); - - // save castle data - if ((fp = lock_fopen(castle_txt,&lock)) == NULL) { - ShowError("int_guild: can't write [%s] !!! data is lost !!!\n", castle_txt); - return 1; - } - - iter = castle_db->iterator(castle_db); - for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) ) - { - char line[16384]; - inter_guildcastle_tostr(line, gc); - fprintf(fp, "%s\n", line); - } - iter->destroy(iter); - - lock_fclose(fp, castle_txt, &lock); - return 0; } -// ƒMƒ‹ƒh–¼ŒŸõ -struct guild* search_guildname(char *str) +void inter_guild_sql_final(void) { - DBIterator* iter; - struct guild* g; + guild_db_->destroy(guild_db_, guild_db_final); + return; +} - iter = guild_db->iterator(guild_db); - for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) ) +// Get guild_id by its name. Returns 0 if not found, -1 on error. +int search_guildname(char *str) +{ + int guild_id; + char esc_name[NAME_LENGTH*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH)); + //Lookup guilds with the same name + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) ) { - if (strcmpi(g->name, str) == 0) - break; + Sql_ShowDebug(sql_handle); + return -1; } - iter->destroy(iter); - return g; + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); + guild_id = atoi(data); + } + else + { + guild_id = 0; + } + Sql_FreeResult(sql_handle); + return guild_id; } -// ƒMƒ‹ƒh‚ª‹ó‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN +// Check if guild is empty static bool guild_check_empty(struct guild *g) { int i; @@ -560,11 +814,8 @@ static bool guild_check_empty(struct guild *g) if( i < g->max_member) return false; // not empty - // ’N‚à‚¢‚È‚¢‚̂ʼnðŽU - guild_db->foreach(guild_db, guild_break_sub, g->guild_id); - inter_guild_storage_delete(g->guild_id); - mapif_guild_broken(g->guild_id, 0); - idb_remove(guild_db, g->guild_id); + //Let the calling function handle the guild removal in case they need + //to do something else with it before freeing the data. [Skotlex] return true; } @@ -572,79 +823,80 @@ unsigned int guild_nextexp(int level) { if (level == 0) return 1; - if (level > 0 && level < 100) + if (level < 100 && level > 0) // Change by hack return guild_exp[level-1]; return 0; } -// ƒMƒ‹ƒhƒXƒLƒ‹‚ª‚ ‚é‚©Šm”F -int guild_checkskill(struct guild *g, int id) +int guild_checkskill(struct guild *g,int id) { int idx = id - GD_SKILLBASE; - if(idx < 0 || idx >= MAX_GUILDSKILL) - return 0; return g->skill[idx].lv; } -// ƒMƒ‹ƒh‚Ìî•ñ‚ÌÄŒvŽZ int guild_calcinfo(struct guild *g) { - int i, c; + int i,c; unsigned int nextexp; - struct guild before = *g; - - // ƒXƒLƒ‹ID‚ÌÝ’è - for(i = 0; i < MAX_GUILDSKILL; i++) - g->skill[i].id=i+GD_SKILLBASE; + struct guild before = *g; // Save guild current values - // ƒMƒ‹ƒhƒŒƒxƒ‹ - if (g->guild_lv <= 0) + if(g->guild_lv<=0) g->guild_lv = 1; nextexp = guild_nextexp(g->guild_lv); - if (nextexp > 0) { - while(g->exp >= nextexp && nextexp > 0) { //fixed guild exp overflow [Kevin] - g->exp -= nextexp; - g->guild_lv++; - g->skill_point++; - nextexp = guild_nextexp(g->guild_lv); - } + + // Consume guild exp and increase guild level + while(g->exp >= nextexp && nextexp > 0){ //fixed guild exp overflow [Kevin] + g->exp-=nextexp; + g->guild_lv++; + g->skill_point++; + nextexp = guild_nextexp(g->guild_lv); } - // ƒMƒ‹ƒh‚ÌŽŸ‚ÌŒoŒ±’l - g->next_exp = guild_nextexp(g->guild_lv); + // Save next exp step + g->next_exp = nextexp; - // ƒƒ“ƒoãŒÀiƒMƒ‹ƒhŠg’£“K—pj - g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6; //Guild Extention skill - currently adds 6 to max per skill lv. + // Set the max number of members, Guild Extention skill - currently adds 6 to max per skill lv. + g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6; if(g->max_member > MAX_GUILD) { ShowError("Guild %d:%s has capacity for too many guild members (%d), max supported is %d\n", g->guild_id, g->name, g->max_member, MAX_GUILD); g->max_member = MAX_GUILD; } + + // Compute the guild average level level + g->average_lv=0; + g->connect_member=0; + for(i=c=0;imax_member;i++) + { + if(g->member[i].account_id>0) + { + if (g->member[i].lv >= 0) + { + g->average_lv+=g->member[i].lv; + c++; + } + else + { + ShowWarning("Guild %d:%s, member %d:%s has an invalid level %d\n", g->guild_id, g->name, g->member[i].char_id, g->member[i].name, g->member[i].lv); + } - // •½‹ÏƒŒƒxƒ‹‚ƃIƒ“ƒ‰ƒCƒ“l” - g->average_lv = 0; - g->connect_member = 0; - c = 0; - for(i = 0; i < g->max_member; i++) { - if (g->member[i].account_id > 0) { - g->average_lv += g->member[i].lv; - c++; - if (g->member[i].online > 0) + if(g->member[i].online) g->connect_member++; } } - if(c) g->average_lv /= c; + if(c) + g->average_lv /= c; - // ‘Sƒf[ƒ^‚ð‘—‚é•K—v‚ª‚ ‚è‚»‚¤ - if (g->max_member != before.max_member || - g->guild_lv != before.guild_lv || - g->skill_point != before.skill_point) { - mapif_guild_info(-1, g); + // Check if guild stats has change + if(g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point ) + { + g->save_flag |= GS_LEVEL; + mapif_guild_info(-1,g); return 1; } @@ -652,238 +904,219 @@ int guild_calcinfo(struct guild *g) } //------------------------------------------------------------------- -// map server‚Ö‚Ì’ÊM +// Packet sent to map server -// ƒMƒ‹ƒhì¬‰Â”Û -int mapif_guild_created(int fd, int account_id, struct guild *g) +int mapif_guild_created(int fd,int account_id,struct guild *g) { WFIFOHEAD(fd, 10); - WFIFOW(fd,0) = 0x3830; - WFIFOL(fd,2) = account_id; - if (g != NULL) { - WFIFOL(fd,6) = g->guild_id; - ShowInfo("Created Guild (%d %s)\n", g->guild_id, g->name); - }else{ - WFIFOL(fd,6) = 0; - } + WFIFOW(fd,0)=0x3830; + WFIFOL(fd,2)=account_id; + if(g != NULL) + { + WFIFOL(fd,6)=g->guild_id; + ShowInfo("int_guild: Guild created (%d - %s)\n",g->guild_id,g->name); + } else + WFIFOL(fd,6)=0; + WFIFOSET(fd,10); return 0; } -// ƒMƒ‹ƒhî•ñŒ©‚‚©‚炸 -int mapif_guild_noinfo(int fd, int guild_id) +// Guild not found +int mapif_guild_noinfo(int fd,int guild_id) { - WFIFOHEAD(fd, 8); - WFIFOW(fd,0) = 0x3831; - WFIFOW(fd,2) = 8; - WFIFOL(fd,4) = guild_id; - WFIFOSET(fd,8); - ShowNotice("int_guild: info not found %d\n", guild_id); - + unsigned char buf[12]; + WBUFW(buf,0)=0x3831; + WBUFW(buf,2)=8; + WBUFL(buf,4)=guild_id; + ShowWarning("int_guild: info not found %d\n",guild_id); + if(fd<0) + mapif_sendall(buf,8); + else + mapif_send(fd,buf,8); return 0; } -// ƒMƒ‹ƒhî•ñ‚܂Ƃߑ—‚è -int mapif_guild_info(int fd, struct guild *g) +// Send guild info +int mapif_guild_info(int fd,struct guild *g) { unsigned char buf[8+sizeof(struct guild)]; - - WBUFW(buf,0) = 0x3831; - memcpy(buf + 4, g, sizeof(struct guild)); - WBUFW(buf,2) = 4 + sizeof(struct guild); - if (fd < 0) - mapif_sendall(buf, WBUFW(buf,2)); + WBUFW(buf,0)=0x3831; + WBUFW(buf,2)=4+sizeof(struct guild); + memcpy(buf+4,g,sizeof(struct guild)); + if(fd<0) + mapif_sendall(buf,WBUFW(buf,2)); else - mapif_send(fd, buf, WBUFW(buf,2)); - + mapif_send(fd,buf,WBUFW(buf,2)); return 0; } -// ƒƒ“ƒo’ljÁ‰Â”Û -int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag) +// ACK member add +int mapif_guild_memberadded(int fd,int guild_id,int account_id,int char_id,int flag) { WFIFOHEAD(fd, 15); - WFIFOW(fd,0) = 0x3832; - WFIFOL(fd,2) = guild_id; - WFIFOL(fd,6) = account_id; - WFIFOL(fd,10) = char_id; - WFIFOB(fd,14) = flag; - WFIFOSET(fd, 15); - + WFIFOW(fd,0)=0x3832; + WFIFOL(fd,2)=guild_id; + WFIFOL(fd,6)=account_id; + WFIFOL(fd,10)=char_id; + WFIFOB(fd,14)=flag; + WFIFOSET(fd,15); return 0; } -// ’E‘Þ/’Ç•ú’Ê’m -int mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes) +// ACK member leave +int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const char *name, const char *mes) { - unsigned char buf[79]; - - WBUFW(buf, 0) = 0x3834; - WBUFL(buf, 2) = guild_id; - WBUFL(buf, 6) = account_id; - WBUFL(buf,10) = char_id; - WBUFB(buf,14) = flag; - memcpy(WBUFP(buf,15), mes, 40); - memcpy(WBUFP(buf,55), name, NAME_LENGTH); - mapif_sendall(buf, 55+NAME_LENGTH); -// mapif_sendall(buf, 79); - ShowInfo("Character left guild (Guild %d, %d - %s: %s)\n", guild_id, account_id, name, mes); - + unsigned char buf[55+NAME_LENGTH]; + WBUFW(buf, 0)=0x3834; + WBUFL(buf, 2)=guild_id; + WBUFL(buf, 6)=account_id; + WBUFL(buf,10)=char_id; + WBUFB(buf,14)=flag; + memcpy(WBUFP(buf,15),mes,40); + memcpy(WBUFP(buf,55),name,NAME_LENGTH); + mapif_sendall(buf,55+NAME_LENGTH); + ShowInfo("int_guild: guild withdraw (%d - %d: %s - %s)\n",guild_id,account_id,name,mes); return 0; } -// ƒIƒ“ƒ‰ƒCƒ“ó‘Ô‚ÆLvXV’Ê’m -int mapif_guild_memberinfoshort(struct guild *g, int idx) +// Send short member's info +int mapif_guild_memberinfoshort(struct guild *g,int idx) { unsigned char buf[19]; - - WBUFW(buf, 0) = 0x3835; - WBUFL(buf, 2) = g->guild_id; - WBUFL(buf, 6) = g->member[idx].account_id; - WBUFL(buf,10) = g->member[idx].char_id; - WBUFB(buf,14) = (unsigned char)g->member[idx].online; - WBUFW(buf,15) = g->member[idx].lv; - WBUFW(buf,17) = g->member[idx].class_; - mapif_sendall(buf, 19); + WBUFW(buf, 0)=0x3835; + WBUFL(buf, 2)=g->guild_id; + WBUFL(buf, 6)=g->member[idx].account_id; + WBUFL(buf,10)=g->member[idx].char_id; + WBUFB(buf,14)=(unsigned char)g->member[idx].online; + WBUFW(buf,15)=g->member[idx].lv; + WBUFW(buf,17)=g->member[idx].class_; + mapif_sendall(buf,19); return 0; } -// ‰ðŽU’Ê’m -int mapif_guild_broken(int guild_id, int flag) +// Send guild broken +int mapif_guild_broken(int guild_id,int flag) { unsigned char buf[7]; - - WBUFW(buf,0) = 0x3836; - WBUFL(buf,2) = guild_id; - WBUFB(buf,6) = flag; - mapif_sendall(buf, 7); - ShowInfo("Guild Break (%d)\n", guild_id); - + WBUFW(buf,0)=0x3836; + WBUFL(buf,2)=guild_id; + WBUFB(buf,6)=flag; + mapif_sendall(buf,7); + ShowInfo("int_guild: Guild broken (%d)\n",guild_id); return 0; } -// ƒMƒ‹ƒh“à”­Œ¾ -int mapif_guild_message(int guild_id, int account_id, char *mes, int len, int sfd) +// Send guild message +int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd) { - unsigned char buf[2048]; - - WBUFW(buf,0) = 0x3837; - WBUFW(buf,2) = len + 12; - WBUFL(buf,4) = guild_id; - WBUFL(buf,8) = account_id; - memcpy(WBUFP(buf,12), mes, len); - mapif_sendallwos(sfd, buf, len + 12); - + unsigned char buf[512]; + if (len > 500) + len = 500; + WBUFW(buf,0)=0x3837; + WBUFW(buf,2)=len+12; + WBUFL(buf,4)=guild_id; + WBUFL(buf,8)=account_id; + memcpy(WBUFP(buf,12),mes,len); + mapif_sendallwos(sfd, buf,len+12); return 0; } -// ƒMƒ‹ƒhŠî–{î•ñ•ÏX’Ê’m -int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len) +// Send basic info +int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len) { unsigned char buf[2048]; - - WBUFW(buf,0) = 0x3839; - WBUFW(buf,2) = len+10; - WBUFL(buf,4) = guild_id; - WBUFW(buf,8) = type; + if (len > 2038) + len = 2038; + WBUFW(buf, 0)=0x3839; + WBUFW(buf, 2)=len+10; + WBUFL(buf, 4)=guild_id; + WBUFW(buf, 8)=type; memcpy(WBUFP(buf,10),data,len); mapif_sendall(buf,len+10); return 0; } -// ƒMƒ‹ƒhƒƒ“ƒoî•ñ•ÏX’Ê’m -int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len) +// Send member info +int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int type,const void *data,int len) { - unsigned char buf[4096]; - - WBUFW(buf, 0) = 0x383a; - WBUFW(buf, 2) = len + 18; - WBUFL(buf, 4) = guild_id; - WBUFL(buf, 8) = account_id; - WBUFL(buf,12) = char_id; - WBUFW(buf,16) = type; - memcpy(WBUFP(buf,18), data, len); + unsigned char buf[2048]; + if (len > 2030) + len = 2030; + WBUFW(buf, 0)=0x383a; + WBUFW(buf, 2)=len+18; + WBUFL(buf, 4)=guild_id; + WBUFL(buf, 8)=account_id; + WBUFL(buf,12)=char_id; + WBUFW(buf,16)=type; + memcpy(WBUFP(buf,18),data,len); mapif_sendall(buf,len+18); - return 0; } -// ƒMƒ‹ƒhƒXƒLƒ‹ƒAƒbƒv’Ê’m -int mapif_guild_skillupack(int guild_id, int skill_num, int account_id) +// ACK guild skill up +int mapif_guild_skillupack(int guild_id,int skill_num,int account_id) { unsigned char buf[14]; - - WBUFW(buf, 0) = 0x383c; - WBUFL(buf, 2) = guild_id; - WBUFL(buf, 6) = skill_num; - WBUFL(buf,10) = account_id; - mapif_sendall(buf, 14); - + WBUFW(buf, 0)=0x383c; + WBUFL(buf, 2)=guild_id; + WBUFL(buf, 6)=skill_num; + WBUFL(buf,10)=account_id; + mapif_sendall(buf,14); return 0; } -// ƒMƒ‹ƒh“¯–¿/“G‘Î’Ê’m -int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2) +// ACK guild alliance +int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) { - unsigned char buf[67]; - - WBUFW(buf, 0) = 0x383d; - WBUFL(buf, 2) = guild_id1; - WBUFL(buf, 6) = guild_id2; - WBUFL(buf,10) = account_id1; - WBUFL(buf,14) = account_id2; - WBUFB(buf,18) = flag; - memcpy(WBUFP(buf,19), name1, NAME_LENGTH); - memcpy(WBUFP(buf,19+NAME_LENGTH), name2, NAME_LENGTH); + unsigned char buf[19+2*NAME_LENGTH]; + WBUFW(buf, 0)=0x383d; + WBUFL(buf, 2)=guild_id1; + WBUFL(buf, 6)=guild_id2; + WBUFL(buf,10)=account_id1; + WBUFL(buf,14)=account_id2; + WBUFB(buf,18)=flag; + memcpy(WBUFP(buf,19),name1,NAME_LENGTH); + memcpy(WBUFP(buf,19+NAME_LENGTH),name2,NAME_LENGTH); mapif_sendall(buf,19+2*NAME_LENGTH); -/* - memcpy(WBUFP(buf,43), name2, NAME_LENGTH); - mapif_sendall(buf, 67); -*/ return 0; } -// ƒMƒ‹ƒh–ðE•ÏX’Ê’m -int mapif_guild_position(struct guild *g, int idx) +// Send a guild position desc +int mapif_guild_position(struct guild *g,int idx) { - unsigned char buf[2048]; - - WBUFW(buf,0) = 0x383b; - WBUFW(buf,2) = sizeof(struct guild_position) + 12; - WBUFL(buf,4) = g->guild_id; - WBUFL(buf,8) = idx; - memcpy(WBUFP(buf,12), &g->position[idx], sizeof(struct guild_position)); - mapif_sendall(buf, WBUFW(buf,2)); - + unsigned char buf[12 + sizeof(struct guild_position)]; + WBUFW(buf,0)=0x383b; + WBUFW(buf,2)=sizeof(struct guild_position)+12; + WBUFL(buf,4)=g->guild_id; + WBUFL(buf,8)=idx; + memcpy(WBUFP(buf,12),&g->position[idx],sizeof(struct guild_position)); + mapif_sendall(buf,WBUFW(buf,2)); return 0; } -// ƒMƒ‹ƒh’m•ÏX’Ê’m +// Send the guild notice int mapif_guild_notice(struct guild *g) { - unsigned char buf[186]; - - WBUFW(buf,0) = 0x383e; - WBUFL(buf,2) = g->guild_id; - memcpy(WBUFP(buf,6), g->mes1, MAX_GUILDMES1); - memcpy(WBUFP(buf,66), g->mes2, MAX_GUILDMES2); - mapif_sendall(buf, 186); - + unsigned char buf[256]; + WBUFW(buf,0)=0x383e; + WBUFL(buf,2)=g->guild_id; + memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1); + memcpy(WBUFP(buf,66),g->mes2,MAX_GUILDMES2); + mapif_sendall(buf,186); return 0; } -// ƒMƒ‹ƒhƒGƒ“ƒuƒŒƒ€•ÏX’Ê’m +// Send emblem data int mapif_guild_emblem(struct guild *g) { - unsigned char buf[2048]; - - WBUFW(buf,0) = 0x383f; - WBUFW(buf,2) = g->emblem_len + 12; - WBUFL(buf,4) = g->guild_id; - WBUFL(buf,8) = g->emblem_id; - memcpy(WBUFP(buf,12), g->emblem_data, g->emblem_len); - mapif_sendall(buf, WBUFW(buf,2)); - + unsigned char buf[12 + sizeof(g->emblem_data)]; + WBUFW(buf,0)=0x383f; + WBUFW(buf,2)=g->emblem_len+12; + WBUFL(buf,4)=g->guild_id; + WBUFL(buf,8)=g->emblem_id; + memcpy(WBUFP(buf,12),g->emblem_data,g->emblem_len); + mapif_sendall(buf,WBUFW(buf,2)); return 0; } @@ -898,76 +1131,94 @@ int mapif_guild_master_changed(struct guild *g, int aid, int cid) return 0; } -int mapif_guild_castle_dataload(int castle_id, int index, int value) +int mapif_guild_castle_dataload(int castle_id,int index,int value) { unsigned char buf[9]; - - WBUFW(buf,0) = 0x3840; - WBUFW(buf,2) = castle_id; - WBUFB(buf,4) = index; - WBUFL(buf,5) = value; + WBUFW(buf, 0)=0x3840; + WBUFW(buf, 2)=castle_id; + WBUFB(buf, 4)=index; + WBUFL(buf, 5)=value; mapif_sendall(buf,9); - return 0; } -int mapif_guild_castle_datasave(int castle_id, int index, int value) +int mapif_guild_castle_datasave(int castle_id,int index,int value) { unsigned char buf[9]; - - WBUFW(buf,0) = 0x3841; - WBUFW(buf,2) = castle_id; - WBUFB(buf,4) = index; - WBUFL(buf,5) = value; + WBUFW(buf, 0)=0x3841; + WBUFW(buf, 2)=castle_id; + WBUFB(buf, 4)=index; + WBUFL(buf, 5)=value; mapif_sendall(buf,9); - return 0; } int mapif_guild_castle_alldataload(int fd) { - DBIterator* iter; - struct guild_castle* gc; - int len = 4; + struct guild_castle s_gc; + struct guild_castle* gc = &s_gc; + int i; + int len; + char* data; WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle)); - WFIFOW(fd,0) = 0x3842; - iter = castle_db->iterator(castle_db); - for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) ) + WFIFOW(fd, 0) = 0x3842; + if( SQL_ERROR == Sql_Query(sql_handle, + "SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," + " `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`" + " FROM `%s` ORDER BY `castle_id`", guild_castle_db) ) + Sql_ShowDebug(sql_handle); + for( i = 0, len = 4; i < MAX_GUILDCASTLE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) { - memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle)); + memset(gc, 0, sizeof(struct guild_castle)); + + Sql_GetData(sql_handle, 0, &data, NULL); gc->castle_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); + + memcpy(WFIFOP(fd, len), gc, sizeof(struct guild_castle)); len += sizeof(struct guild_castle); } - iter->destroy(iter); - WFIFOW(fd,2) = len; + Sql_FreeResult(sql_handle); + WFIFOW(fd, 2) = len; WFIFOSET(fd, len); - + return 0; } + //------------------------------------------------------------------- -// map server‚©‚ç‚Ì’ÊM +// Packet received from map server + // ƒMƒ‹ƒh쬗v‹ -int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_member *master) +int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member *master) { struct guild *g; - int i; - - for(i = 0; i < NAME_LENGTH && name[i]; i++) { - if (!(name[i] & 0xe0) || name[i] == 0x7f) { - ShowInfo("Create Guild: illegal guild name [%s]\n", name); - mapif_guild_created(fd, account_id, NULL); - return 0; - } - } - - if ((g = search_guildname(name)) != NULL) { - ShowInfo("Create Guild: same name guild exists [%s]\n", name); - mapif_guild_created(fd, account_id, NULL); + int i=0; +#ifdef NOISY + ShowInfo("Creating Guild (%s)\n", name); +#endif + if(search_guildname(name) != 0){ + ShowInfo("int_guild: guild with same name exists [%s]\n",name); + mapif_guild_created(fd,account_id,NULL); return 0; } - // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised for (i = 0; i < NAME_LENGTH && name[i]; i++) @@ -983,81 +1234,104 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem } } - g = (struct guild *) aCalloc(sizeof(struct guild), 1); - if (g == NULL) { - ShowFatalError("int_guild: CreateGuild: out of memory !\n"); - mapif_guild_created(fd, account_id, NULL); - exit(EXIT_FAILURE); - } -// memset(g, 0, sizeof(struct guild)); Meh... - g->guild_id = guild_newid++; - memcpy(g->name, name, NAME_LENGTH); - memcpy(g->master, master->name, NAME_LENGTH); - memcpy(&g->member[0], master, sizeof(struct guild_member)); - - g->position[0].mode = 0x11; - strcpy(g->position[ 0].name, "GuildMaster"); - strcpy(g->position[MAX_GUILDPOSITION-1].name, "Newbie"); - for(i = 1; i < MAX_GUILDPOSITION-1; i++) - sprintf(g->position[i].name, "Position %d", i + 1); - - // ‚±‚±‚ŃMƒ‹ƒhî•ñŒvŽZ‚ª•K—v‚ÆŽv‚í‚ê‚é - g->max_member = 16; - g->average_lv = master->lv; - g->connect_member = 1; - for(i = 0; i < MAX_GUILDSKILL; i++) - g->skill[i].id=i + GD_SKILLBASE; + g = (struct guild *)aMalloc(sizeof(struct guild)); + memset(g,0,sizeof(struct guild)); + + memcpy(g->name,name,NAME_LENGTH); + memcpy(g->master,master->name,NAME_LENGTH); + memcpy(&g->member[0],master,sizeof(struct guild_member)); + g->member[0].modified = GS_MEMBER_MODIFIED; + + // Set default positions + g->position[0].mode=0x11; + strcpy(g->position[0].name,"GuildMaster"); + strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie"); + g->position[0].modified = g->position[MAX_GUILDPOSITION-1].modified = GS_POSITION_MODIFIED; + for(i=1;iposition[i].name,"Position %d",i+1); + g->position[i].modified = GS_POSITION_MODIFIED; + } - idb_put(guild_db, g->guild_id, g); + // Initialize guild property + g->max_member=16; + g->average_lv=master->lv; + g->connect_member=1; - mapif_guild_created(fd, account_id, g); - mapif_guild_info(fd, g); + for(i=0;iskill[i].id=i + GD_SKILLBASE; + g->guild_id= -1; //Request to create guild. + + // Create the guild + if (!inter_guild_tosql(g,GS_BASIC|GS_POSITION|GS_SKILL)) { + //Failed to Create guild.... + ShowError("Failed to create Guild %s (Guild Master: %s)\n", g->name, g->master); + mapif_guild_created(fd,account_id,NULL); + aFree(g); + return 0; + } + ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master); + + //Add to cache + idb_put(guild_db_, g->guild_id, g); + + // Report to client + mapif_guild_created(fd,account_id,g); + mapif_guild_info(fd,g); if(log_inter) inter_log("guild %s (id=%d) created by master %s (id=%d)\n", - name, g->guild_id, master->name, master->account_id); + name, g->guild_id, master->name, master->account_id ); return 0; } -// ƒMƒ‹ƒhî•ñ—v‹ -int mapif_parse_GuildInfo(int fd, int guild_id) +// Return guild info to client +int mapif_parse_GuildInfo(int fd,int guild_id) { - struct guild *g; - - g = (struct guild*)idb_get(guild_db, guild_id); - if (g != NULL){ - guild_calcinfo(g); - mapif_guild_info(fd, g); - } else - mapif_guild_noinfo(fd, guild_id); - + struct guild * g = inter_guild_fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is requied. [Skotlex] + if(g) + { + if (!guild_calcinfo(g)) + mapif_guild_info(fd,g); + } + else + mapif_guild_noinfo(fd,guild_id); // Failed to load info return 0; } -// ƒMƒ‹ƒhƒƒ“ƒo’ljÁ—v‹ -int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m) +// Add member to guild +int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) { - struct guild *g; + struct guild * g; int i; - g = (struct guild*)idb_get(guild_db, guild_id); - if (g == NULL) { - mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1); + g = inter_guild_fromsql(guild_id); + if(g==NULL){ + // Failed to add + mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); return 0; } - ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 ); - if( i < g->max_member ) + // Find an empty slot + for(i=0;imax_member;i++) { - memcpy(&g->member[i], m, sizeof(struct guild_member)); - mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 0); - guild_calcinfo(g); - mapif_guild_info(-1, g); + if(g->member[i].account_id==0) + { + memcpy(&g->member[i],m,sizeof(struct guild_member)); + g->member[i].modified = (GS_MEMBER_NEW | GS_MEMBER_MODIFIED); + mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); + if (!guild_calcinfo(g)) //Send members if it was not invoked. + mapif_guild_info(-1,g); + + g->save_flag |= GS_MEMBER; + if (g->save_flag&GS_REMOVE) + g->save_flag&=~GS_REMOVE; + return 0; + } } - else - mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1); + // Failed to add + mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); return 0; } @@ -1066,10 +1340,13 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in { int i, j; - struct guild* g = (struct guild*)idb_get(guild_db, guild_id); + struct guild* g = inter_guild_fromsql(guild_id); if( g == NULL ) { - //TODO + // Unknown guild, just update the player + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) ) + Sql_ShowDebug(sql_handle); + // mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes); return 0; } @@ -1082,13 +1359,15 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in } if( flag ) - { // ’Ç•ú‚ÌꇒǕúƒŠƒXƒg‚É“ü‚ê‚é + { // Write expulsion reason + // Find an empty slot ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 ); - if (j == MAX_GUILDEXPULSION) - { // ˆê”t‚Ȃ̂Ō¢‚Ì‚ðÁ‚· - for(j = 0; j < MAX_GUILDEXPULSION - 1; j++) + if( j == MAX_GUILDEXPULSION ) + { + // Expulsion list is full, flush the oldest one + for( j = 0; j < MAX_GUILDEXPULSION - 1; j++ ) g->expulsion[j] = g->expulsion[j+1]; - j = MAX_GUILDEXPULSION - 1; + j = MAX_GUILDEXPULSION-1; } // Save the expulsion entry g->expulsion[j].account_id = account_id; @@ -1096,41 +1375,54 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in safestrncpy(g->expulsion[j].mes, mes, 40); } - mapif_guild_withdraw(guild_id, account_id, char_id, flag, g->member[i].name, mes); + mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes); + inter_guild_removemember_tosql(g->member[i].account_id,g->member[i].char_id); - memset(&g->member[i], 0, sizeof(struct guild_member)); + memset(&g->member[i],0,sizeof(struct guild_member)); - if (guild_check_empty(g) == 0) - mapif_guild_info(-1,g);// ‚Ü‚¾l‚ª‚¢‚é‚̂Ńf[ƒ^‘—M + if( guild_check_empty(g) ) + mapif_parse_BreakGuild(-1,guild_id); //Break the guild. + else { + //Update member info. + if (!guild_calcinfo(g)) + mapif_guild_info(fd,g); + g->save_flag |= GS_EXPULSION; + } return 0; } -// ƒIƒ“ƒ‰ƒCƒ“/LvXV -int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_) +// Change member info +int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,int char_id,int online,int lv,int class_) { - struct guild *g; - int i, sum, c; + // Could speed up by manipulating only guild_member + struct guild * g; + int i,sum,c; + int prev_count, prev_alv; - g = (struct guild*)idb_get(guild_db, guild_id); - if (g == NULL) + g = inter_guild_fromsql(guild_id); + if(g==NULL) return 0; - + ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id ); if( i < g->max_member ) { - g->member[i].online = online; - g->member[i].lv = lv; - g->member[i].class_ = class_; - mapif_guild_memberinfoshort(g, i); + g->member[i].online = online; + g->member[i].lv = lv; + g->member[i].class_ = class_; + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfoshort(g,i); } + prev_count = g->connect_member; + prev_alv = g->average_lv; + g->average_lv = 0; g->connect_member = 0; - c = 0; // member count - sum = 0; // total sum of base levels + c = 0; + sum = 0; - for(i = 0; i < g->max_member; i++) + for( i = 0; i < g->max_member; i++ ) { if( g->member[i].account_id > 0 ) { @@ -1142,198 +1434,287 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, } if( c ) // this check should always succeed... + { g->average_lv = sum / c; - - //FIXME: how about sending a mapif_guild_info() update to the mapserver? [ultramage] - + if( g->connect_member != prev_count || g->average_lv != prev_alv ) + g->save_flag |= GS_CONNECT; + if( g->save_flag & GS_REMOVE ) + g->save_flag &= ~GS_REMOVE; + } + g->save_flag |= GS_MEMBER; //Update guild member data return 0; } -// ƒMƒ‹ƒh‰ðŽUˆ——pi“¯–¿/“G‘΂ð‰ðœj -int guild_break_sub(DBKey key, void *data, va_list ap) +// BreakGuild +int mapif_parse_BreakGuild(int fd,int guild_id) { - struct guild *g = (struct guild *)data; - int guild_id = va_arg(ap, int); - int i; + struct guild * g; + + g = inter_guild_fromsql(guild_id); + if(g==NULL) + return 0; - for(i = 0; i < MAX_GUILDALLIANCE; i++) { - if (g->alliance[i].guild_id == guild_id) - g->alliance[i].guild_id = 0; - } - return 0; -} + // Delete guild from sql + //printf("- Delete guild %d from guild\n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); -// ƒMƒ‹ƒh‰ðŽU—v‹ -int mapif_parse_BreakGuild(int fd, int guild_id) -{ - struct guild *g; + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) ) + Sql_ShowDebug(sql_handle); - g = (struct guild*)idb_get(guild_db, guild_id); - if(g == NULL) - return 0; + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) ) + Sql_ShowDebug(sql_handle); - guild_db->foreach(guild_db, guild_break_sub, guild_id); - inter_guild_storage_delete(guild_id); - mapif_guild_broken(guild_id, 0); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + //printf("- Update guild %d of char\n",guild_id); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) ) + Sql_ShowDebug(sql_handle); + + mapif_guild_broken(guild_id,0); if(log_inter) - inter_log("guild %s (id=%d) broken\n", g->name, guild_id); + inter_log("guild %s (id=%d) broken\n",g->name,guild_id); - idb_remove(guild_db, guild_id); + //Remove the guild from memory. [Skotlex] + idb_remove(guild_db_, guild_id); return 0; } -// ƒMƒ‹ƒhƒƒbƒZ[ƒW‘—M -int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, char *mes, int len) +// Forward Guild message to others map servers +int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int len) { - return mapif_guild_message(guild_id, account_id, mes, len, fd); + return mapif_guild_message(guild_id,account_id,mes,len, fd); } -// ƒMƒ‹ƒhŠî–{ƒf[ƒ^•ÏX—v‹ -int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const char *data, int len) +// Modification of the guild +int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *data,int len) { - struct guild *g; - short dw = *((short *)data); - - g = (struct guild*)idb_get(guild_db, guild_id); - if (g == NULL) + struct guild * g; + short dw=*((short *)data); + g = inter_guild_fromsql(guild_id); + if(g==NULL) return 0; - switch(type) { - case GBI_GUILDLV: - if (dw > 0 && g->guild_lv + dw <= 50) { - g->guild_lv+=dw; - g->skill_point+=dw; - } else if (dw < 0 && g->guild_lv + dw >= 1) - g->guild_lv += dw; - mapif_guild_info(-1, g); - return 0; - default: - ShowError("int_guild: GuildBasicInfoChange: Unknown type %d\n", type); - break; + switch(type) + { + case GBI_GUILDLV: + if(dw>0 && g->guild_lv+dw<=50) + { + g->guild_lv+=dw; + g->skill_point+=dw; + } + else if(dw<0 && g->guild_lv+dw>=1) + g->guild_lv+=dw; + mapif_guild_info(-1,g); + g->save_flag |= GS_LEVEL; + return 0; + default: + ShowError("int_guild: GuildBasicInfoChange: Unknown type %d\n",type); + break; } - mapif_guild_basicinfochanged(guild_id, type, data, len); - + mapif_guild_basicinfochanged(guild_id,type,data,len); return 0; } -// ƒMƒ‹ƒhƒƒ“ƒoƒf[ƒ^•ÏX—v‹ -int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len) +// Modification of the guild +int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len) { + // Could make some improvement in speed, because only change guild_member int i; - struct guild *g; + struct guild * g; - g = (struct guild*)idb_get(guild_db, guild_id); - if(g == NULL) + g = inter_guild_fromsql(guild_id); + if(g==NULL) return 0; - for(i = 0; i < g->max_member; i++) - if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) - break; - if (i == g->max_member) { - ShowWarning("int_guild: GuildMemberChange: Not found %d,%d in %d[%s]\n", account_id, char_id, guild_id, g->name); + // Search the member + for(i=0;imax_member;i++) + if( g->member[i].account_id==account_id && + g->member[i].char_id==char_id ) + break; + + // Not Found + if(i==g->max_member){ + ShowWarning("int_guild: GuildMemberChange: Not found %d,%d in guild (%d - %s)\n", + account_id,char_id,guild_id,g->name); return 0; } - switch(type) { - case GMI_POSITION: // –ðE - g->member[i].position = *((short *)data); - mapif_guild_memberinfochanged(guild_id, account_id, char_id, type, data, len); - break; - case GMI_EXP: // EXP + + switch(type) { - uint64 exp, old_exp=g->member[i].exp; - g->member[i].exp=*((uint64 *)data); - if (g->member[i].exp > old_exp) + case GMI_POSITION: + { + g->member[i].position=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; + break; + } + case GMI_EXP: + { // EXP + uint64 exp, old_exp=g->member[i].exp; + g->member[i].exp=*((uint64 *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + if (g->member[i].exp > old_exp) + { + exp = g->member[i].exp - old_exp; + + // Compute gained exp + if (guild_exp_rate != 100) + exp = exp*guild_exp_rate/100; + + // Update guild exp + if (exp > UINT64_MAX - g->exp) + g->exp = UINT64_MAX; + else + g->exp+=exp; + + guild_calcinfo(g); + mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp)); + g->save_flag |= GS_LEVEL; + } + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; + break; + } + case GMI_HAIR: { - exp = g->member[i].exp - old_exp; - if (guild_exp_rate != 100) - exp = exp*guild_exp_rate/100; - if (exp > UINT64_MAX - g->exp) - g->exp = UINT64_MAX; - else - g->exp+=exp; - guild_calcinfo(g); - mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp)); + g->member[i].hair=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; //Save new data. + break; } - mapif_guild_memberinfochanged(guild_id, account_id, char_id, type, data, len); - break; - } - case GMI_HAIR: - { - g->member[i].hair=*((short *)data); - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - break; - } - case GMI_HAIR_COLOR: - { - g->member[i].hair_color=*((short *)data); - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - break; + case GMI_HAIR_COLOR: + { + g->member[i].hair_color=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; //Save new data. + break; + } + case GMI_GENDER: + { + g->member[i].gender=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; //Save new data. + break; + } + case GMI_CLASS: + { + g->member[i].class_=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; //Save new data. + break; + } + case GMI_LEVEL: + { + g->member[i].lv=*((short *)data); + g->member[i].modified = GS_MEMBER_MODIFIED; + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + g->save_flag |= GS_MEMBER; //Save new data. + break; + } + default: + ShowError("int_guild: GuildMemberInfoChange: Unknown type %d\n",type); + break; } - case GMI_GENDER: + return 0; +} + +int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender) +{ + return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender)); +} + +int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name) +{ + struct guild *g; + int i, flag = 0; + + g = inter_guild_fromsql(guild_id); + if( g == NULL ) { - g->member[i].gender=*((short *)data); - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - break; + ShowError("inter_guild_charrenamed: Can't find guild %d.\n", guild_id); + return 0; } - case GMI_CLASS: + + ARR_FIND(0, g->max_member, i, g->member[i].char_id == char_id); + if( i == g->max_member ) { - g->member[i].class_=*((short *)data); - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - break; + ShowError("inter_guild_charrenamed: Can't find character %d in the guild\n", char_id); + return 0; } - case GMI_LEVEL: + + if( !strcmp(g->member[i].name, g->master) ) { - g->member[i].lv=*((short *)data); - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - break; + safestrncpy(g->master, name, NAME_LENGTH); + flag |= GS_BASIC; } + safestrncpy(g->member[i].name, name, NAME_LENGTH); + g->member[i].modified = GS_MEMBER_MODIFIED; + flag |= GS_MEMBER; - default: - ShowError("int_guild: GuildMemberInfoChange: Unknown type %d\n", type); - break; - } + if( !inter_guild_tosql(g, flag) ) + return 0; + mapif_guild_info(-1,g); + return 0; } -int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender) +// Change a position desc +int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position *p) { - return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender)); -} + // Could make some improvement in speed, because only change guild_position + struct guild * g; -// ƒMƒ‹ƒh–ðE–¼•ÏX—v‹ -int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p) -{ - struct guild *g = (struct guild*)idb_get(guild_db, guild_id); - - if (g == NULL || idx < 0 || idx >= MAX_GUILDPOSITION) { + g = inter_guild_fromsql(guild_id); + if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION) return 0; - } - memcpy(&g->position[idx], p, sizeof(struct guild_position)); - mapif_guild_position(g, idx); - ShowInfo("int_guild: position [%d] changed\n", idx); + memcpy(&g->position[idx],p,sizeof(struct guild_position)); + mapif_guild_position(g,idx); + g->position[idx].modified = GS_POSITION_MODIFIED; + g->save_flag |= GS_POSITION; // Change guild_position return 0; } -// ƒMƒ‹ƒhƒXƒLƒ‹ƒAƒbƒv—v‹ -int mapif_parse_GuildSkillUp(int fd, int guild_id, int skill_num, int account_id, int max) +// Guild Skill UP +int mapif_parse_GuildSkillUp(int fd,int guild_id,int skill_num,int account_id,int max) { - struct guild *g = (struct guild*)idb_get(guild_db, guild_id); + struct guild * g; int idx = skill_num - GD_SKILLBASE; - if (g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) + g = inter_guild_fromsql(guild_id); + if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) return 0; - if (g->skill_point > 0 && g->skill[idx].id > 0 && g->skill[idx].lv < max) { + if(g->skill_point>0 && g->skill[idx].id>0 && g->skill[idx].lvskill[idx].lv++; g->skill_point--; - if (guild_calcinfo(g) == 0) - mapif_guild_info(-1, g); - mapif_guild_skillupack(guild_id, skill_num, account_id); + if (!guild_calcinfo(g)) + mapif_guild_info(-1,g); + mapif_guild_skillupack(guild_id,skill_num,account_id); + g->save_flag |= (GS_LEVEL|GS_SKILL); // Change guild & guild_skill } - return 0; } @@ -1342,106 +1723,119 @@ static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int ac { int i; char name[NAME_LENGTH]; - for(i=0;ialliance[i].guild_id == guild_id) - { - strcpy(name, g->alliance[i].name); - g->alliance[i].guild_id=0; - break; - } - if (i == MAX_GUILDALLIANCE) + + ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->alliance[i].guild_id == guild_id ); + if( i == MAX_GUILDALLIANCE ) return -1; + + strcpy(name, g->alliance[i].name); + g->alliance[i].guild_id=0; mapif_guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name); + g->save_flag |= GS_ALLIANCE; return 0; } -// ƒMƒ‹ƒh“¯–¿—v‹ -int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) +// Alliance modification +int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) { + // Could speed up struct guild *g[2]; - int j, i; - - g[0] = (struct guild*)idb_get(guild_db, guild_id1); - g[1] = (struct guild*)idb_get(guild_db, guild_id2); - - if(g[0] && g[1]==NULL && (flag&0x8)) //Requested to remove an alliance with a not found guild. - return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, - account_id1, account_id2, flag); //Try to do a manual removal of said guild. - - if (g[0] == NULL || g[1] == NULL) + int j,i; + g[0] = inter_guild_fromsql(guild_id1); + g[1] = inter_guild_fromsql(guild_id2); + + if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild. + return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild. + + if(g[0]==NULL || g[1]==NULL) return 0; - if (!(flag & 0x8)) { - for(i = 0; i < 2 - (flag & 1); i++) { - for(j = 0; j < MAX_GUILDALLIANCE; j++) - if (g[i]->alliance[j].guild_id == 0) { - g[i]->alliance[j].guild_id = g[1-i]->guild_id; - memcpy(g[i]->alliance[j].name, g[1-i]->name, NAME_LENGTH); - g[i]->alliance[j].opposition = flag & 1; - break; - } + if(flag&GUILD_ALLIANCE_REMOVE) + { + // Remove alliance/opposition, in case of alliance, remove on both side + for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++) + { + ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == g[1-i]->guild_id && g[i]->alliance[j].opposition == (flag&GUILD_ALLIANCE_TYPE_MASK) ); + if( j < MAX_GUILDALLIANCE ) + g[i]->alliance[j].guild_id = 0; } - } else { // ŠÖŒW‰ðÁ - for(i = 0; i < 2 - (flag & 1); i++) { - for(j = 0; j < MAX_GUILDALLIANCE; j++) - if (g[i]->alliance[j].guild_id == g[1-i]->guild_id && g[i]->alliance[j].opposition == (flag & 1)) { - g[i]->alliance[j].guild_id = 0; - break; - } + } + else + { + // Add alliance, in case of alliance, add on both side + for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++) + { + // Search an empty slot + ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 ); + if( j < MAX_GUILDALLIANCE ) + { + g[i]->alliance[j].guild_id=g[1-i]->guild_id; + memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH); + // Set alliance type + g[i]->alliance[j].opposition = flag&GUILD_ALLIANCE_TYPE_MASK; + } } } - mapif_guild_alliance(guild_id1, guild_id2, account_id1, account_id2, flag, g[0]->name, g[1]->name); + // Send on all map the new alliance/opposition + mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name); + + // Mark the two guild to be saved + g[0]->save_flag |= GS_ALLIANCE; + g[1]->save_flag |= GS_ALLIANCE; return 0; } -// ƒMƒ‹ƒh’m•ÏX—v‹ -int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) +// Change guild message +int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes2) { struct guild *g; - g = (struct guild*)idb_get(guild_db, guild_id); - if (g == NULL) + g = inter_guild_fromsql(guild_id); + if(g==NULL) return 0; - memcpy(g->mes1, mes1, MAX_GUILDMES1); - memcpy(g->mes2, mes2, MAX_GUILDMES2); + memcpy(g->mes1,mes1,MAX_GUILDMES1); + memcpy(g->mes2,mes2,MAX_GUILDMES2); + g->save_flag |= GS_MES; //Change mes of guild return mapif_guild_notice(g); } -// ƒMƒ‹ƒhƒGƒ“ƒuƒŒƒ€•ÏX—v‹ -int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) +int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data) { - struct guild *g; + struct guild * g; - g = (struct guild*)idb_get(guild_db, guild_id); - if (g == NULL) + g = inter_guild_fromsql(guild_id); + if(g==NULL) return 0; - memcpy(g->emblem_data, data, len); - g->emblem_len = len; - g->emblem_id++; + if (len > sizeof(g->emblem_data)) + len = sizeof(g->emblem_data); + + memcpy(g->emblem_data,data,len); + g->emblem_len=len; + g->emblem_id++; + g->save_flag |= GS_EMBLEM; //Change guild return mapif_guild_emblem(g); } -int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) +int mapif_parse_GuildCastleDataLoad(int fd,int castle_id,int index) { - struct guild_castle *gc = (struct guild_castle*)idb_get(castle_db, castle_id); - - if (gc == NULL) { - return mapif_guild_castle_dataload(castle_id, 0, 0); - } - switch(index) { - case 1: return mapif_guild_castle_dataload(gc->castle_id, index, gc->guild_id); - case 2: return mapif_guild_castle_dataload(gc->castle_id, index, gc->economy); - case 3: return mapif_guild_castle_dataload(gc->castle_id, index, gc->defense); - case 4: return mapif_guild_castle_dataload(gc->castle_id, index, gc->triggerE); - case 5: return mapif_guild_castle_dataload(gc->castle_id, index, gc->triggerD); - case 6: return mapif_guild_castle_dataload(gc->castle_id, index, gc->nextTime); - case 7: return mapif_guild_castle_dataload(gc->castle_id, index, gc->payTime); - case 8: return mapif_guild_castle_dataload(gc->castle_id, index, gc->createTime); - case 9: return mapif_guild_castle_dataload(gc->castle_id, index, gc->visibleC); + struct guild_castle gc; + if (!inter_guildcastle_fromsql(castle_id, &gc)) { + return mapif_guild_castle_dataload(castle_id,0,0); + } + switch(index){ + case 1: return mapif_guild_castle_dataload(gc.castle_id,index,gc.guild_id); break; + case 2: return mapif_guild_castle_dataload(gc.castle_id,index,gc.economy); break; + case 3: return mapif_guild_castle_dataload(gc.castle_id,index,gc.defense); break; + case 4: return mapif_guild_castle_dataload(gc.castle_id,index,gc.triggerE); break; + case 5: return mapif_guild_castle_dataload(gc.castle_id,index,gc.triggerD); break; + case 6: return mapif_guild_castle_dataload(gc.castle_id,index,gc.nextTime); break; + case 7: return mapif_guild_castle_dataload(gc.castle_id,index,gc.payTime); break; + case 8: return mapif_guild_castle_dataload(gc.castle_id,index,gc.createTime); break; + case 9: return mapif_guild_castle_dataload(gc.castle_id,index,gc.visibleC); break; case 10: case 11: case 12: @@ -1450,45 +1844,42 @@ int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) case 15: case 16: case 17: - return mapif_guild_castle_dataload(gc->castle_id, index, gc->guardian[index-10].visible); + return mapif_guild_castle_dataload(gc.castle_id,index,gc.guardian[index-10].visible); break; default: ShowError("mapif_parse_GuildCastleDataLoad ERROR!! (Not found index=%d)\n", index); return 0; } - - return 0; } -int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) +int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value) { - struct guild_castle *gc = (struct guild_castle*)idb_get(castle_db, castle_id); - - if (gc == NULL) - return mapif_guild_castle_datasave(castle_id, index, value); + struct guild_castle gc; + if(!inter_guildcastle_fromsql(castle_id, &gc)) + return mapif_guild_castle_datasave(castle_id,index,value); - switch(index) { + switch(index){ case 1: - if (gc->guild_id != value) { - int gid = (value) ? value : gc->guild_id; - struct guild *g = (struct guild*)idb_get(guild_db, gid); + if( gc.guild_id!=value ){ + int gid=(value)?value:gc.guild_id; + struct guild *g = (struct guild*)idb_get(guild_db_, gid); if(log_inter) inter_log("guild %s (id=%d) %s castle id=%d\n", - (g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id); + (g)?g->name:"??" ,gid, (value)?"occupy":"abandon", castle_id); } - gc->guild_id = value; - if(gc->guild_id == 0) { + gc.guild_id = value; + if(gc.guild_id == 0) { //Delete guardians. - memset(&gc->guardian, 0, sizeof(gc->guardian)); + memset(&gc.guardian, 0, sizeof(gc.guardian)); } break; - case 2: gc->economy = value; break; - case 3: gc->defense = value; break; - case 4: gc->triggerE = value; break; - case 5: gc->triggerD = value; break; - case 6: gc->nextTime = value; break; - case 7: gc->payTime = value; break; - case 8: gc->createTime = value; break; - case 9: gc->visibleC = value; break; + case 2: gc.economy = value; break; + case 3: gc.defense = value; break; + case 4: gc.triggerE = value; break; + case 5: gc.triggerD = value; break; + case 6: gc.nextTime = value; break; + case 7: gc.payTime = value; break; + case 8: gc.createTime = value; break; + case 9: gc.visibleC = value; break; case 10: case 11: case 12: @@ -1497,38 +1888,50 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) case 15: case 16: case 17: - gc->guardian[index-10].visible = value; break; + gc.guardian[index-10].visible = value; break; default: ShowError("mapif_parse_GuildCastleDataSave ERROR!! (Not found index=%d)\n", index); return 0; } - - return mapif_guild_castle_datasave(gc->castle_id, index, value); + inter_guildcastle_tosql(&gc); + mapif_guild_castle_datasave(gc.castle_id,index,value); + return 0; } int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len) { - struct guild *g = (struct guild*)idb_get(guild_db, guild_id); + struct guild * g; struct guild_member gm; int pos; - if(g==NULL || g->guild_id<=0 || len > NAME_LENGTH) + g = inter_guild_fromsql(guild_id); + + if(g==NULL || len > NAME_LENGTH) return 0; + // Find member (name) for (pos = 0; pos < g->max_member && strncmp(g->member[pos].name, name, len); pos++); if (pos == g->max_member) return 0; //Character not found?? + // Switch current and old GM memcpy(&gm, &g->member[pos], sizeof (struct guild_member)); memcpy(&g->member[pos], &g->member[0], sizeof(struct guild_member)); memcpy(&g->member[0], &gm, sizeof(struct guild_member)); + // Switch positions g->member[pos].position = g->member[0].position; + g->member[pos].modified = GS_MEMBER_MODIFIED; g->member[0].position = 0; //Position 0: guild Master. - safestrncpy(g->master, name, NAME_LENGTH); + g->member[0].modified = GS_MEMBER_MODIFIED; + + strncpy(g->master, name, len); + if (len < NAME_LENGTH) + g->master[len] = '\0'; - ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",name, guild_id, g->name); + ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",g->master, guild_id, g->name); + g->save_flag |= (GS_BASIC|GS_MEMBER); //Save main data and member data. return mapif_guild_master_changed(g, g->member[0].account_id, g->member[0].char_id); } @@ -1541,23 +1944,23 @@ int inter_guild_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { - case 0x3030: mapif_parse_CreateGuild(fd, RFIFOL(fd,4), (char*)RFIFOP(fd,8), (struct guild_member *)RFIFOP(fd,32)); break; - case 0x3031: mapif_parse_GuildInfo(fd, RFIFOL(fd,2)); break; - case 0x3032: mapif_parse_GuildAddMember(fd, RFIFOL(fd,4), (struct guild_member *)RFIFOP(fd,8)); break; + case 0x3030: mapif_parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break; + case 0x3031: mapif_parse_GuildInfo(fd,RFIFOL(fd,2)); break; + case 0x3032: mapif_parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break; case 0x3033: mapif_parse_GuildMasterChange(fd,RFIFOL(fd,4),(const char*)RFIFOP(fd,8),RFIFOW(fd,2)-8); break; - case 0x3034: mapif_parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), (const char*)RFIFOP(fd,15)); break; - case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOW(fd,15), RFIFOW(fd,17)); break; - case 0x3036: mapif_parse_BreakGuild(fd, RFIFOL(fd,2)); break; - case 0x3037: mapif_parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break; - case 0x3039: mapif_parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), (const char*)RFIFOP(fd,10), RFIFOW(fd,2)-10); break; - case 0x303A: mapif_parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), (const char*)RFIFOP(fd,18), RFIFOW(fd,2)-18); break; - case 0x303B: mapif_parse_GuildPosition(fd, RFIFOL(fd,4), RFIFOL(fd,8), (struct guild_position *)RFIFOP(fd,12)); break; - case 0x303C: mapif_parse_GuildSkillUp(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14)); break; - case 0x303D: mapif_parse_GuildAlliance(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18)); break; - case 0x303E: mapif_parse_GuildNotice(fd, RFIFOL(fd,2), (const char*)RFIFOP(fd,6), (const char*)RFIFOP(fd,66)); break; - case 0x303F: mapif_parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), (const char*)RFIFOP(fd,12)); break; - case 0x3040: mapif_parse_GuildCastleDataLoad(fd, RFIFOW(fd,2), RFIFOB(fd,4)); break; - case 0x3041: mapif_parse_GuildCastleDataSave(fd, RFIFOW(fd,2), RFIFOB(fd,4), RFIFOL(fd,5)); break; + case 0x3034: mapif_parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break; + case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break; + case 0x3036: mapif_parse_BreakGuild(fd,RFIFOL(fd,2)); break; + case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; + case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const char*)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; + case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break; + case 0x303B: mapif_parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break; + case 0x303C: mapif_parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break; + case 0x303D: mapif_parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break; + case 0x303E: mapif_parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break; + case 0x303F: mapif_parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break; + case 0x3040: mapif_parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),RFIFOB(fd,4)); break; + case 0x3041: mapif_parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break; default: return 0; @@ -1577,4 +1980,8 @@ int inter_guild_leave(int guild_id, int account_id, int char_id) { return mapif_parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **"); } -#endif //TXT_SQL_CONVERT + +int inter_guild_broken(int guild_id) +{ + return mapif_guild_broken(guild_id, 0); +} diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 0be6c50d9..4577357f3 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -1,26 +1,40 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_GUILD_H_ -#define _INT_GUILD_H_ +#ifndef _INT_GUILD_SQL_H_ +#define _INT_GUILD_SQL_H_ + +#define GS_BASIC 0x0001 +#define GS_MEMBER 0x0002 +#define GS_POSITION 0x0004 +#define GS_ALLIANCE 0x0008 +#define GS_EXPULSION 0x0010 +#define GS_SKILL 0x0020 +#define GS_EMBLEM 0x0040 +#define GS_CONNECT 0x0080 +#define GS_LEVEL 0x0100 +#define GS_MES 0x0200 +#define GS_MASK 0x03FF +#define GS_BASIC_MASK (GS_BASIC | GS_EMBLEM | GS_CONNECT | GS_LEVEL | GS_MES) +#define GS_REMOVE 0x8000 struct guild; struct guild_castle; -int inter_guild_init(void); -void inter_guild_final(void); -int inter_guild_save(void); int inter_guild_parse_frommap(int fd); -struct guild *inter_guild_search(int guild_id); +int inter_guild_sql_init(void); +void inter_guild_sql_final(void); int inter_guild_mapif_init(int fd); int inter_guild_leave(int guild_id,int account_id,int char_id); +int mapif_parse_BreakGuild(int fd,int guild_id); +int inter_guild_broken(int guild_id); int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender); +int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name); +int inter_guild_CharOnline(int char_id, int guild_id); +int inter_guild_CharOffline(int char_id, int guild_id); -extern char guild_txt[1024]; -extern char castle_txt[1024]; - -//For the TXT->SQL converter -int inter_guild_fromstr(char *str, struct guild *g); -int inter_guildcastle_fromstr(char *str, struct guild_castle *gc); +//For the TXT->SQL converter. +int inter_guild_tosql(struct guild *g,int flag); +int inter_guildcastle_tosql(struct guild_castle *gc); -#endif /* _INT_GUILD_H_ */ +#endif /* _INT_GUILD_SQL_H_ */ diff --git a/src/char/int_homun.c b/src/char/int_homun.c index ec22499d0..d5a928e59 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -3,363 +3,311 @@ #include "../common/mmo.h" #include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/db.h" -#include "../common/lock.h" +#include "../common/strlib.h" #include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/utils.h" +#include "../common/sql.h" #include "char.h" #include "inter.h" -#include "int_homun.h" #include #include #include -char homun_txt[1024]="save/homun.txt"; -static DBMap* homun_db; // int hom_id -> struct s_homunculus* -static int homun_newid = 100; - -int inter_homun_tostr(char *str,struct s_homunculus *p) +int inter_homunculus_sql_init(void) { - int i; - - str+=sprintf(str,"%d,%d\t%s\t%d,%d,%d,%d,%d," - "%u,%d,%d,%d," - "%u,%d,%d," - "%d,%d,%d,%d,%d,%d\t", - p->hom_id, p->class_, p->name, - p->char_id, p->hp, p->max_hp, p->sp, p->max_sp, - p->intimacy, p->hunger, p->skillpts, p->level, - p->exp, p->rename_flag, p->vaporize, - p->str, p->agi, p->vit, p->int_, p->dex, p->luk); - - for (i = 0; i < MAX_HOMUNSKILL; i++) - { - if (p->hskill[i].id && p->hskill[i].flag == SKILL_FLAG_PERMANENT) - str+=sprintf(str,"%d,%d,", p->hskill[i].id, p->hskill[i].lv); - } - return 0; } - -int inter_homun_fromstr(char *str,struct s_homunculus *p) -{ - int i, next, len; - int tmp_int[25]; - unsigned int tmp_uint[5]; - char tmp_str[256]; - - memset(p,0,sizeof(struct s_homunculus)); - - i=sscanf(str,"%d,%d\t%127[^\t]\t%d,%d,%d,%d,%d," - "%u,%d,%d,%d," - "%u,%d,%d," - "%d,%d,%d,%d,%d,%d\t%n", - &tmp_int[0],&tmp_int[1],tmp_str, - &tmp_int[2],&tmp_int[3],&tmp_int[4],&tmp_int[5],&tmp_int[6], - &tmp_uint[0],&tmp_int[7],&tmp_int[8],&tmp_int[9], - &tmp_uint[1],&tmp_int[10],&tmp_int[11], - &tmp_int[12],&tmp_int[13],&tmp_int[14],&tmp_int[15],&tmp_int[16],&tmp_int[17], - &next); - - if(i!=21) - return 1; - - p->hom_id = tmp_int[0]; - p->class_ = tmp_int[1]; - memcpy(p->name, tmp_str, NAME_LENGTH); - - p->char_id = tmp_int[2]; - p->hp = tmp_int[3]; - p->max_hp = tmp_int[4]; - p->sp = tmp_int[5]; - p->max_sp = tmp_int[6]; - - p->intimacy = tmp_uint[0]; - p->hunger = tmp_int[7]; - p->skillpts = tmp_int[8]; - p->level = tmp_int[9]; - - p->exp = tmp_uint[1]; - p->rename_flag = tmp_int[10]; - p->vaporize = tmp_int[11]; - - p->str = tmp_int[12]; - p->agi = tmp_int[13]; - p->vit = tmp_int[14]; - p->int_= tmp_int[15]; - p->dex = tmp_int[16]; - p->luk = tmp_int[17]; - - //Read skills. - while(str[next] && str[next] != '\n' && str[next] != '\r') { - if (sscanf(str+next, "%d,%d,%n", &tmp_int[0], &tmp_int[1], &len) != 2) - return 2; - - if (tmp_int[0] >= HM_SKILLBASE && tmp_int[0] < HM_SKILLBASE+MAX_HOMUNSKILL) - { - i = tmp_int[0] - HM_SKILLBASE; - p->hskill[i].id = tmp_int[0]; - p->hskill[i].lv = tmp_int[1]; - } else - ShowError("Read Homun: Unsupported Skill ID %d for homunculus (Homun ID=%d)\n", tmp_int[0], p->hom_id); - next += len; - if (str[next] == ' ') - next++; - } - return 0; -} - -int inter_homun_init() +void inter_homunculus_sql_final(void) { - char line[8192]; - struct s_homunculus *p; - FILE *fp; - int c=0; - - homun_db= idb_alloc(DB_OPT_RELEASE_DATA); - - if( (fp=fopen(homun_txt,"r"))==NULL ) - return 1; - while(fgets(line, sizeof(line), fp)) - { - p = (struct s_homunculus*)aCalloc(sizeof(struct s_homunculus), 1); - if(p==NULL){ - ShowFatalError("int_homun: out of memory!\n"); - exit(EXIT_FAILURE); - } - if(inter_homun_fromstr(line,p)==0 && p->hom_id>0){ - if( p->hom_id >= homun_newid) - homun_newid=p->hom_id+1; - idb_put(homun_db,p->hom_id,p); - }else{ - ShowError("int_homun: broken data [%s] line %d\n",homun_txt,c); - aFree(p); - } - c++; - } - fclose(fp); - return 0; -} - -void inter_homun_final() -{ - homun_db->destroy(homun_db, NULL); return; } -int inter_homun_save_sub(DBKey key,void *data,va_list ap) -{ - char line[8192]; - FILE *fp; - inter_homun_tostr(line,(struct s_homunculus *)data); - fp=va_arg(ap,FILE *); - fprintf(fp,"%s\n",line); - return 0; -} - -int inter_homun_save() -{ - FILE *fp; - int lock; - if( (fp=lock_fopen(homun_txt,&lock))==NULL ){ - ShowError("int_homun: can't write [%s] !!! data is lost !!!\n",homun_txt); - return 1; - } - homun_db->foreach(homun_db,inter_homun_save_sub,fp); - lock_fclose(fp,homun_txt,&lock); - return 0; -} - -int inter_homun_delete(int hom_id) -{ - struct s_homunculus *p; - p = (struct s_homunculus*)idb_get(homun_db,hom_id); - if( p == NULL) - return 0; - idb_remove(homun_db,hom_id); - ShowInfo("Deleted homun (hom_id: %d)\n",hom_id); - return 1; -} - -int mapif_homun_created(int fd,int account_id, struct s_homunculus *p) +static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); - WFIFOW(fd, 0) =0x3890; + WFIFOW(fd,0) = 0x3890; WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; WFIFOL(fd,4) = account_id; - WFIFOB(fd,8)= p->hom_id?1:0; - memcpy(WFIFOP(fd,9), p, sizeof(struct s_homunculus)); + WFIFOB(fd,8)= flag; + memcpy(WFIFOP(fd,9),sh,sizeof(struct s_homunculus)); WFIFOSET(fd, WFIFOW(fd,2)); - return 0; } -int mapif_homun_info(int fd,int account_id,struct s_homunculus *p) +static void mapif_homunculus_deleted(int fd, int flag) +{ + WFIFOHEAD(fd, 3); + WFIFOW(fd, 0) = 0x3893; + WFIFOB(fd,2) = flag; //Flag 1 = success + WFIFOSET(fd, 3); +} + +static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); WFIFOW(fd,0) = 0x3891; WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; WFIFOL(fd,4) = account_id; - WFIFOB(fd,8) = 1; // account loaded with success - - memcpy(WFIFOP(fd,9), p, sizeof(struct s_homunculus)); - WFIFOSET(fd,WFIFOW(fd,2)); - return 0; -} - -int mapif_homun_noinfo(int fd,int account_id) -{ - WFIFOHEAD(fd,sizeof(struct s_homunculus) + 9); - WFIFOW(fd,0)=0x3891; - WFIFOW(fd,2)=sizeof(struct s_homunculus) + 9; - WFIFOL(fd,4)=account_id; - WFIFOB(fd,8)=0; - memset(WFIFOP(fd,9),0,sizeof(struct s_homunculus)); - WFIFOSET(fd,WFIFOW(fd,2)); - - return 0; + if( hd != NULL ) + { + WFIFOB(fd,8) = 1; // success + memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus)); + } + else + { + WFIFOB(fd,8) = 0; // not found. + memset(WFIFOP(fd,9), 0, sizeof(struct s_homunculus)); + } + WFIFOSET(fd, sizeof(struct s_homunculus)+9); } -int mapif_save_homun_ack(int fd,int account_id,int flag) +static void mapif_homunculus_saved(int fd, int account_id, bool flag) { WFIFOHEAD(fd, 7); - WFIFOW(fd,0)=0x3892; - WFIFOL(fd,2)=account_id; - WFIFOB(fd,6)=flag; - WFIFOSET(fd,7); - return 0; + WFIFOW(fd,0) = 0x3892; + WFIFOL(fd,2) = account_id; + WFIFOB(fd,6) = flag; // 1:success, 0:failure + WFIFOSET(fd, 7); } -int mapif_delete_homun_ack(int fd,int flag) +static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name) { - WFIFOHEAD(fd, 3); - WFIFOW(fd,0)=0x3893; - WFIFOB(fd,2)=flag; - WFIFOSET(fd,3); - return 0; -} - -int mapif_rename_homun_ack(int fd, int account_id, int char_id, int flag, char *name){ WFIFOHEAD(fd, NAME_LENGTH+12); - WFIFOW(fd, 0) =0x3894; - WFIFOL(fd, 2) =account_id; - WFIFOL(fd, 6) =char_id; - WFIFOB(fd, 10) =flag; - memcpy(WFIFOP(fd, 11), name, NAME_LENGTH); + WFIFOW(fd, 0) = 0x3894; + WFIFOL(fd, 2) = account_id; + WFIFOL(fd, 6) = char_id; + WFIFOB(fd,10) = flag; + safestrncpy((char*)WFIFOP(fd,11), name, NAME_LENGTH); WFIFOSET(fd, NAME_LENGTH+12); - - return 0; } -int mapif_create_homun(int fd) +bool mapif_homunculus_save(struct s_homunculus* hd) { - struct s_homunculus *p; - p= (struct s_homunculus *) aCalloc(sizeof(struct s_homunculus), 1); - if(p==NULL){ - ShowFatalError("int_homun: out of memory !\n"); - //Sending the received data will pass hom_id == 0 <- fail. - mapif_homun_created(fd,RFIFOL(fd,4),(struct s_homunculus*)RFIFOP(fd,8)); - return 0; + bool flag = true; + char esc_name[NAME_LENGTH*2+1]; + + Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH)); + + if( hd->hom_id == 0 ) + {// new homunculus + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` " + "(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) " + "VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, + hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) ) + { + Sql_ShowDebug(sql_handle); + flag = false; + } + else + { + hd->hom_id = (int)Sql_LastInsertId(sql_handle); + } } - memcpy(p, RFIFOP(fd,8), sizeof(struct s_homunculus)); - p->hom_id = homun_newid++; //New ID - idb_put(homun_db,p->hom_id,p); - mapif_homun_created(fd,RFIFOL(fd,4),p); - return 0; + else + { + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'", + hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, + hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) ) + { + Sql_ShowDebug(sql_handle); + flag = false; + } + else + { + SqlStmt* stmt; + int i; + + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", hd->hom_id) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < MAX_HOMUNSKILL; ++i ) + { + if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 ) + { + SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0); + SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0); + if( SQL_ERROR == SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + SqlStmt_Free(stmt); + flag = false; + break; + } + } + } + SqlStmt_Free(stmt); + } + } + + return flag; } -int mapif_load_homun(int fd) + + +// Load an homunculus +bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) { - struct s_homunculus *p; - int account_id; - account_id = RFIFOL(fd,2); - - p = (struct s_homunculus*)idb_get(homun_db,RFIFOL(fd,6)); - if(p==NULL) { - mapif_homun_noinfo(fd,account_id); - return 0; + int i; + char* data; + size_t len; + + memset(hd, 0, sizeof(*hd)); + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", homun_id) ) + { + Sql_ShowDebug(sql_handle); + return false; } - mapif_homun_info(fd,account_id,p); - return 0; -} -static void* create_homun(DBKey key, va_list args) { - struct s_homunculus *p; - p=(struct s_homunculus *)aCalloc(sizeof(struct s_homunculus),1); - p->hom_id = key.i; - return p; -} -int mapif_save_homun(int fd,int account_id,struct s_homunculus *data) -{ - struct s_homunculus *p; - int hom_id; - - if (data->hom_id == 0) - data->hom_id = homun_newid++; - hom_id = data->hom_id; - p = (struct s_homunculus*)idb_ensure(homun_db,hom_id,create_homun); - memcpy(p,data,sizeof(struct s_homunculus)); - mapif_save_homun_ack(fd,account_id,1); - return 0; + if( !Sql_NumRows(sql_handle) ) + { //No homunculus found. + Sql_FreeResult(sql_handle); + return false; + } + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_ShowDebug(sql_handle); + Sql_FreeResult(sql_handle); + return false; + } + + hd->hom_id = homun_id; + Sql_GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data); + Sql_GetData(sql_handle, 3, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name)); + Sql_GetData(sql_handle, 4, &data, NULL); hd->level = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); hd->exp = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10); + Sql_GetData(sql_handle, 7, &data, NULL); hd->hunger = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); hd->str = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); hd->agi = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); hd->vit = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); hd->int_ = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); hd->dex = atoi(data); + Sql_GetData(sql_handle, 13, &data, NULL); hd->luk = atoi(data); + Sql_GetData(sql_handle, 14, &data, NULL); hd->hp = atoi(data); + Sql_GetData(sql_handle, 15, &data, NULL); hd->max_hp = atoi(data); + Sql_GetData(sql_handle, 16, &data, NULL); hd->sp = atoi(data); + Sql_GetData(sql_handle, 17, &data, NULL); hd->max_sp = atoi(data); + Sql_GetData(sql_handle, 18, &data, NULL); hd->skillpts = atoi(data); + Sql_GetData(sql_handle, 19, &data, NULL); hd->rename_flag = atoi(data); + Sql_GetData(sql_handle, 20, &data, NULL); hd->vaporize = atoi(data); + Sql_FreeResult(sql_handle); + + hd->intimacy = cap_value(hd->intimacy, 0, 100000); + hd->hunger = cap_value(hd->hunger, 0, 100); + + // Load Homunculus Skill + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d", homun_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + // id + Sql_GetData(sql_handle, 0, &data, NULL); + i = atoi(data); + if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL ) + continue;// invalid skill id + i = i - HM_SKILLBASE; + hd->hskill[i].id = (unsigned short)atoi(data); + + // lv + Sql_GetData(sql_handle, 1, &data, NULL); + hd->hskill[i].lv = (unsigned char)atoi(data); + } + Sql_FreeResult(sql_handle); + + if( save_log ) + ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name); + + return true; } -int mapif_delete_homun(int fd,int hom_id) +bool mapif_homunculus_delete(int homun_id) { - mapif_delete_homun_ack(fd,inter_homun_delete(hom_id)); - return 0; + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", homun_id) + || SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", homun_id) + ) { + Sql_ShowDebug(sql_handle); + return false; + } + return true; } -int mapif_rename_homun(int fd, int account_id, int char_id, char *name){ +bool mapif_homunculus_rename(char *name) +{ int i; // Check Authorised letters/symbols in the name of the homun - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) == NULL) { - mapif_rename_homun_ack(fd, account_id, char_id, 0, name); - return 0; - } - } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) != NULL) { - mapif_rename_homun_ack(fd, account_id, char_id, 0, name); - return 0; - } + if( char_name_option == 1 ) + {// only letters/symbols in char_name_letters are authorised + for( i = 0; i < NAME_LENGTH && name[i]; i++ ) + if( strchr(char_name_letters, name[i]) == NULL ) + return false; + } else + if( char_name_option == 2 ) + {// letters/symbols in char_name_letters are forbidden + for( i = 0; i < NAME_LENGTH && name[i]; i++ ) + if( strchr(char_name_letters, name[i]) != NULL ) + return false; } - mapif_rename_homun_ack(fd, account_id, char_id, 1, name); - return 0; + return true; } -int mapif_parse_SaveHomun(int fd) + +static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd) { - mapif_save_homun(fd,RFIFOL(fd,4),(struct s_homunculus *)RFIFOP(fd,8)); - return 0; + bool result = mapif_homunculus_save(phd); + mapif_homunculus_created(fd, account_id, phd, result); } -int mapif_parse_DeleteHomun(int fd) +static void mapif_parse_homunculus_delete(int fd, int homun_id) { - mapif_delete_homun(fd,RFIFOL(fd,2)); - return 0; + bool result = mapif_homunculus_delete(homun_id); + mapif_homunculus_deleted(fd, result); } -int mapif_parse_RenameHomun(int fd) +static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) { - mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), (char*)RFIFOP(fd, 10)); - return 0; + struct s_homunculus hd; + bool result = mapif_homunculus_load(homun_id, &hd); + mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL )); +} + +static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd) +{ + bool result = mapif_homunculus_save(phd); + mapif_homunculus_saved(fd, account_id, result); +} + +static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name) +{ + bool result = mapif_homunculus_rename(name); + mapif_homunculus_renamed(fd, account_id, char_id, result, name); } -int inter_homun_parse_frommap(int fd) +/*========================================== + * Inter Packets + *------------------------------------------*/ +int inter_homunculus_parse_frommap(int fd) { - switch(RFIFOW(fd,0)){ - case 0x3090: mapif_create_homun(fd); break; - case 0x3091: mapif_load_homun(fd); break; - case 0x3092: mapif_parse_SaveHomun(fd); break; - case 0x3093: mapif_parse_DeleteHomun(fd); break; - case 0x3094: mapif_parse_RenameHomun(fd); break; - default: - return 0; + unsigned short cmd = RFIFOW(fd,0); + + switch( cmd ) + { + case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; + case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break; + case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; + default: + return 0; } return 1; } diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 1858ed4ba..1c0d76269 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -1,15 +1,18 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_HOMUN_H_ -#define _INT_HOMUN_H_ +#ifndef _INT_HOMUN_SQL_H_ +#define _INT_HOMUN_SQL_H_ -int inter_homun_init(void); -void inter_homun_final(void); -int inter_homun_save(void); -int inter_homun_delete(int homun_id); -int inter_homun_parse_frommap(int fd); +struct s_homunculus; -extern char homun_txt[1024]; +int inter_homunculus_sql_init(void); +void inter_homunculus_sql_final(void); +int inter_homunculus_parse_frommap(int fd); -#endif /* _INT_HOMUN_H_ */ +bool mapif_homunculus_save(struct s_homunculus* hd); +bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd); +bool mapif_homunculus_delete(int homun_id); +bool mapif_homunculus_rename(char *name); + +#endif /* _INT_HOMUN_SQL_H_ */ diff --git a/src/char/int_mail.c b/src/char/int_mail.c new file mode 100644 index 000000000..b19b732c7 --- /dev/null +++ b/src/char/int_mail.c @@ -0,0 +1,476 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/timer.h" +#include "char.h" +#include "inter.h" + +#include +#include +#include + +static int mail_fromsql(int char_id, struct mail_data* md) +{ + int i, j; + struct mail_message *msg; + struct item *item; + char *data; + StringBuf buf; + + memset(md, 0, sizeof(struct mail_data)); + md->amount = 0; + md->full = false; + + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`," + "`zeny`,`amount`,`nameid`,`refine`,`attribute`,`identify`"); + for (i = 0; i < MAX_SLOTS; i++) + StringBuf_Printf(&buf, ",`card%d`", i); + + // I keep the `status` < 3 just in case someone forget to apply the sqlfix + StringBuf_Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d", + mail_db, char_id, MAIL_MAX_INBOX + 1); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); + + StringBuf_Destroy(&buf); + + for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + msg = &md->msg[i]; + Sql_GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); + Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); + Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); + item = &msg->item; + Sql_GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data); + Sql_GetData(sql_handle,11, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle,12, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data); + Sql_GetData(sql_handle,14, &data, NULL); item->identify = atoi(data); + item->expire_time = 0; + + for (j = 0; j < MAX_SLOTS; j++) + { + Sql_GetData(sql_handle, 15 + j, &data, NULL); + item->card[j] = atoi(data); + } + } + + md->full = ( Sql_NumRows(sql_handle) > MAIL_MAX_INBOX ); + + md->amount = i; + Sql_FreeResult(sql_handle); + + md->unchecked = 0; + md->unread = 0; + for (i = 0; i < md->amount; i++) + { + msg = &md->msg[i]; + if( msg->status == MAIL_NEW ) + { + if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) ) + Sql_ShowDebug(sql_handle); + + msg->status = MAIL_UNREAD; + md->unchecked++; + } + else if ( msg->status == MAIL_UNREAD ) + md->unread++; + } + + ShowInfo("mail load complete from DB - id: %d (total: %d)\n", char_id, md->amount); + return 1; +} + +/// Stores a single message in the database. +/// Returns the message's ID if successful (or 0 if it fails). +int mail_savemessage(struct mail_message* msg) +{ + StringBuf buf; + SqlStmt* stmt; + int j; + + // build message save query + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`", mail_db); + for (j = 0; j < MAX_SLOTS; j++) + StringBuf_Printf(&buf, ", `card%d`", j); + StringBuf_Printf(&buf, ") VALUES (?, '%d', ?, '%d', ?, ?, '%lu', '%d', '%d', '%d', '%d', '%d', '%d', '%d'", + msg->send_id, msg->dest_id, (unsigned long)msg->timestamp, msg->status, msg->zeny, msg->item.amount, msg->item.nameid, msg->item.refine, msg->item.attribute, msg->item.identify); + for (j = 0; j < MAX_SLOTS; j++) + StringBuf_Printf(&buf, ", '%d'", msg->item.card[j]); + StringBuf_AppendStr(&buf, ")"); + + // prepare and execute query + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, msg->title, strnlen(msg->title, MAIL_TITLE_LENGTH)) + || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, msg->body, strnlen(msg->body, MAIL_BODY_LENGTH)) + || SQL_SUCCESS != SqlStmt_Execute(stmt) ) + { + SqlStmt_ShowDebug(stmt); + msg->id = 0; + } else + msg->id = (int)SqlStmt_LastInsertId(stmt); + + SqlStmt_Free(stmt); + StringBuf_Destroy(&buf); + + return msg->id; +} + +/// Retrieves a single message from the database. +/// Returns true if the operation succeeds (or false if it fails). +static bool mail_loadmessage(int mail_id, struct mail_message* msg) +{ + int j; + StringBuf buf; + + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`," + "`zeny`,`amount`,`nameid`,`refine`,`attribute`,`identify`"); + for( j = 0; j < MAX_SLOTS; j++ ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) + || SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_ShowDebug(sql_handle); + Sql_FreeResult(sql_handle); + StringBuf_Destroy(&buf); + return false; + } + else + { + char* data; + + Sql_GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH); + Sql_GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); + Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); + Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); + Sql_GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data); + Sql_GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data); + Sql_GetData(sql_handle,12, &data, NULL); msg->item.refine = atoi(data); + Sql_GetData(sql_handle,13, &data, NULL); msg->item.attribute = atoi(data); + Sql_GetData(sql_handle,14, &data, NULL); msg->item.identify = atoi(data); + msg->item.expire_time = 0; + + for( j = 0; j < MAX_SLOTS; j++ ) + { + Sql_GetData(sql_handle,15 + j, &data, NULL); + msg->item.card[j] = atoi(data); + } + } + + StringBuf_Destroy(&buf); + Sql_FreeResult(sql_handle); + + return true; +} + +/*========================================== + * Client Inbox Request + *------------------------------------------*/ +static void mapif_Mail_sendinbox(int fd, int char_id, unsigned char flag) +{ + struct mail_data md; + mail_fromsql(char_id, &md); + + //FIXME: dumping the whole structure like this is unsafe [ultramage] + WFIFOHEAD(fd, sizeof(md) + 9); + WFIFOW(fd,0) = 0x3848; + WFIFOW(fd,2) = sizeof(md) + 9; + WFIFOL(fd,4) = char_id; + WFIFOB(fd,8) = flag; + memcpy(WFIFOP(fd,9),&md,sizeof(md)); + WFIFOSET(fd,WFIFOW(fd,2)); +} + +static void mapif_parse_Mail_requestinbox(int fd) +{ + mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6)); +} + +/*========================================== + * Mark mail as 'Read' + *------------------------------------------*/ +static void mapif_parse_Mail_read(int fd) +{ + int mail_id = RFIFOL(fd,2); + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) ) + Sql_ShowDebug(sql_handle); +} + +/*========================================== + * Client Attachment Request + *------------------------------------------*/ +static bool mail_DeleteAttach(int mail_id) +{ + StringBuf buf; + int i; + + StringBuf_Init(&buf); + StringBuf_Printf(&buf, "UPDATE `%s` SET `zeny` = '0', `nameid` = '0', `amount` = '0', `refine` = '0', `attribute` = '0', `identify` = '0'", mail_db); + for (i = 0; i < MAX_SLOTS; i++) + StringBuf_Printf(&buf, ", `card%d` = '0'", i); + StringBuf_Printf(&buf, " WHERE `id` = '%d'", mail_id); + + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + { + Sql_ShowDebug(sql_handle); + StringBuf_Destroy(&buf); + + return false; + } + + StringBuf_Destroy(&buf); + return true; +} + +static void mapif_Mail_getattach(int fd, int char_id, int mail_id) +{ + struct mail_message msg; + + if( !mail_loadmessage(mail_id, &msg) ) + return; + + if( msg.dest_id != char_id ) + return; + + if( msg.status != MAIL_READ ) + return; + + if( (msg.item.nameid < 1 || msg.item.amount < 1) && msg.zeny < 1 ) + return; // No Attachment + + if( !mail_DeleteAttach(mail_id) ) + return; + + WFIFOHEAD(fd, sizeof(struct item) + 12); + WFIFOW(fd,0) = 0x384a; + WFIFOW(fd,2) = sizeof(struct item) + 12; + WFIFOL(fd,4) = char_id; + WFIFOL(fd,8) = (msg.zeny > 0)?msg.zeny:0; + memcpy(WFIFOP(fd,12), &msg.item, sizeof(struct item)); + WFIFOSET(fd,WFIFOW(fd,2)); +} + +static void mapif_parse_Mail_getattach(int fd) +{ + mapif_Mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6)); +} + +/*========================================== + * Delete Mail + *------------------------------------------*/ +static void mapif_Mail_delete(int fd, int char_id, int mail_id) +{ + bool failed = false; + if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) ) + { + Sql_ShowDebug(sql_handle); + failed = true; + } + + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x384b; + WFIFOL(fd,2) = char_id; + WFIFOL(fd,6) = mail_id; + WFIFOB(fd,10) = failed; + WFIFOSET(fd,11); +} + +static void mapif_parse_Mail_delete(int fd) +{ + mapif_Mail_delete(fd, RFIFOL(fd,2), RFIFOL(fd,6)); +} + +/*========================================== + * Report New Mail to Map Server + *------------------------------------------*/ +void mapif_Mail_new(struct mail_message *msg) +{ + unsigned char buf[74]; + + if( !msg || !msg->id ) + return; + + WBUFW(buf,0) = 0x3849; + WBUFL(buf,2) = msg->dest_id; + WBUFL(buf,6) = msg->id; + memcpy(WBUFP(buf,10), msg->send_name, NAME_LENGTH); + memcpy(WBUFP(buf,34), msg->title, MAIL_TITLE_LENGTH); + mapif_sendall(buf, 74); +} + +/*========================================== + * Return Mail + *------------------------------------------*/ +static void mapif_Mail_return(int fd, int char_id, int mail_id) +{ + struct mail_message msg; + int new_mail = 0; + + if( mail_loadmessage(mail_id, &msg) ) + { + if( msg.dest_id != char_id) + return; + else if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) ) + Sql_ShowDebug(sql_handle); + else + { + char temp_[MAIL_TITLE_LENGTH]; + + // swap sender and receiver + swap(msg.send_id, msg.dest_id); + safestrncpy(temp_, msg.send_name, NAME_LENGTH); + safestrncpy(msg.send_name, msg.dest_name, NAME_LENGTH); + safestrncpy(msg.dest_name, temp_, NAME_LENGTH); + + // set reply message title + snprintf(temp_, MAIL_TITLE_LENGTH, "RE:%s", msg.title); + safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH); + + msg.status = MAIL_NEW; + msg.timestamp = time(NULL); + + new_mail = mail_savemessage(&msg); + mapif_Mail_new(&msg); + } + } + + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x384c; + WFIFOL(fd,2) = char_id; + WFIFOL(fd,6) = mail_id; + WFIFOB(fd,10) = (new_mail == 0); + WFIFOSET(fd,11); +} + +static void mapif_parse_Mail_return(int fd) +{ + mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6)); +} + +/*========================================== + * Send Mail + *------------------------------------------*/ +static void mapif_Mail_send(int fd, struct mail_message* msg) +{ + int len = sizeof(struct mail_message) + 4; + + WFIFOHEAD(fd,len); + WFIFOW(fd,0) = 0x384d; + WFIFOW(fd,2) = len; + memcpy(WFIFOP(fd,4), msg, sizeof(struct mail_message)); + WFIFOSET(fd,len); +} + +static void mapif_parse_Mail_send(int fd) +{ + struct mail_message msg; + char esc_name[NAME_LENGTH*2+1]; + int account_id = 0; + + if(RFIFOW(fd,2) != 8 + sizeof(struct mail_message)) + return; + + account_id = RFIFOL(fd,4); + memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message)); + + // Try to find the Dest Char by Name + Sql_EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH)); + if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) + Sql_ShowDebug(sql_handle); + else + if ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + char *data; + Sql_GetData(sql_handle, 0, &data, NULL); + if (atoi(data) != account_id) + { // Cannot send mail to char in the same account + Sql_GetData(sql_handle, 1, &data, NULL); + msg.dest_id = atoi(data); + } + } + Sql_FreeResult(sql_handle); + msg.status = MAIL_NEW; + + if( msg.dest_id > 0 ) + msg.id = mail_savemessage(&msg); + + mapif_Mail_send(fd, &msg); +} + +void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item) +{ + struct mail_message msg; + memset(&msg, 0, sizeof(struct mail_message)); + + msg.send_id = send_id; + safestrncpy(msg.send_name, send_name, NAME_LENGTH); + msg.dest_id = dest_id; + safestrncpy(msg.dest_name, dest_name, NAME_LENGTH); + safestrncpy(msg.title, title, MAIL_TITLE_LENGTH); + safestrncpy(msg.body, body, MAIL_BODY_LENGTH); + msg.zeny = zeny; + if( item != NULL ) + memcpy(&msg.item, item, sizeof(struct item)); + + msg.timestamp = time(NULL); + + mail_savemessage(&msg); + mapif_Mail_new(&msg); +} + +/*========================================== + * Packets From Map Server + *------------------------------------------*/ +int inter_mail_parse_frommap(int fd) +{ + switch(RFIFOW(fd,0)) + { + case 0x3048: mapif_parse_Mail_requestinbox(fd); break; + case 0x3049: mapif_parse_Mail_read(fd); break; + case 0x304a: mapif_parse_Mail_getattach(fd); break; + case 0x304b: mapif_parse_Mail_delete(fd); break; + case 0x304c: mapif_parse_Mail_return(fd); break; + case 0x304d: mapif_parse_Mail_send(fd); break; + default: + return 0; + } + return 1; +} + +int inter_mail_sql_init(void) +{ + return 1; +} + +void inter_mail_sql_final(void) +{ + return; +} diff --git a/src/char/int_mail.h b/src/char/int_mail.h new file mode 100644 index 000000000..77db51e5b --- /dev/null +++ b/src/char/int_mail.h @@ -0,0 +1,16 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _INT_MAIL_SQL_H_ +#define _INT_MAIL_SQL_H_ + +int inter_mail_parse_frommap(int fd); +void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); + +int inter_mail_sql_init(void); +void inter_mail_sql_final(void); + +int mail_savemessage(struct mail_message* msg); +void mapif_Mail_new(struct mail_message *msg); + +#endif /* _INT_MAIL_SQL_H_ */ diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c new file mode 100644 index 000000000..1b11878b8 --- /dev/null +++ b/src/char/int_mercenary.c @@ -0,0 +1,218 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include +#include +#include + +bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) +{ + char* data; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, NULL); status->mer_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); status->arch_calls = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); status->arch_faith = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); status->spear_calls = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); status->spear_faith = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); status->sword_calls = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); status->sword_faith = atoi(data); + Sql_FreeResult(sql_handle); + + return true; +} + +bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) +{ + if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `mercenary_owner` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; +} + +bool mercenary_owner_delete(int char_id) +{ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) ) + Sql_ShowDebug(sql_handle); + + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `char_id` = '%d'", char_id) ) + Sql_ShowDebug(sql_handle); + + return true; +} + +bool mapif_mercenary_save(struct s_mercenary* merc) +{ + bool flag = true; + + if( merc->mercenary_id == 0 ) + { // Create new DB entry + if( SQL_ERROR == Sql_Query(sql_handle, + "INSERT INTO `mercenary` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')", + merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) ) + { + Sql_ShowDebug(sql_handle); + flag = false; + } + else + merc->mercenary_id = (int)Sql_LastInsertId(sql_handle); + } + else if( SQL_ERROR == Sql_Query(sql_handle, + "UPDATE `mercenary` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'", + merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) ) + { // Update DB entry + Sql_ShowDebug(sql_handle); + flag = false; + } + + return flag; +} + +bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) +{ + char* data; + + memset(merc, 0, sizeof(struct s_mercenary)); + merc->mercenary_id = merc_id; + merc->char_id = char_id; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `mer_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, NULL); merc->class_ = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); merc->hp = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); merc->sp = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); merc->kill_count = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); merc->life_time = atoi(data); + Sql_FreeResult(sql_handle); + if( save_log ) + ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id); + + return true; +} + +bool mapif_mercenary_delete(int merc_id) +{ + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `mer_id` = '%d'", merc_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; +} + +static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) +{ + int size = sizeof(struct s_mercenary) + 5; + + WFIFOHEAD(fd,size); + WFIFOW(fd,0) = 0x3870; + WFIFOW(fd,2) = size; + WFIFOB(fd,4) = flag; + memcpy(WFIFOP(fd,5),merc,sizeof(struct s_mercenary)); + WFIFOSET(fd,size); +} + +static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc) +{ + bool result = mapif_mercenary_save(merc); + mapif_mercenary_send(fd, merc, result); +} + +static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) +{ + struct s_mercenary merc; + bool result = mapif_mercenary_load(merc_id, char_id, &merc); + mapif_mercenary_send(fd, &merc, result); +} + +static void mapif_mercenary_deleted(int fd, unsigned char flag) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x3871; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,3); +} + +static void mapif_parse_mercenary_delete(int fd, int merc_id) +{ + bool result = mapif_mercenary_delete(merc_id); + mapif_mercenary_deleted(fd, result); +} + +static void mapif_mercenary_saved(int fd, unsigned char flag) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x3872; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,3); +} + +static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc) +{ + bool result = mapif_mercenary_save(merc); + mapif_mercenary_saved(fd, result); +} + +int inter_mercenary_sql_init(void) +{ + return 0; +} +void inter_mercenary_sql_final(void) +{ + return; +} + +/*========================================== + * Inter Packets + *------------------------------------------*/ +int inter_mercenary_parse_frommap(int fd) +{ + unsigned short cmd = RFIFOW(fd,0); + + switch( cmd ) + { + case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; + case 0x3072: mapif_parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break; + case 0x3073: mapif_parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + default: + return 0; + } + return 1; +} diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h new file mode 100644 index 000000000..01e4a841f --- /dev/null +++ b/src/char/int_mercenary.h @@ -0,0 +1,20 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _INT_MERCENARY_SQL_H_ +#define _INT_MERCENARY_SQL_H_ + +struct s_mercenary; + +int inter_mercenary_sql_init(void); +void inter_mercenary_sql_final(void); +int inter_mercenary_parse_frommap(int fd); + +// Mercenary Owner Database +bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status); +bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status); +bool mercenary_owner_delete(int char_id); + +bool mapif_mercenary_delete(int merc_id); + +#endif /* _INT_MERCENARY_SQL_H_ */ diff --git a/src/char/int_party.c b/src/char/int_party.c index 2ae9e5319..7d0dd0b75 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -3,11 +3,13 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" +#include "../common/db.h" #include "../common/malloc.h" +#include "../common/strlib.h" #include "../common/socket.h" -#include "../common/db.h" -#include "../common/lock.h" #include "../common/showmsg.h" +#include "../common/mapindex.h" +#include "../common/sql.h" #include "char.h" #include "inter.h" #include "int_party.h" @@ -16,8 +18,6 @@ #include #include -char party_txt[1024] = "save/party.txt"; -#ifndef TXT_SQL_CONVERT struct party_data { struct party party; unsigned int min_lv, max_lv; @@ -25,11 +25,11 @@ struct party_data { unsigned char size; //Total size of party. }; -static DBMap* party_db; // int party_id -> struct party_data* -static int party_newid = 100; +static struct party_data *party_pt; +static DBMap* party_db_; // int party_id -> struct party_data* -int mapif_party_broken(int party_id, int flag); -int party_check_empty(struct party *p); +int mapif_party_broken(int party_id,int flag); +int party_check_empty(struct party_data *p); int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id); int party_check_exp_share(struct party_data *p); int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag); @@ -41,7 +41,10 @@ static int int_party_check_lv(struct party_data *p) { p->min_lv = UINT_MAX; p->max_lv = 0; for(i=0;iparty.member[i].online) + /** + * - If not online OR if it's a family party and this is the child (doesn't affect exp range) + **/ + if(!p->party.member[i].online || p->party.member[i].char_id == p->family ) continue; lv=p->party.member[i].lv; @@ -56,7 +59,6 @@ static int int_party_check_lv(struct party_data *p) { } return 1; } - //Calculates the state of a party. static void int_party_calc_state(struct party_data *p) { @@ -68,14 +70,20 @@ static void int_party_calc_state(struct party_data *p) p->size = p->family = 0; - //Check party size. + //Check party size for(i=0;iparty.member[i].lv) continue; p->size++; if(p->party.member[i].online) p->party.count++; } - if(p->size == 3) { + if( p->size == 2 && ( char_child(p->party.member[0].char_id,p->party.member[1].char_id) || char_child(p->party.member[1].char_id,p->party.member[0].char_id) ) ) { + //Child should be able to share with either of their parents [RoM] + if(p->party.member[0].class_&0x2000) //first slot is the child? + p->family = p->party.member[0].char_id; + else + p->family = p->party.member[1].char_id; + } else if( p->size == 3 ) { //Check Family State. p->family = char_family( p->party.member[0].char_id, @@ -103,212 +111,244 @@ static void int_party_calc_state(struct party_data *p) return; } -// ƒp?ƒeƒBƒf?ƒ^‚Ì•¶Žš—ñ‚Ö‚Ì?Š· -int inter_party_tostr(char *str, struct party *p) { - int i, len; +// Save party to mysql +int inter_party_tosql(struct party *p, int flag, int index) +{ + // 'party' ('party_id','name','exp','item','leader_id','leader_char') + char esc_name[NAME_LENGTH*2+1];// escaped party name + int party_id; - len = sprintf(str, "%d\t%s\t%d,%d\t", p->party_id, p->name, p->exp, p->item); - for(i = 0; i < MAX_PARTY; i++) { - struct party_member *m = &p->member[i]; - len += sprintf(str + len, "%d,%d,%d\t", m->account_id, m->char_id, m->leader); - } + if( p == NULL || p->party_id == 0 ) + return 0; + party_id = p->party_id; - return 0; -} -#endif //TXT_SQL_CONVERT -// ƒp?ƒeƒBƒf?ƒ^‚Ì•¶Žš—ñ‚©‚ç‚Ì?Š· -int inter_party_fromstr(char *str, struct party *p) { - int i, j; - int tmp_int[16]; - char tmp_str[256]; -#ifndef TXT_SQL_CONVERT - struct mmo_charstatus* status; +#ifdef NOISY + ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name); #endif - - memset(p, 0, sizeof(struct party)); - - if (sscanf(str, "%d\t%255[^\t]\t%d,%d\t", &tmp_int[0], tmp_str, &tmp_int[1], &tmp_int[2]) != 4) + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + + if( flag & PS_BREAK ) + {// Break the party + // we'll skip name-checking and just reset everyone with the same party id [celest] + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) + Sql_ShowDebug(sql_handle); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) + Sql_ShowDebug(sql_handle); + //Remove from memory + idb_remove(party_db_, party_id); return 1; + } - p->party_id = tmp_int[0]; - memcpy(p->name, tmp_str, NAME_LENGTH); - p->exp = tmp_int[1]?1:0; - p->item = tmp_int[2]; - - for(j = 0; j < 3 && str != NULL; j++) - str = strchr(str + 1, '\t'); - - for(i = 0; i < MAX_PARTY; i++) { - struct party_member *m = &p->member[i]; - if (str == NULL) - return 1; + if( flag & PS_CREATE ) + {// Create party + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " + "(`name`, `exp`, `item`, `leader_id`, `leader_char`) " + "VALUES ('%s', '%d', '%d', '%d', '%d')", + party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + party_id = p->party_id = (int)Sql_LastInsertId(sql_handle); + } - if (sscanf(str + 1, "%d,%d,%d\t", &tmp_int[0], &tmp_int[1], &tmp_int[2]) != 3) - return 1; + if( flag & PS_BASIC ) + {// Update party info. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'", + party_db, esc_name, p->exp, p->item, party_id) ) + Sql_ShowDebug(sql_handle); + } - m->account_id = tmp_int[0]; - m->char_id = tmp_int[1]; - m->leader = tmp_int[2]?1:0; + if( flag & PS_LEADER ) + {// Update leader + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'", + party_db, p->member[index].account_id, p->member[index].char_id, party_id) ) + Sql_ShowDebug(sql_handle); + } + + if( flag & PS_ADDMEMBER ) + {// Add one party member. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'", + char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) + Sql_ShowDebug(sql_handle); + } - str = strchr(str + 1, '\t'); -#ifndef TXT_SQL_CONVERT - if (!m->account_id) continue; - //Lookup player for rest of data. - status = search_character(m->account_id, m->char_id); - if (!status) continue; - - memcpy(m->name, status->name, NAME_LENGTH); - m->class_ = status->class_; - m->map = status->last_point.map; - m->lv = status->base_level; -#endif //TXT_SQL_CONVERT + if( flag & PS_DELMEMBER ) + {// Remove one party member. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'", + char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) + Sql_ShowDebug(sql_handle); } - return 0; + if( save_log ) + ShowInfo("Party Saved (%d - %s)\n", party_id, p->name); + return 1; } -#ifndef TXT_SQL_CONVERT -// ƒp?ƒeƒBƒf?ƒ^‚̃?ƒh -int inter_party_init() { - char line[8192]; - struct party_data *p; - FILE *fp; - int c = 0; - int i, j; - party_db = idb_alloc(DB_OPT_RELEASE_DATA); +// Read party from mysql +struct party_data *inter_party_fromsql(int party_id) +{ + int leader_id = 0; + int leader_char = 0; + struct party_data* p; + struct party_member* m; + char* data; + size_t len; + int i; - if ((fp = fopen(party_txt, "r")) == NULL) - return 1; +#ifdef NOISY + ShowInfo("Load party request ("CL_BOLD"%d"CL_RESET")\n", party_id); +#endif + if( party_id <= 0 ) + return NULL; + + //Load from memory + p = (struct party_data*)idb_get(party_db_, party_id); + if( p != NULL ) + return p; - while(fgets(line, sizeof(line), fp)) - { - j = 0; - if (sscanf(line, "%d\t%%newid%%\n%n", &i, &j) == 1 && j > 0 && party_newid <= i) { - party_newid = i; - continue; - } + p = party_pt; + memset(p, 0, sizeof(struct party_data)); - p = (struct party_data*)aCalloc(sizeof(struct party_data), 1); - if (p == NULL){ - ShowFatalError("int_party: out of memory!\n"); - exit(EXIT_FAILURE); - } - memset(p, 0, sizeof(struct party_data)); - if (inter_party_fromstr(line, &p->party) == 0 && p->party.party_id > 0) { - int_party_calc_state(p); - if (p->party.party_id >= party_newid) - party_newid = p->party.party_id + 1; - idb_put(party_db, p->party.party_id, p); - party_check_empty(&p->party); - } else { - ShowError("int_party: broken data [%s] line %d\n", party_txt, c + 1); - aFree(p); - } - c++; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) + { + Sql_ShowDebug(sql_handle); + return NULL; } - fclose(fp); - return 0; -} + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + return NULL; -void inter_party_final() -{ - party_db->destroy(party_db, NULL); - return; -} + p->party.party_id = party_id; + Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0); + Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data); + Sql_FreeResult(sql_handle); -// ƒp?ƒeƒB?ƒf?ƒ^‚̃Z?ƒu—p -int inter_party_save_sub(DBKey key, void *data, va_list ap) { - char line[8192]; - FILE *fp; + // Load members + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) ) + { + Sql_ShowDebug(sql_handle); + return NULL; + } + for( i = 0; i < MAX_PARTY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + m = &p->party.member[i]; + Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data); + Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0); + Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data); + m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0); + } + Sql_FreeResult(sql_handle); + + if( save_log ) + ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name); + //Add party to memory. + CREATE(p, struct party_data, 1); + memcpy(p, party_pt, sizeof(struct party_data)); + //init state + int_party_calc_state(p); + idb_put(party_db_, party_id, p); + return p; +} - inter_party_tostr(line, &((struct party_data*)data)->party); - fp = va_arg(ap, FILE *); - fprintf(fp, "%s\n", line); +int inter_party_sql_init(void) +{ + //memory alloc + party_db_ = idb_alloc(DB_OPT_RELEASE_DATA); + party_pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1); + if (!party_pt) { + ShowFatalError("inter_party_sql_init: Out of Memory!\n"); + exit(EXIT_FAILURE); + } + /* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex] + ShowStatus("cleaning party table...\n"); + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL", + party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) ) + Sql_ShowDebug(sql_handle); + */ return 0; } -// ƒp?ƒeƒB?ƒf?ƒ^‚̃Z?ƒu -int inter_party_save() { - FILE *fp; - int lock; - - if ((fp = lock_fopen(party_txt, &lock)) == NULL) { - ShowError("int_party: can't write [%s] !!! data is lost !!!\n", party_txt); - return 1; - } - party_db->foreach(party_db, inter_party_save_sub, fp); - lock_fclose(fp,party_txt, &lock); - return 0; +void inter_party_sql_final(void) +{ + party_db_->destroy(party_db_, NULL); + aFree(party_pt); + return; } // Search for the party according to its name -struct party_data* search_partyname(char *str) +struct party_data* search_partyname(char* str) { - struct DBIterator* iter; - struct party_data* p; - struct party_data* result = NULL; - - iter = party_db->iterator(party_db); - for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) ) + char esc_name[NAME_LENGTH*2+1]; + char* data; + struct party_data* p = NULL; + + Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) ) + Sql_ShowDebug(sql_handle); + else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) { - if( strncmpi(p->party.name, str, NAME_LENGTH) == 0 ) - { - result = p; - break; - } + Sql_GetData(sql_handle, 0, &data, NULL); + p = inter_party_fromsql(atoi(data)); } - iter->destroy(iter); + Sql_FreeResult(sql_handle); - return result; + return p; } // Returns whether this party can keep having exp share or not. -int party_check_exp_share(struct party_data *p) { - return (p->party.count < 2|| p->max_lv - p->min_lv <= party_share_level); +int party_check_exp_share(struct party_data *p) +{ + return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level); } -// ƒp?ƒeƒB‚ª‹ó‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN -int party_check_empty(struct party *p) { +// Is there any member in the party? +int party_check_empty(struct party_data *p) +{ int i; - - for(i = 0; i < MAX_PARTY; i++) { - if (p->member[i].account_id > 0) { - return 0; - } - } - mapif_party_broken(p->party_id, 0); - idb_remove(party_db, p->party_id); - + if (p==NULL||p->party.party_id==0) return 1; + for(i=0;iparty.member[i].account_id;i++); + if (i < MAX_PARTY) return 0; + // If there is no member, then break the party + mapif_party_broken(p->party.party_id,0); + inter_party_tosql(&p->party, PS_BREAK, 0); return 1; } //------------------------------------------------------------------- // map server‚Ö‚Ì’ÊM -// ƒp?ƒeƒBì¬‰Â”Û -int mapif_party_created(int fd,int account_id, int char_id, struct party *p) +// ƒp[ƒeƒBì¬‰Â”Û +int mapif_party_created(int fd,int account_id,int char_id,struct party *p) { WFIFOHEAD(fd, 39); - WFIFOW(fd,0) = 0x3820; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = char_id; - if (p != NULL) { - WFIFOB(fd,10) = 0; - WFIFOL(fd,11) = p->party_id; - memcpy(WFIFOP(fd,15), p->name, NAME_LENGTH); - ShowInfo("Created party (%d - %s)\n", p->party_id, p->name); - } else { - WFIFOB(fd,10) = 1; - WFIFOL(fd,11) = 0; - memset(WFIFOP(fd,15), 0, NAME_LENGTH); + WFIFOW(fd,0)=0x3820; + WFIFOL(fd,2)=account_id; + WFIFOL(fd,6)=char_id; + if(p!=NULL){ + WFIFOB(fd,10)=0; + WFIFOL(fd,11)=p->party_id; + memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH); + ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name); + }else{ + WFIFOB(fd,10)=1; + WFIFOL(fd,11)=0; + memset(WFIFOP(fd,15),0,NAME_LENGTH); } WFIFOSET(fd,39); + return 0; } -// ƒp?ƒeƒBî•ñŒ©‚‚©‚炸 +// ƒp[ƒeƒBî•ñŒ©‚‚©‚炸 static void mapif_party_noinfo(int fd, int party_id, int char_id) { WFIFOHEAD(fd, 12); @@ -319,8 +359,7 @@ static void mapif_party_noinfo(int fd, int party_id, int char_id) WFIFOSET(fd,12); ShowWarning("int_party: info not found (party_id=%d char_id=%d)\n", party_id, char_id); } - -// ƒp?ƒeƒBî•ñ‚܂Ƃߑ—‚è +// ƒp[ƒeƒBî•ñ‚܂Ƃߑ—‚è static void mapif_party_info(int fd, struct party* p, int char_id) { unsigned char buf[8 + sizeof(struct party)]; @@ -328,13 +367,13 @@ static void mapif_party_info(int fd, struct party* p, int char_id) WBUFW(buf,2) = 8 + sizeof(struct party); WBUFL(buf,4) = char_id; memcpy(WBUFP(buf,8), p, sizeof(struct party)); - if (fd < 0) - mapif_sendall(buf, WBUFW(buf,2)); + + if(fd<0) + mapif_sendall(buf,WBUFW(buf,2)); else - mapif_send(fd, buf, WBUFW(buf,2)); + mapif_send(fd,buf,WBUFW(buf,2)); } - -// ƒp?ƒeƒBƒƒ“ƒo’ljÁ‰Â”Û +// ƒp[ƒeƒBƒƒ“ƒo’ljÁ‰Â”Û int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) { WFIFOHEAD(fd, 15); WFIFOW(fd,0) = 0x3822; @@ -347,24 +386,24 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, i return 0; } -// ƒp?ƒeƒBÝ’è?X’Ê’m -int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag) { - unsigned char buf[15]; - - WBUFW(buf,0) = 0x3823; - WBUFL(buf,2) = p->party_id; - WBUFL(buf,6) = account_id; - WBUFW(buf,10) = p->exp; - WBUFW(buf,12) = p->item; - WBUFB(buf,14) = flag; - if (flag == 0) - mapif_sendall(buf, 15); +// ƒp[ƒeƒBÝ’è•ÏX’Ê’m +int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag) +{ + unsigned char buf[16]; + WBUFW(buf,0)=0x3823; + WBUFL(buf,2)=p->party_id; + WBUFL(buf,6)=account_id; + WBUFW(buf,10)=p->exp; + WBUFW(buf,12)=p->item; + WBUFB(buf,14)=flag; + if(flag==0) + mapif_sendall(buf,15); else - mapif_send(fd, buf, 15); + mapif_send(fd,buf,15); return 0; } -// ƒp?ƒeƒB?‘Þ’Ê’m +// ƒp[ƒeƒB’E‘Þ’Ê’m int mapif_party_withdraw(int party_id,int account_id, int char_id) { unsigned char buf[16]; @@ -376,8 +415,9 @@ int mapif_party_withdraw(int party_id,int account_id, int char_id) { return 0; } -// ƒp?ƒeƒBƒ}ƒbƒvXV’Ê’m -int mapif_party_membermoved(struct party *p, int idx) { +// ƒp[ƒeƒBƒ}ƒbƒvXV’Ê’m +int mapif_party_membermoved(struct party *p,int idx) +{ unsigned char buf[20]; WBUFW(buf,0) = 0x3825; @@ -391,29 +431,27 @@ int mapif_party_membermoved(struct party *p, int idx) { return 0; } -// ƒp?ƒeƒB‰ðŽU’Ê’m -int mapif_party_broken(int party_id, int flag) { - unsigned char buf[7]; - WBUFW(buf,0) = 0x3826; - WBUFL(buf,2) = party_id; - WBUFB(buf,6) = flag; - mapif_sendall(buf, 7); - ShowInfo("Party broken (%d)\n", party_id); - +// ƒp[ƒeƒB‰ðŽU’Ê’m +int mapif_party_broken(int party_id,int flag) +{ + unsigned char buf[16]; + WBUFW(buf,0)=0x3826; + WBUFL(buf,2)=party_id; + WBUFB(buf,6)=flag; + mapif_sendall(buf,7); + //printf("int_party: broken %d\n",party_id); return 0; } - -// ƒp?ƒeƒB??Œ¾ -int mapif_party_message(int party_id, int account_id, char *mes, int len, int sfd) { - unsigned char buf[2048]; - - WBUFW(buf,0) = 0x3827; - WBUFW(buf,2) = len + 12; - WBUFL(buf,4) = party_id; - WBUFL(buf,8) = account_id; - memcpy(WBUFP(buf,12), mes, len); - mapif_sendallwos(sfd, buf,len + 12); - +// ƒp[ƒeƒB“à”­Œ¾ +int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd) +{ + unsigned char buf[512]; + WBUFW(buf,0)=0x3827; + WBUFW(buf,2)=len+12; + WBUFL(buf,4)=party_id; + WBUFL(buf,8)=account_id; + memcpy(WBUFP(buf,12),mes,len); + mapif_sendallwos(sfd, buf,len+12); return 0; } @@ -421,83 +459,72 @@ int mapif_party_message(int party_id, int account_id, char *mes, int len, int sf // map server‚©‚ç‚Ì’ÊM -// ƒp?ƒeƒB +// Create Party int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader) { struct party_data *p; int i; - - //FIXME: this should be removed once the savefiles can handle all symbols - for(i = 0; i < NAME_LENGTH && name[i]; i++) { - if (!(name[i] & 0xe0) || name[i] == 0x7f) { - ShowInfo("int_party: illegal party name [%s]\n", name); - mapif_party_created(fd, leader->account_id, leader->char_id, NULL); - return 0; - } - } - - if ((p = search_partyname(name)) != NULL) { - ShowInfo("int_party: same name party exists [%s]\n", name); - mapif_party_created(fd, leader->account_id, leader->char_id, NULL); + if( (p=search_partyname(name))!=NULL){ + mapif_party_created(fd,leader->account_id,leader->char_id,NULL); return 0; } - // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised for (i = 0; i < NAME_LENGTH && name[i]; i++) if (strchr(char_name_letters, name[i]) == NULL) { - mapif_party_created(fd, leader->account_id, leader->char_id, NULL); + mapif_party_created(fd,leader->account_id,leader->char_id,NULL); return 0; } } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden for (i = 0; i < NAME_LENGTH && name[i]; i++) if (strchr(char_name_letters, name[i]) != NULL) { - mapif_party_created(fd, leader->account_id, leader->char_id, NULL); + mapif_party_created(fd,leader->account_id,leader->char_id,NULL); return 0; } } - p = (struct party_data *) aCalloc(sizeof(struct party_data), 1); - if (p == NULL) { - ShowFatalError("int_party: out of memory !\n"); - mapif_party_created(fd,leader->account_id,leader->char_id,NULL); - return 0; - } - p->party.party_id = party_newid++; - memcpy(p->party.name, name, NAME_LENGTH); - p->party.exp = 0; + p = (struct party_data*)aCalloc(1, sizeof(struct party_data)); + + memcpy(p->party.name,name,NAME_LENGTH); + p->party.exp=0; p->party.item=(item?1:0)|(item2?2:0); + memcpy(&p->party.member[0], leader, sizeof(struct party_member)); - p->party.member[0].leader = 1; - int_party_calc_state(p); - idb_put(party_db, p->party.party_id, p); + p->party.member[0].leader=1; + p->party.member[0].online=1; - mapif_party_info(fd, &p->party, 0); - mapif_party_created(fd, leader->account_id, leader->char_id, &p->party); + p->party.party_id=-1;//New party. + if (inter_party_tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) { + //Add party to db + int_party_calc_state(p); + idb_put(party_db_, p->party.party_id, p); + mapif_party_info(fd, &p->party, 0); + mapif_party_created(fd,leader->account_id,leader->char_id,&p->party); + } else { //Failed to create party. + aFree(p); + mapif_party_created(fd,leader->account_id,leader->char_id,NULL); + } return 0; } - -// ƒp?ƒeƒBî•ñ—v‹ +// ƒp[ƒeƒBî•ñ—v‹ static void mapif_parse_PartyInfo(int fd, int party_id, int char_id) { struct party_data *p; + p = inter_party_fromsql(party_id); - p = (struct party_data*)idb_get(party_db, party_id); - if (p != NULL) + if (p) mapif_party_info(fd, &p->party, char_id); - else { + else mapif_party_noinfo(fd, party_id, char_id); - } } - -// ƒp[ƒeƒB’ljÁ—v‹ +// ƒp[ƒeƒB’ljÁ—v‹ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) { struct party_data *p; int i; - p = (struct party_data*)idb_get(party_db, party_id); + p = inter_party_fromsql(party_id); if( p == NULL || p->size == MAX_PARTY ) { mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); return 0; @@ -514,7 +541,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member p->party.member[i].leader = 0; if (p->party.member[i].online) p->party.count++; p->size++; - if (p->size == 3) //Check family state. + if (p->size == 2 || p->size == 3) // Check family state. And also accept either of their Parents. [RoM] int_party_calc_state(p); else //Check even share range. if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { @@ -524,67 +551,89 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member mapif_party_info(-1, &p->party, 0); mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0); + inter_party_tosql(&p->party, PS_ADDMEMBER, i); return 0; } -// ƒp?ƒeƒB?Ý’è?X—v‹ -int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) +// ƒp[ƒeƒB[Ý’è•ÏX—v‹ +int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item) { struct party_data *p; int flag = 0; + p = inter_party_fromsql(party_id); - p = (struct party_data*)idb_get(party_db, party_id); - if (p == NULL) + if(!p) return 0; - p->party.exp = exp; - if (exp>0 && !party_check_exp_share(p)) { - flag |= 0x01; - p->party.exp = 0; + p->party.exp=exp; + if( exp && !party_check_exp_share(p) ){ + flag|=0x01; + p->party.exp=0; } - p->party.item = item&0x3; - mapif_party_optionchanged(fd, &p->party, account_id, flag); + p->party.item = item&0x3; //Filter out invalid values. + mapif_party_optionchanged(fd,&p->party,account_id,flag); + inter_party_tosql(&p->party, PS_BASIC, 0); return 0; } - -// ƒp?ƒeƒB?‘Þ—v‹ +// ƒp[ƒeƒB’E‘Þ—v‹ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) { struct party_data *p; - int i,lv; + int i,j=-1; - p = (struct party_data*)idb_get(party_db, party_id); - if (!p) return 0; + p = inter_party_fromsql(party_id); + if( p == NULL ) + {// Party does not exists? + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) + Sql_ShowDebug(sql_handle); + return 0; + } - for(i = 0; i < MAX_PARTY; i++) { + for (i = 0; i < MAX_PARTY; i++) { if(p->party.member[i].account_id == account_id && - p->party.member[i].char_id == char_id) + p->party.member[i].char_id == char_id) { + break; + } + } + if (i >= MAX_PARTY) + return 0; //Member not found? + + mapif_party_withdraw(party_id, account_id, char_id); + + if (p->party.member[i].leader){ + p->party.member[i].account_id = 0; + for (j = 0; j < MAX_PARTY; j++) { + if (!p->party.member[j].account_id) + continue; + mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id); + p->party.member[j].account_id = 0; + } + //Party gets deleted on the check_empty call below. + } else { + inter_party_tosql(&p->party,PS_DELMEMBER,i); + j = p->party.member[i].lv; + if(p->party.member[i].online) p->party.count--; + memset(&p->party.member[i], 0, sizeof(struct party_member)); + p->size--; + if (j == p->min_lv || j == p->max_lv || p->family) { - mapif_party_withdraw(party_id, account_id, char_id); - lv = p->party.member[i].lv; - if(p->party.member[i].online) p->party.count--; - memset(&p->party.member[i], 0, sizeof(struct party_member)); - p->size--; - if (lv == p->min_lv || lv == p->max_lv || p->family) - { - if(p->family) p->family = 0; //Family state broken. - int_party_check_lv(p); - } - if (party_check_empty(&p->party) == 0) - mapif_party_info(-1, &p->party, 0); - return 0; + if(p->family) p->family = 0; //Family state broken. + int_party_check_lv(p); } } + + if (party_check_empty(p) == 0) + mapif_party_info(-1, &p->party, 0); return 0; } - +// When member goes to other map or levels up. int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) { struct party_data *p; int i; - p = (struct party_data*)idb_get(party_db, party_id); + p = inter_party_fromsql(party_id); if (p == NULL) return 0; @@ -615,6 +664,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id //Send online/offline update. mapif_party_membermoved(&p->party, i); } + if (p->party.member[i].lv != lv) { if(p->party.member[i].lv == p->min_lv || p->party.member[i].lv == p->max_lv) @@ -626,6 +676,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id //There is no need to send level update to map servers //since they do nothing with it. } + if (p->party.member[i].map != map) { p->party.member[i].map = map; mapif_party_membermoved(&p->party, i); @@ -633,19 +684,23 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id return 0; } -// ƒp?ƒeƒB‰ðŽU—v‹ -int mapif_parse_BreakParty(int fd, int party_id) { +// ƒp[ƒeƒB‰ðŽU—v‹ +int mapif_parse_BreakParty(int fd,int party_id) +{ + struct party_data *p; - idb_remove(party_db, party_id); - mapif_party_broken(fd, party_id); + p = inter_party_fromsql(party_id); + if(!p) + return 0; + inter_party_tosql(&p->party,PS_BREAK,0); + mapif_party_broken(fd,party_id); return 0; } - -// ƒp?ƒeƒBƒƒbƒZ?ƒW‘—M -int mapif_parse_PartyMessage(int fd, int party_id, int account_id, char *mes, int len) +// ƒp[ƒeƒBƒƒbƒZ[ƒW‘—M +int mapif_parse_PartyMessage(int fd,int party_id,int account_id,char *mes,int len) { - return mapif_party_message(party_id, account_id, mes, len, fd); + return mapif_party_message(party_id,account_id,mes,len, fd); } int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id) @@ -653,8 +708,9 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id struct party_data *p; int i; - p = (struct party_data*)idb_get(party_db, party_id); - if (p == NULL) + p = inter_party_fromsql(party_id); + + if(!p) return 0; for (i = 0; i < MAX_PARTY; i++) @@ -663,17 +719,21 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id p->party.member[i].leader = 0; if(p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id) + { p->party.member[i].leader = 1; + inter_party_tosql(&p->party,PS_LEADER, i); + } } return 1; } // map server ‚©‚ç‚Ì’ÊM -// ?‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ -// ?ƒpƒPƒbƒg’·ƒf?ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ -// ?ƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ -// ?ƒGƒ‰?‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ -int inter_party_parse_frommap(int fd) { +// E‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ +// EƒpƒPƒbƒg’·ƒf[ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ +// EƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ +// EƒGƒ‰[‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ +int inter_party_parse_frommap(int fd) +{ RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { case 0x3020: mapif_parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break; @@ -688,12 +748,105 @@ int inter_party_parse_frommap(int fd) { default: return 0; } + return 1; +} + +// ƒT[ƒo[‚©‚ç’E‘Þ—v‹iƒLƒƒƒ‰íœ—pj +int inter_party_leave(int party_id,int account_id, int char_id) +{ + return mapif_parse_PartyLeave(-1,party_id,account_id, char_id); +} + +int inter_party_CharOnline(int char_id, int party_id) +{ + struct party_data* p; + int i; + + if( party_id == -1 ) + {// Get party_id from the database + char* data; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + return 0; //Eh? No party? + + Sql_GetData(sql_handle, 0, &data, NULL); + party_id = atoi(data); + Sql_FreeResult(sql_handle); + } + if (party_id == 0) + return 0; //No party... + + p = inter_party_fromsql(party_id); + if(!p) { + ShowError("Character %d's party %d not found!\n", char_id, party_id); + return 0; + } + + //Set member online + for(i=0; iparty.member[i].char_id == char_id) { + if (!p->party.member[i].online) { + p->party.member[i].online = 1; + p->party.count++; + if (p->party.member[i].lv < p->min_lv || + p->party.member[i].lv > p->max_lv) + int_party_check_lv(p); + } + break; + } + } return 1; } -// ƒT?ƒo?‚©‚ç?‘Þ—v‹iƒLƒƒƒ‰íœ—pj -int inter_party_leave(int party_id, int account_id, int char_id) { - return mapif_parse_PartyLeave(-1, party_id, account_id, char_id); +int inter_party_CharOffline(int char_id, int party_id) { + struct party_data *p=NULL; + int i; + + if( party_id == -1 ) + {// Get guild_id from the database + char* data; + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + return 0; //Eh? No party? + + Sql_GetData(sql_handle, 0, &data, NULL); + party_id = atoi(data); + Sql_FreeResult(sql_handle); + } + if (party_id == 0) + return 0; //No party... + + //Character has a party, set character offline and check if they were the only member online + if ((p = inter_party_fromsql(party_id)) == NULL) + return 0; + + //Set member offline + for(i=0; i< MAX_PARTY; i++) { + if(p->party.member[i].char_id == char_id) + { + p->party.member[i].online = 0; + p->party.count--; + if(p->party.member[i].lv == p->min_lv || + p->party.member[i].lv == p->max_lv) + int_party_check_lv(p); + break; + } + } + + if(!p->party.count) + //Parties don't have any data that needs be saved at this point... so just remove it from memory. + idb_remove(party_db_, party_id); + return 1; } -#endif //TXT_SQL_CONVERT diff --git a/src/char/int_party.h b/src/char/int_party.h index ad724e475..d7965c33b 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -1,20 +1,32 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_PARTY_H_ -#define _INT_PARTY_H_ +#ifndef _INT_PARTY_SQL_H_ +#define _INT_PARTY_SQL_H_ + +//Party Flags on what to save/delete. +//Create a new party entry (index holds leader's info) +#define PS_CREATE 0x01 +//Update basic party info. +#define PS_BASIC 0x02 +//Update party's leader +#define PS_LEADER 0x04 +//Specify new party member (index specifies which party member) +#define PS_ADDMEMBER 0x08 +//Specify member that left (index specifies which party member) +#define PS_DELMEMBER 0x10 +//Specify that this party must be deleted. +#define PS_BREAK 0x20 struct party; -int inter_party_init(void); -void inter_party_final(void); -int inter_party_save(void); int inter_party_parse_frommap(int fd); +int inter_party_sql_init(void); +void inter_party_sql_final(void); int inter_party_leave(int party_id,int account_id, int char_id); +int inter_party_CharOnline(int char_id, int party_id); +int inter_party_CharOffline(int char_id, int party_id); +//Required for the TXT->SQL converter +int inter_party_tosql(struct party *p, int flag, int index); -extern char party_txt[1024]; - -//For the TXT->SQL converter -int inter_party_fromstr(char *str, struct party *p); - -#endif /* _INT_PARTY_H_ */ +#endif /* _INT_PARTY_SQL_H_ */ diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 41d61fbc3..114398290 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -4,307 +4,251 @@ #include "../common/mmo.h" #include "../common/malloc.h" #include "../common/socket.h" -#include "../common/db.h" -#include "../common/lock.h" +#include "../common/strlib.h" #include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/sql.h" #include "char.h" #include "inter.h" -#include "int_pet.h" #include #include #include -char pet_txt[1024]="save/pet.txt"; +struct s_pet *pet_pt; -#ifndef TXT_SQL_CONVERT -static DBMap* pet_db; // int pet_id -> struct s_pet* -static int pet_newid = 100; - -int inter_pet_tostr(char *str,struct s_pet *p) +//--------------------------------------------------------- +int inter_pet_tosql(int pet_id, struct s_pet* p) { - int len; - - if(p->hungry < 0) - p->hungry = 0; - else if(p->hungry > 100) - p->hungry = 100; - if(p->intimate < 0) - p->intimate = 0; - else if(p->intimate > 1000) - p->intimate = 1000; - - len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d", - p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id, - p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate); + //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) + char esc_name[NAME_LENGTH*2+1];// escaped pet name + + Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); + p->hungry = cap_value(p->hungry, 0, 100); + p->intimate = cap_value(p->intimate, 0, 1000); + + if( pet_id == -1 ) + {// New pet. + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " + "(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) " + "VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", + pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, + p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + p->pet_id = (int)Sql_LastInsertId(sql_handle); + } + else + {// Update pet. + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", + pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, + p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) ) + { + Sql_ShowDebug(sql_handle); + return 0; + } + } - return 0; + if (save_log) + ShowInfo("Pet saved %d - %s.\n", pet_id, p->name); + return 1; } -#endif //TXT_SQL_CONVERT -int inter_pet_fromstr(char *str,struct s_pet *p) -{ - int s; - int tmp_int[16]; - char tmp_str[256]; - - memset(p,0,sizeof(struct s_pet)); - - s=sscanf(str,"%d,%d,%[^\t]\t%d,%d,%d,%d,%d,%d,%d,%d,%d",&tmp_int[0],&tmp_int[1],tmp_str,&tmp_int[2], - &tmp_int[3],&tmp_int[4],&tmp_int[5],&tmp_int[6],&tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10]); - - if(s!=12) - return 1; - - p->pet_id = tmp_int[0]; - p->class_ = tmp_int[1]; - memcpy(p->name,tmp_str,NAME_LENGTH); - p->account_id = tmp_int[2]; - p->char_id = tmp_int[3]; - p->level = tmp_int[4]; - p->egg_id = tmp_int[5]; - p->equip = tmp_int[6]; - p->intimate = tmp_int[7]; - p->hungry = tmp_int[8]; - p->rename_flag = tmp_int[9]; - p->incuvate = tmp_int[10]; - - if(p->hungry < 0) - p->hungry = 0; - else if(p->hungry > 100) - p->hungry = 100; - if(p->intimate < 0) - p->intimate = 0; - else if(p->intimate > 1000) - p->intimate = 1000; - return 0; -} -#ifndef TXT_SQL_CONVERT -int inter_pet_init() +int inter_pet_fromsql(int pet_id, struct s_pet* p) { - char line[8192]; - struct s_pet *p; - FILE *fp; - int c=0; + char* data; + size_t len; - pet_db= idb_alloc(DB_OPT_RELEASE_DATA); +#ifdef NOISY + ShowInfo("Loading pet (%d)...\n",pet_id); +#endif + memset(p, 0, sizeof(struct s_pet)); - if( (fp=fopen(pet_txt,"r"))==NULL ) - return 1; - while(fgets(line, sizeof(line), fp)) + //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) + + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) { - p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); - if(p==NULL){ - ShowFatalError("int_pet: out of memory!\n"); - exit(EXIT_FAILURE); - } - memset(p,0,sizeof(struct s_pet)); - if(inter_pet_fromstr(line,p)==0 && p->pet_id>0){ - if( p->pet_id >= pet_newid) - pet_newid=p->pet_id+1; - idb_put(pet_db,p->pet_id,p); - }else{ - ShowError("int_pet: broken data [%s] line %d\n",pet_txt,c); - aFree(p); - } - c++; + Sql_ShowDebug(sql_handle); + return 0; } - fclose(fp); - return 0; -} - -void inter_pet_final() -{ - pet_db->destroy(pet_db, NULL); - return; -} -int inter_pet_save_sub(DBKey key,void *data,va_list ap) -{ - char line[8192]; - FILE *fp; - inter_pet_tostr(line,(struct s_pet *)data); - fp=va_arg(ap,FILE *); - fprintf(fp,"%s\n",line); + if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + { + p->pet_id = pet_id; + Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data); + Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); + Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); p->incuvate = atoi(data); + + Sql_FreeResult(sql_handle); + + p->hungry = cap_value(p->hungry, 0, 100); + p->intimate = cap_value(p->intimate, 0, 1000); + + if( save_log ) + ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name); + } return 0; } +//---------------------------------------------- -int inter_pet_save() -{ - FILE *fp; - int lock; - if( (fp=lock_fopen(pet_txt,&lock))==NULL ){ - ShowError("int_pet: can't write [%s] !!! data is lost !!!\n",pet_txt); - return 1; - } - pet_db->foreach(pet_db,inter_pet_save_sub,fp); - lock_fclose(fp,pet_txt,&lock); +int inter_pet_sql_init(void){ + //memory alloc + pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); return 0; } +void inter_pet_sql_final(void){ + if (pet_pt) aFree(pet_pt); + return; +} +//---------------------------------- +int inter_pet_delete(int pet_id){ + ShowInfo("delete pet request: %d...\n",pet_id); -int inter_pet_delete(int pet_id) -{ - struct s_pet *p; - p = (struct s_pet*)idb_get(pet_db,pet_id); - if( p == NULL) - return 1; - else { - idb_remove(pet_db,pet_id); - ShowInfo("Deleted pet (pet_id: %d)\n",pet_id); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) + Sql_ShowDebug(sql_handle); return 0; } - -int mapif_pet_created(int fd,int account_id,struct s_pet *p) +//------------------------------------------------------ +int mapif_pet_created(int fd, int account_id, struct s_pet *p) { - WFIFOHEAD(fd, 11); - WFIFOW(fd,0)=0x3880; - WFIFOL(fd,2)=account_id; + WFIFOHEAD(fd, 11); + WFIFOW(fd, 0) =0x3880; + WFIFOL(fd, 2) =account_id; if(p!=NULL){ - WFIFOB(fd,6)=0; - WFIFOL(fd,7)=p->pet_id; - ShowInfo("Created pet (%d - %s)\n",p->pet_id,p->name); + WFIFOB(fd, 6)=0; + WFIFOL(fd, 7) =p->pet_id; + ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name); }else{ - WFIFOB(fd,6)=1; - WFIFOL(fd,7)=0; + WFIFOB(fd, 6)=1; + WFIFOL(fd, 7)=0; } - WFIFOSET(fd,11); + WFIFOSET(fd, 11); return 0; } -int mapif_pet_info(int fd,int account_id,struct s_pet *p) -{ +int mapif_pet_info(int fd, int account_id, struct s_pet *p){ WFIFOHEAD(fd, sizeof(struct s_pet) + 9); - WFIFOW(fd,0)=0x3881; - WFIFOW(fd,2)=sizeof(struct s_pet) + 9; - WFIFOL(fd,4)=account_id; - WFIFOB(fd,8)=0; - memcpy(WFIFOP(fd,9),p,sizeof(struct s_pet)); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOW(fd, 0) =0x3881; + WFIFOW(fd, 2) =sizeof(struct s_pet) + 9; + WFIFOL(fd, 4) =account_id; + WFIFOB(fd, 8)=0; + memcpy(WFIFOP(fd, 9), p, sizeof(struct s_pet)); + WFIFOSET(fd, WFIFOW(fd, 2)); return 0; } -int mapif_pet_noinfo(int fd,int account_id) -{ - WFIFOHEAD(fd, sizeof(struct s_pet) + 9); - WFIFOW(fd,0)=0x3881; - WFIFOW(fd,2)=sizeof(struct s_pet) + 9; - WFIFOL(fd,4)=account_id; - WFIFOB(fd,8)=1; - memset(WFIFOP(fd,9),0,sizeof(struct s_pet)); - WFIFOSET(fd,WFIFOW(fd,2)); +int mapif_pet_noinfo(int fd, int account_id){ + WFIFOHEAD(fd, sizeof(struct s_pet) + 9); + WFIFOW(fd, 0) =0x3881; + WFIFOW(fd, 2) =sizeof(struct s_pet) + 9; + WFIFOL(fd, 4) =account_id; + WFIFOB(fd, 8)=1; + memset(WFIFOP(fd, 9), 0, sizeof(struct s_pet)); + WFIFOSET(fd, WFIFOW(fd, 2)); return 0; } -int mapif_save_pet_ack(int fd,int account_id,int flag) -{ - WFIFOHEAD(fd, 7); - WFIFOW(fd,0)=0x3882; - WFIFOL(fd,2)=account_id; - WFIFOB(fd,6)=flag; - WFIFOSET(fd,7); +int mapif_save_pet_ack(int fd, int account_id, int flag){ + WFIFOHEAD(fd, 7); + WFIFOW(fd, 0) =0x3882; + WFIFOL(fd, 2) =account_id; + WFIFOB(fd, 6) =flag; + WFIFOSET(fd, 7); return 0; } -int mapif_delete_pet_ack(int fd,int flag) -{ - WFIFOHEAD(fd, 3); - WFIFOW(fd,0)=0x3883; - WFIFOB(fd,2)=flag; - WFIFOSET(fd,3); +int mapif_delete_pet_ack(int fd, int flag){ + WFIFOHEAD(fd, 3); + WFIFOW(fd, 0) =0x3883; + WFIFOB(fd, 2) =flag; + WFIFOSET(fd, 3); return 0; } -int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id, - short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) +int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, + short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name) { - struct s_pet *p; - p= (struct s_pet *) aCalloc(sizeof(struct s_pet), 1); - if(p==NULL){ - ShowFatalError("int_pet: out of memory !\n"); - mapif_pet_created(fd,account_id,NULL); - return 0; - } -// memset(p,0,sizeof(struct s_pet)); unnecessary after aCalloc [Skotlex] - p->pet_id = pet_newid++; - memcpy(p->name,pet_name,NAME_LENGTH); + memset(pet_pt, 0, sizeof(struct s_pet)); + strncpy(pet_pt->name, pet_name, NAME_LENGTH); if(incuvate == 1) - p->account_id = p->char_id = 0; + pet_pt->account_id = pet_pt->char_id = 0; else { - p->account_id = account_id; - p->char_id = char_id; + pet_pt->account_id = account_id; + pet_pt->char_id = char_id; } - p->class_ = pet_class; - p->level = pet_lv; - p->egg_id = pet_egg_id; - p->equip = pet_equip; - p->intimate = intimate; - p->hungry = hungry; - p->rename_flag = rename_flag; - p->incuvate = incuvate; - - if(p->hungry < 0) - p->hungry = 0; - else if(p->hungry > 100) - p->hungry = 100; - if(p->intimate < 0) - p->intimate = 0; - else if(p->intimate > 1000) - p->intimate = 1000; - - idb_put(pet_db,p->pet_id,p); - - mapif_pet_created(fd,account_id,p); + pet_pt->class_ = pet_class; + pet_pt->level = pet_lv; + pet_pt->egg_id = pet_egg_id; + pet_pt->equip = pet_equip; + pet_pt->intimate = intimate; + pet_pt->hungry = hungry; + pet_pt->rename_flag = rename_flag; + pet_pt->incuvate = incuvate; + + if(pet_pt->hungry < 0) + pet_pt->hungry = 0; + else if(pet_pt->hungry > 100) + pet_pt->hungry = 100; + if(pet_pt->intimate < 0) + pet_pt->intimate = 0; + else if(pet_pt->intimate > 1000) + pet_pt->intimate = 1000; + + pet_pt->pet_id = -1; //Signal NEW pet. + if (inter_pet_tosql(pet_pt->pet_id,pet_pt)) + mapif_pet_created(fd, account_id, pet_pt); + else //Failed... + mapif_pet_created(fd, account_id, NULL); return 0; } -int mapif_load_pet(int fd,int account_id,int char_id,int pet_id) -{ - struct s_pet *p; - p = (struct s_pet*)idb_get(pet_db,pet_id); - if(p!=NULL) { - if(p->incuvate == 1) { - p->account_id = p->char_id = 0; - mapif_pet_info(fd,account_id,p); +int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){ + memset(pet_pt, 0, sizeof(struct s_pet)); + + inter_pet_fromsql(pet_id, pet_pt); + + if(pet_pt!=NULL) { + if(pet_pt->incuvate == 1) { + pet_pt->account_id = pet_pt->char_id = 0; + mapif_pet_info(fd, account_id, pet_pt); } - else if(account_id == p->account_id && char_id == p->char_id) - mapif_pet_info(fd,account_id,p); + else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id) + mapif_pet_info(fd, account_id, pet_pt); else - mapif_pet_noinfo(fd,account_id); + mapif_pet_noinfo(fd, account_id); } else - mapif_pet_noinfo(fd,account_id); + mapif_pet_noinfo(fd, account_id); return 0; } -static void* create_pet(DBKey key, va_list args) { - struct s_pet *p; - p=(struct s_pet *)aCalloc(sizeof(struct s_pet),1); - p->pet_id = key.i; - return p; -} -int mapif_save_pet(int fd,int account_id,struct s_pet *data) -{ - struct s_pet *p; - int pet_id, len; +int mapif_save_pet(int fd, int account_id, struct s_pet *data) { + //here process pet save request. + int len; RFIFOHEAD(fd); - len=RFIFOW(fd,2); - + len=RFIFOW(fd, 2); if(sizeof(struct s_pet)!=len-8) { - ShowError("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8); + ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8); } + else{ - pet_id = data->pet_id; - if (pet_id == 0) - pet_id = data->pet_id = pet_newid++; - p = (struct s_pet*)idb_ensure(pet_db,pet_id,create_pet); if(data->hungry < 0) data->hungry = 0; else if(data->hungry > 100) @@ -313,61 +257,47 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) data->intimate = 0; else if(data->intimate > 1000) data->intimate = 1000; - memcpy(p,data,sizeof(struct s_pet)); - if(p->incuvate == 1) - p->account_id = p->char_id = 0; - - mapif_save_pet_ack(fd,account_id,0); + inter_pet_tosql(data->pet_id,data); + mapif_save_pet_ack(fd, account_id, 0); } return 0; } -int mapif_delete_pet(int fd,int pet_id) -{ - mapif_delete_pet_ack(fd,inter_pet_delete(pet_id)); +int mapif_delete_pet(int fd, int pet_id){ + mapif_delete_pet_ack(fd, inter_pet_delete(pet_id)); return 0; } -int mapif_parse_CreatePet(int fd) -{ +int mapif_parse_CreatePet(int fd){ RFIFOHEAD(fd); - mapif_create_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOW(fd,14),RFIFOW(fd,16),RFIFOW(fd,18), - RFIFOW(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),(char*)RFIFOP(fd,24)); + mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18), + RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24)); return 0; } -int mapif_parse_LoadPet(int fd) -{ +int mapif_parse_LoadPet(int fd){ RFIFOHEAD(fd); - mapif_load_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); + mapif_load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10)); return 0; } -int mapif_parse_SavePet(int fd) -{ +int mapif_parse_SavePet(int fd){ RFIFOHEAD(fd); - mapif_save_pet(fd,RFIFOL(fd,4),(struct s_pet *)RFIFOP(fd,8)); + mapif_save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8)); return 0; } -int mapif_parse_DeletePet(int fd) -{ +int mapif_parse_DeletePet(int fd){ RFIFOHEAD(fd); - mapif_delete_pet(fd,RFIFOL(fd,2)); + mapif_delete_pet(fd, RFIFOL(fd, 2)); return 0; } -// map server ‚©‚ç‚Ì’ÊM -// E‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ -// EƒpƒPƒbƒg’·ƒf[ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ -// EƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ -// EƒGƒ‰[‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ -int inter_pet_parse_frommap(int fd) -{ +int inter_pet_parse_frommap(int fd){ RFIFOHEAD(fd); - switch(RFIFOW(fd,0)){ + switch(RFIFOW(fd, 0)){ case 0x3080: mapif_parse_CreatePet(fd); break; case 0x3081: mapif_parse_LoadPet(fd); break; case 0x3082: mapif_parse_SavePet(fd); break; @@ -377,4 +307,3 @@ int inter_pet_parse_frommap(int fd) } return 1; } -#endif //TXT_SQL_CONVERT diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 9234af109..733468c77 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -1,21 +1,21 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_PET_H_ -#define _INT_PET_H_ +#ifndef _INT_PET_SQL_H_ +#define _INT_PET_SQL_H_ struct s_pet; int inter_pet_init(void); -void inter_pet_final(void); +void inter_pet_sql_final(void); int inter_pet_save(void); int inter_pet_delete(int pet_id); int inter_pet_parse_frommap(int fd); - -extern char pet_txt[1024]; +int inter_pet_sql_init(void); +//extern char pet_txt[256]; //Exported for use in the TXT-SQL converter. -int inter_pet_fromstr(char *str,struct s_pet *p); +int inter_pet_tosql(int pet_id, struct s_pet *p); -#endif /* _INT_PET_H_ */ +#endif /* _INT_PET_SQL_H_ */ diff --git a/src/char/int_quest.c b/src/char/int_quest.c new file mode 100644 index 000000000..224205412 --- /dev/null +++ b/src/char/int_quest.c @@ -0,0 +1,184 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/mmo.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/timer.h" + +#include "char.h" +#include "inter.h" +#include "int_quest.h" + +#include +#include +#include + +//Load entire questlog for a character +int mapif_quests_fromsql(int char_id, struct quest questlog[]) +{ + int i; + struct quest tmp_quest; + SqlStmt * stmt; + + stmt = SqlStmt_Malloc(sql_handle); + if( stmt == NULL ) + { + SqlStmt_ShowDebug(stmt); + return 0; + } + + memset(&tmp_quest, 0, sizeof(struct quest)); + + if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB) + || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SqlStmt_Execute(stmt) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT, &tmp_quest.count[0], 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT, &tmp_quest.count[1], 0, NULL, NULL) + || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT, &tmp_quest.count[2], 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) + memcpy(&questlog[i], &tmp_quest, sizeof(tmp_quest)); + + SqlStmt_Free(stmt); + return i; +} + +//Delete a quest +bool mapif_quest_delete(int char_id, int quest_id) +{ + if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; +} + +//Add a quest to a questlog +bool mapif_quest_add(int char_id, struct quest qd) +{ + if ( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; +} + +//Update a questlog +bool mapif_quest_update(int char_id, struct quest qd) +{ + if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) ) + { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; +} + +//Save quests +int mapif_parse_quest_save(int fd) +{ + int i, j, k, num2, num1 = (RFIFOW(fd,2)-8)/sizeof(struct quest); + int char_id = RFIFOL(fd,4); + struct quest qd1[MAX_QUEST_DB],qd2[MAX_QUEST_DB]; + bool success = true; + + memset(qd1, 0, sizeof(qd1)); + memset(qd2, 0, sizeof(qd2)); + if( num1 ) memcpy(&qd1, RFIFOP(fd,8), RFIFOW(fd,2)-8); + num2 = mapif_quests_fromsql(char_id, qd2); + + for( i = 0; i < num1; i++ ) + { + ARR_FIND( 0, num2, j, qd1[i].quest_id == qd2[j].quest_id ); + if( j < num2 ) // Update existed quests + { // Only states and counts are changable. + ARR_FIND( 0, MAX_QUEST_OBJECTIVES, k, qd1[i].count[k] != qd2[j].count[k] ); + if( k != MAX_QUEST_OBJECTIVES || qd1[i].state != qd2[j].state ) + success &= mapif_quest_update(char_id, qd1[i]); + + if( j < (--num2) ) + { + memmove(&qd2[j],&qd2[j+1],sizeof(struct quest)*(num2-j)); + memset(&qd2[num2], 0, sizeof(struct quest)); + } + + } + else // Add new quests + success &= mapif_quest_add(char_id, qd1[i]); + } + + for( i = 0; i < num2; i++ ) // Quests not in qd1 but in qd2 are to be erased. + success &= mapif_quest_delete(char_id, qd2[i].quest_id); + + WFIFOHEAD(fd,7); + WFIFOW(fd,0) = 0x3861; + WFIFOL(fd,2) = char_id; + WFIFOB(fd,6) = success?1:0; + WFIFOSET(fd,7); + + return 0; +} + +//Send questlog to map server +int mapif_parse_quest_load(int fd) +{ + int char_id = RFIFOL(fd,2); + struct quest tmp_questlog[MAX_QUEST_DB]; + int num_quests, i, num_complete = 0; + int complete[MAX_QUEST_DB]; + + memset(tmp_questlog, 0, sizeof(tmp_questlog)); + memset(complete, 0, sizeof(complete)); + + num_quests = mapif_quests_fromsql(char_id, tmp_questlog); + + WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8); + WFIFOW(fd,0) = 0x3860; + WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8; + WFIFOL(fd,4) = char_id; + + //Active and inactive quests + for( i = 0; i < num_quests; i++ ) + { + if( tmp_questlog[i].state == Q_COMPLETE ) + { + complete[num_complete++] = i; + continue; + } + memcpy(WFIFOP(fd,(i-num_complete)*sizeof(struct quest)+8), &tmp_questlog[i], sizeof(struct quest)); + } + + // Completed quests + for( i = num_quests - num_complete; i < num_quests; i++ ) + memcpy(WFIFOP(fd,i*sizeof(struct quest)+8), &tmp_questlog[complete[i-num_quests+num_complete]], sizeof(struct quest)); + + WFIFOSET(fd,num_quests*sizeof(struct quest)+8); + + return 0; +} + +int inter_quest_parse_frommap(int fd) +{ + switch(RFIFOW(fd,0)) + { + case 0x3060: mapif_parse_quest_load(fd); break; + case 0x3061: mapif_parse_quest_save(fd); break; + default: + return 0; + } + return 1; +} diff --git a/src/char/int_quest.h b/src/char/int_quest.h new file mode 100644 index 000000000..f2a0b626e --- /dev/null +++ b/src/char/int_quest.h @@ -0,0 +1,13 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _QUEST_H_ +#define _QUEST_H_ + +/*questlog system*/ +struct quest; + +int inter_quest_parse_frommap(int fd); + +#endif + diff --git a/src/char/int_status.c b/src/char/int_status.c deleted file mode 100644 index 769d35f65..000000000 --- a/src/char/int_status.c +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/lock.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "int_status.h" - -#include - -// Contains all the status change data in-memory. [Skotlex] -static DBMap* scdata_db = NULL; // int char_id -> struct scdata* -char scdata_txt[1024]="save/scdata.txt"; //By [Skotlex] - -#ifdef ENABLE_SC_SAVING -static void* create_scdata(DBKey key, va_list args) -{ - struct scdata *data; - data = (struct scdata*)aCalloc(1, sizeof(struct scdata)); - data->account_id = va_arg(args, int); - data->char_id = key.i; - return data; -} - -/*========================================== - * Loads status change data of the player given. [Skotlex] - *------------------------------------------*/ -struct scdata* status_search_scdata(int aid, int cid) -{ - return (struct scdata*)scdata_db->ensure(scdata_db, db_i2key(cid), create_scdata, aid); -} - -/*========================================== - * Deletes status change data of the player given. [Skotlex] - * Should be invoked after the data of said player was successfully loaded. - *------------------------------------------*/ -void status_delete_scdata(int aid, int cid) -{ - struct scdata* scdata = (struct scdata*)idb_remove(scdata_db, cid); - if (scdata) - { - if (scdata->data) - aFree(scdata->data); - aFree(scdata); - } -} - - -static void inter_status_tostr(char* line, struct scdata *sc_data) -{ - int i, len; - - len = sprintf(line, "%d,%d,%d\t", sc_data->account_id, sc_data->char_id, sc_data->count); - for(i = 0; i < sc_data->count; i++) { - len += sprintf(line + len, "%d,%ld,%ld,%ld,%ld,%ld\t", sc_data->data[i].type, sc_data->data[i].tick, - sc_data->data[i].val1, sc_data->data[i].val2, sc_data->data[i].val3, sc_data->data[i].val4); - } - return; -} - -static int inter_scdata_fromstr(char *line, struct scdata *sc_data) -{ - int i, len, next; - - if (sscanf(line,"%d,%d,%d\t%n",&sc_data->account_id, &sc_data->char_id, &sc_data->count, &next) < 3) - return 0; - - if (sc_data->count < 1) - return 0; - - sc_data->data = (struct status_change_data*)aCalloc(sc_data->count, sizeof (struct status_change_data)); - - for (i = 0; i < sc_data->count; i++) - { - if (sscanf(line + next, "%hu,%ld,%ld,%ld,%ld,%ld\t%n", &sc_data->data[i].type, &sc_data->data[i].tick, - &sc_data->data[i].val1, &sc_data->data[i].val2, &sc_data->data[i].val3, &sc_data->data[i].val4, &len) < 6) - { - aFree(sc_data->data); - return 0; - } - next+=len; - } - return 1; -} -/*========================================== - * Loads all scdata from the given filename. - *------------------------------------------*/ -void status_load_scdata(const char* filename) -{ - FILE *fp; - int sd_count=0, sc_count=0; - char line[8192]; - struct scdata *sc; - - if ((fp = fopen(filename, "r")) == NULL) { - ShowError("status_load_scdata: Cannot open file %s!\n", filename); - return; - } - - while(fgets(line, sizeof(line), fp)) - { - sc = (struct scdata*)aCalloc(1, sizeof(struct scdata)); - if (inter_scdata_fromstr(line, sc)) { - sd_count++; - sc_count+= sc->count; - sc = (struct scdata*)idb_put(scdata_db, sc->char_id, sc); - if (sc) { - ShowError("Duplicate entry in %s for character %d\n", filename, sc->char_id); - if (sc->data) aFree(sc->data); - aFree(sc); - } - } else { - ShowError("status_load_scdata: Broken line data: %s\n", line); - aFree(sc); - } - } - fclose(fp); - ShowStatus("Loaded %d saved status changes for %d characters.\n", sc_count, sd_count); -} - -static int inter_status_save_sub(DBKey key, void *data, va_list ap) { - char line[8192]; - struct scdata * sc_data; - FILE *fp; - - sc_data = (struct scdata *)data; - if (sc_data->count < 1) - return 0; - - fp = va_arg(ap, FILE *); - inter_status_tostr(line, sc_data); - fprintf(fp, "%s\n", line); - return 0; -} - -/*========================================== - * Saves all scdata to the given filename. - *------------------------------------------*/ -void inter_status_save() -{ - FILE *fp; - int lock; - - if ((fp = lock_fopen(scdata_txt, &lock)) == NULL) { - ShowError("int_status: can't write [%s] !!! data is lost !!!\n", scdata_txt); - return; - } - scdata_db->foreach(scdata_db, inter_status_save_sub, fp); - lock_fclose(fp,scdata_txt, &lock); -} - -/*========================================== - * Initializes db. - *------------------------------------------*/ -void status_init() -{ - scdata_db = idb_alloc(DB_OPT_BASE); - status_load_scdata(scdata_txt); -} - -/*========================================== - * Frees up memory. - *------------------------------------------*/ -static int scdata_db_final(DBKey k,void *d,va_list ap) -{ - struct scdata *data = (struct scdata*)d; - if (data->data) - aFree(data->data); - aFree(data); - return 0; -} - -/*========================================== - * Final cleanup. - *------------------------------------------*/ -void status_final(void) -{ - scdata_db->destroy(scdata_db, scdata_db_final); -} - -#endif //ENABLE_SC_SAVING diff --git a/src/char/int_status.h b/src/char/int_status.h deleted file mode 100644 index 3202cd88e..000000000 --- a/src/char/int_status.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_STATUS_H_ -#define _INT_STATUS_H_ - -struct status_change_data; - -struct scdata { - int account_id, char_id; - int count; - struct status_change_data* data; -}; - -extern char scdata_txt[1024]; - -struct scdata* status_search_scdata(int aid, int cid); -void status_delete_scdata(int aid, int cid); -void inter_status_save(void); -void status_init(void); -void status_final(void); - -#endif /* _INT_STATUS_H_ */ diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 2a041b286..248a4521f 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -3,414 +3,184 @@ #include "../common/mmo.h" #include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/db.h" -#include "../common/lock.h" #include "../common/showmsg.h" -#include "../common/utils.h" +#include "../common/socket.h" +#include "../common/strlib.h" // StringBuf +#include "../common/sql.h" #include "char.h" #include "inter.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_guild.h" #include #include #include -// ƒtƒ@ƒCƒ‹–¼‚̃fƒtƒHƒ‹ƒg -// inter_config_read()‚ÅÄݒ肳‚ê‚é -char storage_txt[1024]="save/storage.txt"; -char guild_storage_txt[1024]="save/g_storage.txt"; -static DBMap* storage_db = NULL; // int account_id -> struct storage_data* -static DBMap* guild_storage_db = NULL; // int guild_id -> struct guild_storage* +#define STORAGE_MEMINC 16 -// ‘qŒÉƒf[ƒ^‚ð•¶Žš—ñ‚ɕϊ· -bool storage_tostr(char* str, int account_id, struct storage_data* p) +/// Save storage data to sql +int storage_tosql(int account_id, struct storage_data* p) { - int i,j; - char *str_p = str; - str_p += sprintf(str_p, "%d,%d\t", account_id, p->storage_amount); - - for( i = 0; i < MAX_STORAGE; i++ ) - if( p->items[i].nameid > 0 && p->items[i].amount > 0 ) - { - str_p += sprintf(str_p, "%d,%d,%d,%d,%d,%d,%d", - p->items[i].id,p->items[i].nameid,p->items[i].amount,p->items[i].equip, - p->items[i].identify,p->items[i].refine,p->items[i].attribute); - for(j=0; jitems[i].card[j]); - str_p += sprintf(str_p," "); - } - - *(str_p++)='\t'; - - *str_p='\0'; - - return true; -} - -// •¶Žš—ñ‚ð‘qŒÉƒf[ƒ^‚ɕϊ· -bool storage_fromstr(char* str, int* account_id, struct storage_data* p) -{ - int tmp_int[256]; - char tmp_str[256]; - int next,len,i,j; - - if( sscanf(str, "%d,%d%n", &tmp_int[0], &tmp_int[1], &next) != 2 ) - return false; - - *account_id = tmp_int[0]; - p->storage_amount = tmp_int[1]; //FIXME: limit to MAX_STORAGE? - - next++; - for( i = 0; str[next] && str[next]!='\t' && i < MAX_STORAGE; i++ ) - { - if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str, &len) != 8) - return false; - - p->items[i].id = tmp_int[0]; - p->items[i].nameid = tmp_int[1]; - p->items[i].amount = tmp_int[2]; - p->items[i].equip = tmp_int[3]; - p->items[i].identify = tmp_int[4]; - p->items[i].refine = tmp_int[5]; - p->items[i].attribute = tmp_int[6]; - - for(j = 0; j < MAX_SLOTS && tmp_str[0] && sscanf(tmp_str, ",%d%[0-9,-]",&tmp_int[0], tmp_str) > 0; j++) - p->items[i].card[j] = tmp_int[0]; - - next += len; - if (str[next] == ' ') - next++; - } - - if( i >= MAX_STORAGE && str[next] && str[next] != '\t' ) - ShowWarning("storage_fromstr: Found a storage line with more items than MAX_STORAGE (%d), remaining items have been discarded!\n", MAX_STORAGE); - - return true; + memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE); + return 0; } -int guild_storage_tostr(char *str,struct guild_storage *p) +/// Load storage data to mem +int storage_fromsql(int account_id, struct storage_data* p) { - int i,j,f=0; - char *str_p = str; - str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount); + StringBuf buf; + struct item* item; + char* data; + int i; + int j; - for(i=0;iitems[i].nameid) && (p->items[i].amount) ){ - str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d", - p->items[i].id,p->items[i].nameid,p->items[i].amount,p->items[i].equip, - p->items[i].identify,p->items[i].refine,p->items[i].attribute); - for(j=0; jitems[i].card[j]); - str_p += sprintf(str_p," "); - f++; - } - - *(str_p++)='\t'; + memset(p, 0, sizeof(struct storage_data)); //clean up memory + p->storage_amount = 0; - *str_p='\0'; - if(!f) - str[0]=0; - return 0; -} + // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id); -int guild_storage_fromstr(char *str,struct guild_storage *p) -{ - int tmp_int[256]; - char tmp_str[256]; - int set,next,len,i,j; + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); - set=sscanf(str,"%d,%d%n",&tmp_int[0],&tmp_int[1],&next); - p->storage_amount=tmp_int[1]; + StringBuf_Destroy(&buf); - if(set!=2) - return 1; - if(str[next]=='\n' || str[next]=='\r') - return 0; - next++; - for(i=0;str[next] && str[next]!='\t' && i < MAX_GUILD_STORAGE;i++){ - if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str, &len) == 8) + for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + item = &p->items[i]; + Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data); + for( j = 0; j < MAX_SLOTS; ++j ) { - p->items[i].id = tmp_int[0]; - p->items[i].nameid = tmp_int[1]; - p->items[i].amount = tmp_int[2]; - p->items[i].equip = tmp_int[3]; - p->items[i].identify = tmp_int[4]; - p->items[i].refine = tmp_int[5]; - p->items[i].attribute = tmp_int[6]; - for(j = 0; j < MAX_SLOTS && tmp_str[0] && sscanf(tmp_str, ",%d%[0-9,-]",&tmp_int[0], tmp_str) > 0; j++) - p->items[i].card[j] = tmp_int[0]; - next += len; - if (str[next] == ' ') - next++; + Sql_GetData(sql_handle, 8+j, &data, NULL); item->card[j] = atoi(data); } - else return 1; } - if (i >= MAX_GUILD_STORAGE && str[next] && str[next]!='\t') - ShowWarning("guild_storage_fromstr: Found a storage line with more items than MAX_GUILD_STORAGE (%d), remaining items have been discarded!\n", MAX_GUILD_STORAGE); - return 0; -} - -#ifndef TXT_SQL_CONVERT + p->storage_amount = i; + Sql_FreeResult(sql_handle); -static void* create_storage(DBKey key, va_list args) -{ - return (struct storage_data *) aCalloc(sizeof(struct storage_data), 1); + ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount); + return 1; } -static void* create_guildstorage(DBKey key, va_list args) +/// Save guild_storage data to sql +int guild_storage_tosql(int guild_id, struct guild_storage* p) { - struct guild_storage* gs = NULL; - gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1); - gs->guild_id=key.i; - return gs; + memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE); + ShowInfo ("guild storage save to DB - guild: %d\n", guild_id); + return 0; } -/// Loads storage data into the provided data structure. -/// If data doesn't exist, the destination is zeroed and false is returned. -bool storage_load(int account_id, struct storage_data* storage) +/// Load guild_storage data to mem +int guild_storage_fromsql(int guild_id, struct guild_storage* p) { - struct storage_data* s = (struct storage_data*)idb_get(storage_db, account_id); + StringBuf buf; + struct item* item; + char* data; + int i; + int j; - if( s != NULL ) - memcpy(storage, s, sizeof(*storage)); - else - memset(storage, 0x00, sizeof(*storage)); - - return( s != NULL ); -} - -/// Writes provided data into storage cache. -/// If data contains 0 items, any existing entry in cache is destroyed. -/// If data contains 1+ items and no cache entry exists, a new one is created. -bool storage_save(int account_id, struct storage_data* storage) -{ - if( storage->storage_amount > 0 ) - { - struct storage_data* s = (struct storage_data*)idb_ensure(storage_db, account_id, create_storage); - memcpy(s, storage, sizeof(*storage)); - } - else - { - idb_remove(storage_db, account_id); - } + memset(p, 0, sizeof(struct guild_storage)); //clean up memory + p->storage_amount = 0; + p->guild_id = guild_id; - return true; -} + // storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} + StringBuf_Init(&buf); + StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); + for( j = 0; j < MAX_SLOTS; ++j ) + StringBuf_Printf(&buf, ",`card%d`", j); + StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id); -//--------------------------------------------------------- -// ‘qŒÉƒf[ƒ^‚ð“ǂݞ‚Þ -int inter_storage_init() -{ - char line[65536]; - int c = 0; - FILE *fp; + if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) + Sql_ShowDebug(sql_handle); - storage_db = idb_alloc(DB_OPT_RELEASE_DATA); + StringBuf_Destroy(&buf); - fp=fopen(storage_txt,"r"); - if(fp==NULL){ - ShowError("can't read : %s\n",storage_txt); - return 1; - } - while( fgets(line, sizeof(line), fp) ) + for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) { - int account_id; - struct storage_data *s; - - s = (struct storage_data*)aCalloc(sizeof(struct storage_data), 1); - if( s == NULL ) - { - ShowFatalError("int_storage: out of memory!\n"); - exit(EXIT_FAILURE); - } - - if( storage_fromstr(line,&account_id,s) ) + item = &p->items[i]; + Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); + item->expire_time = 0; + for( j = 0; j < MAX_SLOTS; ++j ) { - idb_put(storage_db,account_id,s); - } - else{ - ShowError("int_storage: broken data in [%s] line %d\n",storage_txt,c); - aFree(s); + Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data); } - c++; } - fclose(fp); - - c = 0; - guild_storage_db = idb_alloc(DB_OPT_RELEASE_DATA); - - fp=fopen(guild_storage_txt,"r"); - if(fp==NULL){ - ShowError("can't read : %s\n",guild_storage_txt); - return 1; - } - while(fgets(line, sizeof(line), fp)) - { - int tmp_int; - struct guild_storage *gs; - - sscanf(line,"%d",&tmp_int); - gs = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1); - if(gs==NULL){ - ShowFatalError("int_storage: out of memory!\n"); - exit(EXIT_FAILURE); - } -// memset(gs,0,sizeof(struct guild_storage)); aCalloc... - gs->guild_id=tmp_int; - if(gs->guild_id > 0 && guild_storage_fromstr(line,gs) == 0) { - idb_put(guild_storage_db,gs->guild_id,gs); - } - else{ - ShowError("int_storage: broken data [%s] line %d\n",guild_storage_txt,c); - aFree(gs); - } - c++; - } - fclose(fp); + p->storage_amount = i; + Sql_FreeResult(sql_handle); + ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount); return 0; } -void inter_storage_final() { - if(storage_db) - { - storage_db->destroy(storage_db, NULL); - } - if(guild_storage_db) - { - guild_storage_db->destroy(guild_storage_db, NULL); - } - return; -} - //--------------------------------------------------------- -// ‘qŒÉƒf[ƒ^‚ð‘‚«ž‚Þ -int inter_storage_save() +// storage data initialize +int inter_storage_sql_init(void) { - struct DBIterator* iter; - DBKey key; - struct storage_data* data; - FILE *fp; - int lock; - if( (fp=lock_fopen(storage_txt,&lock))==NULL ){ - ShowError("int_storage: can't write [%s] !!! data is lost !!!\n",storage_txt); - return 1; - } - - iter = storage_db->iterator(storage_db); - for( data = (struct storage_data*)iter->first(iter,&key); iter->exists(iter); data = (struct storage_data*)iter->next(iter,&key) ) - { - int account_id = key.i; - char line[65536]; - storage_tostr(line,account_id,data); - fprintf(fp,"%s\n",line); - } - iter->destroy(iter); - - lock_fclose(fp,storage_txt,&lock); - return 0; + return 1; } - -//--------------------------------------------------------- -// ‘qŒÉƒf[ƒ^‚ð‘‚«ž‚Þ -int inter_guild_storage_save() +// storage data finalize +void inter_storage_sql_final(void) { - struct DBIterator* iter; - struct guild_storage* data; - FILE *fp; - int lock; - if( (fp=lock_fopen(guild_storage_txt,&lock))==NULL ){ - ShowError("int_storage: can't write [%s] !!! data is lost !!!\n",guild_storage_txt); - return 1; - } - - iter = guild_storage_db->iterator(guild_storage_db); - for( data = (struct guild_storage*)iter->first(iter,NULL); iter->exists(iter); data = (struct guild_storage*)iter->next(iter,NULL) ) - { - char line[65536]; - if(inter_guild_search(data->guild_id) != NULL) - { - guild_storage_tostr(line,data); - if(*line) - fprintf(fp,"%s\n",line); - } - } - iter->destroy(iter); - - lock_fclose(fp,guild_storage_txt,&lock); - return 0; + return; } -// ‘qŒÉƒf[ƒ^íœ +// q?f[^? int inter_storage_delete(int account_id) { - struct storage_data *s = (struct storage_data*)idb_get(storage_db,account_id); - if(s) { - int i; - for(i=0;istorage_amount;i++){ - if(s->items[i].card[0] == (short)0xff00) - inter_pet_delete( MakeDWord(s->items[i].card[1],s->items[i].card[2]) ); - } - idb_remove(storage_db,account_id); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) ) + Sql_ShowDebug(sql_handle); return 0; } - -// ƒMƒ‹ƒh‘qŒÉƒf[ƒ^íœ int inter_guild_storage_delete(int guild_id) { - struct guild_storage *gs = (struct guild_storage*)idb_get(guild_storage_db,guild_id); - if(gs) { - int i; - for(i=0;istorage_amount;i++){ - if(gs->items[i].card[0] == (short)0xff00) - inter_pet_delete( MakeDWord(gs->items[i].card[1],gs->items[i].card[2]) ); - } - idb_remove(guild_storage_db,guild_id); - } + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) ) + Sql_ShowDebug(sql_handle); return 0; } -struct guild_storage *guild2storage(int guild_id) -{ - struct guild_storage* gs = NULL; - if(inter_guild_search(guild_id) != NULL) - gs = (struct guild_storage*)idb_ensure(guild_storage_db, guild_id, create_guildstorage); - return gs; -} - //--------------------------------------------------------- -// map server‚Ö‚Ì’ÊM +// packet from map server int mapif_load_guild_storage(int fd,int account_id,int guild_id) { - struct guild_storage *gs=guild2storage(guild_id); - WFIFOHEAD(fd, sizeof(struct guild_storage)+12); - WFIFOW(fd,0)=0x3818; - if(gs) { - WFIFOW(fd,2)=sizeof(struct guild_storage)+12; - WFIFOL(fd,4)=account_id; - WFIFOL(fd,8)=guild_id; - memcpy(WFIFOP(fd,12),gs,sizeof(struct guild_storage)); - } - else { - WFIFOW(fd,2)=12; - WFIFOL(fd,4)=account_id; - WFIFOL(fd,8)=0; + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + {// guild exists + WFIFOHEAD(fd, sizeof(struct guild_storage)+12); + WFIFOW(fd,0) = 0x3818; + WFIFOW(fd,2) = sizeof(struct guild_storage)+12; + WFIFOL(fd,4) = account_id; + WFIFOL(fd,8) = guild_id; + guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,12)); + WFIFOSET(fd, WFIFOW(fd,2)); + return 0; } - WFIFOSET(fd,WFIFOW(fd,2)); - + // guild does not exist + Sql_FreeResult(sql_handle); + WFIFOHEAD(fd, 12); + WFIFOW(fd,0) = 0x3818; + WFIFOW(fd,2) = 12; + WFIFOL(fd,4) = account_id; + WFIFOL(fd,8) = 0; + WFIFOSET(fd, 12); return 0; } - int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) { WFIFOHEAD(fd,11); @@ -423,7 +193,7 @@ int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) } //--------------------------------------------------------- -// map server‚©‚ç‚Ì’ÊM +// packet from map server int mapif_parse_LoadGuildStorage(int fd) { @@ -434,31 +204,35 @@ int mapif_parse_LoadGuildStorage(int fd) int mapif_parse_SaveGuildStorage(int fd) { - struct guild_storage *gs; - int guild_id, len; + int guild_id; + int len; + RFIFOHEAD(fd); - guild_id=RFIFOL(fd,8); - len=RFIFOW(fd,2); - if(sizeof(struct guild_storage)!=len-12){ - ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12); + guild_id = RFIFOL(fd,8); + len = RFIFOW(fd,2); + + if( sizeof(struct guild_storage) != len - 12 ) + { + ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); } - else { - gs=guild2storage(guild_id); - if(gs) { - memcpy(gs,RFIFOP(fd,12),sizeof(struct guild_storage)); - mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0); + else + { + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + Sql_ShowDebug(sql_handle); + else if( Sql_NumRows(sql_handle) > 0 ) + {// guild exists + Sql_FreeResult(sql_handle); + guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); + mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); + return 0; } - else - mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1); + Sql_FreeResult(sql_handle); } + mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1); return 0; } -// map server ‚©‚ç‚Ì’ÊM -// E‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ -// EƒpƒPƒbƒg’·ƒf[ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ -// EƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ -// EƒGƒ‰[‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ + int inter_storage_parse_frommap(int fd) { RFIFOHEAD(fd); @@ -470,4 +244,3 @@ int inter_storage_parse_frommap(int fd) } return 1; } -#endif //TXT_SQL_CONVERT diff --git a/src/char/int_storage.h b/src/char/int_storage.h index fdd2a5f28..811608f82 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -1,28 +1,22 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_STORAGE_H_ -#define _INT_STORAGE_H_ +#ifndef _INT_STORAGE_SQL_H_ +#define _INT_STORAGE_SQL_H_ struct storage_data; struct guild_storage; -int inter_storage_init(void); -void inter_storage_final(void); -int inter_storage_save(void); -int inter_guild_storage_save(void); +int inter_storage_sql_init(void); +void inter_storage_sql_final(void); int inter_storage_delete(int account_id); int inter_guild_storage_delete(int guild_id); -int inter_storage_parse_frommap(int fd); -extern char storage_txt[1024]; -extern char guild_storage_txt[1024]; +int inter_storage_parse_frommap(int fd); //Exported for use in the TXT-SQL converter. -bool storage_fromstr(char* str, int* account_id, struct storage_data* p); -int guild_storage_fromstr(char *str,struct guild_storage *p); - -bool storage_load(int account_id, struct storage_data* storage); -bool storage_save(int account_id, struct storage_data* storage); +int storage_fromsql(int account_id, struct storage_data* p); +int storage_tosql(int account_id,struct storage_data *p); +int guild_storage_tosql(int guild_id, struct guild_storage *p); -#endif /* _INT_STORAGE_H_ */ +#endif /* _INT_STORAGE_SQL_H_ */ diff --git a/src/char/inter.c b/src/char/inter.c index 298ed38a5..2137579be 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -1,300 +1,327 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/db.h" #include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/timer.h" +#include "../common/db.h" #include "../common/malloc.h" -#include "../common/lock.h" -#include "../common/showmsg.h" #include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" #include "char.h" #include "inter.h" #include "int_party.h" #include "int_guild.h" -#include "int_status.h" #include "int_storage.h" #include "int_pet.h" #include "int_homun.h" +#include "int_mercenary.h" +#include "int_mail.h" +#include "int_auction.h" +#include "int_quest.h" #include #include #include -#define WISDATA_TTL (60*1000) // Existence time of Wisp/page data (60 seconds) - // that is the waiting time of answers of all map-servers -#define WISDELLIST_MAX 256 // Number of elements of Wisp/page data deletion list +#define WISDATA_TTL (60*1000) // Wisƒf[ƒ^‚̶‘¶ŽžŠÔ(60•b) +#define WISDELLIST_MAX 256 // Wisƒf[ƒ^íœƒŠƒXƒg‚Ì—v‘f” -char accreg_txt[1024] = "save/accreg.txt"; -#ifndef TXT_SQL_CONVERT -char inter_log_filename[1024] = "log/inter.log"; -char main_chat_nick[16] = "Main"; -static DBMap* accreg_db = NULL; // int account_id -> struct accreg* +Sql* sql_handle = NULL; + +int char_server_port = 3306; +char char_server_ip[32] = "127.0.0.1"; +char char_server_id[32] = "ragnarok"; +char char_server_pw[32] = "ragnarok"; +char char_server_db[32] = "ragnarok"; +char default_codepage[32] = ""; //Feature by irmin. +static struct accreg *accreg_pt; unsigned int party_share_level = 10; +char main_chat_nick[16] = "Main"; -// sending packet list -// NOTE: This variable ain't used at all! And it's confusing.. where do I add that the length of packet 0x2b07 is 10? x.x [Skotlex] -int inter_send_packet_length[]={ - -1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3000-0x300f - -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, - 35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, - 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, - 9, 9,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; // recv. packet list -int inter_recv_packet_length[]={ - -1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3000-0x300f - 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, //0x3010-0x301f - -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, //0x3020-0x302f Party - -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, //0x3030-0x303f - 5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3040-0x304f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3050-0x305f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3060-0x306f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3070-0x307f - 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f - -1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3090-0x309f Homunculus packets [albator] +int inter_recv_packet_length[] = { + -1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3000- + 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- + -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party + -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030- + 5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- + -1,-1,10,10, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus] + 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish] + -1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus] + 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080- + -1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator] }; struct WisData { int id, fd, count, len; unsigned long tick; - unsigned char src[24], dst[24], msg[1024]; + unsigned char src[24], dst[24], msg[512]; }; static DBMap* wis_db = NULL; // int wis_id -> struct WisData* static int wis_dellist[WISDELLIST_MAX], wis_delnum; - //-------------------------------------------------------- +// Save registry to sql +int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type) +{ + struct global_reg* r; + SqlStmt* stmt; + int i; -// ƒAƒJƒEƒ“ƒg•Ï”‚ð•¶Žš—ñ‚Ö•ÏŠ· -int inter_accreg_tostr(char *str, struct accreg *reg) { - int j; - char *p = str; - - p += sprintf(p, "%d\t", reg->account_id); - for(j = 0; j < reg->reg_num; j++) { - p += sprintf(p,"%s,%s ", reg->reg[j].str, reg->reg[j].value); - } - - return 0; -} -#endif //TXT_SQL_CONVERT -// ƒAƒJƒEƒ“ƒg•Ï”‚ð•¶Žš—ñ‚©‚ç•ÏŠ· -int inter_accreg_fromstr(const char *str, struct accreg *reg) { - int j, n; - const char *p = str; - - if (sscanf(p, "%d\t%n", ®->account_id, &n ) != 1 || reg->account_id <= 0) - return 1; + if( account_id <= 0 ) + return 0; + reg->account_id = account_id; + reg->char_id = char_id; - for(j = 0, p += n; j < ACCOUNT_REG_NUM; j++, p += n) { - if (sscanf(p, "%[^,],%[^ ] %n", reg->reg[j].str, reg->reg[j].value, &n) != 2) - break; + //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) + switch( type ) + { + case 3: //Char Reg + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); + account_id = 0; + break; + case 2: //Account Reg + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + char_id = 0; + break; + case 1: //Account2 Reg + ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); + return 0; + default: + ShowError("inter_accreg_tosql: Invalid type %d\n", type); + return 0; } - reg->reg_num = j; - return 0; -} -#ifndef TXT_SQL_CONVERT -// ƒAƒJƒEƒ“ƒg•Ï”‚̓ǂݞ‚Ý -int inter_accreg_init(void) { - char line[8192]; - FILE *fp; - int c = 0; - struct accreg *reg; - - accreg_db = idb_alloc(DB_OPT_RELEASE_DATA); + if( reg->reg_num <= 0 ) + return 0; - if( (fp = fopen(accreg_txt, "r")) == NULL) - return 1; - while(fgets(line, sizeof(line), fp)) + stmt = SqlStmt_Malloc(sql_handle); + if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d',?,?)", reg_db, type, account_id, char_id) ) + SqlStmt_ShowDebug(stmt); + for( i = 0; i < reg->reg_num; ++i ) { - reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1); - if (reg == NULL) { - ShowFatalError("inter: accreg: out of memory!\n"); - exit(EXIT_FAILURE); + r = ®->reg[i]; + if( r->str[0] != '\0' && r->value != '\0' ) + { + // str + SqlStmt_BindParam(stmt, 0, SQLDT_STRING, r->str, strnlen(r->str, sizeof(r->str))); + // value + SqlStmt_BindParam(stmt, 1, SQLDT_STRING, r->value, strnlen(r->value, sizeof(r->value))); + + if( SQL_ERROR == SqlStmt_Execute(stmt) ) + SqlStmt_ShowDebug(stmt); } - if (inter_accreg_fromstr(line, reg) == 0 && reg->account_id > 0) { - idb_put(accreg_db, reg->account_id, reg); - } else { - ShowError("inter: accreg: broken data [%s] line %d\n", accreg_txt, c); - aFree(reg); - } - c++; } - fclose(fp); - - return 0; + SqlStmt_Free(stmt); + return 1; } -// ƒAƒJƒEƒ“ƒg•Ï”‚̃Z[ƒu—p -int inter_accreg_save_sub(DBKey key, void *data, va_list ap) { - char line[8192]; - FILE *fp; - struct accreg *reg = (struct accreg *)data; - - if (reg->reg_num > 0) { - inter_accreg_tostr(line,reg); - fp = va_arg(ap, FILE *); - fprintf(fp, "%s\n", line); - } +// Load account_reg from sql (type=2) +int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type) +{ + struct global_reg* r; + char* data; + size_t len; + int i; - return 0; -} + if( reg == NULL) + return 0; -// ƒAƒJƒEƒ“ƒg•Ï”‚̃Z[ƒu -int inter_accreg_save(void) { - FILE *fp; - int lock; + memset(reg, 0, sizeof(struct accreg)); + reg->account_id = account_id; + reg->char_id = char_id; - if ((fp = lock_fopen(accreg_txt,&lock)) == NULL) { - ShowError("int_accreg: can't write [%s] !!! data is lost !!!\n", accreg_txt); - return 1; + //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) + switch( type ) + { + case 3: //char reg + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) + Sql_ShowDebug(sql_handle); + break; + case 2: //account reg + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) + Sql_ShowDebug(sql_handle); + break; + case 1: //account2 reg + ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); + return 0; + default: + ShowError("inter_accreg_fromsql: Invalid type %d\n", type); + return 0; + } + for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) + { + r = ®->reg[i]; + // str + Sql_GetData(sql_handle, 0, &data, &len); + memcpy(r->str, data, min(len, sizeof(r->str))); + // value + Sql_GetData(sql_handle, 1, &data, &len); + memcpy(r->value, data, min(len, sizeof(r->value))); } - accreg_db->foreach(accreg_db, inter_accreg_save_sub,fp); - lock_fclose(fp, accreg_txt, &lock); + reg->reg_num = i; + Sql_FreeResult(sql_handle); + return 1; +} +// Initialize +int inter_accreg_sql_init(void) +{ + CREATE(accreg_pt, struct accreg, 1); return 0; + } -//-------------------------------------------------------- -#endif //TXT_SQL_CONVERT /*========================================== - * Ý’èƒtƒ@ƒCƒ‹‚ð“ǂݞ‚Þ + * read config file *------------------------------------------*/ -static int inter_config_read(const char *cfgName) { +static int inter_config_read(const char* cfgName) +{ + int i; char line[1024], w1[1024], w2[1024]; - FILE *fp; + FILE* fp; fp = fopen(cfgName, "r"); - if (fp == NULL) { + if(fp == NULL) { ShowError("file not found: %s\n", cfgName); return 1; } + + ShowInfo("reading file %s...\n", cfgName); + while(fgets(line, sizeof(line), fp)) { - if (line[0] == '/' && line[1] == '/') + i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); + if(i != 2) continue; - if (sscanf(line,"%[^:]: %[^\r\n]", w1, w2) != 2) - continue; - - if (strcmpi(w1, "storage_txt") == 0) { - strncpy(storage_txt, w2, sizeof(storage_txt)); - } else if (strcmpi(w1, "party_txt") == 0) { - strncpy(party_txt, w2, sizeof(party_txt)); - } else if (strcmpi(w1, "pet_txt") == 0) { - strncpy(pet_txt, w2, sizeof(pet_txt)); - } else if (strcmpi(w1, "accreg_txt") == 0) { - strncpy(accreg_txt, w2, sizeof(accreg_txt)); - } else if (strcmpi(w1, "guild_txt") == 0) { - strncpy(guild_txt, w2, sizeof(guild_txt)); - } else if (strcmpi(w1, "castle_txt") == 0) { - strncpy(castle_txt, w2, sizeof(castle_txt)); - } else if (strcmpi(w1, "guild_storage_txt") == 0) { - strncpy(guild_storage_txt, w2, sizeof(guild_storage_txt)); -#ifndef TXT_SQL_CONVERT - } else if (strcmpi(w1, "homun_txt") == 0) { - strncpy(homun_txt, w2, sizeof(homun_txt)); - } else if (strcmpi(w1, "party_share_level") == 0) { - party_share_level = (unsigned int)atof(w2); - } else if (strcmpi(w1, "inter_log_filename") == 0) { - strncpy(inter_log_filename, w2, sizeof(inter_log_filename)); - } else if(strcmpi(w1,"log_inter")==0) { + if(!strcmpi(w1,"char_server_ip")) { + strcpy(char_server_ip,w2); + ShowStatus ("set char_server_ip : %s\n", w2); + } else + if(!strcmpi(w1,"char_server_port")) { + char_server_port = atoi(w2); + ShowStatus ("set char_server_port : %s\n", w2); + } else + if(!strcmpi(w1,"char_server_id")) { + strcpy(char_server_id,w2); + ShowStatus ("set char_server_id : %s\n", w2); + } else + if(!strcmpi(w1,"char_server_pw")) { + strcpy(char_server_pw,w2); + ShowStatus ("set char_server_pw : %s\n", w2); + } else + if(!strcmpi(w1,"char_server_db")) { + strcpy(char_server_db,w2); + ShowStatus ("set char_server_db : %s\n", w2); + } else + if(!strcmpi(w1,"default_codepage")) { + strcpy(default_codepage,w2); + ShowStatus ("set default_codepage : %s\n", w2); + } + else if(!strcmpi(w1,"party_share_level")) + party_share_level = atoi(w2); + else if(!strcmpi(w1,"log_inter")) log_inter = atoi(w2); - } else if(strcmpi(w1, "main_chat_nick")==0){ // Main chat nick [LuzZza] + else if(!strcmpi(w1,"main_chat_nick")) safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick)); -#endif //TXT_SQL_CONVERT - } else if (strcmpi(w1, "import") == 0) { + else if(!strcmpi(w1,"import")) inter_config_read(w2); - } } fclose(fp); + ShowInfo ("done reading %s.\n", cfgName); + return 0; } -#ifndef TXT_SQL_CONVERT -// ƒƒO‘‚«o‚µ -int inter_log(char *fmt,...) { - FILE *logfp; + +// Save interlog into sql +int inter_log(char* fmt, ...) +{ + char str[255]; + char esc_str[sizeof(str)*2+1];// escaped str va_list ap; va_start(ap,fmt); - logfp = fopen(inter_log_filename, "a"); - if (logfp) { - vfprintf(logfp, fmt, ap); - fclose(logfp); - } + vsnprintf(str, sizeof(str), fmt, ap); va_end(ap); - return 0; -} - -// ƒZ[ƒu -int inter_save(void) { -#ifdef ENABLE_SC_SAVING - inter_status_save(); -#endif - inter_party_save(); - inter_guild_save(); - inter_storage_save(); - inter_guild_storage_save(); - inter_pet_save(); - inter_homun_save(); - inter_accreg_save(); + Sql_EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str))); + if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) ) + Sql_ShowDebug(sql_handle); return 0; } -#endif //TXT_SQL_CONVERT -// ‰Šú‰» -int inter_init_txt(const char *file) +// initialize +int inter_init_sql(const char *file) { + //int i; + + ShowInfo ("interserver initialize...\n"); inter_config_read(file); -#ifndef TXT_SQL_CONVERT + //DB connection initialized + sql_handle = Sql_Malloc(); + ShowInfo("Connect Character DB server.... (Character Server)\n"); + if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) ) + { + Sql_ShowDebug(sql_handle); + Sql_Free(sql_handle); + exit(EXIT_FAILURE); + } + + if( *default_codepage ) { + if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) + Sql_ShowDebug(sql_handle); + } + wis_db = idb_alloc(DB_OPT_RELEASE_DATA); + inter_guild_sql_init(); + inter_storage_sql_init(); + inter_party_sql_init(); + inter_pet_sql_init(); + inter_homunculus_sql_init(); + inter_mercenary_sql_init(); + inter_accreg_sql_init(); + inter_mail_sql_init(); + inter_auction_sql_init(); - inter_party_init(); - inter_guild_init(); - inter_storage_init(); - inter_pet_init(); - inter_homun_init(); - inter_accreg_init(); -#endif //TXT_SQL_CONVERT return 0; } -#ifndef TXT_SQL_CONVERT + // finalize -void inter_final(void) { - accreg_db->destroy(accreg_db, NULL); +void inter_final(void) +{ wis_db->destroy(wis_db, NULL); - inter_party_final(); - inter_guild_final(); - inter_storage_final(); - inter_pet_final(); - inter_homun_final(); - + inter_guild_sql_final(); + inter_storage_sql_final(); + inter_party_sql_final(); + inter_pet_sql_final(); + inter_homunculus_sql_final(); + inter_mercenary_sql_final(); + inter_mail_sql_final(); + inter_auction_sql_final(); + + if (accreg_pt) aFree(accreg_pt); return; } -// ƒ}ƒbƒvƒT[ƒo[Ú‘± -int inter_mapif_init(int fd) { +int inter_mapif_init(int fd) +{ inter_guild_mapif_init(fd); return 0; } + //-------------------------------------------------------- -// sended packets to map-server // broadcast sending int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) @@ -316,56 +343,32 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short return 0; } -// Wisp/page transmission to one map-server -int mapif_wis_message2(struct WisData *wd, int fd) { - WFIFOHEAD(fd, 56+wd->len); - WFIFOW(fd, 0) = 0x3801; - WFIFOW(fd, 2) = 56 + wd->len; - WFIFOL(fd, 4) = wd->id; - memcpy(WFIFOP(fd, 8), wd->src, NAME_LENGTH); - memcpy(WFIFOP(fd,32), wd->dst, NAME_LENGTH); - memcpy(WFIFOP(fd,56), wd->msg, wd->len); - wd->count = 1; - WFIFOSET(fd,WFIFOW(fd,2)); - return 1; -} - -// Wisp/page transmission to all map-server -int mapif_wis_message(struct WisData *wd) { +// Wis sending +int mapif_wis_message(struct WisData *wd) +{ unsigned char buf[2048]; if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex] WBUFW(buf, 0) = 0x3801; - WBUFW(buf, 2) = 56 + wd->len; + WBUFW(buf, 2) = 56 +wd->len; WBUFL(buf, 4) = wd->id; memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH); memcpy(WBUFP(buf,32), wd->dst, NAME_LENGTH); memcpy(WBUFP(buf,56), wd->msg, wd->len); - wd->count = mapif_sendall(buf, WBUFW(buf,2)); + wd->count = mapif_sendall(buf,WBUFW(buf,2)); return 0; } -int mapif_wis_fail(int fd, char *src) { - unsigned char buf[27]; - WBUFW(buf, 0) = 0x3802; - memcpy(WBUFP(buf, 2), src, NAME_LENGTH); - WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - mapif_send(fd, buf, 27); - return 0; - -} - -// Wisp/page transmission result to map-server +// Wis sending result int mapif_wis_end(struct WisData *wd, int flag) { unsigned char buf[27]; - WBUFW(buf, 0) = 0x3802; - memcpy(WBUFP(buf, 2), wd->src, 24); - WBUFB(buf,26) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - mapif_send(wd->fd, buf, 27); - + WBUFW(buf, 0)=0x3802; + memcpy(WBUFP(buf, 2),wd->src,24); + WBUFB(buf,26)=flag; + mapif_send(wd->fd,buf,27); return 0; } @@ -376,25 +379,28 @@ static void mapif_account_reg(int fd, unsigned char *src) mapif_sendallwos(fd, src, WBUFW(src,2)); } -// ƒAƒJƒEƒ“ƒg•Ï”—v‹•ÔM -int mapif_account_reg_reply(int fd,int account_id, int char_id) +// Send the requested account_reg +int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) { - struct accreg *reg = (struct accreg*)idb_get(accreg_db,account_id); - - WFIFOHEAD(fd, ACCOUNT_REG_NUM * 288+ 13); - WFIFOW(fd,0) = 0x3804; - WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = char_id; - WFIFOB(fd,12) = 2; //Acc Reg - if (reg == NULL) { - WFIFOW(fd,2) = 13; - } else { - int i, p; - for (p=13,i = 0; i < reg->reg_num; i++) { + struct accreg *reg=accreg_pt; + WFIFOHEAD(fd, 13 + 5000); + inter_accreg_fromsql(account_id,char_id,reg,type); + + WFIFOW(fd,0)=0x3804; + WFIFOL(fd,4)=account_id; + WFIFOL(fd,8)=char_id; + WFIFOB(fd,12)=type; + if(reg->reg_num==0){ + WFIFOW(fd,2)=13; + }else{ + int i,p; + for (p=13,i = 0; i < reg->reg_num && p < 5000; i++) { p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].value)+1; } WFIFOW(fd,2)=p; + if (p>= 5000) + ShowWarning("Too many acc regs for %d:%d, not all values were loaded.\n", account_id, char_id); } WFIFOSET(fd,WFIFOW(fd,2)); return 0; @@ -403,22 +409,23 @@ int mapif_account_reg_reply(int fd,int account_id, int char_id) //Request to kick char from a certain map server. [Skotlex] int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) { - if (fd < 0) - return -1; - - WFIFOHEAD(fd, 7); - WFIFOW(fd,0) = 0x2b1f; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = reason; - WFIFOSET(fd,7); - - return 0; + if (fd >= 0) + { + WFIFOHEAD(fd,7); + WFIFOW(fd,0) = 0x2b1f; + WFIFOL(fd,2) = account_id; + WFIFOB(fd,6) = reason; + WFIFOSET(fd,7); + return 0; + } + return -1; } //-------------------------------------------------------- // Existence check of WISP data -int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) { +int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) +{ unsigned long tick; struct WisData *wd = (struct WisData *)data; tick = va_arg(ap, unsigned long); @@ -429,7 +436,8 @@ int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) { return 0; } -int check_ttl_wisdata(void) { +int check_ttl_wisdata(void) +{ unsigned long tick = gettick(); int i; @@ -449,41 +457,27 @@ int check_ttl_wisdata(void) { } //-------------------------------------------------------- -// received packets from map-server // broadcast sending int mapif_parse_broadcast(int fd) { - RFIFOHEAD(fd); mapif_broadcast(RFIFOP(fd,16), RFIFOW(fd,2), RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), fd); return 0; } -static struct WisData* mapif_create_whisper(int fd, char* src, char* dst, char* mes, int meslen) -{ - static int wisid = 0; - struct WisData* wd = (struct WisData *)aCalloc(sizeof(struct WisData), 1); - if (wd == NULL){ - ShowFatalError("inter: WisRequest: out of memory !\n"); - return NULL; - } - wd->id = ++wisid; - wd->fd = fd; - wd->len= meslen; - memcpy(wd->src, src, NAME_LENGTH); - memcpy(wd->dst, dst, NAME_LENGTH); - memcpy(wd->msg, mes, meslen); - wd->tick = gettick(); - return wd; -} // Wisp/page request to send int mapif_parse_WisRequest(int fd) { - struct mmo_charstatus* char_status; struct WisData* wd; + static int wisid = 0; char name[NAME_LENGTH]; - int fd2; + char esc_name[NAME_LENGTH*2+1];// escaped name + char* data; + size_t len; + + + if ( fd <= 0 ) {return 0;} // check if we have a valid fd if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) { ShowWarning("inter: Wis message size too long.\n"); @@ -492,46 +486,73 @@ int mapif_parse_WisRequest(int fd) ShowError("inter: Wis message doesn't exist.\n"); return 0; } - + safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] + Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) ) + Sql_ShowDebug(sql_handle); + // search if character exists before to ask all map-servers - char_status = search_character_byname(name); - if (char_status == NULL) - return mapif_wis_fail(fd, (char*)RFIFOP(fd, 4)); - - // Character exists. - // to be sure of the correct name, rewrite it - memset(name, 0, NAME_LENGTH); - strncpy(name, char_status->name, NAME_LENGTH); - // if source is destination, don't ask other servers. - if (strcmp((char*)RFIFOP(fd,4),name) == 0) - return mapif_wis_fail(fd, (char*)RFIFOP(fd, 4)); - - //Look for online character. - fd2 = search_character_online(char_status->account_id, char_status->char_id); - if (fd2 >= 0) { //Character online, send whisper. - wd = mapif_create_whisper(fd, (char*)RFIFOP(fd, 4), (char*)RFIFOP(fd,28), (char*)RFIFOP(fd,52), RFIFOW(fd,2)-52); - if (!wd) return 1; - idb_put(wis_db, wd->id, wd); - mapif_wis_message2(wd, fd2); - return 0; + if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + { + unsigned char buf[27]; + WBUFW(buf, 0) = 0x3802; + memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); + WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + mapif_send(fd, buf, 27); + } + else + {// Character exists. So, ask all map-servers + // to be sure of the correct name, rewrite it + Sql_GetData(sql_handle, 0, &data, &len); + memset(name, 0, NAME_LENGTH); + memcpy(name, data, min(len, NAME_LENGTH)); + // if source is destination, don't ask other servers. + if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 ) + { + uint8 buf[27]; + WBUFW(buf, 0) = 0x3802; + memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); + WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + mapif_send(fd, buf, 27); + } + else + { + + CREATE(wd, struct WisData, 1); + + // Whether the failure of previous wisp/page transmission (timeout) + check_ttl_wisdata(); + + wd->id = ++wisid; + wd->fd = fd; + wd->len= RFIFOW(fd,2)-52; + memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH); + memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH); + memcpy(wd->msg, RFIFOP(fd,52), wd->len); + wd->tick = gettick(); + idb_put(wis_db, wd->id, wd); + mapif_wis_message(wd); + } } - //Not found. - return mapif_wis_fail(fd, (char*)RFIFOP(fd,4)); + + Sql_FreeResult(sql_handle); + return 0; } + // Wisp/page transmission result -int mapif_parse_WisReply(int fd) { +int mapif_parse_WisReply(int fd) +{ int id, flag; struct WisData *wd; - RFIFOHEAD(fd); + id = RFIFOL(fd,2); flag = RFIFOB(fd,6); wd = (struct WisData*)idb_get(wis_db, id); - if (wd == NULL) - return 0; // This wisp was probably suppress before, because it was timeout or because of target was found on another map-server + return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server if ((--wd->count) <= 0 || flag != 1) { mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -542,10 +563,10 @@ int mapif_parse_WisReply(int fd) { } // Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers) -int mapif_parse_WisToGM(int fd) { +int mapif_parse_WisToGM(int fd) +{ unsigned char buf[2048]; // 0x3003/0x3803 .w .24B .w .?B - - ShowDebug("Sent packet back!\n"); + memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2)); WBUFW(buf, 0) = 0x3803; mapif_sendall(buf, RFIFOW(fd,2)); @@ -553,32 +574,26 @@ int mapif_parse_WisToGM(int fd) { return 0; } -static void* create_accreg(DBKey key, va_list args) { - struct accreg *reg; - reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1); - reg->account_id = key.i; - return reg; -} - -// ƒAƒJƒEƒ“ƒg•Ï”•Û‘¶—v‹ -int mapif_parse_Registry(int fd) { - int j, p, len; - struct accreg *reg; - RFIFOHEAD(fd); - - switch (RFIFOB(fd,12)) { - case 3: //Character registry - return char_parse_Registry(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,13), RFIFOW(fd,2)-13); - case 2: //Acc Reg - break; - case 1: //Acc Reg2, forward to login - return save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4); - default: //Error? - return 1; +// Save account_reg into sql (type=2) +int mapif_parse_Registry(int fd) +{ + int j,p,len, max; + struct accreg *reg=accreg_pt; + + memset(accreg_pt,0,sizeof(struct accreg)); + switch (RFIFOB(fd, 12)) { + case 3: //Character registry + max = GLOBAL_REG_NUM; + break; + case 2: //Account Registry + max = ACCOUNT_REG_NUM; + break; + case 1: //Account2 registry, must be sent over to login server. + return save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4); + default: + return 1; } - reg = (struct accreg*)idb_ensure(accreg_db, RFIFOL(fd,4), create_accreg); - - for(j=0,p=13;jreg[j].str,&len); reg->reg[j].str[len]='\0'; p +=len+1; //+1 to skip the '\0' between strings. @@ -587,34 +602,32 @@ int mapif_parse_Registry(int fd) { p +=len+1; } reg->reg_num=j; - mapif_account_reg(fd, RFIFOP(fd,0)); // ‘¼‚ÌMAPƒT[ƒo[‚É‘—M + inter_accreg_tosql(RFIFOL(fd,4),RFIFOL(fd,8),reg, RFIFOB(fd,12)); + mapif_account_reg(fd,RFIFOP(fd,0)); // Send updated accounts to other map servers. return 0; } // Request the value of all registries. int mapif_parse_RegistryRequest(int fd) -{ - RFIFOHEAD(fd); +{ //Load Char Registry - if (RFIFOB(fd,12)) - char_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6)); + if (RFIFOB(fd,12)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3); //Load Account Registry - if (RFIFOB(fd,11)) - mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6)); + if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2); //Ask Login Server for Account2 values. - if (RFIFOB(fd,10)) - request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6)); + if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6)); return 1; } -static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name){ +static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name) +{ WFIFOHEAD(fd, NAME_LENGTH+13); - WFIFOW(fd, 0) =0x3806; - WFIFOL(fd, 2) =account_id; - WFIFOL(fd, 6) =char_id; - WFIFOB(fd,10) =type; - WFIFOB(fd,11) =flag; + WFIFOW(fd, 0) = 0x3806; + WFIFOL(fd, 2) = account_id; + WFIFOL(fd, 6) = char_id; + WFIFOB(fd,10) = type; + WFIFOB(fd,11) = flag; memcpy(WFIFOP(fd, 12), name, NAME_LENGTH); WFIFOSET(fd, NAME_LENGTH+13); } @@ -625,11 +638,10 @@ int mapif_parse_NameChangeRequest(int fd) char* name; int i; - RFIFOHEAD(fd); - account_id = RFIFOL(fd, 2); - char_id = RFIFOL(fd, 6); - type = RFIFOB(fd, 10); - name = (char*)RFIFOP(fd, 11); + account_id = RFIFOL(fd,2); + char_id = RFIFOL(fd,6); + type = RFIFOB(fd,10); + name = (char*)RFIFOP(fd,11); // Check Authorised letters/symbols in the name if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised @@ -675,24 +687,17 @@ int inter_check_length(int fd, int length) return length; } -// map server ‚©‚ç‚Ì’ÊMi‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æj -// ƒGƒ‰[‚È‚ç0(false)Aˆ—‚Å‚«‚½‚È‚ç1A -// ƒpƒPƒbƒg’·‚ª‘«‚è‚È‚¯‚ê‚Î2‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ -int inter_parse_frommap(int fd) { - int cmd, len; - RFIFOHEAD(fd); +int inter_parse_frommap(int fd) +{ + int cmd; + int len = 0; cmd = RFIFOW(fd,0); - len = 0; - // interŽIŠÇŠ‚©‚𒲂ׂé - if (cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length)) - return 0; - - if (inter_recv_packet_length[cmd-0x3000] == 0) //This is necessary, because otherwise we return 2 and the char server will just hang waiting for packets! [Skotlex] + if(cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length) || inter_recv_packet_length[cmd - 0x3000] == 0) return 0; // ƒpƒPƒbƒg’·‚𒲂ׂé - if ((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0) + if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0) return 2; switch(cmd) { @@ -704,20 +709,21 @@ int inter_parse_frommap(int fd) { case 0x3005: mapif_parse_RegistryRequest(fd); break; case 0x3006: mapif_parse_NameChangeRequest(fd); break; default: - if (inter_party_parse_frommap(fd)) - break; - if (inter_guild_parse_frommap(fd)) - break; - if (inter_storage_parse_frommap(fd)) - break; - if (inter_pet_parse_frommap(fd)) - break; - if (inter_homun_parse_frommap(fd)) + if( inter_party_parse_frommap(fd) + || inter_guild_parse_frommap(fd) + || inter_storage_parse_frommap(fd) + || inter_pet_parse_frommap(fd) + || inter_homunculus_parse_frommap(fd) + || inter_mercenary_parse_frommap(fd) + || inter_mail_parse_frommap(fd) + || inter_auction_parse_frommap(fd) + || inter_quest_parse_frommap(fd) + ) break; - return 0; + else + return 0; } + RFIFOSKIP(fd, len); return 1; } - -#endif //TXT_SQL_CONVERT diff --git a/src/char/inter.h b/src/char/inter.h index cf3eb4b2e..ac2e1785f 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -1,16 +1,17 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INTER_H_ -#define _INTER_H_ +#ifndef _INTER_SQL_H_ +#define _INTER_SQL_H_ struct accreg; +#include "../common/sql.h" -int inter_init_txt(const char *file); +int inter_init_sql(const char *file); void inter_final(void); -int inter_save(void); int inter_parse_frommap(int fd); int inter_mapif_init(int fd); +int mapif_send_gmaccounts(void); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); int inter_log(char *fmt,...); @@ -18,10 +19,12 @@ int inter_log(char *fmt,...); #define inter_cfgName "conf/inter_athena.conf" extern unsigned int party_share_level; + +extern Sql* sql_handle; +extern Sql* lsql_handle; + extern char main_chat_nick[16]; -//For TXT->SQL conversion -extern char accreg_txt[]; -int inter_accreg_fromstr(const char *str, struct accreg *reg); +int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); -#endif /* _INTER_H_ */ +#endif /* _INTER_SQL_H_ */ diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt deleted file mode 100644 index 823939393..000000000 --- a/src/char_sql/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ - -# -# setup -# -set( SQL_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) - - -# -# char sql -# -if( BUILD_SQL_SERVERS ) -message( STATUS "Creating target char-server_sql" ) -set( SQL_CHAR_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/char.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_auction.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_mail.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_party.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_quest.h" - "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.h" - "${CMAKE_CURRENT_SOURCE_DIR}/inter.h" - ) -set( SQL_CHAR_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/char.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_auction.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_mail.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_party.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_quest.c" - "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.c" - "${CMAKE_CURRENT_SOURCE_DIR}/inter.c" - ) -set( DEPENDENCIES common_sql ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) -set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} ) -source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) -source_group( char FILES ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} ) -include_directories( ${INCLUDE_DIRS} ) -add_executable( char-server_sql ${SOURCE_FILES} ) -add_dependencies( char-server_sql ${DEPENDENCIES} ) -target_link_libraries( char-server_sql ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( char-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_charserver_sql DESCRIPTION "char-server (sql version)" DISPLAY_NAME "char-server_sql" GROUP Runtime ) - install( TARGETS char-server_sql - DESTINATION "." - COMPONENT Runtime_charserver_sql ) -endif( INSTALL_COMPONENT_RUNTIME ) -message( STATUS "Creating target char-server_sql - done" ) -endif( BUILD_SQL_SERVERS ) diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in deleted file mode 100644 index e96113f0e..000000000 --- a/src/char_sql/Makefile.in +++ /dev/null @@ -1,71 +0,0 @@ - -COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ - ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ - ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ - ../common/obj_all/strlib.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/random.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h \ - ../common/strlib.h \ - ../common/mapindex.h ../common/ers.h ../common/random.h - -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - -COMMON_SQL_OBJ = ../common/obj_sql/sql.o -COMMON_H = ../common/sql.h - -CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \ - obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o -CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h - -HAVE_MYSQL=@HAVE_MYSQL@ -ifeq ($(HAVE_MYSQL),yes) - CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) -else - CHAR_SERVER_SQL_DEPENDS=needs_mysql -endif - -@SET_MAKE@ - -##################################################################### -.PHONY : all char-server_sql clean help - -all: char-server_sql - -char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@ - -clean: - rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ - -help: - @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" - @echo "'char-server_sql' - char server (SQL version)" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" - -##################################################################### - -needs_mysql: - @echo "MySQL not found or disabled by the configure script" - @exit 1 - -obj_sql: - -mkdir obj_sql - -obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -# missing object files -../common/obj_all/%.o: - @$(MAKE) -C ../common sql - -../common/obj_sql/%.o: - @$(MAKE) -C ../common sql - -MT19937AR_OBJ: - @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/char_sql/char.c b/src/char_sql/char.c deleted file mode 100644 index 35154d3cf..000000000 --- a/src/char_sql/char.c +++ /dev/null @@ -1,4636 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/version.h" -#include "inter.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_party.h" -#include "int_storage.h" -#include "char.h" - -#include -#include -#include -#include -#include -#include -#include - -// private declarations -#define CHAR_CONF_NAME "conf/char_athena.conf" -#define LAN_CONF_NAME "conf/subnet_athena.conf" -#define SQL_CONF_NAME "conf/inter_athena.conf" - -char char_db[256] = "char"; -char scdata_db[256] = "sc_data"; -char cart_db[256] = "cart_inventory"; -char inventory_db[256] = "inventory"; -char charlog_db[256] = "charlog"; -char storage_db[256] = "storage"; -char interlog_db[256] = "interlog"; -char reg_db[256] = "global_reg_value"; -char skill_db[256] = "skill"; -char memo_db[256] = "memo"; -char guild_db[256] = "guild"; -char guild_alliance_db[256] = "guild_alliance"; -char guild_castle_db[256] = "guild_castle"; -char guild_expulsion_db[256] = "guild_expulsion"; -char guild_member_db[256] = "guild_member"; -char guild_position_db[256] = "guild_position"; -char guild_skill_db[256] = "guild_skill"; -char guild_storage_db[256] = "guild_storage"; -char party_db[256] = "party"; -char pet_db[256] = "pet"; -char mail_db[256] = "mail"; // MAIL SYSTEM -char auction_db[256] = "auction"; // Auctions System -char friend_db[256] = "friends"; -char hotkey_db[256] = "hotkey"; -char quest_db[256] = "quest"; - -// show loading/saving messages -#ifdef TXT_SQL_CONVERT -int save_log = 0; //Have the logs be off by default when converting -#else -int save_log = 1; -#endif - -//If your code editor is having problems syntax highlighting this file, uncomment this and RECOMMENT IT BEFORE COMPILING -//#undef TXT_SQL_CONVERT -#ifndef TXT_SQL_CONVERT -static DBMap* char_db_; // int char_id -> struct mmo_charstatus* - -char db_path[1024] = "db"; - -int db_use_sqldbs; - -struct mmo_map_server { - int fd; - uint32 ip; - uint16 port; - int users; - unsigned short map[MAX_MAP_PER_SERVER]; -} server[MAX_MAP_SERVERS]; - -int login_fd=-1, char_fd=-1; -char userid[24]; -char passwd[24]; -char server_name[20]; -char wisp_server_name[NAME_LENGTH] = "Server"; -char login_ip_str[128]; -uint32 login_ip = 0; -uint16 login_port = 6900; -char char_ip_str[128]; -uint32 char_ip = 0; -char bind_ip_str[128]; -uint32 bind_ip = INADDR_ANY; -uint16 char_port = 6121; -int char_maintenance = 0; -bool char_new = true; -int char_new_display = 0; - -bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor] -int char_name_option = 0; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor] -char unknown_char_name[NAME_LENGTH] = "Unknown"; // Name to use when the requested name cannot be determined -#define TRIM_CHARS "\255\xA0\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex] -char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) in a character name. by [Yor] - -int char_per_account = 0; //Maximum charas per account (default unlimited) [Sirius] -int char_del_level = 0; //From which level u can delete character [Lupus] -int char_del_delay = 86400; - -int log_char = 1; // loggin char or not [devil] -int log_inter = 1; // loggin inter or not [devil] - -// Advanced subnet check [LuzZza] -struct s_subnet { - uint32 mask; - uint32 char_ip; - uint32 map_ip; -} subnet[16]; -int subnet_count = 0; - -struct char_session_data { - bool auth; // whether the session is authed or not - int account_id, login_id1, login_id2, sex; - int found_char[MAX_CHARS]; // ids of chars on this account - char email[40]; // e-mail (default: a@a.com) by [Yor] - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - int gmlevel; - uint32 version; - uint8 clienttype; - char new_name[NAME_LENGTH]; - char birthdate[10+1]; // YYYY-MM-DD -}; - -int max_connect_user = 0; -int gm_allow_level = 99; -int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; -int start_zeny = 0; -int start_weapon = 1201; -int start_armor = 2301; -int guild_exp_rate = 100; - -//Custom limits for the fame lists. [Skotlex] -int fame_list_size_chemist = MAX_FAME_LIST; -int fame_list_size_smith = MAX_FAME_LIST; -int fame_list_size_taekwon = MAX_FAME_LIST; - -// Char-server-side stored fame lists [DracoRPG] -struct fame_list smith_fame_list[MAX_FAME_LIST]; -struct fame_list chemist_fame_list[MAX_FAME_LIST]; -struct fame_list taekwon_fame_list[MAX_FAME_LIST]; - -// check for exit signal -// 0 is saving complete -// other is char_id -unsigned int save_flag = 0; - -// Initial position (it's possible to set it in conf file) -struct point start_point = { 0, 53, 111 }; - -int console = 0; - -//----------------------------------------------------- -// Auth database -//----------------------------------------------------- -#define AUTH_TIMEOUT 30000 - -struct auth_node { - int account_id; - int char_id; - uint32 login_id1; - uint32 login_id2; - uint32 ip; - int sex; - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - int gmlevel; - unsigned changing_mapservers : 1; -}; - -static DBMap* auth_db; // int account_id -> struct auth_node* - -//----------------------------------------------------- -// Online User Database -//----------------------------------------------------- - -struct online_char_data { - int account_id; - int char_id; - int fd; - int waiting_disconnect; - short server; // -2: unknown server, -1: not connected, 0+: id of server -}; - -static DBMap* online_char_db; // int account_id -> struct online_char_data* -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); -int delete_char_sql(int char_id); - -static void* create_online_char_data(DBKey key, va_list args) -{ - struct online_char_data* character; - CREATE(character, struct online_char_data, 1); - character->account_id = key.i; - character->char_id = -1; - character->server = -1; - character->fd = -1; - character->waiting_disconnect = INVALID_TIMER; - return character; -} - -void set_char_charselect(int account_id) -{ - struct online_char_data* character; - - character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); - - if( character->server > -1 ) - if( server[character->server].users > 0 ) // Prevent this value from going negative. - server[character->server].users--; - - character->char_id = -1; - character->server = -1; - - if(character->waiting_disconnect != INVALID_TIMER) { - delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = INVALID_TIMER; - } - - if (login_fd > 0 && !session[login_fd]->flag.eof) - { - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x272b; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - } - -} - -void set_char_online(int map_id, int char_id, int account_id) -{ - struct online_char_data* character; - struct mmo_charstatus *cp; - - //Update DB - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - - //Check to see for online conflicts - character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); - if( character->char_id != -1 && character->server > -1 && character->server != map_id ) - { - ShowNotice("set_char_online: Character %d:%d marked in map server %d, but map server %d claims to have (%d:%d) online!\n", - character->account_id, character->char_id, character->server, map_id, account_id, char_id); - mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - } - - //Update state data - character->char_id = char_id; - character->server = map_id; - - if( character->server > -1 ) - server[character->server].users++; - - //Get rid of disconnect timer - if(character->waiting_disconnect != INVALID_TIMER) { - delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = INVALID_TIMER; - } - - //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it. - cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); - inter_guild_CharOnline(char_id, cp?cp->guild_id:-1); - - //Notify login server - if (login_fd > 0 && !session[login_fd]->flag.eof) - { - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x272b; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - } -} - -void set_char_offline(int char_id, int account_id) -{ - struct online_char_data* character; - - if ( char_id == -1 ) - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) ) - Sql_ShowDebug(sql_handle); - } - else - { - struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); - inter_guild_CharOffline(char_id, cp?cp->guild_id:-1); - if (cp) - idb_remove(char_db_,char_id); - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - } - - if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL) - { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] - if( character->server > -1 ) - if( server[character->server].users > 0 ) // Prevent this value from going negative. - server[character->server].users--; - - if(character->waiting_disconnect != INVALID_TIMER){ - delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = INVALID_TIMER; - } - - if(character->char_id == char_id) - { - character->char_id = -1; - character->server = -1; - } - - //FIXME? Why Kevin free'd the online information when the char was effectively in the map-server? - } - - //Remove char if 1- Set all offline, or 2- character is no longer connected to char-server. - if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1)) - { - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x272c; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - } -} - -static int char_db_setoffline(DBKey key, void* data, va_list ap) -{ - struct online_char_data* character = (struct online_char_data*)data; - int server = va_arg(ap, int); - if (server == -1) { - character->char_id = -1; - character->server = -1; - if(character->waiting_disconnect != INVALID_TIMER){ - delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = INVALID_TIMER; - } - } else if (character->server == server) - character->server = -2; //In some map server that we aren't connected to. - return 0; -} - -static int char_db_kickoffline(DBKey key, void* data, va_list ap) -{ - struct online_char_data* character = (struct online_char_data*)data; - int server_id = va_arg(ap, int); - - if (server_id > -1 && character->server != server_id) - return 0; - - //Kick out any connected characters, and set them offline as appropiate. - if (character->server > -1) - mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 1); - else if (character->waiting_disconnect == INVALID_TIMER) - set_char_offline(character->char_id, character->account_id); - else - return 0; // fail - - return 1; -} - -void set_all_offline(int id) -{ - if (id < 0) - ShowNotice("Sending all users offline.\n"); - else - ShowNotice("Sending users of map-server %d offline.\n",id); - online_char_db->foreach(online_char_db,char_db_kickoffline,id); - - if (id >= 0 || login_fd <= 0 || session[login_fd]->flag.eof) - return; - //Tell login-server to also mark all our characters as offline. - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x2737; - WFIFOSET(login_fd,2); -} - -void set_all_offline_sql(void) -{ - //Set all players to 'OFFLINE' - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) ) - Sql_ShowDebug(sql_handle); -} - -static void* create_charstatus(DBKey key, va_list args) -{ - struct mmo_charstatus *cp; - cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus)); - cp->char_id = key.i; - return cp; -} -#endif //TXT_SQL_CONVERT - -int mmo_char_tosql(int char_id, struct mmo_charstatus* p) -{ - int i = 0; - int count = 0; - int diff = 0; - char save_status[128]; //For displaying save information. [Skotlex] - struct mmo_charstatus *cp; - int errors = 0; //If there are any errors while saving, "cp" will not be updated at the end. - StringBuf buf; - - if (char_id!=p->char_id) return 0; - -#ifndef TXT_SQL_CONVERT - cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); -#else - cp = (struct mmo_charstatus*)aCalloc(1, sizeof(struct mmo_charstatus)); -#endif - - StringBuf_Init(&buf); - memset(save_status, 0, sizeof(save_status)); - - //map inventory data - if( memcmp(p->inventory, cp->inventory, sizeof(p->inventory)) ) - { - if (!memitemdata_to_sql(p->inventory, MAX_INVENTORY, p->char_id, TABLE_INVENTORY)) - strcat(save_status, " inventory"); - else - errors++; - } - - //map cart data - if( memcmp(p->cart, cp->cart, sizeof(p->cart)) ) - { - if (!memitemdata_to_sql(p->cart, MAX_CART, p->char_id, TABLE_CART)) - strcat(save_status, " cart"); - else - errors++; - } - - //map storage data - if( memcmp(p->storage.items, cp->storage.items, sizeof(p->storage.items)) ) - { - if (!memitemdata_to_sql(p->storage.items, MAX_STORAGE, p->account_id, TABLE_STORAGE)) - strcat(save_status, " storage"); - else - errors++; - } - -#ifdef TXT_SQL_CONVERT -{ //Insert the barebones to then update the rest. - char esc_name[NAME_LENGTH*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `account_id`, `char_num`, `name`) VALUES ('%d', '%d', '%d', '%s')", - char_db, p->char_id, p->account_id, p->slot, esc_name) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } else - strcat(save_status, " creation"); -} -#endif - - if ( - (p->base_exp != cp->base_exp) || (p->base_level != cp->base_level) || - (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || - (p->zeny != cp->zeny) || - (p->last_point.map != cp->last_point.map) || - (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || - (p->max_hp != cp->max_hp) || (p->hp != cp->hp) || - (p->max_sp != cp->max_sp) || (p->sp != cp->sp) || - (p->status_point != cp->status_point) || (p->skill_point != cp->skill_point) || - (p->str != cp->str) || (p->agi != cp->agi) || (p->vit != cp->vit) || - (p->int_ != cp->int_) || (p->dex != cp->dex) || (p->luk != cp->luk) || - (p->option != cp->option) || - (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || - (p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) || - (p->shield != cp->shield) || (p->head_top != cp->head_top) || - (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || - (p->rename != cp->rename) || (p->robe != cp->robe) - ) - { //Save status - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," - "`base_exp`='%u', `job_exp`='%u', `zeny`='%d'," - "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," - "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d'," - "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d'," - "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," - "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d'," - "`delete_date`='%lu',`robe`='%d'" - " WHERE `account_id`='%d' AND `char_id` = '%d'", - char_db, p->base_level, p->job_level, - p->base_exp, p->job_exp, p->zeny, - p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, - p->str, p->agi, p->vit, p->int_, p->dex, p->luk, - p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, - p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, - mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, - mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, - (unsigned long)p->delete_date, // FIXME: platform-dependent size - p->robe, - p->account_id, p->char_id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } else - strcat(save_status, " status"); - } - - //Values that will seldom change (to speed up saving) - if ( - (p->hair != cp->hair) || (p->hair_color != cp->hair_color) || (p->clothes_color != cp->clothes_color) || - (p->class_ != cp->class_) || - (p->partner_id != cp->partner_id) || (p->father != cp->father) || - (p->mother != cp->mother) || (p->child != cp->child) || - (p->karma != cp->karma) || (p->manner != cp->manner) || - (p->fame != cp->fame) - ) - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d'," - "`hair`='%d',`hair_color`='%d',`clothes_color`='%d'," - "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d'," - "`karma`='%d',`manner`='%d', `fame`='%d'" - " WHERE `account_id`='%d' AND `char_id` = '%d'", - char_db, p->class_, - p->hair, p->hair_color, p->clothes_color, - p->partner_id, p->father, p->mother, p->child, - p->karma, p->manner, p->fame, - p->account_id, p->char_id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } else - strcat(save_status, " status2"); - } - - /* Mercenary Owner */ - if( (p->mer_id != cp->mer_id) || - (p->arch_calls != cp->arch_calls) || (p->arch_faith != cp->arch_faith) || - (p->spear_calls != cp->spear_calls) || (p->spear_faith != cp->spear_faith) || - (p->sword_calls != cp->sword_calls) || (p->sword_faith != cp->sword_faith) ) - { - if (mercenary_owner_tosql(char_id, p)) - strcat(save_status, " mercenary"); - else - errors++; - } - - //memo points - if( memcmp(p->memo_point, cp->memo_point, sizeof(p->memo_point)) ) - { - char esc_mapname[NAME_LENGTH*2+1]; - - //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - - //insert here. - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db); - for( i = 0, count = 0; i < MAX_MEMOPOINTS; ++i ) - { - if( p->memo_point[i].map ) - { - if( count ) - StringBuf_AppendStr(&buf, ","); - Sql_EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map)); - StringBuf_Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y); - ++count; - } - } - if( count ) - { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - } - strcat(save_status, " memo"); - } - - //FIXME: is this neccessary? [ultramage] - for(i=0;iskill[i].lv != 0) && (p->skill[i].id == 0)) - p->skill[i].id = i; // Fix skill tree - - - //skills - if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) - { - //`skill` (`char_id`, `id`, `lv`) - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`) VALUES ", skill_db); - //insert here. - for( i = 0, count = 0; i < MAX_SKILL; ++i ) - { - if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) - { - if( p->skill[i].flag == SKILL_FLAG_PERMANENT && p->skill[i].lv == 0 ) - continue; - if( p->skill[i].flag != SKILL_FLAG_PERMANENT && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 ) - continue; - if( count ) - StringBuf_AppendStr(&buf, ","); - StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->skill[i].id, (p->skill[i].flag == SKILL_FLAG_PERMANENT ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0)); - ++count; - } - } - if( count ) - { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - } - - strcat(save_status, " skills"); - } - - diff = 0; - for(i = 0; i < MAX_FRIENDS; i++){ - if(p->friends[i].char_id != cp->friends[i].char_id || - p->friends[i].account_id != cp->friends[i].account_id){ - diff = 1; - break; - } - } - - if(diff == 1) - { //Save friends - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db); - for( i = 0, count = 0; i < MAX_FRIENDS; ++i ) - { - if( p->friends[i].char_id > 0 ) - { - if( count ) - StringBuf_AppendStr(&buf, ","); - StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->friends[i].account_id, p->friends[i].char_id); - count++; - } - } - if( count ) - { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - } - strcat(save_status, " friends"); - } - -#ifdef HOTKEY_SAVING - // hotkeys - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db); - diff = 0; - for(i = 0; i < ARRAYLENGTH(p->hotkeys); i++){ - if(memcmp(&p->hotkeys[i], &cp->hotkeys[i], sizeof(struct hotkey))) - { - if( diff ) - StringBuf_AppendStr(&buf, ",");// not the first hotkey - StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv); - diff = 1; - } - } - if(diff) { - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } else - strcat(save_status, " hotkeys"); - } -#endif - StringBuf_Destroy(&buf); - if (save_status[0]!='\0' && save_log) - ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status); -#ifndef TXT_SQL_CONVERT - if (!errors) - memcpy(cp, p, sizeof(struct mmo_charstatus)); -#else - aFree(cp); -#endif - return 0; -} - -/// Saves an array of 'item' entries into the specified table. -int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch) -{ - StringBuf buf; - SqlStmt* stmt; - int i; - int j; - const char* tablename; - const char* selectoption; - struct item item; // temp storage variable - bool* flag; // bit array for inventory matching - bool found; - int errors = 0; - - switch (tableswitch) { - case TABLE_INVENTORY: tablename = inventory_db; selectoption = "char_id"; break; - case TABLE_CART: tablename = cart_db; selectoption = "char_id"; break; - case TABLE_STORAGE: tablename = storage_db; selectoption = "account_id"; break; - case TABLE_GUILD_STORAGE: tablename = guild_storage_db; selectoption = "guild_id"; break; - default: - ShowError("Invalid table name!\n"); - return 1; - } - - - // The following code compares inventory with current database values - // and performs modification/deletion/insertion only on relevant rows. - // This approach is more complicated than a trivial delete&insert, but - // it significantly reduces cpu load on the database server. - - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ", `card%d`", j); - StringBuf_Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id); - - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_ERROR == SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - StringBuf_Destroy(&buf); - return 1; - } - - SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL); - SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL); - for( j = 0; j < MAX_SLOTS; ++j ) - SqlStmt_BindColumn(stmt, 8+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL); - - // bit array indicating which inventory items have already been matched - flag = (bool*) aCallocA(max, sizeof(bool)); - - while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) - { - found = false; - // search for the presence of the item in the char's inventory - for( i = 0; i < max; ++i ) - { - // skip empty and already matched entries - if( items[i].nameid == 0 || flag[i] ) - continue; - - if( items[i].nameid == item.nameid - && items[i].card[0] == item.card[0] - && items[i].card[2] == item.card[2] - && items[i].card[3] == item.card[3] - ) { //They are the same item. - ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] ); - if( j == MAX_SLOTS && - items[i].amount == item.amount && - items[i].equip == item.equip && - items[i].identify == item.identify && - items[i].refine == item.refine && - items[i].attribute == item.attribute && - items[i].expire_time == item.expire_time ) - ; //Do nothing. - else - { - // update all fields. - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u'", - tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); - StringBuf_Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); - - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - } - - found = flag[i] = true; //Item dealt with, - break; //skip to next item in the db. - } - } - if( !found ) - {// Item not present in inventory, remove it. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - } - } - SqlStmt_Free(stmt); - - StringBuf_Clear(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`", tablename, selectoption); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ", `card%d`", j); - StringBuf_AppendStr(&buf, ") VALUES "); - - found = false; - // insert non-matched items into the db as new items - for( i = 0; i < max; ++i ) - { - // skip empty and already matched entries - if( items[i].nameid == 0 || flag[i] ) - continue; - - if( found ) - StringBuf_AppendStr(&buf, ","); - else - found = true; - - StringBuf_Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u'", - id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ", '%d'", items[i].card[j]); - StringBuf_AppendStr(&buf, ")"); - } - - if( found && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - errors++; - } - - StringBuf_Destroy(&buf); - aFree(flag); - - return errors; -} - -int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p); - -#ifndef TXT_SQL_CONVERT -//===================================================================================================== -// Loads the basic character rooster for the given account. Returns total buffer used. -int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) -{ - SqlStmt* stmt; - struct mmo_charstatus p; - int j = 0, i; - char last_map[MAP_NAME_LENGTH_EXT]; - - stmt = SqlStmt_Malloc(sql_handle); - if( stmt == NULL ) - { - SqlStmt_ShowDebug(stmt); - return 0; - } - memset(&p, 0, sizeof(p)); - - // read char data - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT " - "`char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," - "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," - "`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`," - "`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`," - "`robe`" - " FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p.rename, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL) - ) - { - SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - return 0; - } - for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SqlStmt_NextRow(stmt); i++ ) - { - if( p.delete_date && p.delete_date < time(NULL) ) { - delete_char_sql(p.char_id); - i--; - continue; - } - p.last_point.map = mapindex_name2id(last_map); - sd->found_char[i] = p.char_id; - j += mmo_char_tobuf(WBUFP(buf, j), &p); - } - for( ; i < MAX_CHARS; i++ ) - sd->found_char[i] = -1; - - memset(sd->new_name,0,sizeof(sd->new_name)); - - SqlStmt_Free(stmt); - return j; -} - -//===================================================================================================== -int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) -{ - int i,j; - char t_msg[128] = ""; - struct mmo_charstatus* cp; - StringBuf buf; - SqlStmt* stmt; - char last_map[MAP_NAME_LENGTH_EXT]; - char save_map[MAP_NAME_LENGTH_EXT]; - char point_map[MAP_NAME_LENGTH_EXT]; - struct point tmp_point; - struct item tmp_item; - struct s_skill tmp_skill; - struct s_friend tmp_friend; -#ifdef HOTKEY_SAVING - struct hotkey tmp_hotkey; - int hotkey_num; -#endif - - memset(p, 0, sizeof(struct mmo_charstatus)); - - if (save_log) ShowInfo("Char load request (%d)\n", char_id); - - stmt = SqlStmt_Malloc(sql_handle); - if( stmt == NULL ) - { - SqlStmt_ShowDebug(stmt); - return 0; - } - - // read char data - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT " - "`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," - "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," - "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`hair`," - "`hair_color`,`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`," - "`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`" - " FROM `%s` WHERE `char_id`=? LIMIT 1", char_db) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p->hair, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p->shield, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_INT, &p->partner_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_INT, &p->father, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_INT, &p->mother, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_INT, &p->child, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_INT, &p->fame, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_SHORT, &p->rename, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT, &p->robe, 0, NULL, NULL) - ) - { - SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - return 0; - } - if( SQL_ERROR == SqlStmt_NextRow(stmt) ) - { - ShowError("Requested non-existant character id: %d!\n", char_id); - SqlStmt_Free(stmt); - return 0; - } - p->last_point.map = mapindex_name2id(last_map); - p->save_point.map = mapindex_name2id(save_map); - - strcat(t_msg, " status"); - - if (!load_everything) // For quick selection of data when displaying the char menu - { - SqlStmt_Free(stmt); - return 1; - } - - //read memo data - //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - { - tmp_point.map = mapindex_name2id(point_map); - memcpy(&p->memo_point[i], &tmp_point, sizeof(tmp_point)); - } - strcat(t_msg, " memo"); - - //read inventory - //`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); - for( i = 0; i < MAX_SLOTS; ++i ) - StringBuf_Printf(&buf, ", `card%d`", i); - StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY); - - if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - for( i = 0; i < MAX_SLOTS; ++i ) - if( SQL_ERROR == SqlStmt_BindColumn(stmt, 8+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - for( i = 0; i < MAX_INVENTORY && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - memcpy(&p->inventory[i], &tmp_item, sizeof(tmp_item)); - - strcat(t_msg, " inventory"); - - //read cart - //`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`) - StringBuf_Clear(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`"); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ", `card%d`", j); - StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART); - - if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - for( i = 0; i < MAX_SLOTS; ++i ) - if( SQL_ERROR == SqlStmt_BindColumn(stmt, 8+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - for( i = 0; i < MAX_CART && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - memcpy(&p->cart[i], &tmp_item, sizeof(tmp_item)); - strcat(t_msg, " cart"); - - //read storage - storage_fromsql(p->account_id, &p->storage); - strcat(t_msg, " storage"); - - //read skill - //`skill` (`char_id`, `id`, `lv`) - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_USHORT, &tmp_skill.lv, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - tmp_skill.flag = SKILL_FLAG_PERMANENT; - - for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - { - if( tmp_skill.id < ARRAYLENGTH(p->skill) ) - memcpy(&p->skill[tmp_skill.id], &tmp_skill, sizeof(tmp_skill)); - else - ShowWarning("mmo_char_fromsql: ignoring invalid skill (id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", tmp_skill.id, tmp_skill.lv, p->name, p->account_id, p->char_id); - } - strcat(t_msg, " skills"); - - //read friends - //`friends` (`char_id`, `friend_account`, `friend_id`) - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - memcpy(&p->friends[i], &tmp_friend, sizeof(tmp_friend)); - strcat(t_msg, " friends"); - -#ifdef HOTKEY_SAVING - //read hotkeys - //`hotkey` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl` - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) - { - if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS ) - memcpy(&p->hotkeys[hotkey_num], &tmp_hotkey, sizeof(tmp_hotkey)); - else - ShowWarning("mmo_char_fromsql: ignoring invalid hotkey (hotkey=%d,type=%u,id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", hotkey_num, tmp_hotkey.type, tmp_hotkey.id, tmp_hotkey.lv, p->name, p->account_id, p->char_id); - } - strcat(t_msg, " hotkeys"); -#endif - - /* Mercenary Owner DataBase */ - mercenary_owner_fromsql(char_id, p); - strcat(t_msg, " mercenary"); - - - if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly! - SqlStmt_Free(stmt); - StringBuf_Destroy(&buf); - - cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); - memcpy(cp, p, sizeof(struct mmo_charstatus)); - return 1; -} - -//========================================================================================================== -int mmo_char_sql_init(void) -{ - ShowInfo("Begin Initializing.......\n"); - char_db_= idb_alloc(DB_OPT_RELEASE_DATA); - - if(char_per_account == 0){ - ShowStatus("Chars per Account: 'Unlimited'.......\n"); - }else{ - ShowStatus("Chars per Account: '%d'.......\n", char_per_account); - } - - //the 'set offline' part is now in check_login_conn ... - //if the server connects to loginserver - //it will dc all off players - //and send the loginserver the new state.... - - // Force all users offline in sql when starting char-server - // (useful when servers crashs and don't clean the database) - set_all_offline_sql(); - - ShowInfo("Finished initilizing.......\n"); - - return 0; -} - -//----------------------------------- -// Function to change chararcter's names -//----------------------------------- -int rename_char_sql(struct char_session_data *sd, int char_id) -{ - struct mmo_charstatus char_dat; - char esc_name[NAME_LENGTH*2+1]; - - if( sd->new_name[0] == 0 ) // Not ready for rename - return 2; - - if( !mmo_char_fromsql(char_id, &char_dat, false) ) // Only the short data is needed. - return 2; - - if( char_dat.rename == 0 ) - return 1; - - Sql_EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH)); - - // check if the char exist - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) ) - { - Sql_ShowDebug(sql_handle); - return 4; - } - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) ) - { - Sql_ShowDebug(sql_handle); - return 3; - } - - // Change character's name into guild_db. - if( char_dat.guild_id ) - inter_guild_charname_changed(char_dat.guild_id, sd->account_id, char_id, sd->new_name); - - safestrncpy(char_dat.name, sd->new_name, NAME_LENGTH); - memset(sd->new_name,0,sizeof(sd->new_name)); - - // log change - if( log_char ) - { - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" - "VALUES (NOW(), '%s', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')", - charlog_db, "change char name", sd->account_id, char_dat.slot, esc_name) ) - Sql_ShowDebug(sql_handle); - } - - return 0; -} - -int check_char_name(char * name, char * esc_name) -{ - int i; - - // check length of character name - if( name[0] == '\0' ) - return -2; // empty character name - /** - * The client does not allow you to create names with less than 4 characters, however, - * the use of WPE can bypass this, and this fixes the exploit. - **/ - if( strlen( name ) < 4 ) - return -2; - // check content of character name - if( remove_control_chars(name) ) - return -2; // control chars in name - - // check for reserved names - if( strcmpi(name, main_chat_nick) == 0 || strcmpi(name, wisp_server_name) == 0 ) - return -1; // nick reserved for internal server messages - - // Check Authorised letters/symbols in the name of the character - if( char_name_option == 1 ) - { // only letters/symbols in char_name_letters are authorised - for( i = 0; i < NAME_LENGTH && name[i]; i++ ) - if( strchr(char_name_letters, name[i]) == NULL ) - return -2; - } - else if( char_name_option == 2 ) - { // letters/symbols in char_name_letters are forbidden - for( i = 0; i < NAME_LENGTH && name[i]; i++ ) - if( strchr(char_name_letters, name[i]) != NULL ) - return -2; - } - if( name_ignoring_case ) { - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) { - Sql_ShowDebug(sql_handle); - return -2; - } - } else { - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) { - Sql_ShowDebug(sql_handle); - return -2; - } - } - if( Sql_NumRows(sql_handle) > 0 ) - return -1; // name already exists - - return 0; -} - -//----------------------------------- -// Function to create a new character -//----------------------------------- -int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) -{ - char name[NAME_LENGTH]; - char esc_name[NAME_LENGTH*2+1]; - int char_id, flag; - - safestrncpy(name, name_, NAME_LENGTH); - normalize_name(name,TRIM_CHARS); - Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); - - flag = check_char_name(name,esc_name); - if( flag < 0 ) - return flag; - - //check other inputs - if((slot >= MAX_CHARS) // slots - || (str + agi + vit + int_ + dex + luk != 6*5 ) // stats - || (str < 1 || str > 9 || agi < 1 || agi > 9 || vit < 1 || vit > 9 || int_ < 1 || int_ > 9 || dex < 1 || dex > 9 || luk < 1 || luk > 9) // individual stat values - || (str + int_ != 10 || agi + luk != 10 || vit + dex != 10) ) // pairs - return -2; // invalid input - - // check the number of already existing chars in this account - if( char_per_account != 0 ) { - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d'", char_db, sd->account_id) ) - Sql_ShowDebug(sql_handle); - if( Sql_NumRows(sql_handle) >= char_per_account ) - return -2; // character account limit exceeded - } - - // check char slot - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d' LIMIT 1", char_db, sd->account_id, slot) ) - Sql_ShowDebug(sql_handle); - if( Sql_NumRows(sql_handle) > 0 ) - return -2; // slot already in use - - // validation success, log result - if (log_char) { - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)" - "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - charlog_db, "make new char", sd->account_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) ) - Sql_ShowDebug(sql_handle); - } - - //Insert the new char entry to the database - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`," - "`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES (" - "'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')", - char_db, sd->account_id , slot, esc_name, start_zeny, str, agi, vit, int_, dex, luk, - (40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color, - mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) ) - { - Sql_ShowDebug(sql_handle); - return -2; //No, stop the procedure! - } - //Retrieve the newly auto-generated char id - char_id = (int)Sql_LastInsertId(sql_handle); - //Give the char the default items - if (start_weapon > 0) { //add Start Weapon (Knife?) - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_weapon, 1, 1) ) - Sql_ShowDebug(sql_handle); - } - if (start_armor > 0) { //Add default armor (cotton shirt?) - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_armor, 1, 1) ) - Sql_ShowDebug(sql_handle); - } - - ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, slot, name); - return char_id; -} - -/*----------------------------------------------------------------------------------------------------------*/ -/* Divorce Players */ -/*----------------------------------------------------------------------------------------------------------*/ -int divorce_char_sql(int partner_id1, int partner_id2) -{ - unsigned char buf[64]; - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) ) - Sql_ShowDebug(sql_handle); - - WBUFW(buf,0) = 0x2b12; - WBUFL(buf,2) = partner_id1; - WBUFL(buf,6) = partner_id2; - mapif_sendall(buf,10); - - return 0; -} - -/*----------------------------------------------------------------------------------------------------------*/ -/* Delete char - davidsiaw */ -/*----------------------------------------------------------------------------------------------------------*/ -/* Returns 0 if successful - * Returns < 0 for error - */ -int delete_char_sql(int char_id) -{ - char name[NAME_LENGTH]; - char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped. - int account_id, party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id; - char* data; - size_t len; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - ShowError("delete_char_sql: Unable to fetch character data, deletion aborted.\n"); - Sql_FreeResult(sql_handle); - return -1; - } - - Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 1, &data, NULL); account_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); party_id = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); father_id = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data); - - Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH)); - Sql_FreeResult(sql_handle); - - //check for config char del condition [Lupus] - // TODO: Move this out to packet processing (0x68/0x1fb). - if( ( char_del_level > 0 && base_level >= char_del_level ) - || ( char_del_level < 0 && base_level <= -char_del_level ) - ) { - ShowInfo("Char deletion aborted: %s, BaseLevel: %i\n", name, base_level); - return -1; - } - - /* Divorce [Wizputer] */ - if( partner_id ) - divorce_char_sql(char_id, partner_id); - - /* De-addopt [Zephyrus] */ - if( father_id || mother_id ) - { // Char is Baby - unsigned char buf[64]; - - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) ) - Sql_ShowDebug(sql_handle); - - WBUFW(buf,0) = 0x2b25; - WBUFL(buf,2) = father_id; - WBUFL(buf,6) = mother_id; - WBUFL(buf,10) = char_id; // Baby - mapif_sendall(buf,14); - } - - //Make the character leave the party [Skotlex] - if (party_id) - inter_party_leave(party_id, account_id, char_id); - - /* delete char's pet */ - //Delete the hatched pet if you have one... - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incuvate` = '0'", pet_db, char_id) ) - Sql_ShowDebug(sql_handle); - - //Delete all pets that are stored in eggs (inventory + cart) - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* remove homunculus */ - if( hom_id ) - mapif_homunculus_delete(hom_id); - - /* remove mercenary data */ - mercenary_owner_delete(char_id); - - /* delete char's friends list */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* delete char from other's friend list */ - //NOTE: Won't this cause problems for people who are already online? [Skotlex] - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) ) - Sql_ShowDebug(sql_handle); - -#ifdef HOTKEY_SAVING - /* delete hotkeys */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) ) - Sql_ShowDebug(sql_handle); -#endif - - /* delete inventory */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* delete cart inventory */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* delete memo areas */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* delete character registry */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* delete skills */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) ) - Sql_ShowDebug(sql_handle); - -#ifdef ENABLE_SC_SAVING - /* status changes */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) ) - Sql_ShowDebug(sql_handle); -#endif - - if (log_char) { - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')", - charlog_db, account_id, 0, char_id, esc_name) ) - Sql_ShowDebug(sql_handle); - } - - /* delete character */ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - - /* No need as we used inter_guild_leave [Skotlex] - // Also delete info from guildtables. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) ) - Sql_ShowDebug(sql_handle); - */ - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) ) - Sql_ShowDebug(sql_handle); - else if( Sql_NumRows(sql_handle) > 0 ) - mapif_parse_BreakGuild(0,guild_id); - else if( guild_id ) - inter_guild_leave(guild_id, account_id, char_id);// Leave your guild. - return 0; -} - -//--------------------------------------------------------------------- -// This function return the number of online players in all map-servers -//--------------------------------------------------------------------- -int count_users(void) -{ - int i, users; - - users = 0; - for(i = 0; i < ARRAYLENGTH(server); i++) { - if (server[i].fd > 0) { - users += server[i].users; - } - } - return users; -} - -// Writes char data to the buffer in the format used by the client. -// Used in packets 0x6b (chars info) and 0x6d (new char info) -// Returns the size -#define MAX_CHAR_BUF 144 //Max size (for WFIFOHEAD calls) -int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) -{ - unsigned short offset = 0; - uint8* buf; - - if( buffer == NULL || p == NULL ) - return 0; - - buf = WBUFP(buffer,0); - WBUFL(buf,0) = p->char_id; - WBUFL(buf,4) = min(p->base_exp, INT32_MAX); - WBUFL(buf,8) = p->zeny; - WBUFL(buf,12) = min(p->job_exp, INT32_MAX); - WBUFL(buf,16) = p->job_level; - WBUFL(buf,20) = 0; // probably opt1 - WBUFL(buf,24) = 0; // probably opt2 - WBUFL(buf,28) = p->option; - WBUFL(buf,32) = p->karma; - WBUFL(buf,36) = p->manner; - WBUFW(buf,40) = min(p->status_point, INT16_MAX); -#if PACKETVER > 20081217 - WBUFL(buf,42) = p->hp; - WBUFL(buf,46) = p->max_hp; - offset+=4; - buf = WBUFP(buffer,offset); -#else - WBUFW(buf,42) = min(p->hp, INT16_MAX); - WBUFW(buf,44) = min(p->max_hp, INT16_MAX); -#endif - WBUFW(buf,46) = min(p->sp, INT16_MAX); - WBUFW(buf,48) = min(p->max_sp, INT16_MAX); - WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed; - WBUFW(buf,52) = p->class_; - WBUFW(buf,54) = p->hair; - - //When the weapon is sent and your option is riding, the client crashes on login!? - WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon; - - WBUFW(buf,58) = p->base_level; - WBUFW(buf,60) = min(p->skill_point, INT16_MAX); - WBUFW(buf,62) = p->head_bottom; - WBUFW(buf,64) = p->shield; - WBUFW(buf,66) = p->head_top; - WBUFW(buf,68) = p->head_mid; - WBUFW(buf,70) = p->hair_color; - WBUFW(buf,72) = p->clothes_color; - memcpy(WBUFP(buf,74), p->name, NAME_LENGTH); - WBUFB(buf,98) = min(p->str, UINT8_MAX); - WBUFB(buf,99) = min(p->agi, UINT8_MAX); - WBUFB(buf,100) = min(p->vit, UINT8_MAX); - WBUFB(buf,101) = min(p->int_, UINT8_MAX); - WBUFB(buf,102) = min(p->dex, UINT8_MAX); - WBUFB(buf,103) = min(p->luk, UINT8_MAX); - WBUFW(buf,104) = p->slot; -#if PACKETVER >= 20061023 - WBUFW(buf,106) = ( p->rename > 0 ) ? 0 : 1; - offset += 2; -#endif -#if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803 - mapindex_getmapname_ext(mapindex_id2name(p->last_point.map), (char*)WBUFP(buf,108)); - offset += MAP_NAME_LENGTH_EXT; -#endif -#if PACKETVER >= 20100803 - WBUFL(buf,124) = TOL(p->delete_date); - offset += 4; -#endif -#if PACKETVER >= 20110111 - WBUFL(buf,128) = p->robe; - offset += 4; -#endif -#if PACKETVER != 20111116 //2011-11-16 wants 136, ask gravity. - #if PACKETVER >= 20110928 - WBUFL(buf,132) = 0; // change slot feature (0 = disabled, otherwise enabled) - offset += 4; - #endif - #if PACKETVER >= 20111025 - WBUFL(buf,136) = 0; // unknown purpose (0 = disabled, otherwise displays "Add-Ons" sidebar) - offset += 4; - #endif -#endif - - return 106+offset; -} - -//---------------------------------------- -// Function to send characters to a player -//---------------------------------------- -int mmo_char_send006b(int fd, struct char_session_data* sd) -{ - int j, offset = 0; -#if PACKETVER >= 20100413 - offset += 3; -#endif - - if (save_log) - ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); - - j = 24 + offset; // offset - WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF); - WFIFOW(fd,0) = 0x6b; -#if PACKETVER >= 20100413 - WFIFOB(fd,4) = MAX_CHARS; // Max slots. - WFIFOB(fd,5) = MAX_CHARS; // Available slots. - WFIFOB(fd,6) = MAX_CHARS; // Premium slots. -#endif - memset(WFIFOP(fd,4 + offset), 0, 20); // unknown bytes - j+=mmo_chars_fromsql(sd, WFIFOP(fd,j)); - WFIFOW(fd,2) = j; // packet len - WFIFOSET(fd,j); - - return 0; -} - -int char_married(int pl1, int pl2) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - if( pl2 == atoi(data) ) - { - Sql_FreeResult(sql_handle); - return 1; - } - } - Sql_FreeResult(sql_handle); - return 0; -} - -int char_child(int parent_id, int child_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - if( child_id == atoi(data) ) - { - Sql_FreeResult(sql_handle); - return 1; - } - } - Sql_FreeResult(sql_handle); - return 0; -} - -int char_family(int cid1, int cid2, int cid3) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) ) - Sql_ShowDebug(sql_handle); - else while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - int charid; - int partnerid; - int childid; - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); charid = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); childid = atoi(data); - - if( (cid1 == charid && ((cid2 == partnerid && cid3 == childid ) || (cid2 == childid && cid3 == partnerid))) || - (cid1 == partnerid && ((cid2 == charid && cid3 == childid ) || (cid2 == childid && cid3 == charid ))) || - (cid1 == childid && ((cid2 == charid && cid3 == partnerid) || (cid2 == partnerid && cid3 == charid ))) ) - { - Sql_FreeResult(sql_handle); - return childid; - } - } - Sql_FreeResult(sql_handle); - return 0; -} - -//---------------------------------------------------------------------- -// Force disconnection of an online player (with account value) by [Yor] -//---------------------------------------------------------------------- -void disconnect_player(int account_id) -{ - int i; - struct char_session_data* sd; - - // disconnect player if online on char-server - ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == account_id ); - if( i < fd_max ) - set_eof(i); -} - -static void char_auth_ok(int fd, struct char_session_data *sd) -{ - struct online_char_data* character; - - if( (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL ) - { // check if character is not online already. [Skotlex] - if (character->server > -1) - { //Character already online. KICK KICK KICK - mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = add_timer(gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 8; - WFIFOSET(fd,3); - return; - } - if (character->fd >= 0 && character->fd != fd) - { //There's already a connection from this account that hasn't picked a char yet. - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 8; - WFIFOSET(fd,3); - return; - } - character->fd = fd; - } - - if (login_fd > 0) { - // request account data - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x2716; - WFIFOL(login_fd,2) = sd->account_id; - WFIFOSET(login_fd,6); - } - - // mark session as 'authed' - sd->auth = true; - - // set char online on charserver - set_char_charselect(sd->account_id); - - // continues when account data is received... -} - -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); -void mapif_server_reset(int id); - - -/// Resets all the data. -void loginif_reset(void) -{ - int id; - // TODO kick everyone out and reset everything or wait for connect and try to reaquire locks [FlavioJS] - for( id = 0; id < ARRAYLENGTH(server); ++id ) - mapif_server_reset(id); - flush_fifos(); - exit(EXIT_FAILURE); -} - - -/// Checks the conditions for the server to stop. -/// Releases the cookie when all characters are saved. -/// If all the conditions are met, it stops the core loop. -void loginif_check_shutdown(void) -{ - if( runflag != CHARSERVER_ST_SHUTDOWN ) - return; - runflag = CORE_ST_STOP; -} - - -/// Called when the connection to Login Server is disconnected. -void loginif_on_disconnect(void) -{ - ShowWarning("Connection to Login Server lost.\n\n"); -} - - -/// Called when all the connection steps are completed. -void loginif_on_ready(void) -{ - int i; - - loginif_check_shutdown(); - - //Send online accounts to login server. - send_accounts_tologin(INVALID_TIMER, gettick(), 0, 0); - - // if no map-server already connected, display a message... - ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd > 0 && server[i].map[0] ); - if( i == ARRAYLENGTH(server) ) - ShowStatus("Awaiting maps from map-server.\n"); -} - - -int parse_fromlogin(int fd) -{ - struct char_session_data* sd = NULL; - int i; - - // only process data from the login-server - if( fd != login_fd ) - { - ShowDebug("parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd); - do_close(fd); - return 0; - } - - if( session[fd]->flag.eof ) - { - do_close(fd); - login_fd = -1; - loginif_on_disconnect(); - return 0; - } - - sd = (struct char_session_data*)session[fd]->session_data; - - while(RFIFOREST(fd) >= 2) - { - uint16 command = RFIFOW(fd,0); - - switch( command ) - { - - // acknowledgement of connect-to-loginserver request - case 0x2711: - if (RFIFOREST(fd) < 3) - return 0; - - if (RFIFOB(fd,2)) { - //printf("connect login server error : %d\n", RFIFOB(fd,2)); - ShowError("Can not connect to login-server.\n"); - ShowError("The server communication passwords (default s1/p1) are probably invalid.\n"); - ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n"); - ShowError("The communication passwords are set in map_athena.conf and char_athena.conf\n"); - set_eof(fd); - return 0; - } else { - ShowStatus("Connected to login-server (connection #%d).\n", fd); - loginif_on_ready(); - } - RFIFOSKIP(fd,3); - break; - - // acknowledgement of account authentication request - case 0x2713: - if (RFIFOREST(fd) < 25) - return 0; - { - int account_id = RFIFOL(fd,2); - uint32 login_id1 = RFIFOL(fd,6); - uint32 login_id2 = RFIFOL(fd,10); - uint8 sex = RFIFOB(fd,14); - uint8 result = RFIFOB(fd,15); - int request_id = RFIFOL(fd,16); - uint32 version = RFIFOL(fd,20); - uint8 clienttype = RFIFOB(fd,24); - RFIFOSKIP(fd,25); - - if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) && - !sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex ) - { - int client_fd = request_id; - sd->version = version; - sd->clienttype = clienttype; - switch( result ) - { - case 0:// ok - char_auth_ok(client_fd, sd); - break; - case 1:// auth failed - WFIFOHEAD(client_fd,3); - WFIFOW(client_fd,0) = 0x6c; - WFIFOB(client_fd,2) = 0;// rejected from server - WFIFOSET(client_fd,3); - break; - } - } - } - break; - - case 0x2717: // account data - if (RFIFOREST(fd) < 62) - return 0; - - // find the authenticated session with this account id - ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) ); - if( i < fd_max ) - { - int server_id; - memcpy(sd->email, RFIFOP(fd,6), 40); - sd->expiration_time = (time_t)RFIFOL(fd,46); - sd->gmlevel = RFIFOB(fd,50); - safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate)); - ARR_FIND( 0, ARRAYLENGTH(server), server_id, server[server_id].fd > 0 && server[server_id].map[0] ); - // continued from char_auth_ok... - if( server_id == ARRAYLENGTH(server) || //server not online, bugreport:2359 - ( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level ) ) { - // refuse connection (over populated) - WFIFOHEAD(i,3); - WFIFOW(i,0) = 0x6c; - WFIFOW(i,2) = 0; - WFIFOSET(i,3); - } else { - // send characters to player - mmo_char_send006b(i, sd); -#if PACKETVER >= 20110309 - // PIN code system, disabled - WFIFOHEAD(i, 12); - WFIFOW(i, 0) = 0x08B9; - WFIFOW(i, 2) = 0; - WFIFOW(i, 4) = 0; - WFIFOL(i, 6) = sd->account_id; - WFIFOW(i, 10) = 0; - WFIFOSET(i, 12); -#endif - } - } - RFIFOSKIP(fd,62); - break; - - // login-server alive packet - case 0x2718: - if (RFIFOREST(fd) < 2) - return 0; - RFIFOSKIP(fd,2); - break; - - // changesex reply - case 0x2723: - if (RFIFOREST(fd) < 7) - return 0; - { - unsigned char buf[7]; - - int acc = RFIFOL(fd,2); - int sex = RFIFOB(fd,6); - RFIFOSKIP(fd,7); - - if( acc > 0 ) - {// TODO: Is this even possible? - int char_id[MAX_CHARS]; - int class_[MAX_CHARS]; - int guild_id[MAX_CHARS]; - int num; - char* data; - - struct auth_node* node = (struct auth_node*)idb_get(auth_db, acc); - if( node != NULL ) - node->sex = sex; - - // get characters - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) ) - Sql_ShowDebug(sql_handle); - for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - Sql_GetData(sql_handle, 0, &data, NULL); char_id[i] = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); class_[i] = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); guild_id[i] = atoi(data); - } - num = i; - for( i = 0; i < num; ++i ) - { - if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER || - class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY || - class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER || - class_[i] == JOB_WANDERER || class_[i] == JOB_WANDERER_T || - class_[i] == JOB_MINSTREL || class_[i] == JOB_MINSTREL_T ) - { - // job modification - if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ) - class_[i] = (sex ? JOB_BARD : JOB_DANCER); - else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ) - class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY); - else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ) - class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER); - else if( class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER ) - class_[i] = (sex ? JOB_MINSTREL : JOB_WANDERER); - else if( class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T ) - class_[i] = (sex ? JOB_MINSTREL_T : JOB_WANDERER_T); - // remove specifical skills of classes 19,20 4020,4021 and 4042,4043 - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `skill_point` = `skill_point` +" - " (SELECT SUM(lv) FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330' AND `lv` > '0')" - " WHERE `char_id` = '%d'", - char_db, skill_db, char_id[i], char_id[i]) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'", skill_db, char_id[i]) ) - Sql_ShowDebug(sql_handle); - } - // to avoid any problem with equipment and invalid sex, equipment is unequiped. - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'", inventory_db, char_id[i]) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', `head_bottom`='0' WHERE `char_id`='%d'", char_db, class_[i], char_id[i]) ) - Sql_ShowDebug(sql_handle); - - if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex] - inter_guild_sex_changed(guild_id[i], acc, char_id[i], sex); - } - Sql_FreeResult(sql_handle); - - // disconnect player if online on char-server - disconnect_player(acc); - } - - // notify all mapservers about this change - WBUFW(buf,0) = 0x2b0d; - WBUFL(buf,2) = acc; - WBUFB(buf,6) = sex; - mapif_sendall(buf, 7); - } - break; - - // reply to an account_reg2 registry request - case 0x2729: - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - - { //Receive account_reg2 registry, forward to map servers. - unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)]; - memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2)); - WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex] - mapif_sendall(buf, WBUFW(buf,2)); - RFIFOSKIP(fd, RFIFOW(fd,2)); - } - break; - - // State change of account/ban notification (from login-server) - case 0x2731: - if (RFIFOREST(fd) < 11) - return 0; - - { // send to all map-servers to disconnect the player - unsigned char buf[11]; - WBUFW(buf,0) = 0x2b14; - WBUFL(buf,2) = RFIFOL(fd,2); - WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban - WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment - mapif_sendall(buf, 11); - } - // disconnect player if online on char-server - disconnect_player(RFIFOL(fd,2)); - - RFIFOSKIP(fd,11); - break; - - // Login server request to kick a character out. [Skotlex] - case 0x2734: - if (RFIFOREST(fd) < 6) - return 0; - { - int aid = RFIFOL(fd,2); - struct online_char_data* character = (struct online_char_data*)idb_get(online_char_db, aid); - RFIFOSKIP(fd,6); - if( character != NULL ) - {// account is already marked as online! - if( character->server > -1 ) - { //Kick it from the map server it is on. - mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); - } - else - {// Manual kick from char server. - struct char_session_data *tsd; - int i; - ARR_FIND( 0, fd_max, i, session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid ); - if( i < fd_max ) - { - WFIFOHEAD(i,3); - WFIFOW(i,0) = 0x81; - WFIFOB(i,2) = 2; // "Someone has already logged in with this id" - WFIFOSET(i,3); - set_eof(i); - } - else // still moving to the map-server - set_char_offline(-1, aid); - } - } - idb_remove(auth_db, aid);// reject auth attempts from map-server - } - break; - - // ip address update signal from login server - case 0x2735: - { - unsigned char buf[2]; - uint32 new_ip = 0; - - WBUFW(buf,0) = 0x2b1e; - mapif_sendall(buf, 2); - - new_ip = host2ip(login_ip_str); - if (new_ip && new_ip != login_ip) - login_ip = new_ip; //Update login ip, too. - - new_ip = host2ip(char_ip_str); - if (new_ip && new_ip != char_ip) - { //Update ip. - char_ip = new_ip; - ShowInfo("Updating IP for [%s].\n", char_ip_str); - // notify login server about the change - WFIFOHEAD(fd,6); - WFIFOW(fd,0) = 0x2736; - WFIFOL(fd,2) = htonl(char_ip); - WFIFOSET(fd,6); - } - - RFIFOSKIP(fd,2); - } - break; - - default: - ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command); - set_eof(fd); - return 0; - } - } - - RFIFOFLUSH(fd); - return 0; -} - -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data); -int ping_login_server(int tid, unsigned int tick, int id, intptr_t data); -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); - -void do_init_loginif(void) -{ - // establish char-login connection if not present - add_timer_func_list(check_connect_login_server, "check_connect_login_server"); - add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); - - // keep the char-login connection alive - add_timer_func_list(ping_login_server, "ping_login_server"); - add_timer_interval(gettick() + 1000, ping_login_server, 0, 0, ((int)stall_time-2) * 1000); - - // send a list of all online account IDs to login server - add_timer_func_list(send_accounts_tologin, "send_accounts_tologin"); - add_timer_interval(gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour -} - -void do_final_loginif(void) -{ - if( login_fd != -1 ) - { - do_close(login_fd); - login_fd = -1; - } -} - -int request_accreg2(int account_id, int char_id) -{ - if (login_fd > 0) { - WFIFOHEAD(login_fd,10); - WFIFOW(login_fd,0) = 0x272e; - WFIFOL(login_fd,2) = account_id; - WFIFOL(login_fd,6) = char_id; - WFIFOSET(login_fd,10); - return 1; - } - return 0; -} - -//Send packet forward to login-server for account saving -int save_accreg2(unsigned char* buf, int len) -{ - if (login_fd > 0) { - WFIFOHEAD(login_fd,len+4); - memcpy(WFIFOP(login_fd,4), buf, len); - WFIFOW(login_fd,0) = 0x2728; - WFIFOW(login_fd,2) = len+4; - WFIFOSET(login_fd,len+4); - return 1; - } - return 0; -} - -void char_read_fame_list(void) -{ - int i; - char* data; - size_t len; - - // Empty ranking lists - memset(smith_fame_list, 0, sizeof(smith_fame_list)); - memset(chemist_fame_list, 0, sizeof(chemist_fame_list)); - memset(taekwon_fame_list, 0, sizeof(taekwon_fame_list)); - // Build Blacksmith ranking list - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, fame_list_size_smith) ) - Sql_ShowDebug(sql_handle); - for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - // char_id - Sql_GetData(sql_handle, 0, &data, NULL); - smith_fame_list[i].id = atoi(data); - // fame - Sql_GetData(sql_handle, 1, &data, &len); - smith_fame_list[i].fame = atoi(data); - // name - Sql_GetData(sql_handle, 2, &data, &len); - memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH)); - } - // Build Alchemist ranking list - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, fame_list_size_chemist) ) - Sql_ShowDebug(sql_handle); - for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - // char_id - Sql_GetData(sql_handle, 0, &data, NULL); - chemist_fame_list[i].id = atoi(data); - // fame - Sql_GetData(sql_handle, 1, &data, &len); - chemist_fame_list[i].fame = atoi(data); - // name - Sql_GetData(sql_handle, 2, &data, &len); - memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH)); - } - // Build Taekwon ranking list - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) ) - Sql_ShowDebug(sql_handle); - for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - // char_id - Sql_GetData(sql_handle, 0, &data, NULL); - taekwon_fame_list[i].id = atoi(data); - // fame - Sql_GetData(sql_handle, 1, &data, &len); - taekwon_fame_list[i].fame = atoi(data); - // name - Sql_GetData(sql_handle, 2, &data, &len); - memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH)); - } - Sql_FreeResult(sql_handle); -} - -// Send map-servers the fame ranking lists -int char_send_fame_list(int fd) -{ - int i, len = 8; - unsigned char buf[32000]; - - WBUFW(buf,0) = 0x2b1b; - - for(i = 0; i < fame_list_size_smith && smith_fame_list[i].id; i++) { - memcpy(WBUFP(buf, len), &smith_fame_list[i], sizeof(struct fame_list)); - len += sizeof(struct fame_list); - } - // add blacksmith's block length - WBUFW(buf, 6) = len; - - for(i = 0; i < fame_list_size_chemist && chemist_fame_list[i].id; i++) { - memcpy(WBUFP(buf, len), &chemist_fame_list[i], sizeof(struct fame_list)); - len += sizeof(struct fame_list); - } - // add alchemist's block length - WBUFW(buf, 4) = len; - - for(i = 0; i < fame_list_size_taekwon && taekwon_fame_list[i].id; i++) { - memcpy(WBUFP(buf, len), &taekwon_fame_list[i], sizeof(struct fame_list)); - len += sizeof(struct fame_list); - } - // add total packet length - WBUFW(buf, 2) = len; - - if (fd != -1) - mapif_send(fd, buf, len); - else - mapif_sendall(buf, len); - - return 0; -} - -void char_update_fame_list(int type, int index, int fame) -{ - unsigned char buf[8]; - WBUFW(buf,0) = 0x2b22; - WBUFB(buf,2) = type; - WBUFB(buf,3) = index; - WBUFL(buf,4) = fame; - mapif_sendall(buf, 8); -} - -//Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size) -//Returns 1 on found, 0 on not found (buffer is filled with Unknown char name) -int char_loadName(int char_id, char* name) -{ - char* data; - size_t len; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - Sql_GetData(sql_handle, 0, &data, &len); - safestrncpy(name, data, NAME_LENGTH); - return 1; - } - else - { - safestrncpy(name, unknown_char_name, NAME_LENGTH); - } - return 0; -} - -int search_mapserver(unsigned short map, uint32 ip, uint16 port); - - -/// Initializes a server structure. -void mapif_server_init(int id) -{ - memset(&server[id], 0, sizeof(server[id])); - server[id].fd = -1; -} - - -/// Destroys a server structure. -void mapif_server_destroy(int id) -{ - if( server[id].fd == -1 ) - { - do_close(server[id].fd); - server[id].fd = -1; - } -} - - -/// Resets all the data related to a server. -void mapif_server_reset(int id) -{ - int i,j; - unsigned char buf[16384]; - int fd = server[id].fd; - //Notify other map servers that this one is gone. [Skotlex] - WBUFW(buf,0) = 0x2b20; - WBUFL(buf,4) = htonl(server[id].ip); - WBUFW(buf,8) = htons(server[id].port); - j = 0; - for(i = 0; i < MAX_MAP_PER_SERVER; i++) - if (server[id].map[i]) - WBUFW(buf,10+(j++)*4) = server[id].map[i]; - if (j > 0) { - WBUFW(buf,2) = j * 4 + 10; - mapif_sendallwos(fd, buf, WBUFW(buf,2)); - } - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo` WHERE `index`='%d'", server[id].fd) ) - Sql_ShowDebug(sql_handle); - online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server. - mapif_server_destroy(id); - mapif_server_init(id); -} - - -/// Called when the connection to a Map Server is disconnected. -void mapif_on_disconnect(int id) -{ - ShowStatus("Map-server #%d has disconnected.\n", id); - mapif_server_reset(id); -} - - -int parse_frommap(int fd) -{ - int i, j; - int id; - - ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd ); - if( id == ARRAYLENGTH(server) ) - {// not a map server - ShowDebug("parse_frommap: Disconnecting invalid session #%d (is not a map-server)\n", fd); - do_close(fd); - return 0; - } - if( session[fd]->flag.eof ) - { - do_close(fd); - server[id].fd = -1; - mapif_on_disconnect(id); - return 0; - } - - while(RFIFOREST(fd) >= 2) - { - switch(RFIFOW(fd,0)) - { - - case 0x2afa: // Receiving map names list from the map-server - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - - memset(server[id].map, 0, sizeof(server[id].map)); - j = 0; - for(i = 4; i < RFIFOW(fd,2); i += 4) { - server[id].map[j] = RFIFOW(fd,i); - j++; - } - - ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n", - id, j, CONVIP(server[id].ip), server[id].port); - ShowStatus("Map-server %d loading complete.\n", id); - - // send name for wisp to player - WFIFOHEAD(fd, 3 + NAME_LENGTH); - WFIFOW(fd,0) = 0x2afb; - WFIFOB(fd,2) = 0; - memcpy(WFIFOP(fd,3), wisp_server_name, NAME_LENGTH); - WFIFOSET(fd,3+NAME_LENGTH); - - char_send_fame_list(fd); //Send fame list. - - { - unsigned char buf[16384]; - int x; - if (j == 0) { - ShowWarning("Map-server %d has NO maps.\n", id); - } else { - // Transmitting maps information to the other map-servers - WBUFW(buf,0) = 0x2b04; - WBUFW(buf,2) = j * 4 + 10; - WBUFL(buf,4) = htonl(server[id].ip); - WBUFW(buf,8) = htons(server[id].port); - memcpy(WBUFP(buf,10), RFIFOP(fd,4), j * 4); - mapif_sendallwos(fd, buf, WBUFW(buf,2)); - } - // Transmitting the maps of the other map-servers to the new map-server - for(x = 0; x < ARRAYLENGTH(server); x++) { - if (server[x].fd > 0 && x != id) { - WFIFOHEAD(fd,10 +4*ARRAYLENGTH(server)); - WFIFOW(fd,0) = 0x2b04; - WFIFOL(fd,4) = htonl(server[x].ip); - WFIFOW(fd,8) = htons(server[x].port); - j = 0; - for(i = 0; i < ARRAYLENGTH(server); i++) - if (server[x].map[i]) - WFIFOW(fd,10+(j++)*4) = server[x].map[i]; - if (j > 0) { - WFIFOW(fd,2) = j * 4 + 10; - WFIFOSET(fd,WFIFOW(fd,2)); - } - } - } - } - RFIFOSKIP(fd,RFIFOW(fd,2)); - break; - - case 0x2afc: //Packet command is now used for sc_data request. [Skotlex] - if (RFIFOREST(fd) < 10) - return 0; - { -#ifdef ENABLE_SC_SAVING - int aid, cid; - aid = RFIFOL(fd,2); - cid = RFIFOL(fd,6); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", - scdata_db, aid, cid) ) - { - Sql_ShowDebug(sql_handle); - break; - } - if( Sql_NumRows(sql_handle) > 0 ) - { - struct status_change_data scdata; - int count; - char* data; - - WFIFOHEAD(fd,14+50*sizeof(struct status_change_data)); - WFIFOW(fd,0) = 0x2b1d; - WFIFOL(fd,4) = aid; - WFIFOL(fd,8) = cid; - for( count = 0; count < 50 && SQL_SUCCESS == Sql_NextRow(sql_handle); ++count ) - { - Sql_GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); scdata.tick = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data); - memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data)); - } - if (count >= 50) - ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid); - if (count > 0) - { - WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data); - WFIFOW(fd,12) = count; - WFIFOSET(fd,WFIFOW(fd,2)); - - //Clear the data once loaded. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) ) - Sql_ShowDebug(sql_handle); - } - } - Sql_FreeResult(sql_handle); -#endif - RFIFOSKIP(fd, 10); - } - break; - - case 0x2afe: //set MAP user count - if (RFIFOREST(fd) < 4) - return 0; - if (RFIFOW(fd,2) != server[id].users) { - server[id].users = RFIFOW(fd,2); - ShowInfo("User Count: %d (Server: %d)\n", server[id].users, id); - } - RFIFOSKIP(fd, 4); - break; - - case 0x2aff: //set MAP users - if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { - //TODO: When data mismatches memory, update guild/party online/offline states. - int aid, cid; - struct online_char_data* character; - - server[id].users = RFIFOW(fd,4); - online_char_db->foreach(online_char_db,char_db_setoffline,id); //Set all chars from this server as 'unknown' - for(i = 0; i < server[id].users; i++) { - aid = RFIFOL(fd,6+i*8); - cid = RFIFOL(fd,6+i*8+4); - character = (struct online_char_data*)idb_ensure(online_char_db, aid, create_online_char_data); - if( character->server > -1 && character->server != id ) - { - ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n", - character->account_id, character->char_id, character->server, id, aid, cid); - mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - } - character->server = id; - character->char_id = cid; - } - //If any chars remain in -2, they will be cleaned in the cleanup timer. - RFIFOSKIP(fd,RFIFOW(fd,2)); - } - break; - - case 0x2b01: // Receive character data from map-server for saving - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { - int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2); - struct online_char_data* character; - - if (size - 13 != sizeof(struct mmo_charstatus)) - { - ShowError("parse_from_map (save-char): Size mismatch! %d != %d\n", size-13, sizeof(struct mmo_charstatus)); - RFIFOSKIP(fd,size); - break; - } - //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect - if (RFIFOB(fd,12) || ( - (character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL && - character->char_id == cid)) - { - struct mmo_charstatus char_dat; - memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); - mmo_char_tosql(cid, &char_dat); - } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off. - ShowError("parse_from_map (save-char): Received data for non-existant/offline character (%d:%d).\n", aid, cid); - set_char_online(id, cid, aid); - } - - if (RFIFOB(fd,12)) - { //Flag, set character offline after saving. [Skotlex] - set_char_offline(cid, aid); - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x2b21; //Save ack only needed on final save. - WFIFOL(fd,2) = aid; - WFIFOL(fd,6) = cid; - WFIFOSET(fd,10); - } - RFIFOSKIP(fd,size); - } - break; - - case 0x2b02: // req char selection - if( RFIFOREST(fd) < 18 ) - return 0; - { - struct auth_node* node; - - int account_id = RFIFOL(fd,2); - uint32 login_id1 = RFIFOL(fd,6); - uint32 login_id2 = RFIFOL(fd,10); - uint32 ip = RFIFOL(fd,14); - RFIFOSKIP(fd,18); - - if( runflag != CHARSERVER_ST_RUNNING ) - { - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x2b03; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = 0;// not ok - WFIFOSET(fd,7); - } - else - { - // create temporary auth entry - CREATE(node, struct auth_node, 1); - node->account_id = account_id; - node->char_id = 0; - node->login_id1 = login_id1; - node->login_id2 = login_id2; - //node->sex = 0; - node->ip = ntohl(ip); - //node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server) - //node->gmlevel = 0; - idb_put(auth_db, account_id, node); - - //Set char to "@ char select" in online db [Kevin] - set_char_charselect(account_id); - - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x2b03; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = 1;// ok - WFIFOSET(fd,7); - } - } - break; - - case 0x2b05: // request "change map server" - if (RFIFOREST(fd) < 39) - return 0; - { - int map_id, map_fd = -1; - struct online_char_data* data; - struct mmo_charstatus* char_data; - struct mmo_charstatus char_dat; - - map_id = search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port. - if (map_id >= 0) - map_fd = server[map_id].fd; - //Char should just had been saved before this packet, so this should be safe. [Skotlex] - char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); - if (char_data == NULL) - { //Really shouldn't happen. - mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true); - char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); - } - - if( runflag == CHARSERVER_ST_RUNNING && - session_isActive(map_fd) && - char_data ) - { //Send the map server the auth of this player. - struct auth_node* node; - - //Update the "last map" as this is where the player must be spawned on the new map server. - char_data->last_point.map = RFIFOW(fd,18); - char_data->last_point.x = RFIFOW(fd,20); - char_data->last_point.y = RFIFOW(fd,22); - char_data->sex = RFIFOB(fd,30); - - // create temporary auth entry - CREATE(node, struct auth_node, 1); - node->account_id = RFIFOL(fd,2); - node->char_id = RFIFOL(fd,14); - node->login_id1 = RFIFOL(fd,6); - node->login_id2 = RFIFOL(fd,10); - node->sex = RFIFOB(fd,30); - node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing) - node->ip = ntohl(RFIFOL(fd,31)); - node->gmlevel = RFIFOL(fd,35); - node->changing_mapservers = 1; - idb_put(auth_db, RFIFOL(fd,2), node); - - data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); - data->char_id = char_data->char_id; - data->server = map_id; //Update server where char is. - - //Reply with an ack. - WFIFOHEAD(fd,30); - WFIFOW(fd,0) = 0x2b06; - memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28); - WFIFOSET(fd,30); - } else { //Reply with nak - WFIFOHEAD(fd,30); - WFIFOW(fd,0) = 0x2b06; - memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28); - WFIFOL(fd,6) = 0; //Set login1 to 0. - WFIFOSET(fd,30); - } - RFIFOSKIP(fd,35); - } - break; - - case 0x2b07: // Remove RFIFOL(fd,6) (friend_id) from RFIFOL(fd,2) (char_id) friend list [Ind] - if (RFIFOREST(fd) < 10) - return 0; - { - int char_id, friend_id; - char_id = RFIFOL(fd,2); - friend_id = RFIFOL(fd,6); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1", - friend_db, char_id, friend_id) ) { - Sql_ShowDebug(sql_handle); - break; - } - RFIFOSKIP(fd,10); - } - break; - - case 0x2b08: // char name request - if (RFIFOREST(fd) < 6) - return 0; - - WFIFOHEAD(fd,30); - WFIFOW(fd,0) = 0x2b09; - WFIFOL(fd,2) = RFIFOL(fd,2); - char_loadName((int)RFIFOL(fd,2), (char*)WFIFOP(fd,6)); - WFIFOSET(fd,30); - - RFIFOSKIP(fd,6); - break; - - case 0x2b0c: // Map server send information to change an email of an account -> login-server - if (RFIFOREST(fd) < 86) - return 0; - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,86); - memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0),86); // 0x2722 .L .40B .40B - WFIFOW(login_fd,0) = 0x2722; - WFIFOSET(login_fd,86); - } - RFIFOSKIP(fd, 86); - break; - - case 0x2b0e: // Request from map-server to change an account's status (will just be forwarded to login server) - if (RFIFOREST(fd) < 44) - return 0; - { - int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline - char esc_name[NAME_LENGTH*2+1]; - - int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request) - const char* name = (char*)RFIFOP(fd,6); // name of the target character - int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban - short year = RFIFOW(fd,32); - short month = RFIFOW(fd,34); - short day = RFIFOW(fd,36); - short hour = RFIFOW(fd,38); - short minute = RFIFOW(fd,40); - short second = RFIFOW(fd,42); - RFIFOSKIP(fd,44); - - Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) - Sql_ShowDebug(sql_handle); - else - if( Sql_NumRows(sql_handle) == 0 ) - { - result = 1; // 1-player not found - } - else - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - Sql_ShowDebug(sql_handle); - //FIXME: set proper result value? - else - { - char name[NAME_LENGTH]; - int account_id; - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name)); - - if( login_fd <= 0 ) - result = 3; // 3-login-server offline - //FIXME: need to move this check to login server [ultramage] -// else -// if( acc != -1 && isGM(acc) < isGM(account_id) ) -// result = 2; // 2-gm level too low - else - switch( type ) { - case 1: // block - WFIFOHEAD(login_fd,10); - WFIFOW(login_fd,0) = 0x2724; - WFIFOL(login_fd,2) = account_id; - WFIFOL(login_fd,6) = 5; // new account status - WFIFOSET(login_fd,10); - break; - case 2: // ban - WFIFOHEAD(login_fd,18); - WFIFOW(login_fd, 0) = 0x2725; - WFIFOL(login_fd, 2) = account_id; - WFIFOW(login_fd, 6) = year; - WFIFOW(login_fd, 8) = month; - WFIFOW(login_fd,10) = day; - WFIFOW(login_fd,12) = hour; - WFIFOW(login_fd,14) = minute; - WFIFOW(login_fd,16) = second; - WFIFOSET(login_fd,18); - break; - case 3: // unblock - WFIFOHEAD(login_fd,10); - WFIFOW(login_fd,0) = 0x2724; - WFIFOL(login_fd,2) = account_id; - WFIFOL(login_fd,6) = 0; // new account status - WFIFOSET(login_fd,10); - break; - case 4: // unban - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x272a; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - break; - case 5: // changesex - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x2727; - WFIFOL(login_fd,2) = account_id; - WFIFOSET(login_fd,6); - break; - } - } - - Sql_FreeResult(sql_handle); - - // send answer if a player ask, not if the server ask - if( acc != -1 && type != 5) { // Don't send answer for changesex - WFIFOHEAD(fd,34); - WFIFOW(fd, 0) = 0x2b0f; - WFIFOL(fd, 2) = acc; - safestrncpy((char*)WFIFOP(fd,6), name, NAME_LENGTH); - WFIFOW(fd,30) = type; - WFIFOW(fd,32) = result; - WFIFOSET(fd,34); - } - } - break; - - case 0x2b10: // Update and send fame ranking list - if (RFIFOREST(fd) < 11) - return 0; - { - int cid = RFIFOL(fd, 2); - int fame = RFIFOL(fd, 6); - char type = RFIFOB(fd, 10); - int size; - struct fame_list* list; - int player_pos; - int fame_pos; - - switch(type) - { - case 1: size = fame_list_size_smith; list = smith_fame_list; break; - case 2: size = fame_list_size_chemist; list = chemist_fame_list; break; - case 3: size = fame_list_size_taekwon; list = taekwon_fame_list; break; - default: size = 0; list = NULL; break; - } - - ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player - ARR_FIND(0, size, fame_pos, list[fame_pos].fame <= fame);// where the player should be - - if( player_pos == size && fame_pos == size ) - ;// not on list and not enough fame to get on it - else if( fame_pos == player_pos ) - {// same position - list[player_pos].fame = fame; - char_update_fame_list(type, player_pos, fame); - } - else - {// move in the list - if( player_pos == size ) - {// new ranker - not in the list - ARR_MOVE(size - 1, fame_pos, list, struct fame_list); - list[fame_pos].id = cid; - list[fame_pos].fame = fame; - char_loadName(cid, list[fame_pos].name); - } - else - {// already in the list - if( fame_pos == size ) - --fame_pos;// move to the end of the list - ARR_MOVE(player_pos, fame_pos, list, struct fame_list); - list[fame_pos].fame = fame; - } - char_send_fame_list(-1); - } - - RFIFOSKIP(fd,11); - } - break; - - // Divorce chars - case 0x2b11: - if( RFIFOREST(fd) < 10 ) - return 0; - - divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6)); - RFIFOSKIP(fd,10); - break; - - case 0x2b16: // Receive rates [Wizputer] - if( RFIFOREST(fd) < 14 ) - return 0; - { - char esc_server_name[sizeof(server_name)*2+1]; - - Sql_EscapeString(sql_handle, esc_server_name, server_name); - - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'", - fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) ) - Sql_ShowDebug(sql_handle); - RFIFOSKIP(fd,14); - } - break; - - case 0x2b17: // Character disconnected set online 0 [Wizputer] - if (RFIFOREST(fd) < 6) - return 0; - set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6)); - RFIFOSKIP(fd,10); - break; - - case 0x2b18: // Reset all chars to offline [Wizputer] - set_all_offline(id); - RFIFOSKIP(fd,2); - break; - - case 0x2b19: // Character set online [Wizputer] - if (RFIFOREST(fd) < 10) - return 0; - set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6)); - RFIFOSKIP(fd,10); - break; - - case 0x2b1a: // Build and send fame ranking lists [DracoRPG] - if (RFIFOREST(fd) < 2) - return 0; - char_read_fame_list(); - char_send_fame_list(-1); - RFIFOSKIP(fd,2); - break; - - case 0x2b1c: //Request to save status change data. [Skotlex] - if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) - return 0; - { -#ifdef ENABLE_SC_SAVING - int count, aid, cid; - - aid = RFIFOL(fd, 4); - cid = RFIFOL(fd, 8); - count = RFIFOW(fd, 12); - - if( count > 0 ) - { - struct status_change_data data; - StringBuf buf; - int i; - - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db); - for( i = 0; i < count; ++i ) - { - memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); - if( i > 0 ) - StringBuf_AppendStr(&buf, ", "); - StringBuf_Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid, - data.type, data.tick, data.val1, data.val2, data.val3, data.val4); - } - if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - StringBuf_Destroy(&buf); - } -#endif - RFIFOSKIP(fd, RFIFOW(fd, 2)); - } - break; - - case 0x2b23: // map-server alive packet - WFIFOHEAD(fd,2); - WFIFOW(fd,0) = 0x2b24; - WFIFOSET(fd,2); - RFIFOSKIP(fd,2); - break; - - case 0x2b26: // auth request from map-server - if (RFIFOREST(fd) < 19) - return 0; - - { - int account_id; - int char_id; - int login_id1; - char sex; - uint32 ip; - struct auth_node* node; - struct mmo_charstatus* cd; - struct mmo_charstatus char_dat; - - account_id = RFIFOL(fd,2); - char_id = RFIFOL(fd,6); - login_id1 = RFIFOL(fd,10); - sex = RFIFOB(fd,14); - ip = ntohl(RFIFOL(fd,15)); - RFIFOSKIP(fd,19); - - node = (struct auth_node*)idb_get(auth_db, account_id); - cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); - if( cd == NULL ) - { //Really shouldn't happen. - mmo_char_fromsql(char_id, &char_dat, true); - cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); - } - if( runflag == CHARSERVER_ST_RUNNING && - cd != NULL && - node != NULL && - node->account_id == account_id && - node->char_id == char_id && - node->login_id1 == login_id1 && - node->sex == sex /*&& - node->ip == ip*/ ) - {// auth ok - cd->sex = sex; - - WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus)); - WFIFOW(fd,0) = 0x2afd; - WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus); - WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = node->login_id1; - WFIFOL(fd,12) = node->login_id2; - WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT" - WFIFOL(fd,20) = node->gmlevel; - WFIFOB(fd,24) = node->changing_mapservers; - memcpy(WFIFOP(fd,25), cd, sizeof(struct mmo_charstatus)); - WFIFOSET(fd, WFIFOW(fd,2)); - - // only use the auth once and mark user online - idb_remove(auth_db, account_id); - set_char_online(id, char_id, account_id); - } - else - {// auth failed - WFIFOHEAD(fd,19); - WFIFOW(fd,0) = 0x2b27; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = char_id; - WFIFOL(fd,10) = login_id1; - WFIFOB(fd,14) = sex; - WFIFOL(fd,15) = htonl(ip); - WFIFOSET(fd,19); - } - } - break; - - case 0x2736: // ip address update - if (RFIFOREST(fd) < 6) return 0; - server[id].ip = ntohl(RFIFOL(fd, 2)); - ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(server[id].ip)); - RFIFOSKIP(fd,6); - break; - - default: - { - // inter server - packet - int r = inter_parse_frommap(fd); - if (r == 1) break; // processed - if (r == 2) return 0; // need more packet - - // no inter server packet. no char server packet -> disconnect - ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0)); - set_eof(fd); - return 0; - } - } // switch - } // while - - return 0; -} - -void do_init_mapif(void) -{ - int i; - for( i = 0; i < ARRAYLENGTH(server); ++i ) - mapif_server_init(i); -} - -void do_final_mapif(void) -{ - int i; - for( i = 0; i < ARRAYLENGTH(server); ++i ) - mapif_server_destroy(i); -} - -// Searches for the mapserver that has a given map (and optionally ip/port, if not -1). -// If found, returns the server's index in the 'server' array (otherwise returns -1). -int search_mapserver(unsigned short map, uint32 ip, uint16 port) -{ - int i, j; - - for(i = 0; i < ARRAYLENGTH(server); i++) - { - if (server[i].fd > 0 - && (ip == (uint32)-1 || server[i].ip == ip) - && (port == (uint16)-1 || server[i].port == port)) - { - for (j = 0; server[i].map[j]; j++) - if (server[i].map[j] == map) - return i; - } - } - - return -1; -} - -// char_mapif‚̉Šú‰»ˆ—iŒ»Ý‚Íinter_mapif‰Šú‰»‚Ì‚Ýj -static int char_mapif_init(int fd) -{ - return inter_mapif_init(fd); -} - -//-------------------------------------------- -// Test to know if an IP come from LAN or WAN. -//-------------------------------------------- -int lan_subnetcheck(uint32 ip) -{ - int i; - ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); - if( i < subnet_count ) { - ShowInfo("Subnet check [%u.%u.%u.%u]: Matches "CL_CYAN"%u.%u.%u.%u/%u.%u.%u.%u"CL_RESET"\n", CONVIP(ip), CONVIP(subnet[i].char_ip & subnet[i].mask), CONVIP(subnet[i].mask)); - return subnet[i].char_ip; - } else { - ShowInfo("Subnet check [%u.%u.%u.%u]: "CL_CYAN"WAN"CL_RESET"\n", CONVIP(ip)); - return 0; - } -} - - -/// @param result -/// 0 (0x718): An unknown error has occurred. -/// 1: none/success -/// 3 (0x719): A database error occurred. -/// 4 (0x71a): To delete a character you must withdraw from the guild. -/// 5 (0x71b): To delete a character you must withdraw from the party. -/// Any (0x718): An unknown error has occurred. -void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) -{// HC: <0828>.W .L .L .L - WFIFOHEAD(fd,14); - WFIFOW(fd,0) = 0x828; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = result; - WFIFOL(fd,10) = TOL(delete_date); - WFIFOSET(fd,14); -} - - -/// @param result -/// 0 (0x718): An unknown error has occurred. -/// 1: none/success -/// 2 (0x71c): Due to system settings can not be deleted. -/// 3 (0x719): A database error occurred. -/// 4 (0x71d): Deleting not yet possible time. -/// 5 (0x71e): Date of birth do not match. -/// Any (0x718): An unknown error has occurred. -void char_delete2_accept_ack(int fd, int char_id, uint32 result) -{// HC: <082a>.W .L .L - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x82a; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = result; - WFIFOSET(fd,10); -} - - -/// @param result -/// 1 (0x718): none/success, (if char id not in deletion process): An unknown error has occurred. -/// 2 (0x719): A database error occurred. -/// Any (0x718): An unknown error has occurred. -void char_delete2_cancel_ack(int fd, int char_id, uint32 result) -{// HC: <082c>.W .L .L - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x82c; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = result; - WFIFOSET(fd,10); -} - - -static void char_delete2_req(int fd, struct char_session_data* sd) -{// CH: <0827>.W .L - int char_id, i, guild_id, party_id; - char* data; - time_t delete_date; - - char_id = RFIFOL(fd,2); - - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); - if( i == MAX_CHARS ) - {// character not found - char_delete2_ack(fd, char_id, 3, 0); - return; - } - - if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `guild_id`,`party_id`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_ShowDebug(sql_handle); - char_delete2_ack(fd, char_id, 3, 0); - return; - } - - Sql_GetData(sql_handle, 0, &data, NULL); guild_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); party_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); delete_date = strtoul(data, NULL, 10); - - if( delete_date ) - {// character already queued for deletion - char_delete2_ack(fd, char_id, 0, 0); - return; - } - -/* - // Aegis imposes these checks probably to avoid dead member - // entries in guilds/parties, otherwise they are not required. - // TODO: Figure out how these are enforced during waiting. - if( guild_id ) - {// character in guild - char_delete2_ack(fd, char_id, 4, 0); - return; - } - - if( party_id ) - {// character in party - char_delete2_ack(fd, char_id, 5, 0); - return; - } -*/ - - // success - delete_date = time(NULL)+char_del_delay; - - if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) ) - { - Sql_ShowDebug(sql_handle); - char_delete2_ack(fd, char_id, 3, 0); - return; - } - - char_delete2_ack(fd, char_id, 1, delete_date); -} - - -static void char_delete2_accept(int fd, struct char_session_data* sd) -{// CH: <0829>.W .L .6B - char birthdate[8+1]; - int char_id, i, k; - unsigned int base_level; - char* data; - time_t delete_date; - - char_id = RFIFOL(fd,2); - - ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, char_id); - - // construct "YY-MM-DD" - birthdate[0] = RFIFOB(fd,6); - birthdate[1] = RFIFOB(fd,7); - birthdate[2] = '-'; - birthdate[3] = RFIFOB(fd,8); - birthdate[4] = RFIFOB(fd,9); - birthdate[5] = '-'; - birthdate[6] = RFIFOB(fd,10); - birthdate[7] = RFIFOB(fd,11); - birthdate[8] = 0; - - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); - if( i == MAX_CHARS ) - {// character not found - char_delete2_accept_ack(fd, char_id, 3); - return; - } - - if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != Sql_NextRow(sql_handle) ) - {// data error - Sql_ShowDebug(sql_handle); - char_delete2_accept_ack(fd, char_id, 3); - return; - } - - Sql_GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10); - Sql_GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10); - - if( !delete_date || delete_date>time(NULL) ) - {// not queued or delay not yet passed - char_delete2_accept_ack(fd, char_id, 4); - return; - } - - if( strcmp(sd->birthdate+2, birthdate) ) // +2 to cut off the century - {// birth date is wrong - char_delete2_accept_ack(fd, char_id, 5); - return; - } - - if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) ) - {// character level config restriction - char_delete2_accept_ack(fd, char_id, 2); - return; - } - - // success - if( delete_char_sql(char_id) < 0 ) - { - char_delete2_accept_ack(fd, char_id, 3); - return; - } - - // refresh character list cache - for(k = i; k < MAX_CHARS-1; k++) - { - sd->found_char[k] = sd->found_char[k+1]; - } - sd->found_char[MAX_CHARS-1] = -1; - - char_delete2_accept_ack(fd, char_id, 1); -} - - -static void char_delete2_cancel(int fd, struct char_session_data* sd) -{// CH: <082b>.W .L - int char_id, i; - - char_id = RFIFOL(fd,2); - - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == char_id ); - if( i == MAX_CHARS ) - {// character not found - char_delete2_cancel_ack(fd, char_id, 2); - return; - } - - // there is no need to check, whether or not the character was - // queued for deletion, as the client prints an error message by - // itself, if it was not the case (@see char_delete2_cancel_ack) - if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - char_delete2_cancel_ack(fd, char_id, 2); - return; - } - - char_delete2_cancel_ack(fd, char_id, 1); -} - - -int parse_char(int fd) -{ - int i, ch; - char email[40]; - unsigned short cmd; - int map_fd; - struct char_session_data* sd; - uint32 ipl = session[fd]->client_addr; - - sd = (struct char_session_data*)session[fd]->session_data; - - // disconnect any player if no login-server. - if(login_fd < 0) - set_eof(fd); - - if(session[fd]->flag.eof) - { - if( sd != NULL && sd->auth ) - { // already authed client - struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id); - if( data != NULL && data->fd == fd) - data->fd = -1; - if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex] - set_char_offline(-1,sd->account_id); - } - do_close(fd); - return 0; - } - - while( RFIFOREST(fd) >= 2 ) - { - //For use in packets that depend on an sd being present [Skotlex] - #define FIFOSD_CHECK(rest) { if(RFIFOREST(fd) < rest) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,rest); return 0; } } - - cmd = RFIFOW(fd,0); - switch( cmd ) - { - - // request to connect - // 0065 .L .L .L .W .B - case 0x65: - if( RFIFOREST(fd) < 17 ) - return 0; - { - struct auth_node* node; - - int account_id = RFIFOL(fd,2); - uint32 login_id1 = RFIFOL(fd,6); - uint32 login_id2 = RFIFOL(fd,10); - int sex = RFIFOB(fd,16); - RFIFOSKIP(fd,17); - - ShowInfo("request connect - account_id:%d/login_id1:%d/login_id2:%d\n", account_id, login_id1, login_id2); - - if (sd) { - //Received again auth packet for already authentified account?? Discard it. - //TODO: Perhaps log this as a hack attempt? - //TODO: and perhaps send back a reply? - break; - } - - CREATE(session[fd]->session_data, struct char_session_data, 1); - sd = (struct char_session_data*)session[fd]->session_data; - sd->account_id = account_id; - sd->login_id1 = login_id1; - sd->login_id2 = login_id2; - sd->sex = sex; - sd->auth = false; // not authed yet - - // send back account_id - WFIFOHEAD(fd,4); - WFIFOL(fd,0) = account_id; - WFIFOSET(fd,4); - - if( runflag != CHARSERVER_ST_RUNNING ) - { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x6c; - WFIFOB(fd,2) = 0;// rejected from server - WFIFOSET(fd,3); - break; - } - - // search authentification - node = (struct auth_node*)idb_get(auth_db, account_id); - if( node != NULL && - node->account_id == account_id && - node->login_id1 == login_id1 && - node->login_id2 == login_id2 /*&& - node->ip == ipl*/ ) - {// authentication found (coming from map server) - idb_remove(auth_db, account_id); - char_auth_ok(fd, sd); - } - else - {// authentication not found (coming from login server) - if (login_fd > 0) { // don't send request if no login-server - WFIFOHEAD(login_fd,23); - WFIFOW(login_fd,0) = 0x2712; // ask login-server to authentify an account - WFIFOL(login_fd,2) = sd->account_id; - WFIFOL(login_fd,6) = sd->login_id1; - WFIFOL(login_fd,10) = sd->login_id2; - WFIFOB(login_fd,14) = sd->sex; - WFIFOL(login_fd,15) = htonl(ipl); - WFIFOL(login_fd,19) = fd; - WFIFOSET(login_fd,23); - } else { // if no login-server, we must refuse connection - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x6c; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - } - } - } - break; - - // char select - case 0x66: - FIFOSD_CHECK(3); - { - struct mmo_charstatus char_dat; - struct mmo_charstatus *cd; - char* data; - int char_id; - uint32 subnet_map_ip; - struct auth_node* node; - - int slot = RFIFOB(fd,2); - RFIFOSKIP(fd,3); - - if ( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot) - || SQL_SUCCESS != Sql_NextRow(sql_handle) - || SQL_SUCCESS != Sql_GetData(sql_handle, 0, &data, NULL) ) - { //Not found?? May be forged packet. - Sql_ShowDebug(sql_handle); - Sql_FreeResult(sql_handle); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x6c; - WFIFOB(fd,2) = 0; // rejected from server - WFIFOSET(fd,3); - break; - } - - char_id = atoi(data); - Sql_FreeResult(sql_handle); - mmo_char_fromsql(char_id, &char_dat, true); - - //Have to switch over to the DB instance otherwise data won't propagate [Kevin] - cd = (struct mmo_charstatus *)idb_get(char_db_, char_id); - cd->sex = sd->sex; - - if (log_char) { - char esc_name[NAME_LENGTH*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')", - charlog_db, sd->account_id, slot, esc_name) ) - Sql_ShowDebug(sql_handle); - } - ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name); - - // searching map server - i = search_mapserver(cd->last_point.map, -1, -1); - - // if map is not found, we check major cities - if (i < 0) { - unsigned short j; - //First check that there's actually a map server online. - ARR_FIND( 0, ARRAYLENGTH(server), j, server[j].fd >= 0 && server[j].map[0] ); - if (j == ARRAYLENGTH(server)) { - ShowInfo("Connection Closed. No map servers available.\n"); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); - break; - } - if ((i = search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) { - cd->last_point.x = 273; - cd->last_point.y = 354; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_GEFFEN)),-1,-1)) >= 0) { - cd->last_point.x = 120; - cd->last_point.y = 100; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_MORROC)),-1,-1)) >= 0) { - cd->last_point.x = 160; - cd->last_point.y = 94; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_ALBERTA)),-1,-1)) >= 0) { - cd->last_point.x = 116; - cd->last_point.y = 57; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_PAYON)),-1,-1)) >= 0) { - cd->last_point.x = 87; - cd->last_point.y = 117; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_IZLUDE)),-1,-1)) >= 0) { - cd->last_point.x = 94; - cd->last_point.y = 103; - } else { - ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map)); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); - break; - } - ShowWarning("Unable to find map-server for '%s', sending to major city '%s'.\n", mapindex_id2name(cd->last_point.map), mapindex_id2name(j)); - cd->last_point.map = j; - } - - //Send NEW auth packet [Kevin] - //FIXME: is this case even possible? [ultramage] - if ((map_fd = server[i].fd) < 1 || session[map_fd] == NULL) - { - ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i); - server[i].fd = -1; - memset(&server[i], 0, sizeof(struct mmo_map_server)); - //Send server closed. - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); - break; - } - - //Send player to map - WFIFOHEAD(fd,28); - WFIFOW(fd,0) = 0x71; - WFIFOL(fd,2) = cd->char_id; - mapindex_getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6)); - subnet_map_ip = lan_subnetcheck(ipl); // Advanced subnet check [LuzZza] - WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); - WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] - WFIFOSET(fd,28); - - // create temporary auth entry - CREATE(node, struct auth_node, 1); - node->account_id = sd->account_id; - node->char_id = cd->char_id; - node->login_id1 = sd->login_id1; - node->login_id2 = sd->login_id2; - node->sex = sd->sex; - node->expiration_time = sd->expiration_time; - node->gmlevel = sd->gmlevel; - node->ip = ipl; - idb_put(auth_db, sd->account_id, node); - - set_char_online(-2,node->char_id,sd->account_id); - - } - break; - - // create new char - // S 0067 .24B .B .B .B .B .B .B .B .W .W - case 0x67: - FIFOSD_CHECK(37); - - if( !char_new ) //turn character creation on/off [Kevin] - i = -2; - else - i = make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35)); - - //'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3) - if (i < 0) - { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x6e; - switch (i) { - case -1: WFIFOB(fd,2) = 0x00; break; - case -2: WFIFOB(fd,2) = 0xFF; break; - case -3: WFIFOB(fd,2) = 0x01; break; - } - WFIFOSET(fd,3); - } - else - { - int len; - // retrieve data - struct mmo_charstatus char_dat; - mmo_char_fromsql(i, &char_dat, false); //Only the short data is needed. - - // send to player - WFIFOHEAD(fd,2+MAX_CHAR_BUF); - WFIFOW(fd,0) = 0x6d; - len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat); - WFIFOSET(fd,len); - - // add new entry to the chars list - ARR_FIND( 0, MAX_CHARS, ch, sd->found_char[ch] == -1 ); - if( ch < MAX_CHARS ) - sd->found_char[ch] = i; // the char_id of the new char - } - - RFIFOSKIP(fd,37); - break; - - // delete char - case 0x68: - // 2004-04-19aSakexe+ langtype 12 char deletion packet - case 0x1fb: - if (cmd == 0x68) FIFOSD_CHECK(46); - if (cmd == 0x1fb) FIFOSD_CHECK(56); - { - int cid = RFIFOL(fd,2); - - ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); - memcpy(email, RFIFOP(fd,6), 40); - RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56); - - // Check if e-mail is correct - if(strcmpi(email, sd->email) && //email does not matches and - ( - strcmp("a@a.com", sd->email) || //it is not default email, or - (strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default - )) { //Fail - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; // 00 = Incorrect Email address - WFIFOSET(fd,3); - break; - } - - // check if this char exists - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); - if( i == MAX_CHARS ) - { // Such a character does not exist in the account - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x70; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - break; - } - - // remove char from list and compact it - for(ch = i; ch < MAX_CHARS-1; ch++) - sd->found_char[ch] = sd->found_char[ch+1]; - sd->found_char[MAX_CHARS-1] = -1; - - /* Delete character */ - if(delete_char_sql(cid)<0){ - //can't delete the char - //either SQL error or can't delete by some CONFIG conditions - //del fail - WFIFOHEAD(fd,3); - WFIFOW(fd, 0) = 0x70; - WFIFOB(fd, 2) = 0; - WFIFOSET(fd, 3); - break; - } - /* Char successfully deleted.*/ - WFIFOHEAD(fd,2); - WFIFOW(fd,0) = 0x6f; - WFIFOSET(fd,2); - } - break; - - // client keep-alive packet (every 12 seconds) - // R 0187 .l - case 0x187: - if (RFIFOREST(fd) < 6) - return 0; - RFIFOSKIP(fd,6); - break; - - // char rename request - // R 028d .l .l .24B - case 0x28d: - FIFOSD_CHECK(34); - { - int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6); - char name[NAME_LENGTH]; - char esc_name[NAME_LENGTH*2+1]; - safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH); - RFIFOSKIP(fd,34); - - if( aid != sd->account_id ) - break; - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); - if( i == MAX_CHARS ) - break; - - normalize_name(name,TRIM_CHARS); - Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); - if( !check_char_name(name,esc_name) ) - { - i = 1; - safestrncpy(sd->new_name, name, NAME_LENGTH); - } - else - i = 0; - - WFIFOHEAD(fd, 4); - WFIFOW(fd,0) = 0x28e; - WFIFOW(fd,2) = i; - WFIFOSET(fd,4); - } - break; - //Confirm change name. - // 0x28f .L - case 0x28f: - // 0: Sucessfull - // 1: This character's name has already been changed. You cannot change a character's name more than once. - // 2: User information is not correct. - // 3: You have failed to change this character's name. - // 4: Another user is using this character name, so please select another one. - FIFOSD_CHECK(6); - { - int i; - int cid = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); - if( i == MAX_CHARS ) - break; - i = rename_char_sql(sd, cid); - - WFIFOHEAD(fd, 4); - WFIFOW(fd,0) = 0x290; - WFIFOW(fd,2) = i; - WFIFOSET(fd,4); - } - break; - - // captcha code request (not implemented) - // R 07e5 .w .l - case 0x7e5: - WFIFOHEAD(fd,5); - WFIFOW(fd,0) = 0x7e9; - WFIFOW(fd,2) = 5; - WFIFOB(fd,4) = 1; - WFIFOSET(fd,5); - RFIFOSKIP(fd,8); - break; - - // captcha code check (not implemented) - // R 07e7 .w .l .b10 .b14 - case 0x7e7: - WFIFOHEAD(fd,5); - WFIFOW(fd,0) = 0x7e9; - WFIFOW(fd,2) = 5; - WFIFOB(fd,4) = 1; - WFIFOSET(fd,5); - RFIFOSKIP(fd,32); - break; - - // deletion timer request - case 0x827: - FIFOSD_CHECK(6); - char_delete2_req(fd, sd); - RFIFOSKIP(fd,6); - break; - - // deletion accept request - case 0x829: - FIFOSD_CHECK(12); - char_delete2_accept(fd, sd); - RFIFOSKIP(fd,12); - break; - - // deletion cancel request - case 0x82b: - FIFOSD_CHECK(6); - char_delete2_cancel(fd, sd); - RFIFOSKIP(fd,6); - break; - - // login as map-server - case 0x2af8: - if (RFIFOREST(fd) < 60) - return 0; - { - char* l_user = (char*)RFIFOP(fd,2); - char* l_pass = (char*)RFIFOP(fd,26); - l_user[23] = '\0'; - l_pass[23] = '\0'; - ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd <= 0 ); - if( runflag != CHARSERVER_ST_RUNNING || - i == ARRAYLENGTH(server) || - strcmp(l_user, userid) != 0 || - strcmp(l_pass, passwd) != 0 ) - { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2af9; - WFIFOB(fd,2) = 3; - WFIFOSET(fd,3); - } else { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2af9; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - - server[i].fd = fd; - server[i].ip = ntohl(RFIFOL(fd,54)); - server[i].port = ntohs(RFIFOW(fd,58)); - server[i].users = 0; - memset(server[i].map, 0, sizeof(server[i].map)); - session[fd]->func_parse = parse_frommap; - session[fd]->flag.server = 1; - realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - char_mapif_init(fd); - } - - RFIFOSKIP(fd,60); - } - return 0; // avoid processing of followup packets here - - // unknown packet received - default: - ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL)); - set_eof(fd); - return 0; - } - } - - RFIFOFLUSH(fd); - return 0; -} - -// Console Command Parser [Wizputer] -int parse_console(const char* command) -{ - ShowNotice("Console command: %s\n", command); - - if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 ) - runflag = 0; - else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 ) - ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else if( strcmpi("help", command) == 0 ) - { - ShowInfo("To shutdown the server:\n"); - ShowInfo(" 'shutdown|exit|quit|end'\n"); - ShowInfo("To know if server is alive:\n"); - ShowInfo(" 'alive|status'\n"); - } - - return 0; -} - -int mapif_sendall(unsigned char *buf, unsigned int len) -{ - int i, c; - - c = 0; - for(i = 0; i < ARRAYLENGTH(server); i++) { - int fd; - if ((fd = server[i].fd) > 0) { - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - c++; - } - } - - return c; -} - -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) -{ - int i, c; - - c = 0; - for(i = 0; i < ARRAYLENGTH(server); i++) { - int fd; - if ((fd = server[i].fd) > 0 && fd != sfd) { - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - c++; - } - } - - return c; -} - -int mapif_send(int fd, unsigned char *buf, unsigned int len) -{ - int i; - - if (fd >= 0) { - ARR_FIND( 0, ARRAYLENGTH(server), i, fd == server[i].fd ); - if( i < ARRAYLENGTH(server) ) - { - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - return 1; - } - } - return 0; -} - -int broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data) -{ - uint8 buf[6]; - int users = count_users(); - - // only send an update when needed - static int prev_users = 0; - if( prev_users == users ) - return 0; - prev_users = users; - - if( login_fd > 0 && session[login_fd] ) - { - // send number of user to login server - WFIFOHEAD(login_fd,6); - WFIFOW(login_fd,0) = 0x2714; - WFIFOL(login_fd,2) = users; - WFIFOSET(login_fd,6); - } - - // send number of players to all map-servers - WBUFW(buf,0) = 0x2b00; - WBUFL(buf,2) = users; - mapif_sendall(buf,6); - - return 0; -} - -/// load this char's account id into the 'online accounts' packet -static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) -{ - struct online_char_data* character = (struct online_char_data*)data; - int* i = va_arg(ap, int*); - - if(character->server > -1) - { - WFIFOL(login_fd,8+(*i)*4) = character->account_id; - (*i)++; - return 1; - } - return 0; -} - -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data) -{ - if (login_fd > 0 && session[login_fd]) - { - // send account list to login server - int users = online_char_db->size(online_char_db); - int i = 0; - - WFIFOHEAD(login_fd,8+users*4); - WFIFOW(login_fd,0) = 0x272d; - online_char_db->foreach(online_char_db, send_accounts_tologin_sub, &i, users); - WFIFOW(login_fd,2) = 8+ i*4; - WFIFOL(login_fd,4) = i; - WFIFOSET(login_fd,WFIFOW(login_fd,2)); - } - return 0; -} - -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data) -{ - if (login_fd > 0 && session[login_fd] != NULL) - return 0; - - ShowInfo("Attempt to connect to login-server...\n"); - login_fd = make_connection(login_ip, login_port); - if (login_fd == -1) - { //Try again later. [Skotlex] - login_fd = 0; - return 0; - } - session[login_fd]->func_parse = parse_fromlogin; - session[login_fd]->flag.server = 1; - realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - - WFIFOHEAD(login_fd,86); - WFIFOW(login_fd,0) = 0x2710; - memcpy(WFIFOP(login_fd,2), userid, 24); - memcpy(WFIFOP(login_fd,26), passwd, 24); - WFIFOL(login_fd,50) = 0; - WFIFOL(login_fd,54) = htonl(char_ip); - WFIFOW(login_fd,58) = htons(char_port); - memcpy(WFIFOP(login_fd,60), server_name, 20); - WFIFOW(login_fd,80) = 0; - WFIFOW(login_fd,82) = char_maintenance; - WFIFOW(login_fd,84) = char_new_display; //only display (New) if they want to [Kevin] - WFIFOSET(login_fd,86); - - return 1; -} - -// sends a ping packet to login server (will receive pong 0x2718) -int ping_login_server(int tid, unsigned int tick, int id, intptr_t data) -{ - if (login_fd > 0 && session[login_fd] != NULL) - { - WFIFOHEAD(login_fd,2); - WFIFOW(login_fd,0) = 0x2719; - WFIFOSET(login_fd,2); - } - return 0; -} - -//------------------------------------------------ -//Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't -//replies/disconnect the player we tried to kick. [Skotlex] -//------------------------------------------------ -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data) -{ - struct online_char_data* character; - if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) - { //Mark it offline due to timeout. - character->waiting_disconnect = INVALID_TIMER; - set_char_offline(character->char_id, character->account_id); - } - return 0; -} - -static int online_data_cleanup_sub(DBKey key, void *data, va_list ap) -{ - struct online_char_data *character= (struct online_char_data*)data; - if (character->fd != -1) - return 0; //Character still connected - if (character->server == -2) //Unknown server.. set them offline - set_char_offline(character->char_id, character->account_id); - if (character->server < 0) - //Free data from players that have not been online for a while. - db_remove(online_char_db, key); - return 0; -} - -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ - online_char_db->foreach(online_char_db, online_data_cleanup_sub); - return 0; -} - -//---------------------------------- -// Reading Lan Support configuration -// Rewrote: Anvanced subnet check [LuzZza] -//---------------------------------- -int char_lan_config_read(const char *lancfgName) -{ - FILE *fp; - int line_num = 0; - char line[1024], w1[64], w2[64], w3[64], w4[64]; - - if((fp = fopen(lancfgName, "r")) == NULL) { - ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName); - return 1; - } - - ShowInfo("Reading the configuration file %s...\n", lancfgName); - - while(fgets(line, sizeof(line), fp)) - { - line_num++; - if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') - continue; - - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) { - - ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); - continue; - } - - remove_control_chars(w1); - remove_control_chars(w2); - remove_control_chars(w3); - remove_control_chars(w4); - - if( strcmpi(w1, "subnet") == 0 ) - { - subnet[subnet_count].mask = str2ip(w2); - subnet[subnet_count].char_ip = str2ip(w3); - subnet[subnet_count].map_ip = str2ip(w4); - - if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) - { - ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); - continue; - } - - subnet_count++; - } - } - - ShowStatus("Read information about %d subnetworks.\n", subnet_count); - - fclose(fp); - return 0; -} -#endif //TXT_SQL_CONVERT - -void sql_config_read(const char* cfgName) -{ - char line[1024], w1[1024], w2[1024]; - FILE* fp; - - ShowInfo("Reading file %s...\n", cfgName); - - if ((fp = fopen(cfgName, "r")) == NULL) { - ShowError("file not found: %s\n", cfgName); - return; - } - - while(fgets(line, sizeof(line), fp)) - { - if(line[0] == '/' && line[1] == '/') - continue; - - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) - continue; - - if(!strcmpi(w1,"char_db")) - safestrncpy(char_db, w2, sizeof(char_db)); - else if(!strcmpi(w1,"scdata_db")) - safestrncpy(scdata_db, w2, sizeof(scdata_db)); - else if(!strcmpi(w1,"cart_db")) - safestrncpy(cart_db, w2, sizeof(cart_db)); - else if(!strcmpi(w1,"inventory_db")) - safestrncpy(inventory_db, w2, sizeof(inventory_db)); - else if(!strcmpi(w1,"charlog_db")) - safestrncpy(charlog_db, w2, sizeof(charlog_db)); - else if(!strcmpi(w1,"storage_db")) - safestrncpy(storage_db, w2, sizeof(storage_db)); - else if(!strcmpi(w1,"reg_db")) - safestrncpy(reg_db, w2, sizeof(reg_db)); - else if(!strcmpi(w1,"skill_db")) - safestrncpy(skill_db, w2, sizeof(skill_db)); - else if(!strcmpi(w1,"interlog_db")) - safestrncpy(interlog_db, w2, sizeof(interlog_db)); - else if(!strcmpi(w1,"memo_db")) - safestrncpy(memo_db, w2, sizeof(memo_db)); - else if(!strcmpi(w1,"guild_db")) - safestrncpy(guild_db, w2, sizeof(guild_db)); - else if(!strcmpi(w1,"guild_alliance_db")) - safestrncpy(guild_alliance_db, w2, sizeof(guild_alliance_db)); - else if(!strcmpi(w1,"guild_castle_db")) - safestrncpy(guild_castle_db, w2, sizeof(guild_castle_db)); - else if(!strcmpi(w1,"guild_expulsion_db")) - safestrncpy(guild_expulsion_db, w2, sizeof(guild_expulsion_db)); - else if(!strcmpi(w1,"guild_member_db")) - safestrncpy(guild_member_db, w2, sizeof(guild_member_db)); - else if(!strcmpi(w1,"guild_skill_db")) - safestrncpy(guild_skill_db, w2, sizeof(guild_skill_db)); - else if(!strcmpi(w1,"guild_position_db")) - safestrncpy(guild_position_db, w2, sizeof(guild_position_db)); - else if(!strcmpi(w1,"guild_storage_db")) - safestrncpy(guild_storage_db, w2, sizeof(guild_storage_db)); - else if(!strcmpi(w1,"party_db")) - safestrncpy(party_db, w2, sizeof(party_db)); - else if(!strcmpi(w1,"pet_db")) - safestrncpy(pet_db, w2, sizeof(pet_db)); - else if(!strcmpi(w1,"mail_db")) - safestrncpy(mail_db, w2, sizeof(mail_db)); - else if(!strcmpi(w1,"auction_db")) - safestrncpy(auction_db, w2, sizeof(auction_db)); - else if(!strcmpi(w1,"friend_db")) - safestrncpy(friend_db, w2, sizeof(friend_db)); - else if(!strcmpi(w1,"hotkey_db")) - safestrncpy(hotkey_db, w2, sizeof(hotkey_db)); - else if(!strcmpi(w1,"quest_db")) - safestrncpy(quest_db,w2,sizeof(quest_db)); - //support the import command, just like any other config - else if(!strcmpi(w1,"import")) - sql_config_read(w2); - } - fclose(fp); - ShowInfo("Done reading %s.\n", cfgName); -} -#ifndef TXT_SQL_CONVERT - -int char_config_read(const char* cfgName) -{ - char line[1024], w1[1024], w2[1024]; - FILE* fp = fopen(cfgName, "r"); - - if (fp == NULL) { - ShowError("Configuration file not found: %s.\n", cfgName); - return 1; - } - - ShowInfo("Reading configuration file %s...\n", cfgName); - while(fgets(line, sizeof(line), fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) - continue; - - remove_control_chars(w1); - remove_control_chars(w2); - if(strcmpi(w1,"timestamp_format") == 0) { - safestrncpy(timestamp_format, w2, sizeof(timestamp_format)); - } else if(strcmpi(w1,"console_silent")==0){ - ShowInfo("Console Silent Setting: %d\n", atoi(w2)); - msg_silent = atoi(w2); - } else if(strcmpi(w1,"stdout_with_ansisequence")==0){ - stdout_with_ansisequence = config_switch(w2); - } else if (strcmpi(w1, "userid") == 0) { - safestrncpy(userid, w2, sizeof(userid)); - } else if (strcmpi(w1, "passwd") == 0) { - safestrncpy(passwd, w2, sizeof(passwd)); - } else if (strcmpi(w1, "server_name") == 0) { - safestrncpy(server_name, w2, sizeof(server_name)); - ShowStatus("%s server has been initialized\n", w2); - } else if (strcmpi(w1, "wisp_server_name") == 0) { - if (strlen(w2) >= 4) { - safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name)); - } - } else if (strcmpi(w1, "login_ip") == 0) { - char ip_str[16]; - login_ip = host2ip(w2); - if (login_ip) { - safestrncpy(login_ip_str, w2, sizeof(login_ip_str)); - ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str)); - } - } else if (strcmpi(w1, "login_port") == 0) { - login_port = atoi(w2); - } else if (strcmpi(w1, "char_ip") == 0) { - char ip_str[16]; - char_ip = host2ip(w2); - if (char_ip){ - safestrncpy(char_ip_str, w2, sizeof(char_ip_str)); - ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str)); - } - } else if (strcmpi(w1, "bind_ip") == 0) { - char ip_str[16]; - bind_ip = host2ip(w2); - if (bind_ip) { - safestrncpy(bind_ip_str, w2, sizeof(bind_ip_str)); - ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str)); - } - } else if (strcmpi(w1, "char_port") == 0) { - char_port = atoi(w2); - } else if (strcmpi(w1, "char_maintenance") == 0) { - char_maintenance = atoi(w2); - } else if (strcmpi(w1, "char_new") == 0) { - char_new = (bool)atoi(w2); - } else if (strcmpi(w1, "char_new_display") == 0) { - char_new_display = atoi(w2); - } else if (strcmpi(w1, "max_connect_user") == 0) { - max_connect_user = atoi(w2); - if (max_connect_user < 0) - max_connect_user = 0; // unlimited online players - } else if(strcmpi(w1, "gm_allow_level") == 0) { - gm_allow_level = atoi(w2); - if(gm_allow_level < 0) - gm_allow_level = 99; - } else if (strcmpi(w1, "autosave_time") == 0) { - autosave_interval = atoi(w2)*1000; - if (autosave_interval <= 0) - autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; - } else if (strcmpi(w1, "save_log") == 0) { - save_log = config_switch(w2); - } else if (strcmpi(w1, "start_point") == 0) { - char map[MAP_NAME_LENGTH_EXT]; - int x, y; - if (sscanf(w2, "%15[^,],%d,%d", map, &x, &y) < 3) - continue; - start_point.map = mapindex_name2id(map); - if (!start_point.map) - ShowError("Specified start_point %s not found in map-index cache.\n", map); - start_point.x = x; - start_point.y = y; - } else if (strcmpi(w1, "start_zeny") == 0) { - start_zeny = atoi(w2); - if (start_zeny < 0) - start_zeny = 0; - } else if (strcmpi(w1, "start_weapon") == 0) { - start_weapon = atoi(w2); - if (start_weapon < 0) - start_weapon = 0; - } else if (strcmpi(w1, "start_armor") == 0) { - start_armor = atoi(w2); - if (start_armor < 0) - start_armor = 0; - } else if(strcmpi(w1,"log_char")==0) { //log char or not [devil] - log_char = atoi(w2); - } else if (strcmpi(w1, "unknown_char_name") == 0) { - safestrncpy(unknown_char_name, w2, sizeof(unknown_char_name)); - unknown_char_name[NAME_LENGTH-1] = '\0'; - } else if (strcmpi(w1, "name_ignoring_case") == 0) { - name_ignoring_case = (bool)config_switch(w2); - } else if (strcmpi(w1, "char_name_option") == 0) { - char_name_option = atoi(w2); - } else if (strcmpi(w1, "char_name_letters") == 0) { - safestrncpy(char_name_letters, w2, sizeof(char_name_letters)); - } else if (strcmpi(w1, "chars_per_account") == 0) { //maxchars per account [Sirius] - char_per_account = atoi(w2); - } else if (strcmpi(w1, "char_del_level") == 0) { //disable/enable char deletion by its level condition [Lupus] - char_del_level = atoi(w2); - } else if (strcmpi(w1, "char_del_delay") == 0) { - char_del_delay = atoi(w2); - } else if(strcmpi(w1,"db_path")==0) { - safestrncpy(db_path, w2, sizeof(db_path)); - } else if (strcmpi(w1, "console") == 0) { - console = config_switch(w2); - } else if (strcmpi(w1, "fame_list_alchemist") == 0) { - fame_list_size_chemist = atoi(w2); - if (fame_list_size_chemist > MAX_FAME_LIST) { - ShowWarning("Max fame list size is %d (fame_list_alchemist)\n", MAX_FAME_LIST); - fame_list_size_chemist = MAX_FAME_LIST; - } - } else if (strcmpi(w1, "fame_list_blacksmith") == 0) { - fame_list_size_smith = atoi(w2); - if (fame_list_size_smith > MAX_FAME_LIST) { - ShowWarning("Max fame list size is %d (fame_list_blacksmith)\n", MAX_FAME_LIST); - fame_list_size_smith = MAX_FAME_LIST; - } - } else if (strcmpi(w1, "fame_list_taekwon") == 0) { - fame_list_size_taekwon = atoi(w2); - if (fame_list_size_taekwon > MAX_FAME_LIST) { - ShowWarning("Max fame list size is %d (fame_list_taekwon)\n", MAX_FAME_LIST); - fame_list_size_taekwon = MAX_FAME_LIST; - } - } else if (strcmpi(w1, "guild_exp_rate") == 0) { - guild_exp_rate = atoi(w2); - } else if (strcmpi(w1, "import") == 0) { - char_config_read(w2); - } - } - fclose(fp); - - ShowInfo("Done reading %s.\n", cfgName); - return 0; -} - -void do_final(void) -{ - ShowStatus("Terminating...\n"); - - set_all_offline(-1); - set_all_offline_sql(); - - inter_final(); - - flush_fifos(); - - do_final_mapif(); - do_final_loginif(); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo`") ) - Sql_ShowDebug(sql_handle); - - char_db_->destroy(char_db_, NULL); - online_char_db->destroy(online_char_db, NULL); - auth_db->destroy(auth_db, NULL); - - if( char_fd != -1 ) - { - do_close(char_fd); - char_fd = -1; - } - - Sql_Free(sql_handle); - mapindex_final(); - - ShowStatus("Finished.\n"); -} - -//------------------------------ -// Function called when the server -// has received a crash signal. -//------------------------------ -void do_abort(void) -{ -} - -void set_server_type(void) -{ - SERVER_TYPE = ATHENA_SERVER_CHAR; -} - - -/// Called when a terminate signal is received. -void do_shutdown(void) -{ - if( runflag != CHARSERVER_ST_SHUTDOWN ) - { - int id; - runflag = CHARSERVER_ST_SHUTDOWN; - ShowStatus("Shutting down...\n"); - // TODO proper shutdown procedure; wait for acks?, kick all characters, ... [FlavoJS] - for( id = 0; id < ARRAYLENGTH(server); ++id ) - mapif_server_reset(id); - loginif_check_shutdown(); - flush_fifos(); - runflag = CORE_ST_STOP; - } -} - - -int do_init(int argc, char **argv) -{ - //Read map indexes - mapindex_init(); - start_point.map = mapindex_name2id("new_zone01"); - - char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]); - char_lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME); - sql_config_read(SQL_CONF_NAME); - - if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) { - ShowError("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); - ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); - ShowNotice("And then change the user/password to use in conf/char_athena.conf (or conf/import/char_conf.txt)\n"); - } - - ShowInfo("Finished reading the char-server configuration.\n"); - - inter_init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server ÃʱâÈ­ - ShowInfo("Finished reading the inter-server configuration.\n"); - - ShowInfo("Initializing char server.\n"); - auth_db = idb_alloc(DB_OPT_RELEASE_DATA); - online_char_db = idb_alloc(DB_OPT_RELEASE_DATA); - mmo_char_sql_init(); - char_read_fame_list(); //Read fame lists. - ShowInfo("char server initialized.\n"); - - if ((naddr_ != 0) && (!login_ip || !char_ip)) - { - char ip_str[16]; - ip2str(addr_[0], ip_str); - - if (naddr_ > 1) - ShowStatus("Multiple interfaces detected.. using %s as our IP address\n", ip_str); - else - ShowStatus("Defaulting to %s as our IP address\n", ip_str); - if (!login_ip) { - safestrncpy(login_ip_str, ip_str, sizeof(login_ip_str)); - login_ip = str2ip(login_ip_str); - } - if (!char_ip) { - safestrncpy(char_ip_str, ip_str, sizeof(char_ip_str)); - char_ip = str2ip(char_ip_str); - } - } - - do_init_loginif(); - do_init_mapif(); - - // periodically update the overall user count on all mapservers + login server - add_timer_func_list(broadcast_user_count, "broadcast_user_count"); - add_timer_interval(gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000); - - // ??? - add_timer_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect"); - - // ??? - add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - add_timer_interval(gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); - - if( console ) - { - //##TODO invoke a CONSOLE_START plugin event - } - - //Cleaning the tables for NULL entrys @ startup [Sirius] - //Chardb clean - ShowInfo("Cleaning the '%s' table...\n", char_db); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) ) - Sql_ShowDebug(sql_handle); - - //guilddb clean - ShowInfo("Cleaning the '%s' table...\n", guild_db); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) ) - Sql_ShowDebug(sql_handle); - - //guildmemberdb clean - ShowInfo("Cleaning the '%s' table...\n", guild_member_db); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) ) - Sql_ShowDebug(sql_handle); - - ShowInfo("End of char server initilization function.\n"); - - set_defaultparse(parse_char); - ShowInfo("open port %d.....\n",char_port); - char_fd = make_listen_bind(bind_ip, char_port); - ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); - - if( runflag != CORE_ST_STOP ) - { - shutdown_callback = do_shutdown; - runflag = CHARSERVER_ST_RUNNING; - } - - return 0; -} - -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/char.h b/src/char_sql/char.h deleted file mode 100644 index c9ec54a16..000000000 --- a/src/char_sql/char.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _CHAR_SQL_H_ -#define _CHAR_SQL_H_ - -#include "../common/core.h" // CORE_ST_LAST - -#ifndef TXT_SQL_CONVERT -enum E_CHARSERVER_ST -{ - CHARSERVER_ST_RUNNING = CORE_ST_LAST, - CHARSERVER_ST_SHUTDOWN, - CHARSERVER_ST_LAST -}; -#endif - -struct mmo_charstatus; - -#define MAX_MAP_SERVERS 30 - -#define DEFAULT_AUTOSAVE_INTERVAL 300*1000 - -enum { - TABLE_INVENTORY, - TABLE_CART, - TABLE_STORAGE, - TABLE_GUILD_STORAGE, -}; - -int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch); - -int mapif_sendall(unsigned char *buf,unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); -int mapif_send(int fd,unsigned char *buf,unsigned int len); - -int char_married(int pl1,int pl2); -int char_child(int parent_id, int child_id); -int char_family(int pl1,int pl2,int pl3); - -int request_accreg2(int account_id, int char_id); -int save_accreg2(unsigned char* buf, int len); - -extern int char_name_option; -extern char char_name_letters[]; -extern bool char_gm_read; -extern int autosave_interval; -extern int save_log; -extern char db_path[]; -extern char char_db[256]; -extern char scdata_db[256]; -extern char cart_db[256]; -extern char inventory_db[256]; -extern char charlog_db[256]; -extern char storage_db[256]; -extern char interlog_db[256]; -extern char reg_db[256]; -extern char skill_db[256]; -extern char memo_db[256]; -extern char guild_db[256]; -extern char guild_alliance_db[256]; -extern char guild_castle_db[256]; -extern char guild_expulsion_db[256]; -extern char guild_member_db[256]; -extern char guild_position_db[256]; -extern char guild_skill_db[256]; -extern char guild_storage_db[256]; -extern char party_db[256]; -extern char pet_db[256]; -extern char mail_db[256]; -extern char auction_db[256]; -extern char quest_db[256]; - -extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] - -extern int guild_exp_rate; -extern int log_inter; - -//Exported for use in the TXT-SQL converter. -int mmo_char_tosql(int char_id, struct mmo_charstatus *p); -void sql_config_read(const char *cfgName); - -#endif /* _CHAR_SQL_H_ */ diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c deleted file mode 100644 index 04e321062..000000000 --- a/src/char_sql/int_auction.c +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/db.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" -#include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_mail.h" -#include "int_auction.h" - -#include -#include -#include - -static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* - -void auction_delete(struct auction_data *auction); -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data); - -static int auction_count(int char_id, bool buy) -{ - int i = 0; - struct auction_data *auction; - DBIterator* iter; - DBKey key; - - iter = auction_db_->iterator(auction_db_); - for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) - { - if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) ) - i++; - } - iter->destroy(iter); - - return i; -} - -void auction_save(struct auction_data *auction) -{ - int j; - StringBuf buf; - SqlStmt* stmt; - - if( !auction ) - return; - - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "UPDATE `%s` SET `seller_id` = '%d', `seller_name` = ?, `buyer_id` = '%d', `buyer_name` = ?, `price` = '%d', `buynow` = '%d', `hours` = '%d', `timestamp` = '%lu', `nameid` = '%d', `item_name` = ?, `type` = '%d', `refine` = '%d', `attribute` = '%d'", - auction_db, auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute); - for( j = 0; j < MAX_SLOTS; j++ ) - StringBuf_Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]); - StringBuf_Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id); - - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - } - - SqlStmt_Free(stmt); - StringBuf_Destroy(&buf); -} - -unsigned int auction_create(struct auction_data *auction) -{ - int j; - StringBuf buf; - SqlStmt* stmt; - - if( !auction ) - return false; - - auction->timestamp = time(NULL) + (auction->hours * 3600); - - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`", auction_db); - for( j = 0; j < MAX_SLOTS; j++ ) - StringBuf_Printf(&buf, ",`card%d`", j); - StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%d',?,'%d','%d','%d'", - auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute); - for( j = 0; j < MAX_SLOTS; j++ ) - StringBuf_Printf(&buf, ",'%d'", auction->item.card[j]); - StringBuf_AppendStr(&buf, ")"); - - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - auction->auction_id = 0; - } - else - { - struct auction_data *auction_; - unsigned int tick = auction->hours * 3600000; - - auction->item.amount = 1; - auction->item.identify = 1; - auction->item.expire_time = 0; - - auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt); - auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0); - ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name); - - CREATE(auction_, struct auction_data, 1); - memcpy(auction_, auction, sizeof(struct auction_data)); - idb_put(auction_db_, auction_->auction_id, auction_); - } - - SqlStmt_Free(stmt); - StringBuf_Destroy(&buf); - - return auction->auction_id; -} - -static void mapif_Auction_message(int char_id, unsigned char result) -{ - unsigned char buf[74]; - - WBUFW(buf,0) = 0x3854; - WBUFL(buf,2) = char_id; - WBUFL(buf,6) = result; - mapif_sendall(buf,7); -} - -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct auction_data *auction; - if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) - { - if( auction->buyer_id ) - { - mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item); - mapif_Auction_message(auction->buyer_id, 6); // You have won the auction - mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL); - } - else - mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item); - - ShowInfo("Auction End: id %u.\n", auction->auction_id); - - auction->auction_end_timer = INVALID_TIMER; - auction_delete(auction); - } - - return 0; -} - -void auction_delete(struct auction_data *auction) -{ - unsigned int auction_id = auction->auction_id; - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) ) - Sql_ShowDebug(sql_handle); - - if( auction->auction_end_timer != INVALID_TIMER ) - delete_timer(auction->auction_end_timer, auction_end_timer); - - idb_remove(auction_db_, auction_id); -} - -void inter_auctions_fromsql(void) -{ - int i; - struct auction_data *auction; - struct item *item; - char *data; - StringBuf buf; - unsigned int tick = gettick(), endtick; - time_t now = time(NULL); - - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`," - "`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`"); - for( i = 0; i < MAX_SLOTS; i++ ) - StringBuf_Printf(&buf, ",`card%d`", i); - StringBuf_Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", auction_db); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - - StringBuf_Destroy(&buf); - - while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - CREATE(auction, struct auction_data, 1); - Sql_GetData(sql_handle, 0, &data, NULL); auction->auction_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); auction->seller_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 5, &data, NULL); auction->price = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); auction->buynow = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); auction->hours = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); auction->timestamp = atoi(data); - - item = &auction->item; - Sql_GetData(sql_handle, 9, &data, NULL); item->nameid = atoi(data); - Sql_GetData(sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH); - Sql_GetData(sql_handle,11, &data, NULL); auction->type = atoi(data); - - Sql_GetData(sql_handle,12, &data, NULL); item->refine = atoi(data); - Sql_GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data); - - item->identify = 1; - item->amount = 1; - item->expire_time = 0; - - for( i = 0; i < MAX_SLOTS; i++ ) - { - Sql_GetData(sql_handle, 14 + i, &data, NULL); - item->card[i] = atoi(data); - } - - if( auction->timestamp > now ) - endtick = ((unsigned int)(auction->timestamp - now) * 1000) + tick; - else - endtick = tick + 10000; // 10 Second's to process ended auctions - - auction->auction_end_timer = add_timer(endtick, auction_end_timer, auction->auction_id, 0); - idb_put(auction_db_, auction->auction_id, auction); - } - - Sql_FreeResult(sql_handle); -} - -static void mapif_Auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf) -{ - int len = (sizeof(struct auction_data) * count) + 12; - - WFIFOHEAD(fd, len); - WFIFOW(fd,0) = 0x3850; - WFIFOW(fd,2) = len; - WFIFOL(fd,4) = char_id; - WFIFOW(fd,8) = count; - WFIFOW(fd,10) = pages; - memcpy(WFIFOP(fd,12), buf, len - 12); - WFIFOSET(fd,len); -} - -static void mapif_parse_Auction_requestlist(int fd) -{ - char searchtext[NAME_LENGTH]; - int char_id = RFIFOL(fd,4), len = sizeof(struct auction_data); - int price = RFIFOL(fd,10); - short type = RFIFOW(fd,8), page = max(1,RFIFOW(fd,14)); - unsigned char buf[5 * sizeof(struct auction_data)]; - DBIterator* iter; - DBKey key; - struct auction_data *auction; - short i = 0, j = 0, pages = 1; - - memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH); - - iter = auction_db_->iterator(auction_db_); - for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) - { - if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) || - (type == 1 && auction->type != IT_WEAPON) || - (type == 2 && auction->type != IT_CARD) || - (type == 3 && auction->type != IT_ETC) || - (type == 4 && !strstr(auction->item_name, searchtext)) || - (type == 5 && auction->price > price) || - (type == 6 && auction->seller_id != char_id) || - (type == 7 && auction->buyer_id != char_id) ) - continue; - - i++; - if( i > 5 ) - { // Counting Pages of Total Results (5 Results per Page) - pages++; - i = 1; // First Result of This Page - } - - if( page != pages ) - continue; // This is not the requested Page - - memcpy(WBUFP(buf, j * len), auction, len); - j++; // Found Results - } - iter->destroy(iter); - - mapif_Auction_sendlist(fd, char_id, j, pages, buf); -} - -static void mapif_Auction_register(int fd, struct auction_data *auction) -{ - int len = sizeof(struct auction_data) + 4; - - WFIFOHEAD(fd,len); - WFIFOW(fd,0) = 0x3851; - WFIFOW(fd,2) = len; - memcpy(WFIFOP(fd,4), auction, sizeof(struct auction_data)); - WFIFOSET(fd,len); -} - -static void mapif_parse_Auction_register(int fd) -{ - struct auction_data auction; - if( RFIFOW(fd,2) != sizeof(struct auction_data) + 4 ) - return; - - memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data)); - if( auction_count(auction.seller_id, false) < 5 ) - auction.auction_id = auction_create(&auction); - - mapif_Auction_register(fd, &auction); -} - -static void mapif_Auction_cancel(int fd, int char_id, unsigned char result) -{ - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x3852; - WFIFOL(fd,2) = char_id; - WFIFOB(fd,6) = result; - WFIFOSET(fd,7); -} - -static void mapif_parse_Auction_cancel(int fd) -{ - int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); - struct auction_data *auction; - - if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) - { - mapif_Auction_cancel(fd, char_id, 1); // Bid Number is Incorrect - return; - } - - if( auction->seller_id != char_id ) - { - mapif_Auction_cancel(fd, char_id, 2); // You cannot end the auction - return; - } - - if( auction->buyer_id > 0 ) - { - mapif_Auction_cancel(fd, char_id, 3); // An auction with at least one bidder cannot be canceled - return; - } - - mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction canceled.", 0, &auction->item); - auction_delete(auction); - - mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled -} - -static void mapif_Auction_close(int fd, int char_id, unsigned char result) -{ - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x3853; - WFIFOL(fd,2) = char_id; - WFIFOB(fd,6) = result; - WFIFOSET(fd,7); -} - -static void mapif_parse_Auction_close(int fd) -{ - int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); - struct auction_data *auction; - - if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) - { - mapif_Auction_close(fd, char_id, 2); // Bid Number is Incorrect - return; - } - - if( auction->seller_id != char_id ) - { - mapif_Auction_close(fd, char_id, 1); // You cannot end the auction - return; - } - - if( auction->buyer_id == 0 ) - { - mapif_Auction_close(fd, char_id, 1); // You cannot end the auction - return; - } - - // Send Money to Seller - mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction closed.", auction->price, NULL); - // Send Item to Buyer - mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Auction winner.", 0, &auction->item); - mapif_Auction_message(auction->buyer_id, 6); // You have won the auction - auction_delete(auction); - - mapif_Auction_close(fd, char_id, 0); // You have ended the auction -} - -static void mapif_Auction_bid(int fd, int char_id, int bid, unsigned char result) -{ - WFIFOHEAD(fd,11); - WFIFOW(fd,0) = 0x3855; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = bid; // To Return Zeny - WFIFOB(fd,10) = result; - WFIFOSET(fd,11); -} - -static void mapif_parse_Auction_bid(int fd) -{ - int char_id = RFIFOL(fd,4), bid = RFIFOL(fd,12); - unsigned int auction_id = RFIFOL(fd,8); - struct auction_data *auction; - - if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id ) - { - mapif_Auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction - return; - } - - if( auction_count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id ) - { - mapif_Auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time - return; - } - - if( auction->buyer_id > 0 ) - { // Send Money back to the previous Buyer - if( auction->buyer_id != char_id ) - { - mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Someone has placed a higher bid.", auction->price, NULL); - mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction - } - else - mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have placed a higher bid.", auction->price, NULL); - } - - auction->buyer_id = char_id; - safestrncpy(auction->buyer_name, (char*)RFIFOP(fd,16), NAME_LENGTH); - auction->price = bid; - - if( bid >= auction->buynow ) - { // Automatic won the auction - mapif_Auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction - - mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have won the auction.", 0, &auction->item); - mapif_Auction_message(char_id, 6); // You have won the auction - mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->buynow, NULL); - - auction_delete(auction); - return; - } - - auction_save(auction); - - mapif_Auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction -} - -/*========================================== - * Packets From Map Server - *------------------------------------------*/ -int inter_auction_parse_frommap(int fd) -{ - switch(RFIFOW(fd,0)) - { - case 0x3050: mapif_parse_Auction_requestlist(fd); break; - case 0x3051: mapif_parse_Auction_register(fd); break; - case 0x3052: mapif_parse_Auction_cancel(fd); break; - case 0x3053: mapif_parse_Auction_close(fd); break; - case 0x3055: mapif_parse_Auction_bid(fd); break; - default: - return 0; - } - return 1; -} - -int inter_auction_sql_init(void) -{ - auction_db_ = idb_alloc(DB_OPT_RELEASE_DATA); - inter_auctions_fromsql(); - - return 0; -} - -void inter_auction_sql_final(void) -{ - auction_db_->destroy(auction_db_,NULL); - - return; -} diff --git a/src/char_sql/int_auction.h b/src/char_sql/int_auction.h deleted file mode 100644 index bf26b152c..000000000 --- a/src/char_sql/int_auction.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_AUCTION_SQL_H_ -#define _INT_AUCTION_SQL_H_ - -int inter_auction_parse_frommap(int fd); - -int inter_auction_sql_init(void); -void inter_auction_sql_final(void); - -#endif /* _INT_AUCTION_SQL_H_ */ diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c deleted file mode 100644 index 7b467f92a..000000000 --- a/src/char_sql/int_guild.c +++ /dev/null @@ -1,2018 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/db.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_guild.h" - -#include -#include -#include - -#define GS_MEMBER_UNMODIFIED 0x00 -#define GS_MEMBER_MODIFIED 0x01 -#define GS_MEMBER_NEW 0x02 - -#define GS_POSITION_UNMODIFIED 0x00 -#define GS_POSITION_MODIFIED 0x01 - -// LSB = 0 => Alliance, LSB = 1 => Opposition -#define GUILD_ALLIANCE_TYPE_MASK 0x01 -#define GUILD_ALLIANCE_REMOVE 0x08 - -static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - -#ifndef TXT_SQL_CONVERT -//Guild cache -static DBMap* guild_db_; // int guild_id -> struct guild* - -struct guild_castle castles[MAX_GUILDCASTLE]; - -static unsigned int guild_exp[100]; - -int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes); -int mapif_guild_broken(int guild_id,int flag); -static bool guild_check_empty(struct guild *g); -int guild_calcinfo(struct guild *g); -int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len); -int mapif_guild_info(int fd,struct guild *g); -int guild_break_sub(int key,void *data,va_list ap); -int inter_guild_tosql(struct guild *g,int flag); - -static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - static int last_id = 0; //To know in which guild we were. - int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving. - DBIterator* iter; - DBKey key; - struct guild* g; - - if( last_id == 0 ) //Save the first guild in the list. - state = 1; - - iter = guild_db_->iterator(guild_db_); - for( g = (struct guild*)iter->first(iter,&key); iter->exists(iter); g = (struct guild*)iter->next(iter,&key) ) - { - if( state == 0 && g->guild_id == last_id ) - state++; //Save next guild in the list. - else - if( state == 1 && g->save_flag&GS_MASK ) - { - inter_guild_tosql(g, g->save_flag&GS_MASK); - g->save_flag &= ~GS_MASK; - - //Some guild saved. - last_id = g->guild_id; - state++; - } - - if( g->save_flag == GS_REMOVE ) - {// Nothing to save, guild is ready for removal. - if (save_log) - ShowInfo("Guild Unloaded (%d - %s)\n", g->guild_id, g->name); - db_remove(guild_db_, key); - } - } - iter->destroy(iter); - - if( state != 2 ) //Reached the end of the guild db without saving. - last_id = 0; //Reset guild saved, return to beginning. - - state = guild_db_->size(guild_db_); - if( state < 1 ) state = 1; //Calculate the time slot for the next save. - add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0); - return 0; -} - -int inter_guild_removemember_tosql(int account_id, int char_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) ) - Sql_ShowDebug(sql_handle); - return 0; -} -#endif //TXT_SQL_CONVERT - -// Save guild into sql -int inter_guild_tosql(struct guild *g,int flag) -{ - // Table guild (GS_BASIC_MASK) - // GS_EMBLEM `emblem_len`,`emblem_id`,`emblem_data` - // GS_CONNECT `connect_member`,`average_lv` - // GS_MES `mes1`,`mes2` - // GS_LEVEL `guild_lv`,`max_member`,`exp`,`next_exp`,`skill_point` - // GS_BASIC `name`,`master`,`char_id` - - // GS_MEMBER `guild_member` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) - // GS_POSITION `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) - // GS_ALLIANCE `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`) - // GS_EXPULSION `guild_expulsion` (`guild_id`,`account_id`,`name`,`mes`) - // GS_SKILL `guild_skill` (`guild_id`,`id`,`lv`) - - // temporary storage for str convertion. They must be twice the size of the - // original string to ensure no overflows will occur. [Skotlex] - char t_info[256]; - char esc_name[NAME_LENGTH*2+1]; - char esc_master[NAME_LENGTH*2+1]; - char new_guild = 0; - int i=0; - - if (g->guild_id<=0 && g->guild_id != -1) return 0; - -#ifdef NOISY - ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag); -#endif - - Sql_EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH)); - Sql_EscapeStringLen(sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH)); - *t_info = '\0'; - -#ifndef TXT_SQL_CONVERT - // Insert a new guild the guild - if (flag&GS_BASIC && g->guild_id == -1) - { - strcat(t_info, " guild_create"); - - // Create a new guild - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " - "(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " - "VALUES ('%s', '%s', '%d', '%d', '%d', '%d')", - guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) - { - Sql_ShowDebug(sql_handle); - if (g->guild_id == -1) - return 0; //Failed to create guild! - } - else - { - g->guild_id = (int)Sql_LastInsertId(sql_handle); - new_guild = 1; - } - } -#else - // Insert a new guild the guild - if (flag&GS_BASIC) - { - strcat(t_info, " guild_create"); - // Since the PK is guild id + master id, a replace will not be enough if we are overwriting data, we need to wipe the previous guild. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` where `guild_id` = '%d'", guild_db, g->guild_id) ) - Sql_ShowDebug(sql_handle); - // Create a new guild - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " - "(`guild_id`,`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " - "VALUES ('%d', '%s', '%s', '%d', '%d', '%d', '%d')", - guild_db, g->guild_id, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; //Failed to create guild. - } - } -#endif //TXT_SQL_CONVERT - // If we need an update on an existing guild or more update on the new guild - if (((flag & GS_BASIC_MASK) && !new_guild) || ((flag & (GS_BASIC_MASK & ~GS_BASIC)) && new_guild)) - { - StringBuf buf; - bool add_comma = false; - - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "UPDATE `%s` SET ", guild_db); - - if (flag & GS_EMBLEM) - { - char emblem_data[sizeof(g->emblem_data)*2+1]; - char* pData = emblem_data; - - strcat(t_info, " emblem"); - // Convert emblem_data to hex - //TODO: why not use binary directly? [ultramage] - for(i=0; iemblem_len; i++){ - *pData++ = dataToHex[(g->emblem_data[i] >> 4) & 0x0F]; - *pData++ = dataToHex[g->emblem_data[i] & 0x0F]; - } - *pData = 0; - StringBuf_Printf(&buf, "`emblem_len`=%d, `emblem_id`=%d, `emblem_data`='%s'", g->emblem_len, g->emblem_id, emblem_data); - add_comma = true; - } - if (flag & GS_BASIC) - { - strcat(t_info, " basic"); - if( add_comma ) - StringBuf_AppendStr(&buf, ", "); - else - add_comma = true; - StringBuf_Printf(&buf, "`name`='%s', `master`='%s', `char_id`=%d", esc_name, esc_master, g->member[0].char_id); - } - if (flag & GS_CONNECT) - { - strcat(t_info, " connect"); - if( add_comma ) - StringBuf_AppendStr(&buf, ", "); - else - add_comma = true; - StringBuf_Printf(&buf, "`connect_member`=%d, `average_lv`=%d", g->connect_member, g->average_lv); - } - if (flag & GS_MES) - { - char esc_mes1[sizeof(g->mes1)*2+1]; - char esc_mes2[sizeof(g->mes2)*2+1]; - - strcat(t_info, " mes"); - if( add_comma ) - StringBuf_AppendStr(&buf, ", "); - else - add_comma = true; - Sql_EscapeStringLen(sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1))); - Sql_EscapeStringLen(sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2))); - StringBuf_Printf(&buf, "`mes1`='%s', `mes2`='%s'", esc_mes1, esc_mes2); - } - if (flag & GS_LEVEL) - { - strcat(t_info, " level"); - if( add_comma ) - StringBuf_AppendStr(&buf, ", "); - else - add_comma = true; - StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); - } - StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "%s", StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - StringBuf_Destroy(&buf); - } - - if (flag&GS_MEMBER) - { - struct guild_member *m; - - strcat(t_info, " members"); - // Update only needed players - for(i=0;imax_member;i++){ - m = &g->member[i]; -#ifndef TXT_SQL_CONVERT - if (!m->modified) - continue; -#endif - if(m->account_id) { - //Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO - Sql_EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) " - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%"PRIu64"','%d','%d','%d','%s')", - guild_member_db, g->guild_id, m->account_id, m->char_id, - m->hair, m->hair_color, m->gender, - m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) ) - Sql_ShowDebug(sql_handle); - if (m->modified & GS_MEMBER_NEW) - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'", - char_db, g->guild_id, m->char_id) ) - Sql_ShowDebug(sql_handle); - } - m->modified = GS_MEMBER_UNMODIFIED; - } - } - } - - if (flag&GS_POSITION){ - strcat(t_info, " positions"); - //printf("- Insert guild %d to guild_position\n",g->guild_id); - for(i=0;iposition[i]; -#ifndef TXT_SQL_CONVERT - if (!p->modified) - continue; -#endif - Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')", - guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) ) - Sql_ShowDebug(sql_handle); - p->modified = GS_POSITION_UNMODIFIED; - } - } - - if (flag&GS_ALLIANCE) - { - // Delete current alliances - // NOTE: no need to do it on both sides since both guilds in memory had - // their info changed, not to mention this would also mess up oppositions! - // [Skotlex] - //if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) ) - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) ) - { - Sql_ShowDebug(sql_handle); - } - else - { - //printf("- Insert guild %d to guild_alliance\n",g->guild_id); - for(i=0;ialliance[i]; - if(a->guild_id>0) - { - Sql_EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) " - "VALUES ('%d','%d','%d','%s')", - guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) ) - Sql_ShowDebug(sql_handle); - } - } - } - } - - if (flag&GS_EXPULSION){ - strcat(t_info, " expulsions"); - //printf("- Insert guild %d to guild_expulsion\n",g->guild_id); - for(i=0;iexpulsion[i]; - if(e->account_id>0){ - char esc_mes[sizeof(e->mes)*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH)); - Sql_EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes))); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) " - "VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) ) - Sql_ShowDebug(sql_handle); - } - } - } - - if (flag&GS_SKILL){ - strcat(t_info, " skills"); - //printf("- Insert guild %d to guild_skill\n",g->guild_id); - for(i=0;iskill[i].id>0 && g->skill[i].lv>0){ - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')", - guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) ) - Sql_ShowDebug(sql_handle); - } - } - } - - if (save_log) - ShowInfo("Saved guild (%d - %s):%s\n",g->guild_id,g->name,t_info); - return 1; -} - -#ifndef TXT_SQL_CONVERT -// Read guild from sql -struct guild * inter_guild_fromsql(int guild_id) -{ - struct guild *g; - char* data; - size_t len; - char* p; - int i; - - if( guild_id <= 0 ) - return NULL; - - g = (struct guild*)idb_get(guild_db_, guild_id); - if( g ) - return g; - -#ifdef NOISY - ShowInfo("Guild load request (%d)...\n", guild_id); -#endif - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` " - "FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", guild_db, char_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - return NULL; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - return NULL;// Guild does not exists. - - CREATE(g, struct guild, 1); - - g->guild_id = guild_id; - Sql_GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data); - if( g->max_member > MAX_GUILD ) - { // Fix reduction of MAX_GUILD [PoW] - ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD); - g->max_member = MAX_GUILD; - } - Sql_GetData(sql_handle, 5, &data, NULL); g->average_lv = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10); - Sql_GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10); - Sql_GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data); - Sql_GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1))); - Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2))); - Sql_GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data); - Sql_GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data); - Sql_GetData(sql_handle, 13, &data, &len); - // convert emblem data from hexadecimal to binary - //TODO: why not store it in the db as binary directly? [ultramage] - for( i = 0, p = g->emblem_data; i < g->emblem_len; ++i, ++p ) - { - if( *data >= '0' && *data <= '9' ) - *p = *data - '0'; - else if( *data >= 'a' && *data <= 'f' ) - *p = *data - 'a' + 10; - else if( *data >= 'A' && *data <= 'F' ) - *p = *data - 'A' + 10; - *p <<= 4; - ++data; - - if( *data >= '0' && *data <= '9' ) - *p |= *data - '0'; - else if( *data >= 'a' && *data <= 'f' ) - *p |= *data - 'a' + 10; - else if( *data >= 'A' && *data <= 'F' ) - *p |= *data - 'A' + 10; - ++data; - } - - // load guild member info - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` " - "FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - aFree(g); - return NULL; - } - for( i = 0; i < g->max_member && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - struct guild_member* m = &g->member[i]; - - Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); m->hair = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); m->hair_color = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); m->gender = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); m->class_ = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); m->lv = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10); - Sql_GetData(sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); m->online = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); m->position = atoi(data); - if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW] - m->position = MAX_GUILDPOSITION - 1; - Sql_GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); - m->modified = GS_MEMBER_UNMODIFIED; - } - - //printf("- Read guild_position %d from sql \n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - aFree(g); - return NULL; - } - while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - int position; - struct guild_position* p; - - Sql_GetData(sql_handle, 0, &data, NULL); position = atoi(data); - if( position < 0 || position >= MAX_GUILDPOSITION ) - continue;// invalid position - p = &g->position[position]; - Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 2, &data, NULL); p->mode = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); p->exp_mode = atoi(data); - p->modified = GS_POSITION_UNMODIFIED; - } - - //printf("- Read guild_alliance %d from sql \n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - aFree(g); - return NULL; - } - for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - struct guild_alliance* a = &g->alliance[i]; - - Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH)); - } - - //printf("- Read guild_expulsion %d from sql \n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - aFree(g); - return NULL; - } - for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - struct guild_expulsion *e = &g->expulsion[i]; - - Sql_GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes))); - } - - //printf("- Read guild_skill %d from sql \n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) ) - { - Sql_ShowDebug(sql_handle); - aFree(g); - return NULL; - } - - for(i = 0; i < MAX_GUILDSKILL; i++) - { //Skill IDs must always be initialized. [Skotlex] - g->skill[i].id = i + GD_SKILLBASE; - } - - while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - int id; - Sql_GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE; - if( id < 0 && id >= MAX_GUILDSKILL ) - continue;// invalid guild skill - Sql_GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data); - } - Sql_FreeResult(sql_handle); - - idb_put(guild_db_, guild_id, g); //Add to cache - g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long. - - if (save_log) - ShowInfo("Guild loaded (%d - %s)\n", guild_id, g->name); - - return g; -} -#endif //TXT_SQL_CONVERT - -int inter_guildcastle_tosql(struct guild_castle *gc) -{ - // `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`) - - if (gc==NULL) return 0; - #ifdef GUILD_DEBUG -ShowDebug("Save guild_castle (%d)\n", gc->castle_id); - #endif - -// sql_query("DELETE FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, gc->castle_id); - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " - "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," - "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`)" - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", - guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, - gc->guardian[0].visible, gc->guardian[1].visible, gc->guardian[2].visible, gc->guardian[3].visible, gc->guardian[4].visible, gc->guardian[5].visible, gc->guardian[6].visible, gc->guardian[7].visible) ) - Sql_ShowDebug(sql_handle); - -#ifndef TXT_SQL_CONVERT - memcpy(&castles[gc->castle_id],gc,sizeof(struct guild_castle)); -#endif //TXT_SQL_CONVERT - return 0; -} - -#ifndef TXT_SQL_CONVERT -// Read guild_castle from sql -int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) -{ - static int castles_init=0; - char* data; - - if (gc==NULL) return 0; - if (castle_id==-1) return 0; - - if(!castles_init) - { - int i; - for(i=0;icastle_id=castle_id; - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_FreeResult(sql_handle); - return 1; //Assume empty castle. - } - - Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); - Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); - Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); - Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); - Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); - Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); - Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); - - Sql_FreeResult(sql_handle); - memcpy(&castles[castle_id],gc,sizeof(struct guild_castle)); - - if( save_log ) - ShowInfo("Loaded Castle %d (guild %d)\n", castle_id, gc->guild_id); - - return 1; -} - - -// Read exp_guild.txt -int inter_guild_ReadEXP(void) -{ - int i; - FILE *fp; - char line[1024]; - for (i=0;i<100;i++) guild_exp[i]=0; - //this is going to be discussed, temp fix - sprintf(line, "%s/pre-re/exp_guild.txt", db_path); - fp=fopen(line,"r"); - if(fp==NULL){ - ShowError("can't read %s\n", line); - return 1; - } - i=0; - while(fgets(line, sizeof(line), fp) && i < 100) - { - if(line[0]=='/' && line[1]=='/') - continue; - guild_exp[i]=(unsigned int)atof(line); - i++; - } - fclose(fp); - - return 0; -} - - -int inter_guild_CharOnline(int char_id, int guild_id) -{ - struct guild *g; - int i; - - if (guild_id == -1) { - //Get guild_id from the database - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - guild_id = atoi(data); - } - else - { - guild_id = 0; - } - Sql_FreeResult(sql_handle); - } - if (guild_id == 0) - return 0; //No guild... - - g = inter_guild_fromsql(guild_id); - if(!g) { - ShowError("Character %d's guild %d not found!\n", char_id, guild_id); - return 0; - } - - //Member has logged in before saving, tell saver not to delete - if(g->save_flag & GS_REMOVE) - g->save_flag &= ~GS_REMOVE; - - //Set member online - ARR_FIND( 0, g->max_member, i, g->member[i].char_id == char_id ); - if( i < g->max_member ) - { - g->member[i].online = 1; - g->member[i].modified = GS_MEMBER_MODIFIED; - } - - return 1; -} - -int inter_guild_CharOffline(int char_id, int guild_id) -{ - struct guild *g=NULL; - int online_count, i; - - if (guild_id == -1) - { - //Get guild_id from the database - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - guild_id = atoi(data); - } - else - { - guild_id = 0; - } - Sql_FreeResult(sql_handle); - } - if (guild_id == 0) - return 0; //No guild... - - //Character has a guild, set character offline and check if they were the only member online - g = inter_guild_fromsql(guild_id); - if (g == NULL) //Guild not found? - return 0; - - //Set member offline - ARR_FIND( 0, g->max_member, i, g->member[i].char_id == char_id ); - if( i < g->max_member ) - { - g->member[i].online = 0; - g->member[i].modified = GS_MEMBER_MODIFIED; - } - - online_count = 0; - for( i = 0; i < g->max_member; i++ ) - if( g->member[i].online ) - online_count++; - - // Remove guild from memory if no players online - if( online_count == 0 ) - g->save_flag |= GS_REMOVE; - - return 1; -} - -// Initialize guild sql -int inter_guild_sql_init(void) -{ - //Initialize the guild cache - guild_db_= idb_alloc(DB_OPT_RELEASE_DATA); - - //Read exp file - inter_guild_ReadEXP(); - - add_timer_func_list(guild_save_timer, "guild_save_timer"); - add_timer(gettick() + 10000, guild_save_timer, 0, 0); - return 0; -} - -static int guild_db_final(DBKey key, void *data, va_list ap) -{ - struct guild *g = (struct guild*)data; - if (g->save_flag&GS_MASK) { - inter_guild_tosql(g, g->save_flag&GS_MASK); - return 1; - } - return 0; -} - -void inter_guild_sql_final(void) -{ - guild_db_->destroy(guild_db_, guild_db_final); - return; -} - -// Get guild_id by its name. Returns 0 if not found, -1 on error. -int search_guildname(char *str) -{ - int guild_id; - char esc_name[NAME_LENGTH*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH)); - //Lookup guilds with the same name - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) ) - { - Sql_ShowDebug(sql_handle); - return -1; - } - - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); - guild_id = atoi(data); - } - else - { - guild_id = 0; - } - Sql_FreeResult(sql_handle); - return guild_id; -} - -// Check if guild is empty -static bool guild_check_empty(struct guild *g) -{ - int i; - ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 ); - if( i < g->max_member) - return false; // not empty - - //Let the calling function handle the guild removal in case they need - //to do something else with it before freeing the data. [Skotlex] - return true; -} - -unsigned int guild_nextexp(int level) -{ - if (level == 0) - return 1; - if (level < 100 && level > 0) // Change by hack - return guild_exp[level-1]; - - return 0; -} - -int guild_checkskill(struct guild *g,int id) -{ - int idx = id - GD_SKILLBASE; - - if(idx < 0 || idx >= MAX_GUILDSKILL) - return 0; - - return g->skill[idx].lv; -} - -int guild_calcinfo(struct guild *g) -{ - int i,c; - unsigned int nextexp; - struct guild before = *g; // Save guild current values - - if(g->guild_lv<=0) - g->guild_lv = 1; - nextexp = guild_nextexp(g->guild_lv); - - // Consume guild exp and increase guild level - while(g->exp >= nextexp && nextexp > 0){ //fixed guild exp overflow [Kevin] - g->exp-=nextexp; - g->guild_lv++; - g->skill_point++; - nextexp = guild_nextexp(g->guild_lv); - } - - // Save next exp step - g->next_exp = nextexp; - - // Set the max number of members, Guild Extention skill - currently adds 6 to max per skill lv. - g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6; - if(g->max_member > MAX_GUILD) - { - ShowError("Guild %d:%s has capacity for too many guild members (%d), max supported is %d\n", g->guild_id, g->name, g->max_member, MAX_GUILD); - g->max_member = MAX_GUILD; - } - - // Compute the guild average level level - g->average_lv=0; - g->connect_member=0; - for(i=c=0;imax_member;i++) - { - if(g->member[i].account_id>0) - { - if (g->member[i].lv >= 0) - { - g->average_lv+=g->member[i].lv; - c++; - } - else - { - ShowWarning("Guild %d:%s, member %d:%s has an invalid level %d\n", g->guild_id, g->name, g->member[i].char_id, g->member[i].name, g->member[i].lv); - } - - if(g->member[i].online) - g->connect_member++; - } - } - if(c) - g->average_lv /= c; - - // Check if guild stats has change - if(g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point ) - { - g->save_flag |= GS_LEVEL; - mapif_guild_info(-1,g); - return 1; - } - - return 0; -} - -//------------------------------------------------------------------- -// Packet sent to map server - -int mapif_guild_created(int fd,int account_id,struct guild *g) -{ - WFIFOHEAD(fd, 10); - WFIFOW(fd,0)=0x3830; - WFIFOL(fd,2)=account_id; - if(g != NULL) - { - WFIFOL(fd,6)=g->guild_id; - ShowInfo("int_guild: Guild created (%d - %s)\n",g->guild_id,g->name); - } else - WFIFOL(fd,6)=0; - - WFIFOSET(fd,10); - return 0; -} - -// Guild not found -int mapif_guild_noinfo(int fd,int guild_id) -{ - unsigned char buf[12]; - WBUFW(buf,0)=0x3831; - WBUFW(buf,2)=8; - WBUFL(buf,4)=guild_id; - ShowWarning("int_guild: info not found %d\n",guild_id); - if(fd<0) - mapif_sendall(buf,8); - else - mapif_send(fd,buf,8); - return 0; -} - -// Send guild info -int mapif_guild_info(int fd,struct guild *g) -{ - unsigned char buf[8+sizeof(struct guild)]; - WBUFW(buf,0)=0x3831; - WBUFW(buf,2)=4+sizeof(struct guild); - memcpy(buf+4,g,sizeof(struct guild)); - if(fd<0) - mapif_sendall(buf,WBUFW(buf,2)); - else - mapif_send(fd,buf,WBUFW(buf,2)); - return 0; -} - -// ACK member add -int mapif_guild_memberadded(int fd,int guild_id,int account_id,int char_id,int flag) -{ - WFIFOHEAD(fd, 15); - WFIFOW(fd,0)=0x3832; - WFIFOL(fd,2)=guild_id; - WFIFOL(fd,6)=account_id; - WFIFOL(fd,10)=char_id; - WFIFOB(fd,14)=flag; - WFIFOSET(fd,15); - return 0; -} - -// ACK member leave -int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const char *name, const char *mes) -{ - unsigned char buf[55+NAME_LENGTH]; - WBUFW(buf, 0)=0x3834; - WBUFL(buf, 2)=guild_id; - WBUFL(buf, 6)=account_id; - WBUFL(buf,10)=char_id; - WBUFB(buf,14)=flag; - memcpy(WBUFP(buf,15),mes,40); - memcpy(WBUFP(buf,55),name,NAME_LENGTH); - mapif_sendall(buf,55+NAME_LENGTH); - ShowInfo("int_guild: guild withdraw (%d - %d: %s - %s)\n",guild_id,account_id,name,mes); - return 0; -} - -// Send short member's info -int mapif_guild_memberinfoshort(struct guild *g,int idx) -{ - unsigned char buf[19]; - WBUFW(buf, 0)=0x3835; - WBUFL(buf, 2)=g->guild_id; - WBUFL(buf, 6)=g->member[idx].account_id; - WBUFL(buf,10)=g->member[idx].char_id; - WBUFB(buf,14)=(unsigned char)g->member[idx].online; - WBUFW(buf,15)=g->member[idx].lv; - WBUFW(buf,17)=g->member[idx].class_; - mapif_sendall(buf,19); - return 0; -} - -// Send guild broken -int mapif_guild_broken(int guild_id,int flag) -{ - unsigned char buf[7]; - WBUFW(buf,0)=0x3836; - WBUFL(buf,2)=guild_id; - WBUFB(buf,6)=flag; - mapif_sendall(buf,7); - ShowInfo("int_guild: Guild broken (%d)\n",guild_id); - return 0; -} - -// Send guild message -int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd) -{ - unsigned char buf[512]; - if (len > 500) - len = 500; - WBUFW(buf,0)=0x3837; - WBUFW(buf,2)=len+12; - WBUFL(buf,4)=guild_id; - WBUFL(buf,8)=account_id; - memcpy(WBUFP(buf,12),mes,len); - mapif_sendallwos(sfd, buf,len+12); - return 0; -} - -// Send basic info -int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len) -{ - unsigned char buf[2048]; - if (len > 2038) - len = 2038; - WBUFW(buf, 0)=0x3839; - WBUFW(buf, 2)=len+10; - WBUFL(buf, 4)=guild_id; - WBUFW(buf, 8)=type; - memcpy(WBUFP(buf,10),data,len); - mapif_sendall(buf,len+10); - return 0; -} - -// Send member info -int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int type,const void *data,int len) -{ - unsigned char buf[2048]; - if (len > 2030) - len = 2030; - WBUFW(buf, 0)=0x383a; - WBUFW(buf, 2)=len+18; - WBUFL(buf, 4)=guild_id; - WBUFL(buf, 8)=account_id; - WBUFL(buf,12)=char_id; - WBUFW(buf,16)=type; - memcpy(WBUFP(buf,18),data,len); - mapif_sendall(buf,len+18); - return 0; -} - -// ACK guild skill up -int mapif_guild_skillupack(int guild_id,int skill_num,int account_id) -{ - unsigned char buf[14]; - WBUFW(buf, 0)=0x383c; - WBUFL(buf, 2)=guild_id; - WBUFL(buf, 6)=skill_num; - WBUFL(buf,10)=account_id; - mapif_sendall(buf,14); - return 0; -} - -// ACK guild alliance -int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) -{ - unsigned char buf[19+2*NAME_LENGTH]; - WBUFW(buf, 0)=0x383d; - WBUFL(buf, 2)=guild_id1; - WBUFL(buf, 6)=guild_id2; - WBUFL(buf,10)=account_id1; - WBUFL(buf,14)=account_id2; - WBUFB(buf,18)=flag; - memcpy(WBUFP(buf,19),name1,NAME_LENGTH); - memcpy(WBUFP(buf,19+NAME_LENGTH),name2,NAME_LENGTH); - mapif_sendall(buf,19+2*NAME_LENGTH); - return 0; -} - -// Send a guild position desc -int mapif_guild_position(struct guild *g,int idx) -{ - unsigned char buf[12 + sizeof(struct guild_position)]; - WBUFW(buf,0)=0x383b; - WBUFW(buf,2)=sizeof(struct guild_position)+12; - WBUFL(buf,4)=g->guild_id; - WBUFL(buf,8)=idx; - memcpy(WBUFP(buf,12),&g->position[idx],sizeof(struct guild_position)); - mapif_sendall(buf,WBUFW(buf,2)); - return 0; -} - -// Send the guild notice -int mapif_guild_notice(struct guild *g) -{ - unsigned char buf[256]; - WBUFW(buf,0)=0x383e; - WBUFL(buf,2)=g->guild_id; - memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1); - memcpy(WBUFP(buf,66),g->mes2,MAX_GUILDMES2); - mapif_sendall(buf,186); - return 0; -} - -// Send emblem data -int mapif_guild_emblem(struct guild *g) -{ - unsigned char buf[12 + sizeof(g->emblem_data)]; - WBUFW(buf,0)=0x383f; - WBUFW(buf,2)=g->emblem_len+12; - WBUFL(buf,4)=g->guild_id; - WBUFL(buf,8)=g->emblem_id; - memcpy(WBUFP(buf,12),g->emblem_data,g->emblem_len); - mapif_sendall(buf,WBUFW(buf,2)); - return 0; -} - -int mapif_guild_master_changed(struct guild *g, int aid, int cid) -{ - unsigned char buf[14]; - WBUFW(buf,0)=0x3843; - WBUFL(buf,2)=g->guild_id; - WBUFL(buf,6)=aid; - WBUFL(buf,10)=cid; - mapif_sendall(buf,14); - return 0; -} - -int mapif_guild_castle_dataload(int castle_id,int index,int value) -{ - unsigned char buf[9]; - WBUFW(buf, 0)=0x3840; - WBUFW(buf, 2)=castle_id; - WBUFB(buf, 4)=index; - WBUFL(buf, 5)=value; - mapif_sendall(buf,9); - return 0; -} - -int mapif_guild_castle_datasave(int castle_id,int index,int value) -{ - unsigned char buf[9]; - WBUFW(buf, 0)=0x3841; - WBUFW(buf, 2)=castle_id; - WBUFB(buf, 4)=index; - WBUFL(buf, 5)=value; - mapif_sendall(buf,9); - return 0; -} - -int mapif_guild_castle_alldataload(int fd) -{ - struct guild_castle s_gc; - struct guild_castle* gc = &s_gc; - int i; - int len; - char* data; - - WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle)); - WFIFOW(fd, 0) = 0x3842; - if( SQL_ERROR == Sql_Query(sql_handle, - "SELECT `castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," - " `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`" - " FROM `%s` ORDER BY `castle_id`", guild_castle_db) ) - Sql_ShowDebug(sql_handle); - for( i = 0, len = 4; i < MAX_GUILDCASTLE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - memset(gc, 0, sizeof(struct guild_castle)); - - Sql_GetData(sql_handle, 0, &data, NULL); gc->castle_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); gc->guardian[0].visible = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); gc->guardian[1].visible = atoi(data); - Sql_GetData(sql_handle, 12, &data, NULL); gc->guardian[2].visible = atoi(data); - Sql_GetData(sql_handle, 13, &data, NULL); gc->guardian[3].visible = atoi(data); - Sql_GetData(sql_handle, 14, &data, NULL); gc->guardian[4].visible = atoi(data); - Sql_GetData(sql_handle, 15, &data, NULL); gc->guardian[5].visible = atoi(data); - Sql_GetData(sql_handle, 16, &data, NULL); gc->guardian[6].visible = atoi(data); - Sql_GetData(sql_handle, 17, &data, NULL); gc->guardian[7].visible = atoi(data); - - memcpy(WFIFOP(fd, len), gc, sizeof(struct guild_castle)); - len += sizeof(struct guild_castle); - } - Sql_FreeResult(sql_handle); - WFIFOW(fd, 2) = len; - WFIFOSET(fd, len); - - return 0; -} - - -//------------------------------------------------------------------- -// Packet received from map server - - -// ƒMƒ‹ƒh쬗v‹ -int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member *master) -{ - struct guild *g; - int i=0; -#ifdef NOISY - ShowInfo("Creating Guild (%s)\n", name); -#endif - if(search_guildname(name) != 0){ - ShowInfo("int_guild: guild with same name exists [%s]\n",name); - mapif_guild_created(fd,account_id,NULL); - return 0; - } - // Check Authorised letters/symbols in the name of the character - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) == NULL) { - mapif_guild_created(fd,account_id,NULL); - return 0; - } - } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) != NULL) { - mapif_guild_created(fd,account_id,NULL); - return 0; - } - } - - g = (struct guild *)aMalloc(sizeof(struct guild)); - memset(g,0,sizeof(struct guild)); - - memcpy(g->name,name,NAME_LENGTH); - memcpy(g->master,master->name,NAME_LENGTH); - memcpy(&g->member[0],master,sizeof(struct guild_member)); - g->member[0].modified = GS_MEMBER_MODIFIED; - - // Set default positions - g->position[0].mode=0x11; - strcpy(g->position[0].name,"GuildMaster"); - strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie"); - g->position[0].modified = g->position[MAX_GUILDPOSITION-1].modified = GS_POSITION_MODIFIED; - for(i=1;iposition[i].name,"Position %d",i+1); - g->position[i].modified = GS_POSITION_MODIFIED; - } - - // Initialize guild property - g->max_member=16; - g->average_lv=master->lv; - g->connect_member=1; - - for(i=0;iskill[i].id=i + GD_SKILLBASE; - g->guild_id= -1; //Request to create guild. - - // Create the guild - if (!inter_guild_tosql(g,GS_BASIC|GS_POSITION|GS_SKILL)) { - //Failed to Create guild.... - ShowError("Failed to create Guild %s (Guild Master: %s)\n", g->name, g->master); - mapif_guild_created(fd,account_id,NULL); - aFree(g); - return 0; - } - ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild_id, g->name, g->master); - - //Add to cache - idb_put(guild_db_, g->guild_id, g); - - // Report to client - mapif_guild_created(fd,account_id,g); - mapif_guild_info(fd,g); - - if(log_inter) - inter_log("guild %s (id=%d) created by master %s (id=%d)\n", - name, g->guild_id, master->name, master->account_id ); - - return 0; -} - -// Return guild info to client -int mapif_parse_GuildInfo(int fd,int guild_id) -{ - struct guild * g = inter_guild_fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is requied. [Skotlex] - if(g) - { - if (!guild_calcinfo(g)) - mapif_guild_info(fd,g); - } - else - mapif_guild_noinfo(fd,guild_id); // Failed to load info - return 0; -} - -// Add member to guild -int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) -{ - struct guild * g; - int i; - - g = inter_guild_fromsql(guild_id); - if(g==NULL){ - // Failed to add - mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); - return 0; - } - - // Find an empty slot - for(i=0;imax_member;i++) - { - if(g->member[i].account_id==0) - { - memcpy(&g->member[i],m,sizeof(struct guild_member)); - g->member[i].modified = (GS_MEMBER_NEW | GS_MEMBER_MODIFIED); - mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); - if (!guild_calcinfo(g)) //Send members if it was not invoked. - mapif_guild_info(-1,g); - - g->save_flag |= GS_MEMBER; - if (g->save_flag&GS_REMOVE) - g->save_flag&=~GS_REMOVE; - return 0; - } - } - - // Failed to add - mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); - return 0; -} - -// Delete member from guild -int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) -{ - int i, j; - - struct guild* g = inter_guild_fromsql(guild_id); - if( g == NULL ) - { - // Unknown guild, just update the player - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) ) - Sql_ShowDebug(sql_handle); - // mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes); - return 0; - } - - // Find the member - ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id ); - if( i == g->max_member ) - { - //TODO - return 0; - } - - if( flag ) - { // Write expulsion reason - // Find an empty slot - ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 ); - if( j == MAX_GUILDEXPULSION ) - { - // Expulsion list is full, flush the oldest one - for( j = 0; j < MAX_GUILDEXPULSION - 1; j++ ) - g->expulsion[j] = g->expulsion[j+1]; - j = MAX_GUILDEXPULSION-1; - } - // Save the expulsion entry - g->expulsion[j].account_id = account_id; - safestrncpy(g->expulsion[j].name, g->member[i].name, NAME_LENGTH); - safestrncpy(g->expulsion[j].mes, mes, 40); - } - - mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes); - inter_guild_removemember_tosql(g->member[i].account_id,g->member[i].char_id); - - memset(&g->member[i],0,sizeof(struct guild_member)); - - if( guild_check_empty(g) ) - mapif_parse_BreakGuild(-1,guild_id); //Break the guild. - else { - //Update member info. - if (!guild_calcinfo(g)) - mapif_guild_info(fd,g); - g->save_flag |= GS_EXPULSION; - } - - return 0; -} - -// Change member info -int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,int char_id,int online,int lv,int class_) -{ - // Could speed up by manipulating only guild_member - struct guild * g; - int i,sum,c; - int prev_count, prev_alv; - - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id ); - if( i < g->max_member ) - { - g->member[i].online = online; - g->member[i].lv = lv; - g->member[i].class_ = class_; - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfoshort(g,i); - } - - prev_count = g->connect_member; - prev_alv = g->average_lv; - - g->average_lv = 0; - g->connect_member = 0; - c = 0; - sum = 0; - - for( i = 0; i < g->max_member; i++ ) - { - if( g->member[i].account_id > 0 ) - { - sum += g->member[i].lv; - c++; - } - if( g->member[i].online ) - g->connect_member++; - } - - if( c ) // this check should always succeed... - { - g->average_lv = sum / c; - if( g->connect_member != prev_count || g->average_lv != prev_alv ) - g->save_flag |= GS_CONNECT; - if( g->save_flag & GS_REMOVE ) - g->save_flag &= ~GS_REMOVE; - } - g->save_flag |= GS_MEMBER; //Update guild member data - return 0; -} - -// BreakGuild -int mapif_parse_BreakGuild(int fd,int guild_id) -{ - struct guild * g; - - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - // Delete guild from sql - //printf("- Delete guild %d from guild\n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - //printf("- Update guild %d of char\n",guild_id); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) ) - Sql_ShowDebug(sql_handle); - - mapif_guild_broken(guild_id,0); - - if(log_inter) - inter_log("guild %s (id=%d) broken\n",g->name,guild_id); - - //Remove the guild from memory. [Skotlex] - idb_remove(guild_db_, guild_id); - return 0; -} - -// Forward Guild message to others map servers -int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int len) -{ - return mapif_guild_message(guild_id,account_id,mes,len, fd); -} - -// Modification of the guild -int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *data,int len) -{ - struct guild * g; - short dw=*((short *)data); - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - switch(type) - { - case GBI_GUILDLV: - if(dw>0 && g->guild_lv+dw<=50) - { - g->guild_lv+=dw; - g->skill_point+=dw; - } - else if(dw<0 && g->guild_lv+dw>=1) - g->guild_lv+=dw; - mapif_guild_info(-1,g); - g->save_flag |= GS_LEVEL; - return 0; - default: - ShowError("int_guild: GuildBasicInfoChange: Unknown type %d\n",type); - break; - } - mapif_guild_basicinfochanged(guild_id,type,data,len); - return 0; -} - -// Modification of the guild -int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len) -{ - // Could make some improvement in speed, because only change guild_member - int i; - struct guild * g; - - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - // Search the member - for(i=0;imax_member;i++) - if( g->member[i].account_id==account_id && - g->member[i].char_id==char_id ) - break; - - // Not Found - if(i==g->max_member){ - ShowWarning("int_guild: GuildMemberChange: Not found %d,%d in guild (%d - %s)\n", - account_id,char_id,guild_id,g->name); - return 0; - } - - switch(type) - { - case GMI_POSITION: - { - g->member[i].position=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; - break; - } - case GMI_EXP: - { // EXP - uint64 exp, old_exp=g->member[i].exp; - g->member[i].exp=*((uint64 *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - if (g->member[i].exp > old_exp) - { - exp = g->member[i].exp - old_exp; - - // Compute gained exp - if (guild_exp_rate != 100) - exp = exp*guild_exp_rate/100; - - // Update guild exp - if (exp > UINT64_MAX - g->exp) - g->exp = UINT64_MAX; - else - g->exp+=exp; - - guild_calcinfo(g); - mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp)); - g->save_flag |= GS_LEVEL; - } - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; - break; - } - case GMI_HAIR: - { - g->member[i].hair=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; //Save new data. - break; - } - case GMI_HAIR_COLOR: - { - g->member[i].hair_color=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; //Save new data. - break; - } - case GMI_GENDER: - { - g->member[i].gender=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; //Save new data. - break; - } - case GMI_CLASS: - { - g->member[i].class_=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; //Save new data. - break; - } - case GMI_LEVEL: - { - g->member[i].lv=*((short *)data); - g->member[i].modified = GS_MEMBER_MODIFIED; - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - g->save_flag |= GS_MEMBER; //Save new data. - break; - } - default: - ShowError("int_guild: GuildMemberInfoChange: Unknown type %d\n",type); - break; - } - return 0; -} - -int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender) -{ - return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender)); -} - -int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name) -{ - struct guild *g; - int i, flag = 0; - - g = inter_guild_fromsql(guild_id); - if( g == NULL ) - { - ShowError("inter_guild_charrenamed: Can't find guild %d.\n", guild_id); - return 0; - } - - ARR_FIND(0, g->max_member, i, g->member[i].char_id == char_id); - if( i == g->max_member ) - { - ShowError("inter_guild_charrenamed: Can't find character %d in the guild\n", char_id); - return 0; - } - - if( !strcmp(g->member[i].name, g->master) ) - { - safestrncpy(g->master, name, NAME_LENGTH); - flag |= GS_BASIC; - } - safestrncpy(g->member[i].name, name, NAME_LENGTH); - g->member[i].modified = GS_MEMBER_MODIFIED; - flag |= GS_MEMBER; - - if( !inter_guild_tosql(g, flag) ) - return 0; - - mapif_guild_info(-1,g); - - return 0; -} - -// Change a position desc -int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position *p) -{ - // Could make some improvement in speed, because only change guild_position - struct guild * g; - - g = inter_guild_fromsql(guild_id); - if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION) - return 0; - - memcpy(&g->position[idx],p,sizeof(struct guild_position)); - mapif_guild_position(g,idx); - g->position[idx].modified = GS_POSITION_MODIFIED; - g->save_flag |= GS_POSITION; // Change guild_position - return 0; -} - -// Guild Skill UP -int mapif_parse_GuildSkillUp(int fd,int guild_id,int skill_num,int account_id,int max) -{ - struct guild * g; - int idx = skill_num - GD_SKILLBASE; - - g = inter_guild_fromsql(guild_id); - if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) - return 0; - - if(g->skill_point>0 && g->skill[idx].id>0 && g->skill[idx].lvskill[idx].lv++; - g->skill_point--; - if (!guild_calcinfo(g)) - mapif_guild_info(-1,g); - mapif_guild_skillupack(guild_id,skill_num,account_id); - g->save_flag |= (GS_LEVEL|GS_SKILL); // Change guild & guild_skill - } - return 0; -} - -//Manual deletion of an alliance when partnering guild does not exists. [Skotlex] -static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag) -{ - int i; - char name[NAME_LENGTH]; - - ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->alliance[i].guild_id == guild_id ); - if( i == MAX_GUILDALLIANCE ) - return -1; - - strcpy(name, g->alliance[i].name); - g->alliance[i].guild_id=0; - - mapif_guild_alliance(g->guild_id,guild_id,account_id1,account_id2,flag,g->name,name); - g->save_flag |= GS_ALLIANCE; - return 0; -} - -// Alliance modification -int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) -{ - // Could speed up - struct guild *g[2]; - int j,i; - g[0] = inter_guild_fromsql(guild_id1); - g[1] = inter_guild_fromsql(guild_id2); - - if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild. - return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild. - - if(g[0]==NULL || g[1]==NULL) - return 0; - - if(flag&GUILD_ALLIANCE_REMOVE) - { - // Remove alliance/opposition, in case of alliance, remove on both side - for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++) - { - ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == g[1-i]->guild_id && g[i]->alliance[j].opposition == (flag&GUILD_ALLIANCE_TYPE_MASK) ); - if( j < MAX_GUILDALLIANCE ) - g[i]->alliance[j].guild_id = 0; - } - } - else - { - // Add alliance, in case of alliance, add on both side - for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++) - { - // Search an empty slot - ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 ); - if( j < MAX_GUILDALLIANCE ) - { - g[i]->alliance[j].guild_id=g[1-i]->guild_id; - memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH); - // Set alliance type - g[i]->alliance[j].opposition = flag&GUILD_ALLIANCE_TYPE_MASK; - } - } - } - - // Send on all map the new alliance/opposition - mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name); - - // Mark the two guild to be saved - g[0]->save_flag |= GS_ALLIANCE; - g[1]->save_flag |= GS_ALLIANCE; - return 0; -} - -// Change guild message -int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes2) -{ - struct guild *g; - - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - memcpy(g->mes1,mes1,MAX_GUILDMES1); - memcpy(g->mes2,mes2,MAX_GUILDMES2); - g->save_flag |= GS_MES; //Change mes of guild - return mapif_guild_notice(g); -} - -int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data) -{ - struct guild * g; - - g = inter_guild_fromsql(guild_id); - if(g==NULL) - return 0; - - if (len > sizeof(g->emblem_data)) - len = sizeof(g->emblem_data); - - memcpy(g->emblem_data,data,len); - g->emblem_len=len; - g->emblem_id++; - g->save_flag |= GS_EMBLEM; //Change guild - return mapif_guild_emblem(g); -} - -int mapif_parse_GuildCastleDataLoad(int fd,int castle_id,int index) -{ - struct guild_castle gc; - if (!inter_guildcastle_fromsql(castle_id, &gc)) { - return mapif_guild_castle_dataload(castle_id,0,0); - } - switch(index){ - case 1: return mapif_guild_castle_dataload(gc.castle_id,index,gc.guild_id); break; - case 2: return mapif_guild_castle_dataload(gc.castle_id,index,gc.economy); break; - case 3: return mapif_guild_castle_dataload(gc.castle_id,index,gc.defense); break; - case 4: return mapif_guild_castle_dataload(gc.castle_id,index,gc.triggerE); break; - case 5: return mapif_guild_castle_dataload(gc.castle_id,index,gc.triggerD); break; - case 6: return mapif_guild_castle_dataload(gc.castle_id,index,gc.nextTime); break; - case 7: return mapif_guild_castle_dataload(gc.castle_id,index,gc.payTime); break; - case 8: return mapif_guild_castle_dataload(gc.castle_id,index,gc.createTime); break; - case 9: return mapif_guild_castle_dataload(gc.castle_id,index,gc.visibleC); break; - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - return mapif_guild_castle_dataload(gc.castle_id,index,gc.guardian[index-10].visible); break; - default: - ShowError("mapif_parse_GuildCastleDataLoad ERROR!! (Not found index=%d)\n", index); - return 0; - } -} - -int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value) -{ - struct guild_castle gc; - if(!inter_guildcastle_fromsql(castle_id, &gc)) - return mapif_guild_castle_datasave(castle_id,index,value); - - switch(index){ - case 1: - if( gc.guild_id!=value ){ - int gid=(value)?value:gc.guild_id; - struct guild *g = (struct guild*)idb_get(guild_db_, gid); - if(log_inter) - inter_log("guild %s (id=%d) %s castle id=%d\n", - (g)?g->name:"??" ,gid, (value)?"occupy":"abandon", castle_id); - } - gc.guild_id = value; - if(gc.guild_id == 0) { - //Delete guardians. - memset(&gc.guardian, 0, sizeof(gc.guardian)); - } - break; - case 2: gc.economy = value; break; - case 3: gc.defense = value; break; - case 4: gc.triggerE = value; break; - case 5: gc.triggerD = value; break; - case 6: gc.nextTime = value; break; - case 7: gc.payTime = value; break; - case 8: gc.createTime = value; break; - case 9: gc.visibleC = value; break; - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - gc.guardian[index-10].visible = value; break; - default: - ShowError("mapif_parse_GuildCastleDataSave ERROR!! (Not found index=%d)\n", index); - return 0; - } - inter_guildcastle_tosql(&gc); - mapif_guild_castle_datasave(gc.castle_id,index,value); - return 0; -} - -int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len) -{ - struct guild * g; - struct guild_member gm; - int pos; - - g = inter_guild_fromsql(guild_id); - - if(g==NULL || len > NAME_LENGTH) - return 0; - - // Find member (name) - for (pos = 0; pos < g->max_member && strncmp(g->member[pos].name, name, len); pos++); - - if (pos == g->max_member) - return 0; //Character not found?? - - // Switch current and old GM - memcpy(&gm, &g->member[pos], sizeof (struct guild_member)); - memcpy(&g->member[pos], &g->member[0], sizeof(struct guild_member)); - memcpy(&g->member[0], &gm, sizeof(struct guild_member)); - - // Switch positions - g->member[pos].position = g->member[0].position; - g->member[pos].modified = GS_MEMBER_MODIFIED; - g->member[0].position = 0; //Position 0: guild Master. - g->member[0].modified = GS_MEMBER_MODIFIED; - - strncpy(g->master, name, len); - if (len < NAME_LENGTH) - g->master[len] = '\0'; - - ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",g->master, guild_id, g->name); - g->save_flag |= (GS_BASIC|GS_MEMBER); //Save main data and member data. - return mapif_guild_master_changed(g, g->member[0].account_id, g->member[0].char_id); -} - -// map server ‚©‚ç‚Ì’ÊM -// E‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ -// EƒpƒPƒbƒg’·ƒf[ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ -// EƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ -// EƒGƒ‰[‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ -int inter_guild_parse_frommap(int fd) -{ - RFIFOHEAD(fd); - switch(RFIFOW(fd,0)) { - case 0x3030: mapif_parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break; - case 0x3031: mapif_parse_GuildInfo(fd,RFIFOL(fd,2)); break; - case 0x3032: mapif_parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break; - case 0x3033: mapif_parse_GuildMasterChange(fd,RFIFOL(fd,4),(const char*)RFIFOP(fd,8),RFIFOW(fd,2)-8); break; - case 0x3034: mapif_parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break; - case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break; - case 0x3036: mapif_parse_BreakGuild(fd,RFIFOL(fd,2)); break; - case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; - case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const char*)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; - case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break; - case 0x303B: mapif_parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break; - case 0x303C: mapif_parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break; - case 0x303D: mapif_parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break; - case 0x303E: mapif_parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break; - case 0x303F: mapif_parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break; - case 0x3040: mapif_parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),RFIFOB(fd,4)); break; - case 0x3041: mapif_parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break; - - default: - return 0; - } - - return 1; -} - -// processes a mapserver connection event -int inter_guild_mapif_init(int fd) -{ - return mapif_guild_castle_alldataload(fd); -} - -// ƒT[ƒo[‚©‚ç’E‘Þ—v‹iƒLƒƒƒ‰íœ—pj -int inter_guild_leave(int guild_id, int account_id, int char_id) -{ - return mapif_parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **"); -} - -int inter_guild_broken(int guild_id) -{ - return mapif_guild_broken(guild_id, 0); -} -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/int_guild.h b/src/char_sql/int_guild.h deleted file mode 100644 index 4577357f3..000000000 --- a/src/char_sql/int_guild.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_GUILD_SQL_H_ -#define _INT_GUILD_SQL_H_ - -#define GS_BASIC 0x0001 -#define GS_MEMBER 0x0002 -#define GS_POSITION 0x0004 -#define GS_ALLIANCE 0x0008 -#define GS_EXPULSION 0x0010 -#define GS_SKILL 0x0020 -#define GS_EMBLEM 0x0040 -#define GS_CONNECT 0x0080 -#define GS_LEVEL 0x0100 -#define GS_MES 0x0200 -#define GS_MASK 0x03FF -#define GS_BASIC_MASK (GS_BASIC | GS_EMBLEM | GS_CONNECT | GS_LEVEL | GS_MES) -#define GS_REMOVE 0x8000 - -struct guild; -struct guild_castle; - -int inter_guild_parse_frommap(int fd); -int inter_guild_sql_init(void); -void inter_guild_sql_final(void); -int inter_guild_mapif_init(int fd); -int inter_guild_leave(int guild_id,int account_id,int char_id); -int mapif_parse_BreakGuild(int fd,int guild_id); -int inter_guild_broken(int guild_id); -int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender); -int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name); -int inter_guild_CharOnline(int char_id, int guild_id); -int inter_guild_CharOffline(int char_id, int guild_id); - -//For the TXT->SQL converter. -int inter_guild_tosql(struct guild *g,int flag); -int inter_guildcastle_tosql(struct guild_castle *gc); - -#endif /* _INT_GUILD_SQL_H_ */ diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c deleted file mode 100644 index d5a928e59..000000000 --- a/src/char_sql/int_homun.c +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" - -#include -#include -#include - - -int inter_homunculus_sql_init(void) -{ - return 0; -} -void inter_homunculus_sql_final(void) -{ - return; -} - -static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) -{ - WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); - WFIFOW(fd,0) = 0x3890; - WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; - WFIFOL(fd,4) = account_id; - WFIFOB(fd,8)= flag; - memcpy(WFIFOP(fd,9),sh,sizeof(struct s_homunculus)); - WFIFOSET(fd, WFIFOW(fd,2)); -} - -static void mapif_homunculus_deleted(int fd, int flag) -{ - WFIFOHEAD(fd, 3); - WFIFOW(fd, 0) = 0x3893; - WFIFOB(fd,2) = flag; //Flag 1 = success - WFIFOSET(fd, 3); -} - -static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) -{ - WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); - WFIFOW(fd,0) = 0x3891; - WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; - WFIFOL(fd,4) = account_id; - if( hd != NULL ) - { - WFIFOB(fd,8) = 1; // success - memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus)); - } - else - { - WFIFOB(fd,8) = 0; // not found. - memset(WFIFOP(fd,9), 0, sizeof(struct s_homunculus)); - } - WFIFOSET(fd, sizeof(struct s_homunculus)+9); -} - -static void mapif_homunculus_saved(int fd, int account_id, bool flag) -{ - WFIFOHEAD(fd, 7); - WFIFOW(fd,0) = 0x3892; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = flag; // 1:success, 0:failure - WFIFOSET(fd, 7); -} - -static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name) -{ - WFIFOHEAD(fd, NAME_LENGTH+12); - WFIFOW(fd, 0) = 0x3894; - WFIFOL(fd, 2) = account_id; - WFIFOL(fd, 6) = char_id; - WFIFOB(fd,10) = flag; - safestrncpy((char*)WFIFOP(fd,11), name, NAME_LENGTH); - WFIFOSET(fd, NAME_LENGTH+12); -} - -bool mapif_homunculus_save(struct s_homunculus* hd) -{ - bool flag = true; - char esc_name[NAME_LENGTH*2+1]; - - Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH)); - - if( hd->hom_id == 0 ) - {// new homunculus - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` " - "(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) " - "VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, - hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) ) - { - Sql_ShowDebug(sql_handle); - flag = false; - } - else - { - hd->hom_id = (int)Sql_LastInsertId(sql_handle); - } - } - else - { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'", - hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, - hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) ) - { - Sql_ShowDebug(sql_handle); - flag = false; - } - else - { - SqlStmt* stmt; - int i; - - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", hd->hom_id) ) - SqlStmt_ShowDebug(stmt); - for( i = 0; i < MAX_HOMUNSKILL; ++i ) - { - if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 ) - { - SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0); - SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0); - if( SQL_ERROR == SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - SqlStmt_Free(stmt); - flag = false; - break; - } - } - } - SqlStmt_Free(stmt); - } - } - - return flag; -} - - - -// Load an homunculus -bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) -{ - int i; - char* data; - size_t len; - - memset(hd, 0, sizeof(*hd)); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", homun_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - if( !Sql_NumRows(sql_handle) ) - { //No homunculus found. - Sql_FreeResult(sql_handle); - return false; - } - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_ShowDebug(sql_handle); - Sql_FreeResult(sql_handle); - return false; - } - - hd->hom_id = homun_id; - Sql_GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data); - Sql_GetData(sql_handle, 3, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name)); - Sql_GetData(sql_handle, 4, &data, NULL); hd->level = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); hd->exp = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10); - Sql_GetData(sql_handle, 7, &data, NULL); hd->hunger = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); hd->str = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); hd->agi = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); hd->vit = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); hd->int_ = atoi(data); - Sql_GetData(sql_handle, 12, &data, NULL); hd->dex = atoi(data); - Sql_GetData(sql_handle, 13, &data, NULL); hd->luk = atoi(data); - Sql_GetData(sql_handle, 14, &data, NULL); hd->hp = atoi(data); - Sql_GetData(sql_handle, 15, &data, NULL); hd->max_hp = atoi(data); - Sql_GetData(sql_handle, 16, &data, NULL); hd->sp = atoi(data); - Sql_GetData(sql_handle, 17, &data, NULL); hd->max_sp = atoi(data); - Sql_GetData(sql_handle, 18, &data, NULL); hd->skillpts = atoi(data); - Sql_GetData(sql_handle, 19, &data, NULL); hd->rename_flag = atoi(data); - Sql_GetData(sql_handle, 20, &data, NULL); hd->vaporize = atoi(data); - Sql_FreeResult(sql_handle); - - hd->intimacy = cap_value(hd->intimacy, 0, 100000); - hd->hunger = cap_value(hd->hunger, 0, 100); - - // Load Homunculus Skill - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d", homun_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - // id - Sql_GetData(sql_handle, 0, &data, NULL); - i = atoi(data); - if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL ) - continue;// invalid skill id - i = i - HM_SKILLBASE; - hd->hskill[i].id = (unsigned short)atoi(data); - - // lv - Sql_GetData(sql_handle, 1, &data, NULL); - hd->hskill[i].lv = (unsigned char)atoi(data); - } - Sql_FreeResult(sql_handle); - - if( save_log ) - ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name); - - return true; -} - -bool mapif_homunculus_delete(int homun_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", homun_id) - || SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", homun_id) - ) { - Sql_ShowDebug(sql_handle); - return false; - } - return true; -} - -bool mapif_homunculus_rename(char *name) -{ - int i; - - // Check Authorised letters/symbols in the name of the homun - if( char_name_option == 1 ) - {// only letters/symbols in char_name_letters are authorised - for( i = 0; i < NAME_LENGTH && name[i]; i++ ) - if( strchr(char_name_letters, name[i]) == NULL ) - return false; - } else - if( char_name_option == 2 ) - {// letters/symbols in char_name_letters are forbidden - for( i = 0; i < NAME_LENGTH && name[i]; i++ ) - if( strchr(char_name_letters, name[i]) != NULL ) - return false; - } - - return true; -} - - -static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd) -{ - bool result = mapif_homunculus_save(phd); - mapif_homunculus_created(fd, account_id, phd, result); -} - -static void mapif_parse_homunculus_delete(int fd, int homun_id) -{ - bool result = mapif_homunculus_delete(homun_id); - mapif_homunculus_deleted(fd, result); -} - -static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) -{ - struct s_homunculus hd; - bool result = mapif_homunculus_load(homun_id, &hd); - mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL )); -} - -static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd) -{ - bool result = mapif_homunculus_save(phd); - mapif_homunculus_saved(fd, account_id, result); -} - -static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name) -{ - bool result = mapif_homunculus_rename(name); - mapif_homunculus_renamed(fd, account_id, char_id, result, name); -} - -/*========================================== - * Inter Packets - *------------------------------------------*/ -int inter_homunculus_parse_frommap(int fd) -{ - unsigned short cmd = RFIFOW(fd,0); - - switch( cmd ) - { - case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; - case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; - case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; - default: - return 0; - } - return 1; -} diff --git a/src/char_sql/int_homun.h b/src/char_sql/int_homun.h deleted file mode 100644 index 1c0d76269..000000000 --- a/src/char_sql/int_homun.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_HOMUN_SQL_H_ -#define _INT_HOMUN_SQL_H_ - -struct s_homunculus; - -int inter_homunculus_sql_init(void); -void inter_homunculus_sql_final(void); -int inter_homunculus_parse_frommap(int fd); - -bool mapif_homunculus_save(struct s_homunculus* hd); -bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd); -bool mapif_homunculus_delete(int homun_id); -bool mapif_homunculus_rename(char *name); - -#endif /* _INT_HOMUN_SQL_H_ */ diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c deleted file mode 100644 index b19b732c7..000000000 --- a/src/char_sql/int_mail.c +++ /dev/null @@ -1,476 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" -#include "../common/timer.h" -#include "char.h" -#include "inter.h" - -#include -#include -#include - -static int mail_fromsql(int char_id, struct mail_data* md) -{ - int i, j; - struct mail_message *msg; - struct item *item; - char *data; - StringBuf buf; - - memset(md, 0, sizeof(struct mail_data)); - md->amount = 0; - md->full = false; - - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`,`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`," - "`zeny`,`amount`,`nameid`,`refine`,`attribute`,`identify`"); - for (i = 0; i < MAX_SLOTS; i++) - StringBuf_Printf(&buf, ",`card%d`", i); - - // I keep the `status` < 3 just in case someone forget to apply the sqlfix - StringBuf_Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d", - mail_db, char_id, MAIL_MAX_INBOX + 1); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - - StringBuf_Destroy(&buf); - - for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - msg = &md->msg[i]; - Sql_GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); - Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); - Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); - item = &msg->item; - Sql_GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data); - Sql_GetData(sql_handle,11, &data, NULL); item->nameid = atoi(data); - Sql_GetData(sql_handle,12, &data, NULL); item->refine = atoi(data); - Sql_GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data); - Sql_GetData(sql_handle,14, &data, NULL); item->identify = atoi(data); - item->expire_time = 0; - - for (j = 0; j < MAX_SLOTS; j++) - { - Sql_GetData(sql_handle, 15 + j, &data, NULL); - item->card[j] = atoi(data); - } - } - - md->full = ( Sql_NumRows(sql_handle) > MAIL_MAX_INBOX ); - - md->amount = i; - Sql_FreeResult(sql_handle); - - md->unchecked = 0; - md->unread = 0; - for (i = 0; i < md->amount; i++) - { - msg = &md->msg[i]; - if( msg->status == MAIL_NEW ) - { - if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) ) - Sql_ShowDebug(sql_handle); - - msg->status = MAIL_UNREAD; - md->unchecked++; - } - else if ( msg->status == MAIL_UNREAD ) - md->unread++; - } - - ShowInfo("mail load complete from DB - id: %d (total: %d)\n", char_id, md->amount); - return 1; -} - -/// Stores a single message in the database. -/// Returns the message's ID if successful (or 0 if it fails). -int mail_savemessage(struct mail_message* msg) -{ - StringBuf buf; - SqlStmt* stmt; - int j; - - // build message save query - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`", mail_db); - for (j = 0; j < MAX_SLOTS; j++) - StringBuf_Printf(&buf, ", `card%d`", j); - StringBuf_Printf(&buf, ") VALUES (?, '%d', ?, '%d', ?, ?, '%lu', '%d', '%d', '%d', '%d', '%d', '%d', '%d'", - msg->send_id, msg->dest_id, (unsigned long)msg->timestamp, msg->status, msg->zeny, msg->item.amount, msg->item.nameid, msg->item.refine, msg->item.attribute, msg->item.identify); - for (j = 0; j < MAX_SLOTS; j++) - StringBuf_Printf(&buf, ", '%d'", msg->item.card[j]); - StringBuf_AppendStr(&buf, ")"); - - // prepare and execute query - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, msg->title, strnlen(msg->title, MAIL_TITLE_LENGTH)) - || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, msg->body, strnlen(msg->body, MAIL_BODY_LENGTH)) - || SQL_SUCCESS != SqlStmt_Execute(stmt) ) - { - SqlStmt_ShowDebug(stmt); - msg->id = 0; - } else - msg->id = (int)SqlStmt_LastInsertId(stmt); - - SqlStmt_Free(stmt); - StringBuf_Destroy(&buf); - - return msg->id; -} - -/// Retrieves a single message from the database. -/// Returns true if the operation succeeds (or false if it fails). -static bool mail_loadmessage(int mail_id, struct mail_message* msg) -{ - int j; - StringBuf buf; - - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`,`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`," - "`zeny`,`amount`,`nameid`,`refine`,`attribute`,`identify`"); - for( j = 0; j < MAX_SLOTS; j++ ) - StringBuf_Printf(&buf, ",`card%d`", j); - StringBuf_Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) - || SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_ShowDebug(sql_handle); - Sql_FreeResult(sql_handle); - StringBuf_Destroy(&buf); - return false; - } - else - { - char* data; - - Sql_GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH); - Sql_GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); - Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); - Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); - Sql_GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data); - Sql_GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data); - Sql_GetData(sql_handle,12, &data, NULL); msg->item.refine = atoi(data); - Sql_GetData(sql_handle,13, &data, NULL); msg->item.attribute = atoi(data); - Sql_GetData(sql_handle,14, &data, NULL); msg->item.identify = atoi(data); - msg->item.expire_time = 0; - - for( j = 0; j < MAX_SLOTS; j++ ) - { - Sql_GetData(sql_handle,15 + j, &data, NULL); - msg->item.card[j] = atoi(data); - } - } - - StringBuf_Destroy(&buf); - Sql_FreeResult(sql_handle); - - return true; -} - -/*========================================== - * Client Inbox Request - *------------------------------------------*/ -static void mapif_Mail_sendinbox(int fd, int char_id, unsigned char flag) -{ - struct mail_data md; - mail_fromsql(char_id, &md); - - //FIXME: dumping the whole structure like this is unsafe [ultramage] - WFIFOHEAD(fd, sizeof(md) + 9); - WFIFOW(fd,0) = 0x3848; - WFIFOW(fd,2) = sizeof(md) + 9; - WFIFOL(fd,4) = char_id; - WFIFOB(fd,8) = flag; - memcpy(WFIFOP(fd,9),&md,sizeof(md)); - WFIFOSET(fd,WFIFOW(fd,2)); -} - -static void mapif_parse_Mail_requestinbox(int fd) -{ - mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6)); -} - -/*========================================== - * Mark mail as 'Read' - *------------------------------------------*/ -static void mapif_parse_Mail_read(int fd) -{ - int mail_id = RFIFOL(fd,2); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) ) - Sql_ShowDebug(sql_handle); -} - -/*========================================== - * Client Attachment Request - *------------------------------------------*/ -static bool mail_DeleteAttach(int mail_id) -{ - StringBuf buf; - int i; - - StringBuf_Init(&buf); - StringBuf_Printf(&buf, "UPDATE `%s` SET `zeny` = '0', `nameid` = '0', `amount` = '0', `refine` = '0', `attribute` = '0', `identify` = '0'", mail_db); - for (i = 0; i < MAX_SLOTS; i++) - StringBuf_Printf(&buf, ", `card%d` = '0'", i); - StringBuf_Printf(&buf, " WHERE `id` = '%d'", mail_id); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) - { - Sql_ShowDebug(sql_handle); - StringBuf_Destroy(&buf); - - return false; - } - - StringBuf_Destroy(&buf); - return true; -} - -static void mapif_Mail_getattach(int fd, int char_id, int mail_id) -{ - struct mail_message msg; - - if( !mail_loadmessage(mail_id, &msg) ) - return; - - if( msg.dest_id != char_id ) - return; - - if( msg.status != MAIL_READ ) - return; - - if( (msg.item.nameid < 1 || msg.item.amount < 1) && msg.zeny < 1 ) - return; // No Attachment - - if( !mail_DeleteAttach(mail_id) ) - return; - - WFIFOHEAD(fd, sizeof(struct item) + 12); - WFIFOW(fd,0) = 0x384a; - WFIFOW(fd,2) = sizeof(struct item) + 12; - WFIFOL(fd,4) = char_id; - WFIFOL(fd,8) = (msg.zeny > 0)?msg.zeny:0; - memcpy(WFIFOP(fd,12), &msg.item, sizeof(struct item)); - WFIFOSET(fd,WFIFOW(fd,2)); -} - -static void mapif_parse_Mail_getattach(int fd) -{ - mapif_Mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6)); -} - -/*========================================== - * Delete Mail - *------------------------------------------*/ -static void mapif_Mail_delete(int fd, int char_id, int mail_id) -{ - bool failed = false; - if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) ) - { - Sql_ShowDebug(sql_handle); - failed = true; - } - - WFIFOHEAD(fd,11); - WFIFOW(fd,0) = 0x384b; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = mail_id; - WFIFOB(fd,10) = failed; - WFIFOSET(fd,11); -} - -static void mapif_parse_Mail_delete(int fd) -{ - mapif_Mail_delete(fd, RFIFOL(fd,2), RFIFOL(fd,6)); -} - -/*========================================== - * Report New Mail to Map Server - *------------------------------------------*/ -void mapif_Mail_new(struct mail_message *msg) -{ - unsigned char buf[74]; - - if( !msg || !msg->id ) - return; - - WBUFW(buf,0) = 0x3849; - WBUFL(buf,2) = msg->dest_id; - WBUFL(buf,6) = msg->id; - memcpy(WBUFP(buf,10), msg->send_name, NAME_LENGTH); - memcpy(WBUFP(buf,34), msg->title, MAIL_TITLE_LENGTH); - mapif_sendall(buf, 74); -} - -/*========================================== - * Return Mail - *------------------------------------------*/ -static void mapif_Mail_return(int fd, int char_id, int mail_id) -{ - struct mail_message msg; - int new_mail = 0; - - if( mail_loadmessage(mail_id, &msg) ) - { - if( msg.dest_id != char_id) - return; - else if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) ) - Sql_ShowDebug(sql_handle); - else - { - char temp_[MAIL_TITLE_LENGTH]; - - // swap sender and receiver - swap(msg.send_id, msg.dest_id); - safestrncpy(temp_, msg.send_name, NAME_LENGTH); - safestrncpy(msg.send_name, msg.dest_name, NAME_LENGTH); - safestrncpy(msg.dest_name, temp_, NAME_LENGTH); - - // set reply message title - snprintf(temp_, MAIL_TITLE_LENGTH, "RE:%s", msg.title); - safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH); - - msg.status = MAIL_NEW; - msg.timestamp = time(NULL); - - new_mail = mail_savemessage(&msg); - mapif_Mail_new(&msg); - } - } - - WFIFOHEAD(fd,11); - WFIFOW(fd,0) = 0x384c; - WFIFOL(fd,2) = char_id; - WFIFOL(fd,6) = mail_id; - WFIFOB(fd,10) = (new_mail == 0); - WFIFOSET(fd,11); -} - -static void mapif_parse_Mail_return(int fd) -{ - mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6)); -} - -/*========================================== - * Send Mail - *------------------------------------------*/ -static void mapif_Mail_send(int fd, struct mail_message* msg) -{ - int len = sizeof(struct mail_message) + 4; - - WFIFOHEAD(fd,len); - WFIFOW(fd,0) = 0x384d; - WFIFOW(fd,2) = len; - memcpy(WFIFOP(fd,4), msg, sizeof(struct mail_message)); - WFIFOSET(fd,len); -} - -static void mapif_parse_Mail_send(int fd) -{ - struct mail_message msg; - char esc_name[NAME_LENGTH*2+1]; - int account_id = 0; - - if(RFIFOW(fd,2) != 8 + sizeof(struct mail_message)) - return; - - account_id = RFIFOL(fd,4); - memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message)); - - // Try to find the Dest Char by Name - Sql_EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH)); - if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) - Sql_ShowDebug(sql_handle); - else - if ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - char *data; - Sql_GetData(sql_handle, 0, &data, NULL); - if (atoi(data) != account_id) - { // Cannot send mail to char in the same account - Sql_GetData(sql_handle, 1, &data, NULL); - msg.dest_id = atoi(data); - } - } - Sql_FreeResult(sql_handle); - msg.status = MAIL_NEW; - - if( msg.dest_id > 0 ) - msg.id = mail_savemessage(&msg); - - mapif_Mail_send(fd, &msg); -} - -void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item) -{ - struct mail_message msg; - memset(&msg, 0, sizeof(struct mail_message)); - - msg.send_id = send_id; - safestrncpy(msg.send_name, send_name, NAME_LENGTH); - msg.dest_id = dest_id; - safestrncpy(msg.dest_name, dest_name, NAME_LENGTH); - safestrncpy(msg.title, title, MAIL_TITLE_LENGTH); - safestrncpy(msg.body, body, MAIL_BODY_LENGTH); - msg.zeny = zeny; - if( item != NULL ) - memcpy(&msg.item, item, sizeof(struct item)); - - msg.timestamp = time(NULL); - - mail_savemessage(&msg); - mapif_Mail_new(&msg); -} - -/*========================================== - * Packets From Map Server - *------------------------------------------*/ -int inter_mail_parse_frommap(int fd) -{ - switch(RFIFOW(fd,0)) - { - case 0x3048: mapif_parse_Mail_requestinbox(fd); break; - case 0x3049: mapif_parse_Mail_read(fd); break; - case 0x304a: mapif_parse_Mail_getattach(fd); break; - case 0x304b: mapif_parse_Mail_delete(fd); break; - case 0x304c: mapif_parse_Mail_return(fd); break; - case 0x304d: mapif_parse_Mail_send(fd); break; - default: - return 0; - } - return 1; -} - -int inter_mail_sql_init(void) -{ - return 1; -} - -void inter_mail_sql_final(void) -{ - return; -} diff --git a/src/char_sql/int_mail.h b/src/char_sql/int_mail.h deleted file mode 100644 index 77db51e5b..000000000 --- a/src/char_sql/int_mail.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_MAIL_SQL_H_ -#define _INT_MAIL_SQL_H_ - -int inter_mail_parse_frommap(int fd); -void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); - -int inter_mail_sql_init(void); -void inter_mail_sql_final(void); - -int mail_savemessage(struct mail_message* msg); -void mapif_Mail_new(struct mail_message *msg); - -#endif /* _INT_MAIL_SQL_H_ */ diff --git a/src/char_sql/int_mercenary.c b/src/char_sql/int_mercenary.c deleted file mode 100644 index c7d7b687d..000000000 --- a/src/char_sql/int_mercenary.c +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" - -#include -#include -#include - -bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) -{ - char* data; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_FreeResult(sql_handle); - return false; - } - - Sql_GetData(sql_handle, 0, &data, NULL); status->mer_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); status->arch_calls = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); status->arch_faith = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); status->spear_calls = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); status->spear_faith = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); status->sword_calls = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); status->sword_faith = atoi(data); - Sql_FreeResult(sql_handle); - - return true; -} - -bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `mercenary_owner` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; -} - -bool mercenary_owner_delete(int char_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) ) - Sql_ShowDebug(sql_handle); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `char_id` = '%d'", char_id) ) - Sql_ShowDebug(sql_handle); - - return true; -} - -bool mapif_mercenary_save(struct s_mercenary* merc) -{ - bool flag = true; - - if( merc->mercenary_id == 0 ) - { // Create new DB entry - if( SQL_ERROR == Sql_Query(sql_handle, - "INSERT INTO `mercenary` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')", - merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) ) - { - Sql_ShowDebug(sql_handle); - flag = false; - } - else - merc->mercenary_id = (int)Sql_LastInsertId(sql_handle); - } - else if( SQL_ERROR == Sql_Query(sql_handle, - "UPDATE `mercenary` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'", - merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) ) - { // Update DB entry - Sql_ShowDebug(sql_handle); - flag = false; - } - - return flag; -} - -bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) -{ - char* data; - - memset(merc, 0, sizeof(struct s_mercenary)); - merc->mercenary_id = merc_id; - merc->char_id = char_id; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `mer_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - Sql_FreeResult(sql_handle); - return false; - } - - Sql_GetData(sql_handle, 0, &data, NULL); merc->class_ = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); merc->hp = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); merc->sp = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); merc->kill_count = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); merc->life_time = atoi(data); - Sql_FreeResult(sql_handle); - if( save_log ) - ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id); - - return true; -} - -bool mapif_mercenary_delete(int merc_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `mer_id` = '%d'", merc_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; -} - -#ifndef TXT_SQL_CONVERT - -static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) -{ - int size = sizeof(struct s_mercenary) + 5; - - WFIFOHEAD(fd,size); - WFIFOW(fd,0) = 0x3870; - WFIFOW(fd,2) = size; - WFIFOB(fd,4) = flag; - memcpy(WFIFOP(fd,5),merc,sizeof(struct s_mercenary)); - WFIFOSET(fd,size); -} - -static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc) -{ - bool result = mapif_mercenary_save(merc); - mapif_mercenary_send(fd, merc, result); -} - -static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) -{ - struct s_mercenary merc; - bool result = mapif_mercenary_load(merc_id, char_id, &merc); - mapif_mercenary_send(fd, &merc, result); -} - -static void mapif_mercenary_deleted(int fd, unsigned char flag) -{ - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x3871; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,3); -} - -static void mapif_parse_mercenary_delete(int fd, int merc_id) -{ - bool result = mapif_mercenary_delete(merc_id); - mapif_mercenary_deleted(fd, result); -} - -static void mapif_mercenary_saved(int fd, unsigned char flag) -{ - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x3872; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,3); -} - -static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc) -{ - bool result = mapif_mercenary_save(merc); - mapif_mercenary_saved(fd, result); -} - -int inter_mercenary_sql_init(void) -{ - return 0; -} -void inter_mercenary_sql_final(void) -{ - return; -} - -/*========================================== - * Inter Packets - *------------------------------------------*/ -int inter_mercenary_parse_frommap(int fd) -{ - unsigned short cmd = RFIFOW(fd,0); - - switch( cmd ) - { - case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; - case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x3072: mapif_parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3073: mapif_parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; - default: - return 0; - } - return 1; -} -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/int_mercenary.h b/src/char_sql/int_mercenary.h deleted file mode 100644 index 01e4a841f..000000000 --- a/src/char_sql/int_mercenary.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_MERCENARY_SQL_H_ -#define _INT_MERCENARY_SQL_H_ - -struct s_mercenary; - -int inter_mercenary_sql_init(void); -void inter_mercenary_sql_final(void); -int inter_mercenary_parse_frommap(int fd); - -// Mercenary Owner Database -bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status); -bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status); -bool mercenary_owner_delete(int char_id); - -bool mapif_mercenary_delete(int merc_id); - -#endif /* _INT_MERCENARY_SQL_H_ */ diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c deleted file mode 100644 index 14cef56e5..000000000 --- a/src/char_sql/int_party.c +++ /dev/null @@ -1,870 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" -#include "int_party.h" - -#include -#include -#include - -#ifndef TXT_SQL_CONVERT -struct party_data { - struct party party; - unsigned int min_lv, max_lv; - int family; //Is this party a family? if so, this holds the child id. - unsigned char size; //Total size of party. -}; - -static struct party_data *party_pt; -static DBMap* party_db_; // int party_id -> struct party_data* - -int mapif_party_broken(int party_id,int flag); -int party_check_empty(struct party_data *p); -int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id); -int party_check_exp_share(struct party_data *p); -int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag); - -//Updates party's level range and unsets even share if broken. -static int int_party_check_lv(struct party_data *p) { - int i; - unsigned int lv; - p->min_lv = UINT_MAX; - p->max_lv = 0; - for(i=0;iparty.member[i].online || p->party.member[i].char_id == p->family ) - continue; - - lv=p->party.member[i].lv; - if (lv < p->min_lv) p->min_lv = lv; - if (lv > p->max_lv) p->max_lv = lv; - } - - if (p->party.exp && !party_check_exp_share(p)) { - p->party.exp = 0; - mapif_party_optionchanged(0, &p->party, 0, 0); - return 0; - } - return 1; -} -//Calculates the state of a party. -static void int_party_calc_state(struct party_data *p) -{ - int i; - unsigned int lv; - p->min_lv = UINT_MAX; - p->max_lv = 0; - p->party.count = - p->size = - p->family = 0; - - //Check party size - for(i=0;iparty.member[i].lv) continue; - p->size++; - if(p->party.member[i].online) - p->party.count++; - } - if( p->size == 2 && ( char_child(p->party.member[0].char_id,p->party.member[1].char_id) || char_child(p->party.member[1].char_id,p->party.member[0].char_id) ) ) { - //Child should be able to share with either of their parents [RoM] - if(p->party.member[0].class_&0x2000) //first slot is the child? - p->family = p->party.member[0].char_id; - else - p->family = p->party.member[1].char_id; - } else if( p->size == 3 ) { - //Check Family State. - p->family = char_family( - p->party.member[0].char_id, - p->party.member[1].char_id, - p->party.member[2].char_id - ); - } - //max/min levels. - for(i=0;iparty.member[i].lv; - if (!lv) continue; - if(p->party.member[i].online && - //On families, the kid is not counted towards exp share rules. - p->party.member[i].char_id != p->family) - { - if( lv < p->min_lv ) p->min_lv=lv; - if( p->max_lv < lv ) p->max_lv=lv; - } - } - - if (p->party.exp && !party_check_exp_share(p)) { - p->party.exp = 0; //Set off even share. - mapif_party_optionchanged(0, &p->party, 0, 0); - } - return; -} -#endif //TXT_SQL_CONVERT -// Save party to mysql -int inter_party_tosql(struct party *p, int flag, int index) -{ - // 'party' ('party_id','name','exp','item','leader_id','leader_char') - char esc_name[NAME_LENGTH*2+1];// escaped party name - int party_id; - - if( p == NULL || p->party_id == 0 ) - return 0; - party_id = p->party_id; - -#ifdef NOISY - ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name); -#endif - Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); - -#ifndef TXT_SQL_CONVERT - if( flag & PS_BREAK ) - {// Break the party - // we'll skip name-checking and just reset everyone with the same party id [celest] - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) - Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) - Sql_ShowDebug(sql_handle); - //Remove from memory - idb_remove(party_db_, party_id); - return 1; - } -#endif //TXT_SQL_CONVERT - if( flag & PS_CREATE ) - {// Create party -#ifndef TXT_SQL_CONVERT - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " - "(`name`, `exp`, `item`, `leader_id`, `leader_char`) " - "VALUES ('%s', '%d', '%d', '%d', '%d')", - party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - party_id = p->party_id = (int)Sql_LastInsertId(sql_handle); -#else - //During conversion, you want to specify the id, and allow overwriting - //(in case someone is re-running the process. - - if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` " - "(`party_id`, `name`, `exp`, `item`, `leader_id`, `leader_char`) " - "VALUES ('%d', '%s', '%d', '%d', '%d', '%d')", - party_db, p->party_id, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } -#endif - } - -#ifndef TXT_SQL_CONVERT - if( flag & PS_BASIC ) - {// Update party info. - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'", - party_db, esc_name, p->exp, p->item, party_id) ) - Sql_ShowDebug(sql_handle); - } - - if( flag & PS_LEADER ) - {// Update leader - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'", - party_db, p->member[index].account_id, p->member[index].char_id, party_id) ) - Sql_ShowDebug(sql_handle); - } - - if( flag & PS_ADDMEMBER ) - {// Add one party member. - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'", - char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) - Sql_ShowDebug(sql_handle); - } - - if( flag & PS_DELMEMBER ) - {// Remove one party member. - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'", - char_db, party_id, p->member[index].account_id, p->member[index].char_id) ) - Sql_ShowDebug(sql_handle); - } -#endif //TXT_SQL_CONVERT - if( save_log ) - ShowInfo("Party Saved (%d - %s)\n", party_id, p->name); - return 1; -} -#ifndef TXT_SQL_CONVERT -// Read party from mysql -struct party_data *inter_party_fromsql(int party_id) -{ - int leader_id = 0; - int leader_char = 0; - struct party_data* p; - struct party_member* m; - char* data; - size_t len; - int i; - -#ifdef NOISY - ShowInfo("Load party request ("CL_BOLD"%d"CL_RESET")\n", party_id); -#endif - if( party_id <= 0 ) - return NULL; - - //Load from memory - p = (struct party_data*)idb_get(party_db_, party_id); - if( p != NULL ) - return p; - - p = party_pt; - memset(p, 0, sizeof(struct party_data)); - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) ) - { - Sql_ShowDebug(sql_handle); - return NULL; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - return NULL; - - p->party.party_id = party_id; - Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0); - Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data); - Sql_FreeResult(sql_handle); - - // Load members - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) ) - { - Sql_ShowDebug(sql_handle); - return NULL; - } - for( i = 0; i < MAX_PARTY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - m = &p->party.member[i]; - Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data); - Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0); - Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data); - m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0); - } - Sql_FreeResult(sql_handle); - - if( save_log ) - ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name); - //Add party to memory. - CREATE(p, struct party_data, 1); - memcpy(p, party_pt, sizeof(struct party_data)); - //init state - int_party_calc_state(p); - idb_put(party_db_, party_id, p); - return p; -} - -int inter_party_sql_init(void) -{ - //memory alloc - party_db_ = idb_alloc(DB_OPT_RELEASE_DATA); - party_pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1); - if (!party_pt) { - ShowFatalError("inter_party_sql_init: Out of Memory!\n"); - exit(EXIT_FAILURE); - } - - /* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex] - ShowStatus("cleaning party table...\n"); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL", - party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) ) - Sql_ShowDebug(sql_handle); - */ - return 0; -} - -void inter_party_sql_final(void) -{ - party_db_->destroy(party_db_, NULL); - aFree(party_pt); - return; -} - -// Search for the party according to its name -struct party_data* search_partyname(char* str) -{ - char esc_name[NAME_LENGTH*2+1]; - char* data; - struct party_data* p = NULL; - - Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) ) - Sql_ShowDebug(sql_handle); - else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - Sql_GetData(sql_handle, 0, &data, NULL); - p = inter_party_fromsql(atoi(data)); - } - Sql_FreeResult(sql_handle); - - return p; -} - -// Returns whether this party can keep having exp share or not. -int party_check_exp_share(struct party_data *p) -{ - return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level); -} - -// Is there any member in the party? -int party_check_empty(struct party_data *p) -{ - int i; - if (p==NULL||p->party.party_id==0) return 1; - for(i=0;iparty.member[i].account_id;i++); - if (i < MAX_PARTY) return 0; - // If there is no member, then break the party - mapif_party_broken(p->party.party_id,0); - inter_party_tosql(&p->party, PS_BREAK, 0); - return 1; -} - -//------------------------------------------------------------------- -// map server‚Ö‚Ì’ÊM - -// ƒp[ƒeƒBì¬‰Â”Û -int mapif_party_created(int fd,int account_id,int char_id,struct party *p) -{ - WFIFOHEAD(fd, 39); - WFIFOW(fd,0)=0x3820; - WFIFOL(fd,2)=account_id; - WFIFOL(fd,6)=char_id; - if(p!=NULL){ - WFIFOB(fd,10)=0; - WFIFOL(fd,11)=p->party_id; - memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH); - ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name); - }else{ - WFIFOB(fd,10)=1; - WFIFOL(fd,11)=0; - memset(WFIFOP(fd,15),0,NAME_LENGTH); - } - WFIFOSET(fd,39); - - return 0; -} - -// ƒp[ƒeƒBî•ñŒ©‚‚©‚炸 -static void mapif_party_noinfo(int fd, int party_id, int char_id) -{ - WFIFOHEAD(fd, 12); - WFIFOW(fd,0) = 0x3821; - WFIFOW(fd,2) = 12; - WFIFOL(fd,4) = char_id; - WFIFOL(fd,8) = party_id; - WFIFOSET(fd,12); - ShowWarning("int_party: info not found (party_id=%d char_id=%d)\n", party_id, char_id); -} -// ƒp[ƒeƒBî•ñ‚܂Ƃߑ—‚è -static void mapif_party_info(int fd, struct party* p, int char_id) -{ - unsigned char buf[8 + sizeof(struct party)]; - WBUFW(buf,0) = 0x3821; - WBUFW(buf,2) = 8 + sizeof(struct party); - WBUFL(buf,4) = char_id; - memcpy(WBUFP(buf,8), p, sizeof(struct party)); - - if(fd<0) - mapif_sendall(buf,WBUFW(buf,2)); - else - mapif_send(fd,buf,WBUFW(buf,2)); -} -// ƒp[ƒeƒBƒƒ“ƒo’ljÁ‰Â”Û -int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) { - WFIFOHEAD(fd, 15); - WFIFOW(fd,0) = 0x3822; - WFIFOL(fd,2) = party_id; - WFIFOL(fd,6) = account_id; - WFIFOL(fd,10) = char_id; - WFIFOB(fd,14) = flag; - WFIFOSET(fd,15); - - return 0; -} - -// ƒp[ƒeƒBÝ’è•ÏX’Ê’m -int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag) -{ - unsigned char buf[16]; - WBUFW(buf,0)=0x3823; - WBUFL(buf,2)=p->party_id; - WBUFL(buf,6)=account_id; - WBUFW(buf,10)=p->exp; - WBUFW(buf,12)=p->item; - WBUFB(buf,14)=flag; - if(flag==0) - mapif_sendall(buf,15); - else - mapif_send(fd,buf,15); - return 0; -} - -// ƒp[ƒeƒB’E‘Þ’Ê’m -int mapif_party_withdraw(int party_id,int account_id, int char_id) { - unsigned char buf[16]; - - WBUFW(buf,0) = 0x3824; - WBUFL(buf,2) = party_id; - WBUFL(buf,6) = account_id; - WBUFL(buf,10) = char_id; - mapif_sendall(buf, 14); - return 0; -} - -// ƒp[ƒeƒBƒ}ƒbƒvXV’Ê’m -int mapif_party_membermoved(struct party *p,int idx) -{ - unsigned char buf[20]; - - WBUFW(buf,0) = 0x3825; - WBUFL(buf,2) = p->party_id; - WBUFL(buf,6) = p->member[idx].account_id; - WBUFL(buf,10) = p->member[idx].char_id; - WBUFW(buf,14) = p->member[idx].map; - WBUFB(buf,16) = p->member[idx].online; - WBUFW(buf,17) = p->member[idx].lv; - mapif_sendall(buf, 19); - return 0; -} - -// ƒp[ƒeƒB‰ðŽU’Ê’m -int mapif_party_broken(int party_id,int flag) -{ - unsigned char buf[16]; - WBUFW(buf,0)=0x3826; - WBUFL(buf,2)=party_id; - WBUFB(buf,6)=flag; - mapif_sendall(buf,7); - //printf("int_party: broken %d\n",party_id); - return 0; -} -// ƒp[ƒeƒB“à”­Œ¾ -int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd) -{ - unsigned char buf[512]; - WBUFW(buf,0)=0x3827; - WBUFW(buf,2)=len+12; - WBUFL(buf,4)=party_id; - WBUFL(buf,8)=account_id; - memcpy(WBUFP(buf,12),mes,len); - mapif_sendallwos(sfd, buf,len+12); - return 0; -} - -//------------------------------------------------------------------- -// map server‚©‚ç‚Ì’ÊM - - -// Create Party -int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader) -{ - struct party_data *p; - int i; - if( (p=search_partyname(name))!=NULL){ - mapif_party_created(fd,leader->account_id,leader->char_id,NULL); - return 0; - } - // Check Authorised letters/symbols in the name of the character - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) == NULL) { - mapif_party_created(fd,leader->account_id,leader->char_id,NULL); - return 0; - } - } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) != NULL) { - mapif_party_created(fd,leader->account_id,leader->char_id,NULL); - return 0; - } - } - - p = (struct party_data*)aCalloc(1, sizeof(struct party_data)); - - memcpy(p->party.name,name,NAME_LENGTH); - p->party.exp=0; - p->party.item=(item?1:0)|(item2?2:0); - - memcpy(&p->party.member[0], leader, sizeof(struct party_member)); - p->party.member[0].leader=1; - p->party.member[0].online=1; - - p->party.party_id=-1;//New party. - if (inter_party_tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) { - //Add party to db - int_party_calc_state(p); - idb_put(party_db_, p->party.party_id, p); - mapif_party_info(fd, &p->party, 0); - mapif_party_created(fd,leader->account_id,leader->char_id,&p->party); - } else { //Failed to create party. - aFree(p); - mapif_party_created(fd,leader->account_id,leader->char_id,NULL); - } - - return 0; -} -// ƒp[ƒeƒBî•ñ—v‹ -static void mapif_parse_PartyInfo(int fd, int party_id, int char_id) -{ - struct party_data *p; - p = inter_party_fromsql(party_id); - - if (p) - mapif_party_info(fd, &p->party, char_id); - else - mapif_party_noinfo(fd, party_id, char_id); -} -// ƒp[ƒeƒB’ljÁ—v‹ -int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) -{ - struct party_data *p; - int i; - - p = inter_party_fromsql(party_id); - if( p == NULL || p->size == MAX_PARTY ) { - mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); - return 0; - } - - ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 ); - if( i == MAX_PARTY ) - {// Party full - mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); - return 0; - } - - memcpy(&p->party.member[i], member, sizeof(struct party_member)); - p->party.member[i].leader = 0; - if (p->party.member[i].online) p->party.count++; - p->size++; - if (p->size == 2 || p->size == 3) // Check family state. And also accept either of their Parents. [RoM] - int_party_calc_state(p); - else //Check even share range. - if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { - if (p->family) p->family = 0; //Family state broken. - int_party_check_lv(p); - } - - mapif_party_info(-1, &p->party, 0); - mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0); - inter_party_tosql(&p->party, PS_ADDMEMBER, i); - - return 0; -} - -// ƒp[ƒeƒB[Ý’è•ÏX—v‹ -int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item) -{ - struct party_data *p; - int flag = 0; - p = inter_party_fromsql(party_id); - - if(!p) - return 0; - - p->party.exp=exp; - if( exp && !party_check_exp_share(p) ){ - flag|=0x01; - p->party.exp=0; - } - p->party.item = item&0x3; //Filter out invalid values. - mapif_party_optionchanged(fd,&p->party,account_id,flag); - inter_party_tosql(&p->party, PS_BASIC, 0); - return 0; -} -// ƒp[ƒeƒB’E‘Þ—v‹ -int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) -{ - struct party_data *p; - int i,j=-1; - - p = inter_party_fromsql(party_id); - if( p == NULL ) - {// Party does not exists? - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) ) - Sql_ShowDebug(sql_handle); - return 0; - } - - for (i = 0; i < MAX_PARTY; i++) { - if(p->party.member[i].account_id == account_id && - p->party.member[i].char_id == char_id) { - break; - } - } - if (i >= MAX_PARTY) - return 0; //Member not found? - - mapif_party_withdraw(party_id, account_id, char_id); - - if (p->party.member[i].leader){ - p->party.member[i].account_id = 0; - for (j = 0; j < MAX_PARTY; j++) { - if (!p->party.member[j].account_id) - continue; - mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id); - p->party.member[j].account_id = 0; - } - //Party gets deleted on the check_empty call below. - } else { - inter_party_tosql(&p->party,PS_DELMEMBER,i); - j = p->party.member[i].lv; - if(p->party.member[i].online) p->party.count--; - memset(&p->party.member[i], 0, sizeof(struct party_member)); - p->size--; - if (j == p->min_lv || j == p->max_lv || p->family) - { - if(p->family) p->family = 0; //Family state broken. - int_party_check_lv(p); - } - } - - if (party_check_empty(p) == 0) - mapif_party_info(-1, &p->party, 0); - return 0; -} -// When member goes to other map or levels up. -int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) -{ - struct party_data *p; - int i; - - p = inter_party_fromsql(party_id); - if (p == NULL) - return 0; - - for(i = 0; i < MAX_PARTY && - (p->party.member[i].account_id != account_id || - p->party.member[i].char_id != char_id); i++); - - if (i == MAX_PARTY) return 0; - - if (p->party.member[i].online != online) - { - p->party.member[i].online = online; - if (online) - p->party.count++; - else - p->party.count--; - // Even share check situations: Family state (always breaks) - // character logging on/off is max/min level (update level range) - // or character logging on/off has a different level (update level range using new level) - if (p->family || - (p->party.member[i].lv <= p->min_lv || p->party.member[i].lv >= p->max_lv) || - (p->party.member[i].lv != lv && (lv <= p->min_lv || lv >= p->max_lv)) - ) - { - p->party.member[i].lv = lv; - int_party_check_lv(p); - } - //Send online/offline update. - mapif_party_membermoved(&p->party, i); - } - - if (p->party.member[i].lv != lv) { - if(p->party.member[i].lv == p->min_lv || - p->party.member[i].lv == p->max_lv) - { - p->party.member[i].lv = lv; - int_party_check_lv(p); - } else - p->party.member[i].lv = lv; - //There is no need to send level update to map servers - //since they do nothing with it. - } - - if (p->party.member[i].map != map) { - p->party.member[i].map = map; - mapif_party_membermoved(&p->party, i); - } - return 0; -} - -// ƒp[ƒeƒB‰ðŽU—v‹ -int mapif_parse_BreakParty(int fd,int party_id) -{ - struct party_data *p; - - p = inter_party_fromsql(party_id); - - if(!p) - return 0; - inter_party_tosql(&p->party,PS_BREAK,0); - mapif_party_broken(fd,party_id); - return 0; -} -// ƒp[ƒeƒBƒƒbƒZ[ƒW‘—M -int mapif_parse_PartyMessage(int fd,int party_id,int account_id,char *mes,int len) -{ - return mapif_party_message(party_id,account_id,mes,len, fd); -} - -int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id) -{ - struct party_data *p; - int i; - - p = inter_party_fromsql(party_id); - - if(!p) - return 0; - - for (i = 0; i < MAX_PARTY; i++) - { - if(p->party.member[i].leader) - p->party.member[i].leader = 0; - if(p->party.member[i].account_id == account_id && - p->party.member[i].char_id == char_id) - { - p->party.member[i].leader = 1; - inter_party_tosql(&p->party,PS_LEADER, i); - } - } - return 1; -} - -// map server ‚©‚ç‚Ì’ÊM -// E‚PƒpƒPƒbƒg‚̂݉ðÍ‚·‚邱‚Æ -// EƒpƒPƒbƒg’·ƒf[ƒ^‚Íinter.c‚ɃZƒbƒg‚µ‚Ä‚¨‚­‚±‚Æ -// EƒpƒPƒbƒg’·ƒ`ƒFƒbƒN‚âARFIFOSKIP‚͌ĂÑo‚µŒ³‚Ås‚í‚ê‚é‚Ì‚Ås‚Á‚Ă͂Ȃç‚È‚¢ -// EƒGƒ‰[‚È‚ç0(false)A‚»‚¤‚łȂ¢‚È‚ç1(true)‚ð‚©‚¦‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢ -int inter_party_parse_frommap(int fd) -{ - RFIFOHEAD(fd); - switch(RFIFOW(fd,0)) { - case 0x3020: mapif_parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break; - case 0x3021: mapif_parse_PartyInfo(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break; - case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,4), (struct party_member*)RFIFOP(fd,8)); break; - case 0x3023: mapif_parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break; - case 0x3024: mapif_parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; - case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break; - case 0x3026: mapif_parse_BreakParty(fd, RFIFOL(fd,2)); break; - case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break; - case 0x3029: mapif_parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; - default: - return 0; - } - return 1; -} - -// ƒT[ƒo[‚©‚ç’E‘Þ—v‹iƒLƒƒƒ‰íœ—pj -int inter_party_leave(int party_id,int account_id, int char_id) -{ - return mapif_parse_PartyLeave(-1,party_id,account_id, char_id); -} - -int inter_party_CharOnline(int char_id, int party_id) -{ - struct party_data* p; - int i; - - if( party_id == -1 ) - {// Get party_id from the database - char* data; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - return 0; //Eh? No party? - - Sql_GetData(sql_handle, 0, &data, NULL); - party_id = atoi(data); - Sql_FreeResult(sql_handle); - } - if (party_id == 0) - return 0; //No party... - - p = inter_party_fromsql(party_id); - if(!p) { - ShowError("Character %d's party %d not found!\n", char_id, party_id); - return 0; - } - - //Set member online - for(i=0; iparty.member[i].char_id == char_id) { - if (!p->party.member[i].online) { - p->party.member[i].online = 1; - p->party.count++; - if (p->party.member[i].lv < p->min_lv || - p->party.member[i].lv > p->max_lv) - int_party_check_lv(p); - } - break; - } - } - return 1; -} - -int inter_party_CharOffline(int char_id, int party_id) { - struct party_data *p=NULL; - int i; - - if( party_id == -1 ) - {// Get guild_id from the database - char* data; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - return 0; //Eh? No party? - - Sql_GetData(sql_handle, 0, &data, NULL); - party_id = atoi(data); - Sql_FreeResult(sql_handle); - } - if (party_id == 0) - return 0; //No party... - - //Character has a party, set character offline and check if they were the only member online - if ((p = inter_party_fromsql(party_id)) == NULL) - return 0; - - //Set member offline - for(i=0; i< MAX_PARTY; i++) { - if(p->party.member[i].char_id == char_id) - { - p->party.member[i].online = 0; - p->party.count--; - if(p->party.member[i].lv == p->min_lv || - p->party.member[i].lv == p->max_lv) - int_party_check_lv(p); - break; - } - } - - if(!p->party.count) - //Parties don't have any data that needs be saved at this point... so just remove it from memory. - idb_remove(party_db_, party_id); - return 1; -} -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/int_party.h b/src/char_sql/int_party.h deleted file mode 100644 index d7965c33b..000000000 --- a/src/char_sql/int_party.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_PARTY_SQL_H_ -#define _INT_PARTY_SQL_H_ - -//Party Flags on what to save/delete. -//Create a new party entry (index holds leader's info) -#define PS_CREATE 0x01 -//Update basic party info. -#define PS_BASIC 0x02 -//Update party's leader -#define PS_LEADER 0x04 -//Specify new party member (index specifies which party member) -#define PS_ADDMEMBER 0x08 -//Specify member that left (index specifies which party member) -#define PS_DELMEMBER 0x10 -//Specify that this party must be deleted. -#define PS_BREAK 0x20 - -struct party; - -int inter_party_parse_frommap(int fd); -int inter_party_sql_init(void); -void inter_party_sql_final(void); -int inter_party_leave(int party_id,int account_id, int char_id); -int inter_party_CharOnline(int char_id, int party_id); -int inter_party_CharOffline(int char_id, int party_id); -//Required for the TXT->SQL converter -int inter_party_tosql(struct party *p, int flag, int index); - -#endif /* _INT_PARTY_SQL_H_ */ diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c deleted file mode 100644 index 3ce7c4559..000000000 --- a/src/char_sql/int_pet.c +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" - -#include -#include -#include - -struct s_pet *pet_pt; - -//--------------------------------------------------------- -int inter_pet_tosql(int pet_id, struct s_pet* p) -{ - //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - char esc_name[NAME_LENGTH*2+1];// escaped pet name - - Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); - p->hungry = cap_value(p->hungry, 0, 100); - p->intimate = cap_value(p->intimate, 0, 1000); - - if( pet_id == -1 ) - {// New pet. - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " - "(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) " - "VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, - p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - p->pet_id = (int)Sql_LastInsertId(sql_handle); - } - else - {// Update pet. - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id, - p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - } - - if (save_log) - ShowInfo("Pet saved %d - %s.\n", pet_id, p->name); - return 1; -} -#ifndef TXT_SQL_CONVERT -int inter_pet_fromsql(int pet_id, struct s_pet* p) -{ - char* data; - size_t len; - -#ifdef NOISY - ShowInfo("Loading pet (%d)...\n",pet_id); -#endif - memset(p, 0, sizeof(struct s_pet)); - - //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) - { - Sql_ShowDebug(sql_handle); - return 0; - } - - if( SQL_SUCCESS == Sql_NextRow(sql_handle) ) - { - p->pet_id = pet_id; - Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data); - Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH)); - Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); p->incuvate = atoi(data); - - Sql_FreeResult(sql_handle); - - p->hungry = cap_value(p->hungry, 0, 100); - p->intimate = cap_value(p->intimate, 0, 1000); - - if( save_log ) - ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name); - } - return 0; -} -//---------------------------------------------- - -int inter_pet_sql_init(void){ - //memory alloc - pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); - return 0; -} -void inter_pet_sql_final(void){ - if (pet_pt) aFree(pet_pt); - return; -} -//---------------------------------- -int inter_pet_delete(int pet_id){ - ShowInfo("delete pet request: %d...\n",pet_id); - - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) - Sql_ShowDebug(sql_handle); - return 0; -} -//------------------------------------------------------ -int mapif_pet_created(int fd, int account_id, struct s_pet *p) -{ - WFIFOHEAD(fd, 11); - WFIFOW(fd, 0) =0x3880; - WFIFOL(fd, 2) =account_id; - if(p!=NULL){ - WFIFOB(fd, 6)=0; - WFIFOL(fd, 7) =p->pet_id; - ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name); - }else{ - WFIFOB(fd, 6)=1; - WFIFOL(fd, 7)=0; - } - WFIFOSET(fd, 11); - - return 0; -} - -int mapif_pet_info(int fd, int account_id, struct s_pet *p){ - WFIFOHEAD(fd, sizeof(struct s_pet) + 9); - WFIFOW(fd, 0) =0x3881; - WFIFOW(fd, 2) =sizeof(struct s_pet) + 9; - WFIFOL(fd, 4) =account_id; - WFIFOB(fd, 8)=0; - memcpy(WFIFOP(fd, 9), p, sizeof(struct s_pet)); - WFIFOSET(fd, WFIFOW(fd, 2)); - - return 0; -} - -int mapif_pet_noinfo(int fd, int account_id){ - WFIFOHEAD(fd, sizeof(struct s_pet) + 9); - WFIFOW(fd, 0) =0x3881; - WFIFOW(fd, 2) =sizeof(struct s_pet) + 9; - WFIFOL(fd, 4) =account_id; - WFIFOB(fd, 8)=1; - memset(WFIFOP(fd, 9), 0, sizeof(struct s_pet)); - WFIFOSET(fd, WFIFOW(fd, 2)); - - return 0; -} - -int mapif_save_pet_ack(int fd, int account_id, int flag){ - WFIFOHEAD(fd, 7); - WFIFOW(fd, 0) =0x3882; - WFIFOL(fd, 2) =account_id; - WFIFOB(fd, 6) =flag; - WFIFOSET(fd, 7); - - return 0; -} - -int mapif_delete_pet_ack(int fd, int flag){ - WFIFOHEAD(fd, 3); - WFIFOW(fd, 0) =0x3883; - WFIFOB(fd, 2) =flag; - WFIFOSET(fd, 3); - - return 0; -} - -int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, - short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name) -{ - memset(pet_pt, 0, sizeof(struct s_pet)); - strncpy(pet_pt->name, pet_name, NAME_LENGTH); - if(incuvate == 1) - pet_pt->account_id = pet_pt->char_id = 0; - else { - pet_pt->account_id = account_id; - pet_pt->char_id = char_id; - } - pet_pt->class_ = pet_class; - pet_pt->level = pet_lv; - pet_pt->egg_id = pet_egg_id; - pet_pt->equip = pet_equip; - pet_pt->intimate = intimate; - pet_pt->hungry = hungry; - pet_pt->rename_flag = rename_flag; - pet_pt->incuvate = incuvate; - - if(pet_pt->hungry < 0) - pet_pt->hungry = 0; - else if(pet_pt->hungry > 100) - pet_pt->hungry = 100; - if(pet_pt->intimate < 0) - pet_pt->intimate = 0; - else if(pet_pt->intimate > 1000) - pet_pt->intimate = 1000; - - pet_pt->pet_id = -1; //Signal NEW pet. - if (inter_pet_tosql(pet_pt->pet_id,pet_pt)) - mapif_pet_created(fd, account_id, pet_pt); - else //Failed... - mapif_pet_created(fd, account_id, NULL); - - return 0; -} - -int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){ - memset(pet_pt, 0, sizeof(struct s_pet)); - - inter_pet_fromsql(pet_id, pet_pt); - - if(pet_pt!=NULL) { - if(pet_pt->incuvate == 1) { - pet_pt->account_id = pet_pt->char_id = 0; - mapif_pet_info(fd, account_id, pet_pt); - } - else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id) - mapif_pet_info(fd, account_id, pet_pt); - else - mapif_pet_noinfo(fd, account_id); - } - else - mapif_pet_noinfo(fd, account_id); - - return 0; -} - -int mapif_save_pet(int fd, int account_id, struct s_pet *data) { - //here process pet save request. - int len; - RFIFOHEAD(fd); - len=RFIFOW(fd, 2); - if(sizeof(struct s_pet)!=len-8) { - ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8); - } - - else{ - if(data->hungry < 0) - data->hungry = 0; - else if(data->hungry > 100) - data->hungry = 100; - if(data->intimate < 0) - data->intimate = 0; - else if(data->intimate > 1000) - data->intimate = 1000; - inter_pet_tosql(data->pet_id,data); - mapif_save_pet_ack(fd, account_id, 0); - } - - return 0; -} - -int mapif_delete_pet(int fd, int pet_id){ - mapif_delete_pet_ack(fd, inter_pet_delete(pet_id)); - - return 0; -} - -int mapif_parse_CreatePet(int fd){ - RFIFOHEAD(fd); - mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18), - RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24)); - return 0; -} - -int mapif_parse_LoadPet(int fd){ - RFIFOHEAD(fd); - mapif_load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10)); - return 0; -} - -int mapif_parse_SavePet(int fd){ - RFIFOHEAD(fd); - mapif_save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8)); - return 0; -} - -int mapif_parse_DeletePet(int fd){ - RFIFOHEAD(fd); - mapif_delete_pet(fd, RFIFOL(fd, 2)); - return 0; -} - -int inter_pet_parse_frommap(int fd){ - RFIFOHEAD(fd); - switch(RFIFOW(fd, 0)){ - case 0x3080: mapif_parse_CreatePet(fd); break; - case 0x3081: mapif_parse_LoadPet(fd); break; - case 0x3082: mapif_parse_SavePet(fd); break; - case 0x3083: mapif_parse_DeletePet(fd); break; - default: - return 0; - } - return 1; -} -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/int_pet.h b/src/char_sql/int_pet.h deleted file mode 100644 index 733468c77..000000000 --- a/src/char_sql/int_pet.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_PET_SQL_H_ -#define _INT_PET_SQL_H_ - -struct s_pet; - -int inter_pet_init(void); -void inter_pet_sql_final(void); -int inter_pet_save(void); -int inter_pet_delete(int pet_id); - -int inter_pet_parse_frommap(int fd); -int inter_pet_sql_init(void); -//extern char pet_txt[256]; - -//Exported for use in the TXT-SQL converter. -int inter_pet_tosql(int pet_id, struct s_pet *p); - -#endif /* _INT_PET_SQL_H_ */ diff --git a/src/char_sql/int_quest.c b/src/char_sql/int_quest.c deleted file mode 100644 index 224205412..000000000 --- a/src/char_sql/int_quest.c +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" -#include "../common/timer.h" - -#include "char.h" -#include "inter.h" -#include "int_quest.h" - -#include -#include -#include - -//Load entire questlog for a character -int mapif_quests_fromsql(int char_id, struct quest questlog[]) -{ - int i; - struct quest tmp_quest; - SqlStmt * stmt; - - stmt = SqlStmt_Malloc(sql_handle); - if( stmt == NULL ) - { - SqlStmt_ShowDebug(stmt); - return 0; - } - - memset(&tmp_quest, 0, sizeof(struct quest)); - - if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB) - || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SqlStmt_Execute(stmt) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT, &tmp_quest.count[0], 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT, &tmp_quest.count[1], 0, NULL, NULL) - || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT, &tmp_quest.count[2], 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); - - for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) - memcpy(&questlog[i], &tmp_quest, sizeof(tmp_quest)); - - SqlStmt_Free(stmt); - return i; -} - -//Delete a quest -bool mapif_quest_delete(int char_id, int quest_id) -{ - if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; -} - -//Add a quest to a questlog -bool mapif_quest_add(int char_id, struct quest qd) -{ - if ( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; -} - -//Update a questlog -bool mapif_quest_update(int char_id, struct quest qd) -{ - if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) ) - { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; -} - -//Save quests -int mapif_parse_quest_save(int fd) -{ - int i, j, k, num2, num1 = (RFIFOW(fd,2)-8)/sizeof(struct quest); - int char_id = RFIFOL(fd,4); - struct quest qd1[MAX_QUEST_DB],qd2[MAX_QUEST_DB]; - bool success = true; - - memset(qd1, 0, sizeof(qd1)); - memset(qd2, 0, sizeof(qd2)); - if( num1 ) memcpy(&qd1, RFIFOP(fd,8), RFIFOW(fd,2)-8); - num2 = mapif_quests_fromsql(char_id, qd2); - - for( i = 0; i < num1; i++ ) - { - ARR_FIND( 0, num2, j, qd1[i].quest_id == qd2[j].quest_id ); - if( j < num2 ) // Update existed quests - { // Only states and counts are changable. - ARR_FIND( 0, MAX_QUEST_OBJECTIVES, k, qd1[i].count[k] != qd2[j].count[k] ); - if( k != MAX_QUEST_OBJECTIVES || qd1[i].state != qd2[j].state ) - success &= mapif_quest_update(char_id, qd1[i]); - - if( j < (--num2) ) - { - memmove(&qd2[j],&qd2[j+1],sizeof(struct quest)*(num2-j)); - memset(&qd2[num2], 0, sizeof(struct quest)); - } - - } - else // Add new quests - success &= mapif_quest_add(char_id, qd1[i]); - } - - for( i = 0; i < num2; i++ ) // Quests not in qd1 but in qd2 are to be erased. - success &= mapif_quest_delete(char_id, qd2[i].quest_id); - - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x3861; - WFIFOL(fd,2) = char_id; - WFIFOB(fd,6) = success?1:0; - WFIFOSET(fd,7); - - return 0; -} - -//Send questlog to map server -int mapif_parse_quest_load(int fd) -{ - int char_id = RFIFOL(fd,2); - struct quest tmp_questlog[MAX_QUEST_DB]; - int num_quests, i, num_complete = 0; - int complete[MAX_QUEST_DB]; - - memset(tmp_questlog, 0, sizeof(tmp_questlog)); - memset(complete, 0, sizeof(complete)); - - num_quests = mapif_quests_fromsql(char_id, tmp_questlog); - - WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8); - WFIFOW(fd,0) = 0x3860; - WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8; - WFIFOL(fd,4) = char_id; - - //Active and inactive quests - for( i = 0; i < num_quests; i++ ) - { - if( tmp_questlog[i].state == Q_COMPLETE ) - { - complete[num_complete++] = i; - continue; - } - memcpy(WFIFOP(fd,(i-num_complete)*sizeof(struct quest)+8), &tmp_questlog[i], sizeof(struct quest)); - } - - // Completed quests - for( i = num_quests - num_complete; i < num_quests; i++ ) - memcpy(WFIFOP(fd,i*sizeof(struct quest)+8), &tmp_questlog[complete[i-num_quests+num_complete]], sizeof(struct quest)); - - WFIFOSET(fd,num_quests*sizeof(struct quest)+8); - - return 0; -} - -int inter_quest_parse_frommap(int fd) -{ - switch(RFIFOW(fd,0)) - { - case 0x3060: mapif_parse_quest_load(fd); break; - case 0x3061: mapif_parse_quest_save(fd); break; - default: - return 0; - } - return 1; -} diff --git a/src/char_sql/int_quest.h b/src/char_sql/int_quest.h deleted file mode 100644 index f2a0b626e..000000000 --- a/src/char_sql/int_quest.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _QUEST_H_ -#define _QUEST_H_ - -/*questlog system*/ -struct quest; - -int inter_quest_parse_frommap(int fd); - -#endif - diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c deleted file mode 100644 index e4d2395f1..000000000 --- a/src/char_sql/int_storage.c +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" -#include "char.h" -#include "inter.h" - -#include -#include -#include - - -#define STORAGE_MEMINC 16 - -/// Save storage data to sql -int storage_tosql(int account_id, struct storage_data* p) -{ - memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE); - return 0; -} - -#ifndef TXT_SQL_CONVERT -/// Load storage data to mem -int storage_fromsql(int account_id, struct storage_data* p) -{ - StringBuf buf; - struct item* item; - char* data; - int i; - int j; - - memset(p, 0, sizeof(struct storage_data)); //clean up memory - p->storage_amount = 0; - - // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`"); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ",`card%d`", j); - StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - - StringBuf_Destroy(&buf); - - for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - item = &p->items[i]; - Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data); - for( j = 0; j < MAX_SLOTS; ++j ) - { - Sql_GetData(sql_handle, 8+j, &data, NULL); item->card[j] = atoi(data); - } - } - p->storage_amount = i; - Sql_FreeResult(sql_handle); - - ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount); - return 1; -} -#endif //TXT_SQL_CONVERT - -/// Save guild_storage data to sql -int guild_storage_tosql(int guild_id, struct guild_storage* p) -{ - memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE); - ShowInfo ("guild storage save to DB - guild: %d\n", guild_id); - return 0; -} - -#ifndef TXT_SQL_CONVERT -/// Load guild_storage data to mem -int guild_storage_fromsql(int guild_id, struct guild_storage* p) -{ - StringBuf buf; - struct item* item; - char* data; - int i; - int j; - - memset(p, 0, sizeof(struct guild_storage)); //clean up memory - p->storage_amount = 0; - p->guild_id = guild_id; - - // storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} - StringBuf_Init(&buf); - StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`"); - for( j = 0; j < MAX_SLOTS; ++j ) - StringBuf_Printf(&buf, ",`card%d`", j); - StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id); - - if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) ) - Sql_ShowDebug(sql_handle); - - StringBuf_Destroy(&buf); - - for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - item = &p->items[i]; - Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data); - item->expire_time = 0; - for( j = 0; j < MAX_SLOTS; ++j ) - { - Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data); - } - } - p->storage_amount = i; - Sql_FreeResult(sql_handle); - - ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount); - return 0; -} - -//--------------------------------------------------------- -// storage data initialize -int inter_storage_sql_init(void) -{ - return 1; -} -// storage data finalize -void inter_storage_sql_final(void) -{ - return; -} - -// q?f[^? -int inter_storage_delete(int account_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) ) - Sql_ShowDebug(sql_handle); - return 0; -} -int inter_guild_storage_delete(int guild_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) ) - Sql_ShowDebug(sql_handle); - return 0; -} - -//--------------------------------------------------------- -// packet from map server - -int mapif_load_guild_storage(int fd,int account_id,int guild_id) -{ - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) - Sql_ShowDebug(sql_handle); - else if( Sql_NumRows(sql_handle) > 0 ) - {// guild exists - WFIFOHEAD(fd, sizeof(struct guild_storage)+12); - WFIFOW(fd,0) = 0x3818; - WFIFOW(fd,2) = sizeof(struct guild_storage)+12; - WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = guild_id; - guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,12)); - WFIFOSET(fd, WFIFOW(fd,2)); - return 0; - } - // guild does not exist - Sql_FreeResult(sql_handle); - WFIFOHEAD(fd, 12); - WFIFOW(fd,0) = 0x3818; - WFIFOW(fd,2) = 12; - WFIFOL(fd,4) = account_id; - WFIFOL(fd,8) = 0; - WFIFOSET(fd, 12); - return 0; -} -int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) -{ - WFIFOHEAD(fd,11); - WFIFOW(fd,0)=0x3819; - WFIFOL(fd,2)=account_id; - WFIFOL(fd,6)=guild_id; - WFIFOB(fd,10)=fail; - WFIFOSET(fd,11); - return 0; -} - -//--------------------------------------------------------- -// packet from map server - -int mapif_parse_LoadGuildStorage(int fd) -{ - RFIFOHEAD(fd); - mapif_load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6)); - return 0; -} - -int mapif_parse_SaveGuildStorage(int fd) -{ - int guild_id; - int len; - - RFIFOHEAD(fd); - guild_id = RFIFOL(fd,8); - len = RFIFOW(fd,2); - - if( sizeof(struct guild_storage) != len - 12 ) - { - ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); - } - else - { - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) - Sql_ShowDebug(sql_handle); - else if( Sql_NumRows(sql_handle) > 0 ) - {// guild exists - Sql_FreeResult(sql_handle); - guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); - mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); - return 0; - } - Sql_FreeResult(sql_handle); - } - mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1); - return 0; -} - - -int inter_storage_parse_frommap(int fd) -{ - RFIFOHEAD(fd); - switch(RFIFOW(fd,0)){ - case 0x3018: mapif_parse_LoadGuildStorage(fd); break; - case 0x3019: mapif_parse_SaveGuildStorage(fd); break; - default: - return 0; - } - return 1; -} -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/int_storage.h b/src/char_sql/int_storage.h deleted file mode 100644 index 811608f82..000000000 --- a/src/char_sql/int_storage.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INT_STORAGE_SQL_H_ -#define _INT_STORAGE_SQL_H_ - -struct storage_data; -struct guild_storage; - -int inter_storage_sql_init(void); -void inter_storage_sql_final(void); -int inter_storage_delete(int account_id); -int inter_guild_storage_delete(int guild_id); - -int inter_storage_parse_frommap(int fd); - -//Exported for use in the TXT-SQL converter. -int storage_fromsql(int account_id, struct storage_data* p); -int storage_tosql(int account_id,struct storage_data *p); -int guild_storage_tosql(int guild_id, struct guild_storage *p); - -#endif /* _INT_STORAGE_SQL_H_ */ diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c deleted file mode 100644 index 50f05f6a3..000000000 --- a/src/char_sql/inter.c +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_party.h" -#include "int_guild.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_mail.h" -#include "int_auction.h" -#include "int_quest.h" - -#include -#include -#include - -#define WISDATA_TTL (60*1000) // Wisƒf[ƒ^‚̶‘¶ŽžŠÔ(60•b) -#define WISDELLIST_MAX 256 // Wisƒf[ƒ^íœƒŠƒXƒg‚Ì—v‘f” - - -Sql* sql_handle = NULL; - -int char_server_port = 3306; -char char_server_ip[32] = "127.0.0.1"; -char char_server_id[32] = "ragnarok"; -char char_server_pw[32] = "ragnarok"; -char char_server_db[32] = "ragnarok"; -char default_codepage[32] = ""; //Feature by irmin. - -#ifndef TXT_SQL_CONVERT - -static struct accreg *accreg_pt; -unsigned int party_share_level = 10; -char main_chat_nick[16] = "Main"; - -// recv. packet list -int inter_recv_packet_length[] = { - -1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3000- - 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- - -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party - -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030- - 5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040- - -1,-1,10,10, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus] - 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish] - -1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus] - 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080- - -1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator] -}; - -struct WisData { - int id, fd, count, len; - unsigned long tick; - unsigned char src[24], dst[24], msg[512]; -}; -static DBMap* wis_db = NULL; // int wis_id -> struct WisData* -static int wis_dellist[WISDELLIST_MAX], wis_delnum; - -#endif //TXT_SQL_CONVERT -//-------------------------------------------------------- -// Save registry to sql -int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type) -{ - struct global_reg* r; - SqlStmt* stmt; - int i; - - if( account_id <= 0 ) - return 0; - reg->account_id = account_id; - reg->char_id = char_id; - - //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) - switch( type ) - { - case 3: //Char Reg - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) - Sql_ShowDebug(sql_handle); - account_id = 0; - break; - case 2: //Account Reg - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) - Sql_ShowDebug(sql_handle); - char_id = 0; - break; - case 1: //Account2 Reg - ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); - return 0; - default: - ShowError("inter_accreg_tosql: Invalid type %d\n", type); - return 0; - } - - if( reg->reg_num <= 0 ) - return 0; - - stmt = SqlStmt_Malloc(sql_handle); - if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d',?,?)", reg_db, type, account_id, char_id) ) - SqlStmt_ShowDebug(stmt); - for( i = 0; i < reg->reg_num; ++i ) - { - r = ®->reg[i]; - if( r->str[0] != '\0' && r->value != '\0' ) - { - // str - SqlStmt_BindParam(stmt, 0, SQLDT_STRING, r->str, strnlen(r->str, sizeof(r->str))); - // value - SqlStmt_BindParam(stmt, 1, SQLDT_STRING, r->value, strnlen(r->value, sizeof(r->value))); - - if( SQL_ERROR == SqlStmt_Execute(stmt) ) - SqlStmt_ShowDebug(stmt); - } - } - SqlStmt_Free(stmt); - return 1; -} -#ifndef TXT_SQL_CONVERT - -// Load account_reg from sql (type=2) -int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type) -{ - struct global_reg* r; - char* data; - size_t len; - int i; - - if( reg == NULL) - return 0; - - memset(reg, 0, sizeof(struct accreg)); - reg->account_id = account_id; - reg->char_id = char_id; - - //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) - switch( type ) - { - case 3: //char reg - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) ) - Sql_ShowDebug(sql_handle); - break; - case 2: //account reg - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) ) - Sql_ShowDebug(sql_handle); - break; - case 1: //account2 reg - ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n"); - return 0; - default: - ShowError("inter_accreg_fromsql: Invalid type %d\n", type); - return 0; - } - for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) - { - r = ®->reg[i]; - // str - Sql_GetData(sql_handle, 0, &data, &len); - memcpy(r->str, data, min(len, sizeof(r->str))); - // value - Sql_GetData(sql_handle, 1, &data, &len); - memcpy(r->value, data, min(len, sizeof(r->value))); - } - reg->reg_num = i; - Sql_FreeResult(sql_handle); - return 1; -} - -// Initialize -int inter_accreg_sql_init(void) -{ - CREATE(accreg_pt, struct accreg, 1); - return 0; - -} -#endif //TXT_SQL_CONVERT - -/*========================================== - * read config file - *------------------------------------------*/ -static int inter_config_read(const char* cfgName) -{ - int i; - char line[1024], w1[1024], w2[1024]; - FILE* fp; - - fp = fopen(cfgName, "r"); - if(fp == NULL) { - ShowError("file not found: %s\n", cfgName); - return 1; - } - - ShowInfo("reading file %s...\n", cfgName); - - while(fgets(line, sizeof(line), fp)) - { - i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); - if(i != 2) - continue; - - if(!strcmpi(w1,"char_server_ip")) { - strcpy(char_server_ip,w2); - ShowStatus ("set char_server_ip : %s\n", w2); - } else - if(!strcmpi(w1,"char_server_port")) { - char_server_port = atoi(w2); - ShowStatus ("set char_server_port : %s\n", w2); - } else - if(!strcmpi(w1,"char_server_id")) { - strcpy(char_server_id,w2); - ShowStatus ("set char_server_id : %s\n", w2); - } else - if(!strcmpi(w1,"char_server_pw")) { - strcpy(char_server_pw,w2); - ShowStatus ("set char_server_pw : %s\n", w2); - } else - if(!strcmpi(w1,"char_server_db")) { - strcpy(char_server_db,w2); - ShowStatus ("set char_server_db : %s\n", w2); - } else - if(!strcmpi(w1,"default_codepage")) { - strcpy(default_codepage,w2); - ShowStatus ("set default_codepage : %s\n", w2); - } -#ifndef TXT_SQL_CONVERT - else if(!strcmpi(w1,"party_share_level")) - party_share_level = atoi(w2); - else if(!strcmpi(w1,"log_inter")) - log_inter = atoi(w2); - else if(!strcmpi(w1,"main_chat_nick")) - safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick)); -#endif //TXT_SQL_CONVERT - else if(!strcmpi(w1,"import")) - inter_config_read(w2); - } - fclose(fp); - - ShowInfo ("done reading %s.\n", cfgName); - - return 0; -} -#ifndef TXT_SQL_CONVERT - -// Save interlog into sql -int inter_log(char* fmt, ...) -{ - char str[255]; - char esc_str[sizeof(str)*2+1];// escaped str - va_list ap; - - va_start(ap,fmt); - vsnprintf(str, sizeof(str), fmt, ap); - va_end(ap); - - Sql_EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str))); - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) ) - Sql_ShowDebug(sql_handle); - - return 0; -} - -#endif //TXT_SQL_CONVERT - -// initialize -int inter_init_sql(const char *file) -{ - //int i; - - ShowInfo ("interserver initialize...\n"); - inter_config_read(file); - - //DB connection initialized - sql_handle = Sql_Malloc(); - ShowInfo("Connect Character DB server.... (Character Server)\n"); - if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) ) - { - Sql_ShowDebug(sql_handle); - Sql_Free(sql_handle); - exit(EXIT_FAILURE); - } - - if( *default_codepage ) { - if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) - Sql_ShowDebug(sql_handle); - } - -#ifndef TXT_SQL_CONVERT - wis_db = idb_alloc(DB_OPT_RELEASE_DATA); - inter_guild_sql_init(); - inter_storage_sql_init(); - inter_party_sql_init(); - inter_pet_sql_init(); - inter_homunculus_sql_init(); - inter_mercenary_sql_init(); - inter_accreg_sql_init(); - inter_mail_sql_init(); - inter_auction_sql_init(); - -#endif //TXT_SQL_CONVERT - return 0; -} -#ifndef TXT_SQL_CONVERT - -// finalize -void inter_final(void) -{ - wis_db->destroy(wis_db, NULL); - - inter_guild_sql_final(); - inter_storage_sql_final(); - inter_party_sql_final(); - inter_pet_sql_final(); - inter_homunculus_sql_final(); - inter_mercenary_sql_final(); - inter_mail_sql_final(); - inter_auction_sql_final(); - - if (accreg_pt) aFree(accreg_pt); - return; -} - -int inter_mapif_init(int fd) -{ - inter_guild_mapif_init(fd); - - return 0; -} - - -//-------------------------------------------------------- - -// broadcast sending -int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) -{ - unsigned char *buf = (unsigned char*)aMallocA((len)*sizeof(unsigned char)); - - WBUFW(buf,0) = 0x3800; - WBUFW(buf,2) = len; - WBUFL(buf,4) = fontColor; - WBUFW(buf,8) = fontType; - WBUFW(buf,10) = fontSize; - WBUFW(buf,12) = fontAlign; - WBUFW(buf,14) = fontY; - memcpy(WBUFP(buf,16), mes, len - 16); - mapif_sendallwos(sfd, buf, len); - - if (buf) - aFree(buf); - return 0; -} - -// Wis sending -int mapif_wis_message(struct WisData *wd) -{ - unsigned char buf[2048]; - if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex] - - WBUFW(buf, 0) = 0x3801; - WBUFW(buf, 2) = 56 +wd->len; - WBUFL(buf, 4) = wd->id; - memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH); - memcpy(WBUFP(buf,32), wd->dst, NAME_LENGTH); - memcpy(WBUFP(buf,56), wd->msg, wd->len); - wd->count = mapif_sendall(buf,WBUFW(buf,2)); - - return 0; -} - -// Wis sending result -int mapif_wis_end(struct WisData *wd, int flag) -{ - unsigned char buf[27]; - - WBUFW(buf, 0)=0x3802; - memcpy(WBUFP(buf, 2),wd->src,24); - WBUFB(buf,26)=flag; - mapif_send(wd->fd,buf,27); - return 0; -} - -// Account registry transfer to map-server -static void mapif_account_reg(int fd, unsigned char *src) -{ - WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO - mapif_sendallwos(fd, src, WBUFW(src,2)); -} - -// Send the requested account_reg -int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) -{ - struct accreg *reg=accreg_pt; - WFIFOHEAD(fd, 13 + 5000); - inter_accreg_fromsql(account_id,char_id,reg,type); - - WFIFOW(fd,0)=0x3804; - WFIFOL(fd,4)=account_id; - WFIFOL(fd,8)=char_id; - WFIFOB(fd,12)=type; - if(reg->reg_num==0){ - WFIFOW(fd,2)=13; - }else{ - int i,p; - for (p=13,i = 0; i < reg->reg_num && p < 5000; i++) { - p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. - p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].value)+1; - } - WFIFOW(fd,2)=p; - if (p>= 5000) - ShowWarning("Too many acc regs for %d:%d, not all values were loaded.\n", account_id, char_id); - } - WFIFOSET(fd,WFIFOW(fd,2)); - return 0; -} - -//Request to kick char from a certain map server. [Skotlex] -int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) -{ - if (fd >= 0) - { - WFIFOHEAD(fd,7); - WFIFOW(fd,0) = 0x2b1f; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = reason; - WFIFOSET(fd,7); - return 0; - } - return -1; -} - -//-------------------------------------------------------- - -// Existence check of WISP data -int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) -{ - unsigned long tick; - struct WisData *wd = (struct WisData *)data; - tick = va_arg(ap, unsigned long); - - if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX) - wis_dellist[wis_delnum++] = wd->id; - - return 0; -} - -int check_ttl_wisdata(void) -{ - unsigned long tick = gettick(); - int i; - - do { - wis_delnum = 0; - wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick); - for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]); - ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); - // removed. not send information after a timeout. Just no answer for the player - //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - idb_remove(wis_db, wd->id); - } - } while(wis_delnum >= WISDELLIST_MAX); - - return 0; -} - -//-------------------------------------------------------- - -// broadcast sending -int mapif_parse_broadcast(int fd) -{ - mapif_broadcast(RFIFOP(fd,16), RFIFOW(fd,2), RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), fd); - return 0; -} - - -// Wisp/page request to send -int mapif_parse_WisRequest(int fd) -{ - struct WisData* wd; - static int wisid = 0; - char name[NAME_LENGTH]; - char esc_name[NAME_LENGTH*2+1];// escaped name - char* data; - size_t len; - - - if ( fd <= 0 ) {return 0;} // check if we have a valid fd - - if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) { - ShowWarning("inter: Wis message size too long.\n"); - return 0; - } else if (RFIFOW(fd,2)-52 <= 0) { // normaly, impossible, but who knows... - ShowError("inter: Wis message doesn't exist.\n"); - return 0; - } - - safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] - - Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) ) - Sql_ShowDebug(sql_handle); - - // search if character exists before to ask all map-servers - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) - { - unsigned char buf[27]; - WBUFW(buf, 0) = 0x3802; - memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); - WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - mapif_send(fd, buf, 27); - } - else - {// Character exists. So, ask all map-servers - // to be sure of the correct name, rewrite it - Sql_GetData(sql_handle, 0, &data, &len); - memset(name, 0, NAME_LENGTH); - memcpy(name, data, min(len, NAME_LENGTH)); - // if source is destination, don't ask other servers. - if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 ) - { - uint8 buf[27]; - WBUFW(buf, 0) = 0x3802; - memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); - WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - mapif_send(fd, buf, 27); - } - else - { - - CREATE(wd, struct WisData, 1); - - // Whether the failure of previous wisp/page transmission (timeout) - check_ttl_wisdata(); - - wd->id = ++wisid; - wd->fd = fd; - wd->len= RFIFOW(fd,2)-52; - memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH); - memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH); - memcpy(wd->msg, RFIFOP(fd,52), wd->len); - wd->tick = gettick(); - idb_put(wis_db, wd->id, wd); - mapif_wis_message(wd); - } - } - - Sql_FreeResult(sql_handle); - return 0; -} - - -// Wisp/page transmission result -int mapif_parse_WisReply(int fd) -{ - int id, flag; - struct WisData *wd; - - id = RFIFOL(fd,2); - flag = RFIFOB(fd,6); - wd = (struct WisData*)idb_get(wis_db, id); - if (wd == NULL) - return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server - - if ((--wd->count) <= 0 || flag != 1) { - mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - idb_remove(wis_db, id); - } - - return 0; -} - -// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers) -int mapif_parse_WisToGM(int fd) -{ - unsigned char buf[2048]; // 0x3003/0x3803 .w .24B .w .?B - - memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2)); - WBUFW(buf, 0) = 0x3803; - mapif_sendall(buf, RFIFOW(fd,2)); - - return 0; -} - -// Save account_reg into sql (type=2) -int mapif_parse_Registry(int fd) -{ - int j,p,len, max; - struct accreg *reg=accreg_pt; - - memset(accreg_pt,0,sizeof(struct accreg)); - switch (RFIFOB(fd, 12)) { - case 3: //Character registry - max = GLOBAL_REG_NUM; - break; - case 2: //Account Registry - max = ACCOUNT_REG_NUM; - break; - case 1: //Account2 registry, must be sent over to login server. - return save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4); - default: - return 1; - } - for(j=0,p=13;jreg[j].str,&len); - reg->reg[j].str[len]='\0'; - p +=len+1; //+1 to skip the '\0' between strings. - sscanf((char*)RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len); - reg->reg[j].value[len]='\0'; - p +=len+1; - } - reg->reg_num=j; - - inter_accreg_tosql(RFIFOL(fd,4),RFIFOL(fd,8),reg, RFIFOB(fd,12)); - mapif_account_reg(fd,RFIFOP(fd,0)); // Send updated accounts to other map servers. - return 0; -} - -// Request the value of all registries. -int mapif_parse_RegistryRequest(int fd) -{ - //Load Char Registry - if (RFIFOB(fd,12)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3); - //Load Account Registry - if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2); - //Ask Login Server for Account2 values. - if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6)); - return 1; -} - -static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name) -{ - WFIFOHEAD(fd, NAME_LENGTH+13); - WFIFOW(fd, 0) = 0x3806; - WFIFOL(fd, 2) = account_id; - WFIFOL(fd, 6) = char_id; - WFIFOB(fd,10) = type; - WFIFOB(fd,11) = flag; - memcpy(WFIFOP(fd, 12), name, NAME_LENGTH); - WFIFOSET(fd, NAME_LENGTH+13); -} - -int mapif_parse_NameChangeRequest(int fd) -{ - int account_id, char_id, type; - char* name; - int i; - - account_id = RFIFOL(fd,2); - char_id = RFIFOL(fd,6); - type = RFIFOB(fd,10); - name = (char*)RFIFOP(fd,11); - - // Check Authorised letters/symbols in the name - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) == NULL) { - mapif_namechange_ack(fd, account_id, char_id, type, 0, name); - return 0; - } - } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; i < NAME_LENGTH && name[i]; i++) - if (strchr(char_name_letters, name[i]) != NULL) { - mapif_namechange_ack(fd, account_id, char_id, type, 0, name); - return 0; - } - } - //TODO: type holds the type of object to rename. - //If it were a player, it needs to have the guild information and db information - //updated here, because changing it on the map won't make it be saved [Skotlex] - - //name allowed. - mapif_namechange_ack(fd, account_id, char_id, type, 1, name); - return 0; -} - -//-------------------------------------------------------- - -/// Returns the length of the next complete packet to process, -/// or 0 if no complete packet exists in the queue. -/// -/// @param length The minimum allowed length, or -1 for dynamic lookup -int inter_check_length(int fd, int length) -{ - if( length == -1 ) - {// variable-length packet - if( RFIFOREST(fd) < 4 ) - return 0; - length = RFIFOW(fd,2); - } - - if( (int)RFIFOREST(fd) < length ) - return 0; - - return length; -} - -int inter_parse_frommap(int fd) -{ - int cmd; - int len = 0; - cmd = RFIFOW(fd,0); - // interŽIŠÇŠ‚©‚𒲂ׂé - if(cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length) || inter_recv_packet_length[cmd - 0x3000] == 0) - return 0; - - // ƒpƒPƒbƒg’·‚𒲂ׂé - if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0) - return 2; - - switch(cmd) { - case 0x3000: mapif_parse_broadcast(fd); break; - case 0x3001: mapif_parse_WisRequest(fd); break; - case 0x3002: mapif_parse_WisReply(fd); break; - case 0x3003: mapif_parse_WisToGM(fd); break; - case 0x3004: mapif_parse_Registry(fd); break; - case 0x3005: mapif_parse_RegistryRequest(fd); break; - case 0x3006: mapif_parse_NameChangeRequest(fd); break; - default: - if( inter_party_parse_frommap(fd) - || inter_guild_parse_frommap(fd) - || inter_storage_parse_frommap(fd) - || inter_pet_parse_frommap(fd) - || inter_homunculus_parse_frommap(fd) - || inter_mercenary_parse_frommap(fd) - || inter_mail_parse_frommap(fd) - || inter_auction_parse_frommap(fd) - || inter_quest_parse_frommap(fd) - ) - break; - else - return 0; - } - - RFIFOSKIP(fd, len); - return 1; -} - -#endif //TXT_SQL_CONVERT diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h deleted file mode 100644 index ac2e1785f..000000000 --- a/src/char_sql/inter.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INTER_SQL_H_ -#define _INTER_SQL_H_ - -struct accreg; -#include "../common/sql.h" - -int inter_init_sql(const char *file); -void inter_final(void); -int inter_parse_frommap(int fd); -int inter_mapif_init(int fd); -int mapif_send_gmaccounts(void); -int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); - -int inter_log(char *fmt,...); - -#define inter_cfgName "conf/inter_athena.conf" - -extern unsigned int party_share_level; - -extern Sql* sql_handle; -extern Sql* lsql_handle; - -extern char main_chat_nick[16]; - -int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); - -#endif /* _INTER_SQL_H_ */ diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt index eabc47eac..fa657f8fd 100644 --- a/src/login/CMakeLists.txt +++ b/src/login/CMakeLists.txt @@ -3,12 +3,10 @@ # setup # set( LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) -set( TXT_LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) set( SQL_LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) # # targets # -add_subdirectory( txt ) add_subdirectory( sql ) diff --git a/src/login/Makefile.in b/src/login/Makefile.in index dd7bc3b48..7dfe085c0 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -18,8 +18,6 @@ MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar LOGIN_OBJ = login.o -LOGIN_TXT_OBJ = $(LOGIN_OBJ:%=obj_txt/%) \ - obj_txt/account_txt.o obj_txt/ipban_txt.o obj_txt/loginlog_txt.o LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \ obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o LOGIN_H = login.h account.h ipban.h loginlog.h @@ -30,26 +28,22 @@ ifeq ($(HAVE_MYSQL),yes) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif -LOGIN_SERVER_TXT_DEPENDS=obj_txt $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @SET_MAKE@ ##################################################################### -.PHONY :all txt sql clean help +.PHONY :all sql clean help -all: txt sql - -txt: obj_txt login-server +all: sql sql: obj_sql login-server_sql clean: - rm -rf *.o obj_txt obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ + rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ help: - @echo "possible targets are 'sql' 'txt' 'all' 'clean' 'help'" + @echo "possible targets are 'sql' 'all' 'clean' 'help'" @echo "'sql' - login server (SQL version)" - @echo "'txt' - login server (TXT version)" @echo "'all' - builds all above targets" @echo "'clean' - cleans builds and objects" @echo "'help' - outputs this message" @@ -61,29 +55,23 @@ needs_mysql: @exit 1 # object directories -obj_txt: - test -d obj_txt || mkdir obj_txt obj_sql: test -d obj_sql || mkdir obj_sql #executables -login-server: $(LOGIN_SERVER_TXT_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@ # login object files -obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_TXT @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files ../common/obj_all/%.o: - @$(MAKE) -C ../common txt + @$(MAKE) -C ../common sql ../common/obj_sql/%.o: @$(MAKE) -C ../common sql diff --git a/src/login/account.h b/src/login/account.h index 650f2c661..170d60aca 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -12,12 +12,8 @@ typedef struct AccountDBIterator AccountDBIterator; // standard engines -#ifdef WITH_TXT -AccountDB* account_db_txt(void); -#endif -#ifdef WITH_SQL AccountDB* account_db_sql(void); -#endif + // extra engines (will probably use the other txt functions) #define ACCOUNTDB_CONSTRUCTOR_(engine) account_db_##engine #define ACCOUNTDB_CONSTRUCTOR(engine) ACCOUNTDB_CONSTRUCTOR_(engine) diff --git a/src/login/account_txt.c b/src/login/account_txt.c deleted file mode 100644 index 79e22ac3b..000000000 --- a/src/login/account_txt.c +++ /dev/null @@ -1,645 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/db.h" -#include "../common/lock.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "account.h" -#include -#include -#include - -/// global defines -#define ACCOUNT_TXT_DB_VERSION 20110114 -#define AUTHS_BEFORE_SAVE 10 // flush every 10 saves -#define AUTH_SAVING_INTERVAL 60000 // flush every 10 minutes - -/// internal structure -typedef struct AccountDB_TXT -{ - AccountDB vtable; // public interface - - DBMap* accounts; // in-memory accounts storage - int next_account_id; // auto_increment - int auths_before_save; // prevents writing to disk too often - int save_timer; // save timer id - - char account_db[1024]; // account data storage file - bool case_sensitive; // how to look up usernames - -} AccountDB_TXT; - -/// internal structure -typedef struct AccountDBIterator_TXT -{ - AccountDBIterator vtable; // public interface - - DBIterator* iter; -} AccountDBIterator_TXT; - -/// internal functions -static bool account_db_txt_init(AccountDB* self); -static void account_db_txt_destroy(AccountDB* self); -static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen); -static bool account_db_txt_set_property(AccountDB* self, const char* option, const char* value); -static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc); -static bool account_db_txt_remove(AccountDB* self, const int account_id); -static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc); -static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id); -static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid); -static AccountDBIterator* account_db_txt_iterator(AccountDB* self); -static void account_db_txt_iter_destroy(AccountDBIterator* self); -static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc); - -static bool mmo_auth_fromstr(struct mmo_account* acc, char* str, unsigned int version); -static bool mmo_auth_tostr(const struct mmo_account* acc, char* str); -static void mmo_auth_sync(AccountDB_TXT* self); -static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr_t data); - -/// public constructor -AccountDB* account_db_txt(void) -{ - AccountDB_TXT* db = (AccountDB_TXT*)aCalloc(1, sizeof(AccountDB_TXT)); - - // set up the vtable - db->vtable.init = &account_db_txt_init; - db->vtable.destroy = &account_db_txt_destroy; - db->vtable.get_property = &account_db_txt_get_property; - db->vtable.set_property = &account_db_txt_set_property; - db->vtable.save = &account_db_txt_save; - db->vtable.create = &account_db_txt_create; - db->vtable.remove = &account_db_txt_remove; - db->vtable.load_num = &account_db_txt_load_num; - db->vtable.load_str = &account_db_txt_load_str; - db->vtable.iterator = &account_db_txt_iterator; - - // initialize to default values - db->accounts = NULL; - db->next_account_id = START_ACCOUNT_NUM; - db->auths_before_save = AUTHS_BEFORE_SAVE; - db->save_timer = INVALID_TIMER; - safestrncpy(db->account_db, "save/account.txt", sizeof(db->account_db)); - db->case_sensitive = false; - - return &db->vtable; -} - - -/* ------------------------------------------------------------------------- */ - - -/// opens accounts file, loads it, and starts a periodic saving timer -static bool account_db_txt_init(AccountDB* self) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts; - FILE* fp; - char line[2048]; - unsigned int version = 0; - - // create accounts database - db->accounts = idb_alloc(DB_OPT_RELEASE_DATA); - accounts = db->accounts; - - // open data file - fp = fopen(db->account_db, "r"); - if( fp == NULL ) - { - // no account file -> no account -> no login, including char-server (ERROR) - ShowError(CL_RED"account_db_txt_init: Accounts file [%s] not found."CL_RESET"\n", db->account_db); - return false; - } - - // load data file - while( fgets(line, sizeof(line), fp) != NULL ) - { - int account_id, n; - unsigned int v; - struct mmo_account acc; - struct mmo_account* tmp; - struct DBIterator* iter; - int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp; - - if( line[0] == '/' && line[1] == '/' ) - continue; - - n = 0; - if( sscanf(line, "%d%n", &v, &n) == 1 && (line[n] == '\n' || line[n] == '\r') ) - {// format version definition - version = v; - continue; - } - - n = 0; - if( sscanf(line, "%d\t%%newid%%%n", &account_id, &n) == 1 && (line[n] == '\n' || line[n] == '\r') ) - {// auto-increment - if( account_id > db->next_account_id ) - db->next_account_id = account_id; - continue; - } - - if( !mmo_auth_fromstr(&acc, line, version) ) - { - ShowError("account_db_txt_init: skipping invalid data: %s", line); - continue; - } - - // apply constraints & checks here - if( acc.sex != 'S' && (acc.account_id < START_ACCOUNT_NUM || acc.account_id > END_ACCOUNT_NUM) ) - ShowWarning("account_db_txt_init: account %d:'%s' has ID outside of the defined range for accounts (min:%d max:%d)!\n", acc.account_id, acc.userid, START_ACCOUNT_NUM, END_ACCOUNT_NUM); - - iter = accounts->iterator(accounts); - for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) ) - if( compare(acc.userid, tmp->userid) == 0 ) - break; - iter->destroy(iter); - - if( tmp != NULL ) - {// entry with identical username - ShowWarning("account_db_txt_init: account %d:'%s' has same username as account %d. The account will be inaccessible!\n", acc.account_id, acc.userid, tmp->account_id); - } - - if( idb_get(accounts, acc.account_id) != NULL ) - {// account id already occupied - ShowError("account_db_txt_init: ID collision for account id %d! Discarding data for account '%s'...\n", acc.account_id, acc.userid); - continue; - } - - // record entry in db - tmp = (struct mmo_account*)aMalloc(sizeof(struct mmo_account)); - memcpy(tmp, &acc, sizeof(struct mmo_account)); - idb_put(accounts, acc.account_id, tmp); - - if( acc.account_id >= db->next_account_id ) - db->next_account_id = acc.account_id + 1; - } - - // close data file - fclose(fp); - - // initialize data saving timer - add_timer_func_list(mmo_auth_sync_timer, "mmo_auth_sync_timer"); - db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (intptr_t)db, AUTH_SAVING_INTERVAL); - - return true; -} - -/// flush accounts db, close savefile and deallocate structures -static void account_db_txt_destroy(AccountDB* self) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - - // stop saving timer - delete_timer(db->save_timer, mmo_auth_sync_timer); - - // write data - mmo_auth_sync(db); - - // delete accounts database - accounts->destroy(accounts, NULL); - db->accounts = NULL; - - // delete entire structure - aFree(db); -} - -/// Gets a property from this database. -static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - const char* signature = "account.txt."; - - if( strcmp(key, "engine.name") == 0 ) - { - safesnprintf(buf, buflen, "txt"); - return true; - } - if( strcmp(key, "engine.version") == 0 ) - { - safesnprintf(buf, buflen, "%d", ACCOUNT_TXT_DB_VERSION); - return true; - } - if( strcmp(key, "engine.comment") == 0 ) - { - safesnprintf(buf, buflen, "TXT Account Database %d", ACCOUNT_TXT_DB_VERSION); - return true; - } - - if( strncmp(key, signature, strlen(signature)) != 0 ) - return false; - - key += strlen(signature); - - if( strcmpi(key, "account_db") == 0 ) - safesnprintf(buf, buflen, "%s", db->account_db); - else if( strcmpi(key, "case_sensitive") == 0 ) - safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0)); - else - return false;// not found - - return true; -} - -/// Sets a property in this database. -static bool account_db_txt_set_property(AccountDB* self, const char* key, const char* value) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - const char* signature = "account.txt."; - - if( strncmp(key, signature, strlen(signature)) != 0 ) - return false; - - key += strlen(signature); - - if( strcmpi(key, "account_db") == 0 ) - safestrncpy(db->account_db, value, sizeof(db->account_db)); - else if( strcmpi(key, "case_sensitive") == 0 ) - db->case_sensitive = config_switch(value); - else // no match - return false; - - return true; -} - -/// Add a new entry for this account to the account db and save it. -/// If acc->account_id is -1, the account id will be auto-generated, -/// and its value will be written to acc->account_id if everything succeeds. -static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - struct mmo_account* tmp; - - // decide on the account id to assign - int account_id = ( acc->account_id != -1 ) ? acc->account_id : db->next_account_id; - - // absolute maximum - if( account_id > END_ACCOUNT_NUM ) - return false; - - // check if the account_id is free - tmp = (struct mmo_account*)idb_get(accounts, account_id); - if( tmp != NULL ) - {// error condition - entry already present - ShowError("account_db_txt_create: cannot create account %d:'%s', this id is already occupied by %d:'%s'!\n", account_id, acc->userid, account_id, tmp->userid); - return false; - } - - // copy the data and store it in the db - CREATE(tmp, struct mmo_account, 1); - memcpy(tmp, acc, sizeof(struct mmo_account)); - tmp->account_id = account_id; - idb_put(accounts, account_id, tmp); - - // increment the auto_increment value - if( account_id >= db->next_account_id ) - db->next_account_id = account_id + 1; - - // flush data - mmo_auth_sync(db); - - // write output - acc->account_id = account_id; - - return true; -} - -/// find an existing entry for this account id and delete it -static bool account_db_txt_remove(AccountDB* self, const int account_id) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - - //TODO: find out if this really works - struct mmo_account* tmp = (struct mmo_account*)idb_remove(accounts, account_id); - if( tmp == NULL ) - {// error condition - entry not present - ShowError("account_db_txt_remove: no such account with id %d\n", account_id); - return false; - } - - // flush data - mmo_auth_sync(db); - - return true; -} - -/// rewrite the data stored in the account_db with the one provided -static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - int account_id = acc->account_id; - - // retrieve previous data - struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id); - if( tmp == NULL ) - {// error condition - entry not found - return false; - } - - // overwrite with new data - memcpy(tmp, acc, sizeof(struct mmo_account)); - - // modify save counter and save if needed - if( --db->auths_before_save == 0 ) - mmo_auth_sync(db); - - return true; -} - -/// retrieve data from db and store it in the provided data structure -static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - - // retrieve data - struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id); - if( tmp == NULL ) - {// entry not found - return false; - } - - // store it - memcpy(acc, tmp, sizeof(struct mmo_account)); - - return true; -} - -/// retrieve data from db and store it in the provided data structure -static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - - // retrieve data - struct DBIterator* iter = accounts->iterator(accounts); - struct mmo_account* tmp; - int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp; - - for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) ) - if( compare(userid, tmp->userid) == 0 ) - break; - iter->destroy(iter); - - if( tmp == NULL ) - {// entry not found - return false; - } - - // store it - memcpy(acc, tmp, sizeof(struct mmo_account)); - - return true; -} - - -/// Returns a new forward iterator. -static AccountDBIterator* account_db_txt_iterator(AccountDB* self) -{ - AccountDB_TXT* db = (AccountDB_TXT*)self; - DBMap* accounts = db->accounts; - AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)aCalloc(1, sizeof(AccountDBIterator_TXT)); - - // set up the vtable - iter->vtable.destroy = &account_db_txt_iter_destroy; - iter->vtable.next = &account_db_txt_iter_next; - - // fill data - iter->iter = db_iterator(accounts); - - return &iter->vtable; -} - - -/// Destroys this iterator, releasing all allocated memory (including itself). -static void account_db_txt_iter_destroy(AccountDBIterator* self) -{ - AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self; - dbi_destroy(iter->iter); - aFree(iter); -} - - -/// Fetches the next account in the database. -static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc) -{ - AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self; - struct mmo_account* tmp = (struct mmo_account*)dbi_next(iter->iter); - if( dbi_exists(iter->iter) ) - { - memcpy(acc, tmp, sizeof(struct mmo_account)); - return true; - } - return false; -} - - -/// parse input string into the provided account data structure -static bool mmo_auth_fromstr(struct mmo_account* a, char* str, unsigned int version) -{ - char* fields[32]; - int count; - char* regs; - int i, n; - - // zero out the destination first - memset(a, 0x00, sizeof(struct mmo_account)); - - // defaults for older format versions - safestrncpy(a->birthdate, "0000-00-00", sizeof(a->birthdate)); - - // extract tab-separated columns from line - count = sv_split(str, strlen(str), 0, '\t', fields, ARRAYLENGTH(fields), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF)); - - if( version == ACCOUNT_TXT_DB_VERSION && count == 14 ) - { - a->account_id = strtol(fields[1], NULL, 10); - safestrncpy(a->userid, fields[2], sizeof(a->userid)); - safestrncpy(a->pass, fields[3], sizeof(a->pass)); - a->sex = fields[4][0]; - safestrncpy(a->email, fields[5], sizeof(a->email)); - a->level = strtoul(fields[6], NULL, 10); - a->state = strtoul(fields[7], NULL, 10); - a->unban_time = strtol(fields[8], NULL, 10); - a->expiration_time = strtol(fields[9], NULL, 10); - a->logincount = strtoul(fields[10], NULL, 10); - safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin)); - safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip)); - safestrncpy(a->birthdate, fields[13], sizeof(a->birthdate)); - regs = fields[14]; - } - else - if( version == 20080409 && count == 13 ) - { - a->account_id = strtol(fields[1], NULL, 10); - safestrncpy(a->userid, fields[2], sizeof(a->userid)); - safestrncpy(a->pass, fields[3], sizeof(a->pass)); - a->sex = fields[4][0]; - safestrncpy(a->email, fields[5], sizeof(a->email)); - a->level = strtoul(fields[6], NULL, 10); - a->state = strtoul(fields[7], NULL, 10); - a->unban_time = strtol(fields[8], NULL, 10); - a->expiration_time = strtol(fields[9], NULL, 10); - a->logincount = strtoul(fields[10], NULL, 10); - safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin)); - safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip)); - regs = fields[13]; - } - else - if( version == 0 && count == 14 ) - { - a->account_id = strtol(fields[1], NULL, 10); - safestrncpy(a->userid, fields[2], sizeof(a->userid)); - safestrncpy(a->pass, fields[3], sizeof(a->pass)); - safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); - a->sex = fields[5][0]; - a->logincount = strtoul(fields[6], NULL, 10); - a->state = strtoul(fields[7], NULL, 10); - safestrncpy(a->email, fields[8], sizeof(a->email)); - //safestrncpy(a->error_message, fields[9], sizeof(a->error_message)); - a->expiration_time = strtol(fields[10], NULL, 10); - safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip)); - //safestrncpy(a->memo, fields[12], sizeof(a->memo)); - a->unban_time = strtol(fields[13], NULL, 10); - regs = fields[14]; - } - else - if( version == 0 && count == 13 ) - { - a->account_id = strtol(fields[1], NULL, 10); - safestrncpy(a->userid, fields[2], sizeof(a->userid)); - safestrncpy(a->pass, fields[3], sizeof(a->pass)); - safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); - a->sex = fields[5][0]; - a->logincount = strtoul(fields[6], NULL, 10); - a->state = strtoul(fields[7], NULL, 10); - safestrncpy(a->email, fields[8], sizeof(a->email)); - //safestrncpy(a->error_message, fields[9], sizeof(a->error_message)); - a->expiration_time = strtol(fields[10], NULL, 10); - safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip)); - //safestrncpy(a->memo, fields[12], sizeof(a->memo)); - regs = fields[13]; - } - else - if( version == 0 && count == 8 ) - { - a->account_id = strtol(fields[1], NULL, 10); - safestrncpy(a->userid, fields[2], sizeof(a->userid)); - safestrncpy(a->pass, fields[3], sizeof(a->pass)); - safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin)); - a->sex = fields[5][0]; - a->logincount = strtoul(fields[6], NULL, 10); - a->state = strtoul(fields[7], NULL, 10); - regs = fields[8]; - } - else - {// unmatched row - return false; - } - - // extract account regs - // {reg namereg value}* - n = 0; - for( i = 0; i < ACCOUNT_REG2_NUM; ++i ) - { - char key[32]; - char value[256]; - - regs += n; - - if (sscanf(regs, "%31[^\t,],%255[^\t ] %n", key, value, &n) != 2) - { - // We must check if a str is void. If it's, we can continue to read other REG2. - // Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good) - if (regs[0] == ',' && sscanf(regs, ",%[^\t ] %n", value, &n) == 1) { - i--; - continue; - } else - break; - } - - safestrncpy(a->account_reg2[i].str, key, 32); - safestrncpy(a->account_reg2[i].value, value, 256); - } - a->account_reg2_num = i; - - return true; -} - -/// dump the contents of the account data structure into the provided string buffer -static bool mmo_auth_tostr(const struct mmo_account* a, char* str) -{ - int i; - char* str_p = str; - - str_p += sprintf(str_p, "%d\t%s\t%s\t%c\t%s\t%u\t%u\t%ld\t%ld\t%u\t%s\t%s\t%s\t", - a->account_id, a->userid, a->pass, a->sex, a->email, a->level, - a->state, (long)a->unban_time, (long)a->expiration_time, - a->logincount, a->lastlogin, a->last_ip, a->birthdate); - - for( i = 0; i < a->account_reg2_num; ++i ) - if( a->account_reg2[i].str[0] ) - str_p += sprintf(str_p, "%s,%s ", a->account_reg2[i].str, a->account_reg2[i].value); - - return true; -} - -/// dump the entire account db to disk -static void mmo_auth_sync(AccountDB_TXT* db) -{ - int lock; - FILE *fp; - struct DBIterator* iter; - struct mmo_account* acc; - - fp = lock_fopen(db->account_db, &lock); - if( fp == NULL ) - { - return; - } - - fprintf(fp, "%d\n", ACCOUNT_TXT_DB_VERSION); // savefile version - - fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n"); - fprintf(fp, "// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, birth date, repeated(register key, register value)\n"); - fprintf(fp, "// where:\n"); - fprintf(fp, "// sex : M or F for normal accounts, S for server accounts\n"); - fprintf(fp, "// level : this account's gm level\n"); - fprintf(fp, "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n"); - fprintf(fp, "// unban time : 0: no ban, : banned until the date (unix timestamp)\n"); - fprintf(fp, "// expiration time : 0: unlimited account, : account expires on the date (unix timestamp)\n"); - - //TODO: sort? - - iter = db->accounts->iterator(db->accounts); - for( acc = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); acc = (struct mmo_account*)iter->next(iter,NULL) ) - { - char buf[2048]; // ought to be big enough ^^ - mmo_auth_tostr(acc, buf); - fprintf(fp, "%s\n", buf); - } - fprintf(fp, "%d\t%%newid%%\n", db->next_account_id); - iter->destroy(iter); - - lock_fclose(fp, db->account_db, &lock); - - // reset save counter - db->auths_before_save = AUTHS_BEFORE_SAVE; -} - -static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - AccountDB_TXT* db = (AccountDB_TXT*)data; - - if( db->auths_before_save < AUTHS_BEFORE_SAVE ) - mmo_auth_sync(db); // db was modified, flush it - - return 0; -} diff --git a/src/login/ipban_txt.c b/src/login/ipban_txt.c deleted file mode 100644 index 6fee15c28..000000000 --- a/src/login/ipban_txt.c +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/strlib.h" -#include "login.h" -#include "ipban.h" -#include -#include - -void ipban_init(void) -{ -} - -void ipban_final(void) -{ -} - -bool ipban_check(uint32 ip) -{ - return false; -} - -void ipban_log(uint32 ip) -{ -} - -bool ipban_config_read(const char* key, const char* value) -{ - // login server settings - if( strcmpi(key, "ipban.enable") == 0 ) - login_config.ipban = (bool)config_switch(value); - else - if( strcmpi(key, "ipban.dynamic_pass_failure_ban") == 0 ) - login_config.dynamic_pass_failure_ban = (bool)config_switch(value); - else - if( strcmpi(key, "ipban.dynamic_pass_failure_ban_interval") == 0 ) - login_config.dynamic_pass_failure_ban_interval = atoi(value); - else - if( strcmpi(key, "ipban.dynamic_pass_failure_ban_limit") == 0 ) - login_config.dynamic_pass_failure_ban_limit = atoi(value); - else - if( strcmpi(key, "ipban.dynamic_pass_failure_ban_duration") == 0 ) - login_config.dynamic_pass_failure_ban_duration = atoi(value); - else - return false; - - return true; -} - diff --git a/src/login/login.c b/src/login/login.c index 53f36c270..e2c16eaed 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -30,12 +30,7 @@ static struct{ AccountDB* (*constructor)(void); AccountDB* db; } account_engines[] = { -#ifdef WITH_TXT - {account_db_txt, NULL}, -#endif -#ifdef WITH_SQL {account_db_sql, NULL}, -#endif #ifdef ACCOUNTDB_ENGINE_0 {ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_0), NULL}, #endif diff --git a/src/login/loginlog_txt.c b/src/login/loginlog_txt.c deleted file mode 100644 index 76ad08c54..000000000 --- a/src/login/loginlog_txt.c +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/core.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "account.h" -#include "login.h" - -#include -#include -#include - -char login_log_filename[1024] = "log/login.log"; - - -// Returns the number of failed login attemps by the ip in the last minutes. -unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) -{ - // XXX not implemented - return 0; -} - - -/*============================================= - * Records an event in the login log - *---------------------------------------------*/ -void login_log(uint32 ip, const char* username, int rcode, const char* message) -{ - FILE* log_fp; - - if( !login_config.log_login ) - return; - - log_fp = fopen(login_log_filename, "a"); - if( log_fp != NULL ) - { - char esc_username[NAME_LENGTH*4+1]; - char esc_message[255*4+1]; - time_t raw_time; - char str_time[24]; - - sv_escape_c(esc_username, username, safestrnlen(username,NAME_LENGTH), NULL); - sv_escape_c(esc_message, message, safestrnlen(message,255), NULL); - - time(&raw_time); - strftime(str_time, 24, login_config.date_format, localtime(&raw_time)); - str_time[23] = '\0'; - - fprintf(log_fp, "%s\t%s\t%s\t%d\t%s\n", str_time, ip2str(ip,NULL), esc_username, rcode, esc_message); - - fclose(log_fp); - } -} - - -bool loginlog_config_read(const char* w1, const char* w2) -{ - if(!strcmpi(w1, "login_log_filename")) - safestrncpy(login_log_filename, w2, sizeof(login_log_filename)); - else - return false; - - return true; -} - - -bool loginlog_init(void) -{ - return true; -} - - -bool loginlog_final(void) -{ - return true; -} diff --git a/src/login/txt/CMakeLists.txt b/src/login/txt/CMakeLists.txt deleted file mode 100644 index 1df5b32a9..000000000 --- a/src/login/txt/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ - -# -# login txt -# -if( BUILD_TXT_SERVERS ) -message( STATUS "Creating target login-server" ) -set( TXT_LOGIN_HEADERS - "${TXT_LOGIN_SOURCE_DIR}/account.h" - "${TXT_LOGIN_SOURCE_DIR}/ipban.h" - "${TXT_LOGIN_SOURCE_DIR}/login.h" - "${TXT_LOGIN_SOURCE_DIR}/loginlog.h" - ) -set( TXT_LOGIN_SOURCES - "${TXT_LOGIN_SOURCE_DIR}/account_txt.c" - "${TXT_LOGIN_SOURCE_DIR}/ipban_txt.c" - "${TXT_LOGIN_SOURCE_DIR}/login.c" - "${TXT_LOGIN_SOURCE_DIR}/loginlog_txt.c" - ) -set( DEPENDENCIES common_base ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DWITH_TXT" ) -set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_LOGIN_HEADERS} ${TXT_LOGIN_SOURCES} ) -source_group( common FILES ${COMMON_BASE_HEADERS} ) -source_group( login FILES ${TXT_LOGIN_HEADERS} ${TXT_LOGIN_SOURCES} ) -include_directories( ${INCLUDE_DIRS} ) -add_executable( login-server ${SOURCE_FILES} ) -add_dependencies( login-server ${DEPENDENCIES} ) -target_link_libraries( login-server ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( login-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_loginserver_txt DESCRIPTION "login-server (txt version)" DISPLAY_NAME "login-server" GROUP Runtime ) - install( TARGETS login-server - DESTINATION "." - COMPONENT Runtime_loginserver_txt ) -endif( INSTALL_COMPONENT_RUNTIME ) -set( TARGET_LIST ${TARGET_LIST} login-server CACHE INTERNAL "" ) -message( STATUS "Creating target login-server - done" ) -endif( BUILD_TXT_SERVERS ) diff --git a/src/map/CMakeLists.txt b/src/map/CMakeLists.txt index 1d82fc2ca..51c3538ef 100644 --- a/src/map/CMakeLists.txt +++ b/src/map/CMakeLists.txt @@ -3,12 +3,10 @@ # setup # set( MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) -set( TXT_MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) set( SQL_MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) # # targets # -add_subdirectory( txt ) add_subdirectory( sql ) diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 3f64942e0..dc0e48bf9 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -25,8 +25,6 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \ intif.o trade.o party.o vending.o guild.o pet.o \ log.o mail.o date.o unit.o homunculus.o mercenary.o quest.o instance.o \ buyingstore.o searchstore.o duel.o -MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) \ - obj_txt/mapreg_txt.o MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \ obj_sql/mapreg_sql.o MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ @@ -95,22 +93,18 @@ obj_sql: -mkdir obj_sql # executables -map-server: obj_txt $(MAP_TXT_OBJ) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ @PCRE_LIBS@ map-server_sql: obj_sql $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files -obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files ../common/obj_all/%.o: - @$(MAKE) -C ../common txt + @$(MAKE) -C ../common sql ../common/obj_sql/%.o: @$(MAKE) -C ../common sql diff --git a/src/map/atcommand.c b/src/map/atcommand.c index ab5d632ff..de5d4549b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -30,6 +30,7 @@ #include "npc.h" #include "pet.h" #include "homunculus.h" +#include "mail.h" #include "mercenary.h" #include "party.h" #include "guild.h" @@ -38,9 +39,6 @@ #include "trade.h" #include "unit.h" -#ifndef TXT_ONLY -#include "mail.h" -#endif #include #include @@ -4333,9 +4331,7 @@ ACMD_FUNC(reloadbattleconf) ) { // Exp or Drop rates changed. mob_reload(); //Needed as well so rate changes take effect. -#ifndef TXT_ONLY chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); -#endif } clif_displaymessage(fd, msg_txt(255)); return 0; @@ -7112,9 +7108,7 @@ ACMD_FUNC(misceffect) ACMD_FUNC(mail) { nullpo_ret(sd); -#ifndef TXT_ONLY mail_openmail(sd); -#endif return 0; } @@ -8434,9 +8428,7 @@ ACMD_FUNC(auction) { nullpo_ret(sd); -#ifndef TXT_ONLY clif_Auction_openwindow(sd); -#endif return 0; } diff --git a/src/map/chrif.c b/src/map/chrif.c index ebafdf0da..03b4baeb0 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -225,11 +225,7 @@ void chrif_checkdefaultlogin(void) { if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) { ShowError("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); -#ifdef TXT_ONLY - ShowNotice("Please edit your save/account.txt file to create a proper inter-server user/password (gender 'S')\n"); -#else ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); -#endif ShowNotice("and then edit your user/password in conf/map_athena.conf (or conf/import/map_conf.txt)\n"); } } @@ -312,10 +308,8 @@ int chrif_save(struct map_session_data *sd, int flag) merc_save(sd->hd); if( sd->md && mercenary_get_lifetime(sd->md) > 0 ) mercenary_save(sd->md); -#ifndef TXT_ONLY if( sd->save_quest ) intif_quest_save(sd); -#endif return 0; } @@ -1536,16 +1530,12 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_ chrif_connect(char_fd); chrif_connected = (chrif_state == 2); -#ifndef TXT_ONLY srvinfo = 0; -#endif /* not TXT_ONLY */ } else { -#ifndef TXT_ONLY if (srvinfo == 0) { chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); srvinfo = 1; } -#endif /* not TXT_ONLY */ } if (chrif_isconnected()) displayed = 0; return 0; @@ -1555,7 +1545,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_ * Asks char server to remove friend_id from the friend list of char_id *------------------------------------------*/ int chrif_removefriend(int char_id, int friend_id) { -#ifndef TXT_ONLY + chrif_check(-1); WFIFOHEAD(char_fd,10); @@ -1563,7 +1553,7 @@ int chrif_removefriend(int char_id, int friend_id) { WFIFOL(char_fd,2) = char_id; WFIFOL(char_fd,6) = friend_id; WFIFOSET(char_fd,10); -#endif + return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 48aca796d..e102fc169 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8137,9 +8137,7 @@ void clif_refresh(struct map_session_data *sd) // unlike vending, resuming buyingstore crashes the client. buyingstore_close(sd); -#ifndef TXT_ONLY mail_clear(sd); -#endif } @@ -9205,9 +9203,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) sd->state.changemap = false; } -#ifndef TXT_ONLY mail_clear(sd); -#endif if(map[sd->bl.m].flag.loadevent) // Lance npc_script_event(sd, NPCE_LOADMAP); @@ -13425,7 +13421,6 @@ void clif_parse_Check(int fd, struct map_session_data *sd) } -#ifndef TXT_ONLY /// MAIL SYSTEM /// By Zephyrus @@ -14205,8 +14200,6 @@ void clif_parse_Auction_buysell(int fd, struct map_session_data* sd) intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1); } -#endif - /// CASH/POINT SHOP /// @@ -16515,7 +16508,6 @@ static int packetdb_readdb(void) {clif_parse_Check,"check"}, {clif_parse_Adopt_request,"adoptrequest"}, {clif_parse_Adopt_reply,"adoptreply"}, -#ifndef TXT_ONLY // MAIL SYSTEM {clif_parse_Mail_refreshinbox,"mailrefresh"}, {clif_parse_Mail_read,"mailread"}, @@ -16536,7 +16528,6 @@ static int packetdb_readdb(void) {clif_parse_Auction_bid,"auctionbid"}, // Quest Log System {clif_parse_questStateAck,"queststate"}, -#endif {clif_parse_cashshop_buy,"cashshopbuy"}, {clif_parse_ViewPlayerEquip,"viewplayerequip"}, {clif_parse_EquipTick,"equiptickbox"}, diff --git a/src/map/clif.h b/src/map/clif.h index efe85cefc..206b7d68e 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -641,7 +641,6 @@ void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, b int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type); int do_init_clif(void); -#ifndef TXT_ONLY // MAIL SYSTEM void clif_Mail_window(int fd, int flag); void clif_Mail_read(struct map_session_data *sd, int mail_id); @@ -657,7 +656,6 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages, void clif_Auction_message(int fd, unsigned char flag); void clif_Auction_close(int fd, unsigned char flag); void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd); -#endif void clif_bossmapinfo(int fd, struct mob_data *md, short flag); void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd); diff --git a/src/map/intif.c b/src/map/intif.c index 20623a146..51002f027 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1412,8 +1412,6 @@ int intif_quest_save(TBL_PC *sd) return 0; } -#ifndef TXT_ONLY - /*========================================== * MAIL SYSTEM * By Zephyrus @@ -1888,8 +1886,6 @@ static void intif_parse_Auction_message(int fd) clif_Auction_message(sd->fd, result); } -#endif - /*========================================== * Mercenary's System *------------------------------------------*/ @@ -2049,7 +2045,6 @@ int intif_parse(int fd) case 0x3860: intif_parse_questlog(fd); break; case 0x3861: intif_parse_questsave(fd); break; -#ifndef TXT_ONLY // Mail System case 0x3848: intif_parse_Mail_inboxreceived(fd); break; case 0x3849: intif_parse_Mail_new(fd); break; @@ -2064,7 +2059,7 @@ int intif_parse(int fd) case 0x3853: intif_parse_Auction_close(fd); break; case 0x3854: intif_parse_Auction_message(fd); break; case 0x3855: intif_parse_Auction_bid(fd); break; -#endif + // Mercenary System case 0x3870: intif_parse_mercenary_received(fd); break; case 0x3871: intif_parse_mercenary_deleted(fd); break; diff --git a/src/map/intif.h b/src/map/intif.h index 1df990108..88e1f1ce7 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -83,7 +83,6 @@ int intif_mercenary_request(int merc_id, int char_id); int intif_mercenary_delete(int merc_id); int intif_mercenary_save(struct s_mercenary *merc); -#ifndef TXT_ONLY // MAIL SYSTEM int intif_Mail_requestinbox(int char_id, unsigned char flag); int intif_Mail_read(int mail_id); @@ -97,7 +96,6 @@ int intif_Auction_register(struct auction_data *auction); int intif_Auction_cancel(int char_id, unsigned int auction_id); int intif_Auction_close(int char_id, unsigned int auction_id); int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid); -#endif int CheckForCharServer(void); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3c2e75810..8043c965d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -984,7 +984,6 @@ static int itemdb_readdb(void) return 0; } -#ifndef TXT_ONLY /*====================================== * item_db table reading *======================================*/ @@ -1034,18 +1033,15 @@ static int itemdb_read_sqldb(void) return 0; } -#endif /* not TXT_ONLY */ /*==================================== * read all item-related databases *------------------------------------*/ static void itemdb_read(void) { -#ifndef TXT_ONLY if (db_use_sqldbs) itemdb_read_sqldb(); else -#endif itemdb_readdb(); itemdb_read_itemgroup(); diff --git a/src/map/log.c b/src/map/log.c index fb1aa11a1..76497db3c 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -136,7 +136,6 @@ void log_branch(struct map_session_data* sd) if( !log_config.branch ) return; -#ifndef TXT_ONLY if( log_config.sql_logs ) { SqlStmt* stmt; @@ -152,7 +151,6 @@ void log_branch(struct map_session_data* sd) SqlStmt_Free(stmt); } else -#endif { char timestring[255]; time_t curtime; @@ -179,7 +177,6 @@ void log_pick(int id, int m, e_log_pick_type type, int amount, struct item* itm) if( !should_log_item(itm->nameid, amount, itm->refine) ) return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus] -#ifndef TXT_ONLY if( log_config.sql_logs ) { if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", @@ -190,7 +187,6 @@ void log_pick(int id, int m, e_log_pick_type type, int amount, struct item* itm) } } else -#endif { char timestring[255]; time_t curtime; @@ -228,7 +224,6 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) ) return; -#ifndef TXT_ONLY if( log_config.sql_logs ) { if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", @@ -239,7 +234,6 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess } } else -#endif { char timestring[255]; time_t curtime; @@ -263,7 +257,6 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp) if( !log_config.mvpdrop ) return; -#ifndef TXT_ONLY if( log_config.sql_logs ) { if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", @@ -274,7 +267,6 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp) } } else -#endif { char timestring[255]; time_t curtime; @@ -298,7 +290,6 @@ void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message) if( cmdlvl < log_config.gm ) return; -#ifndef TXT_ONLY if( log_config.sql_logs ) { SqlStmt* stmt; @@ -316,7 +307,6 @@ void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message) SqlStmt_Free(stmt); } else -#endif { char timestring[255]; time_t curtime; @@ -340,7 +330,6 @@ void log_npc(struct map_session_data* sd, const char* message) if( !log_config.npc ) return; -#ifndef TXT_ONLY if( log_config.sql_logs ) { SqlStmt* stmt; @@ -357,7 +346,6 @@ void log_npc(struct map_session_data* sd, const char* message) SqlStmt_Free(stmt); } else -#endif { char timestring[255]; time_t curtime; @@ -386,7 +374,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, return; } -#ifndef TXT_ONLY if( log_config.sql_logs ) { SqlStmt* stmt; @@ -404,7 +391,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, SqlStmt_Free(stmt); } else -#endif { char timestring[255]; time_t curtime; @@ -457,16 +443,7 @@ int log_config_read(const char* cfgName) if( strcmpi(w1, "enable_logs") == 0 ) log_config.enable_logs = (e_log_pick_type)config_switch(w2); else if( strcmpi(w1, "sql_logs") == 0 ) - { log_config.sql_logs = (bool)config_switch(w2); -#ifdef TXT_ONLY - if( log_config.sql_logs ) - { - ShowWarning("log_config_read: SQL logging is not supported on this server.\n"); - log_config.sql_logs = false; - } -#endif - } //start of common filter settings else if( strcmpi(w1, "rare_items_log") == 0 ) log_config.rare_items_log = atoi(w2); diff --git a/src/map/mail.c b/src/map/mail.c index d410faf28..bb1063fbf 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -1,8 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef TXT_ONLY - #include "../common/nullpo.h" #include "../common/showmsg.h" @@ -194,5 +192,3 @@ bool mail_invalid_operation(struct map_session_data *sd) return false; } - -#endif diff --git a/src/map/map.c b/src/map/map.c index fee813241..841e95df1 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -44,9 +44,7 @@ #include "mercenary.h" #include "atcommand.h" #include "log.h" -#ifndef TXT_ONLY #include "mail.h" -#endif #include #include #include @@ -56,7 +54,6 @@ #include #endif -#ifndef TXT_ONLY char default_codepage[32] = ""; int map_server_port = 3306; @@ -83,8 +80,6 @@ char log_db_pw[32] = "ragnarok"; char log_db_db[32] = "log"; Sql* logmysql_handle; -#endif /* not TXT_ONLY */ - // This param using for sending mainchat // messages like whispers to this nick. [LuzZza] char main_chat_nick[16] = "Main"; @@ -3240,8 +3235,6 @@ int inter_config_read(char *cfgName) if(strcmpi(w1, "main_chat_nick")==0) safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick)); - - #ifndef TXT_ONLY else if(strcmpi(w1,"item_db_db")==0) strcpy(item_db_db,w2); @@ -3295,7 +3288,6 @@ int inter_config_read(char *cfgName) else if(strcmpi(w1,"log_db_db")==0) strcpy(log_db_db, w2); - #endif else if( mapreg_config_read(w1,w2) ) continue; @@ -3309,7 +3301,6 @@ int inter_config_read(char *cfgName) return 0; } -#ifndef TXT_ONLY /*======================================= * MySQL Init *---------------------------------------*/ @@ -3363,8 +3354,6 @@ int log_sql_init(void) return 0; } -#endif /* not TXT_ONLY */ - int map_db_final(DBKey k,void *d,va_list ap) { struct map_data_other_server *mdos = (struct map_data_other_server*)d; @@ -3498,9 +3487,8 @@ void do_final(void) iwall_db->destroy(iwall_db, NULL); regen_db->destroy(regen_db, NULL); -#ifndef TXT_ONLY map_sql_close(); -#endif /* not TXT_ONLY */ + ShowStatus("Finished.\n"); } @@ -3762,11 +3750,9 @@ int do_init(int argc, char *argv[]) iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls -#ifndef TXT_ONLY map_sql_init(); if (log_config.sql_logs) log_sql_init(); -#endif /* not TXT_ONLY */ mapindex_init(); if(enable_grf) diff --git a/src/map/map.h b/src/map/map.h index afd7aa883..2dece688d 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -709,8 +709,6 @@ typedef struct mercenary_data TBL_MER; extern char main_chat_nick[16]; -#ifndef TXT_ONLY - #include "../common/sql.h" extern int db_use_sqldbs; @@ -726,8 +724,6 @@ extern char mob_db2_db[32]; extern char mob_skill_db_db[32]; extern char mob_skill_db2_db[32]; -#endif /* not TXT_ONLY */ - void do_shutdown(void); #endif /* _MAP_H_ */ diff --git a/src/map/mapreg_txt.c b/src/map/mapreg_txt.c deleted file mode 100644 index 95be201e2..000000000 --- a/src/map/mapreg_txt.c +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/lock.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "script.h" -#include -#include -#include - -static DBMap* mapreg_db = NULL; // int var_id -> int value -static DBMap* mapregstr_db = NULL; // int var_id -> char* value - -static char mapreg_txt[256] = "save/mapreg.txt"; -static bool mapreg_dirty = false; -#define MAPREG_AUTOSAVE_INTERVAL (300*1000) - - -/// Looks up the value of an integer variable using its uid. -int mapreg_readreg(int uid) -{ - return (int)idb_get(mapreg_db, uid); -} - -/// Looks up the value of a string variable using its uid. -char* mapreg_readregstr(int uid) -{ - return (char*)idb_get(mapregstr_db, uid); -} - -/// Modifies the value of an integer variable. -bool mapreg_setreg(int uid, int val) -{ - if( val != 0 ) - idb_put(mapreg_db,uid,(void*)val); - else - idb_remove(mapreg_db,uid); - - mapreg_dirty = true; - return true; -} - -/// Modifies the value of a string variable. -bool mapreg_setregstr(int uid, const char* str) -{ - if( str == NULL || *str == 0 ) - idb_remove(mapregstr_db,uid); - else - idb_put(mapregstr_db,uid,aStrdup(str)); - - mapreg_dirty = true; - return true; -} - -/// Loads permanent variables from savefile -static void script_load_mapreg(void) -{ - FILE* fp; - char line[1024]; - - fp = fopen(mapreg_txt,"rt"); - if( fp == NULL ) - return; - - while( fgets(line,sizeof(line),fp) ) - { - char varname[32+1]; - char value[255+1]; - int n,s,i; - - // read name and index - if( sscanf(line, "%32[^,],%d\t%n", varname,&i,&n) != 2 && - (i = 0, sscanf(line,"%[^\t]\t%n", varname,&n) != 1) ) - continue; - - // read value - if( sscanf(line + n, "%[^\n\r]", value) != 1 ) - { - ShowError("%s: %s broken data !\n", mapreg_txt, varname); - continue; - } - - s = add_str(varname); - if( varname[strlen(varname)-1] == '$' ) - idb_put(mapregstr_db, (i<<24)|s, aStrdup(value)); - else - idb_put(mapreg_db, (i<<24)|s, (void*)atoi(value)); - } - fclose(fp); - - mapreg_dirty = false; -} - -/// Saves permanent variables to savefile -static void script_save_mapreg(void) -{ - FILE *fp; - int lock; - DBIterator* iter; - void* data; - DBKey key; - - fp = lock_fopen(mapreg_txt,&lock); - if( fp == NULL ) - { - ShowError("script_save_mapreg: Unable to lock-open file [%s]!\n", mapreg_txt); - return; - } - - iter = mapreg_db->iterator(mapreg_db); - for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) - { - int num = (key.i & 0x00ffffff); - int i = (key.i & 0xff000000) >> 24; - const char* name = get_str(num); - - if( name[1] == '@' ) - continue; - - if( i == 0 ) - fprintf(fp, "%s\t%d\n", name, (int)data); - else - fprintf(fp, "%s,%d\t%d\n", name, i, (int)data); - } - iter->destroy(iter); - - iter = mapregstr_db->iterator(mapregstr_db); - for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) - { - int num = (key.i & 0x00ffffff); - int i = (key.i & 0xff000000) >> 24; - const char* name = get_str(num); - - if( name[1] == '@' ) - continue; - - if( i == 0 ) - fprintf(fp, "%s\t%s\n", name, (char *)data); - else - fprintf(fp, "%s,%d\t%s\n", name, i, (char *)data); - } - iter->destroy(iter); - - lock_fclose(fp,mapreg_txt,&lock); - - mapreg_dirty = false; -} - -static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) -{ - if( mapreg_dirty ) - script_save_mapreg(); - - return 0; -} - - -void mapreg_reload(void) -{ - if( mapreg_dirty ) - script_save_mapreg(); - - mapreg_db->clear(mapreg_db, NULL); - mapregstr_db->clear(mapregstr_db, NULL); - - script_load_mapreg(); -} - -void mapreg_final(void) -{ - if( mapreg_dirty ) - script_save_mapreg(); - - mapreg_db->destroy(mapreg_db,NULL); - mapregstr_db->destroy(mapregstr_db,NULL); -} - -void mapreg_init(void) -{ - mapreg_db = idb_alloc(DB_OPT_BASE); - mapregstr_db = idb_alloc(DB_OPT_RELEASE_DATA); - - script_load_mapreg(); - - add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); - add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); -} - -bool mapreg_config_read(const char* w1, const char* w2) -{ - if(!strcmpi(w1, "mapreg_txt")) - safestrncpy(mapreg_txt, w2, sizeof(mapreg_txt)); - else - return false; - - return true; -} diff --git a/src/map/mob.c b/src/map/mob.c index 6f0bd859d..acdfd5049 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3719,7 +3719,6 @@ static void mob_readdb(void) } } -#ifndef TXT_ONLY /*========================================== * mob_db table reading *------------------------------------------*/ @@ -3774,7 +3773,6 @@ static int mob_read_sqldb(void) } return 0; } -#endif /* not TXT_ONLY */ /*========================================== * MOB display graphic change data reading @@ -4301,7 +4299,6 @@ static void mob_readskilldb(void) { } } -#ifndef TXT_ONLY /** * mob_skill_db table reading [CalciumKid] * not overly sure if this is all correct @@ -4358,7 +4355,6 @@ static int mob_read_sqlskilldb(void) } return 0; } -#endif /* not TXT_ONLY */ /*========================================== * mob_race2_db.txt reading @@ -4393,14 +4389,12 @@ static bool mob_readdb_race2(char* fields[], int columns, int current) */ static void mob_load(void) { -#ifndef TXT_ONLY if (db_use_sqldbs) { mob_read_sqldb(); mob_read_sqlskilldb(); } else -#endif { mob_readdb(); mob_readskilldb(); diff --git a/src/map/pc.c b/src/map/pc.c index 17a695fff..3155484dd 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1188,10 +1188,8 @@ int pc_reg_received(struct map_session_data *sd) status_calc_pc(sd,1); chrif_scdata_request(sd->status.account_id, sd->status.char_id); -#ifndef TXT_ONLY intif_Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox intif_request_questlog(sd); -#endif if (sd->state.connect_new == 0 && sd->fd) { //Character already loaded map! Gotta trigger LoadEndAck manually. @@ -1199,9 +1197,8 @@ int pc_reg_received(struct map_session_data *sd) clif_parse_LoadEndAck(sd->fd, sd); } -#ifndef TXT_ONLY pc_inventory_rentals(sd); -#endif + return 1; } @@ -7962,15 +7959,10 @@ int pc_divorce(struct map_session_data *sd) if( (p_sd = map_charid2sd(sd->status.partner_id)) == NULL ) { // Lets char server do the divorce -#ifndef TXT_ONLY if( chrif_divorce(sd->status.char_id, sd->status.partner_id) ) return -1; // No char server connected return 0; -#else - ShowError("pc_divorce: p_sd nullpo\n"); - return -1; -#endif } // Both players online, lets do the divorce manually diff --git a/src/map/script.c b/src/map/script.c index c06a69a60..d9f2bc2e0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -13543,7 +13543,6 @@ BUILDIN_FUNC(setd) return 0; } -#ifndef TXT_ONLY int buildin_query_sql_sub(struct script_state* st, Sql* handle) { int i, j; @@ -13643,22 +13642,14 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) script_pushint(st, i); return 0; } -#endif BUILDIN_FUNC(query_sql) { -#ifndef TXT_ONLY return buildin_query_sql_sub(st, mmysql_handle); -#else - //for TXT version, we always return -1 - script_pushint(st,-1); - return 0; -#endif } BUILDIN_FUNC(query_logsql) { -#ifndef TXT_ONLY if( !log_config.sql_logs ) {// logmysql_handle == NULL ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2)); @@ -13667,11 +13658,6 @@ BUILDIN_FUNC(query_logsql) } return buildin_query_sql_sub(st, logmysql_handle); -#else - //for TXT version, we always return -1 - script_pushint(st,-1); - return 0; -#endif } //Allows escaping of a given string. @@ -13684,11 +13670,7 @@ BUILDIN_FUNC(escape_sql) str = script_getstr(st,2); len = strlen(str); esc_str = (char*)aMallocA(len*2+1); -#if defined(TXT_ONLY) - jstrescapecpy(esc_str, str); -#else Sql_EscapeStringLen(mmysql_handle, esc_str, str, len); -#endif script_pushstr(st, esc_str); return 0; } @@ -14709,9 +14691,8 @@ BUILDIN_FUNC(openmail) if( sd == NULL ) return 0; -#ifndef TXT_ONLY mail_openmail(sd); -#endif + return 0; } @@ -14723,9 +14704,8 @@ BUILDIN_FUNC(openauction) if( sd == NULL ) return 0; -#ifndef TXT_ONLY clif_Auction_openwindow(sd); -#endif + return 0; } @@ -14778,7 +14758,6 @@ BUILDIN_FUNC(setcell) *------------------------------------------*/ BUILDIN_FUNC(mercenary_create) { -#ifndef TXT_ONLY struct map_session_data *sd; int class_, contract_time; @@ -14792,7 +14771,6 @@ BUILDIN_FUNC(mercenary_create) contract_time = script_getnum(st,3); merc_create(sd, class_, contract_time); -#endif return 0; } diff --git a/src/map/txt/CMakeLists.txt b/src/map/txt/CMakeLists.txt deleted file mode 100644 index b2634000a..000000000 --- a/src/map/txt/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ - -# -# map txt -# -if( BUILD_TXT_SERVERS ) -message( STATUS "Creating target map-server" ) -set( TXT_MAP_HEADERS - "${TXT_MAP_SOURCE_DIR}/atcommand.h" - "${TXT_MAP_SOURCE_DIR}/battle.h" - "${TXT_MAP_SOURCE_DIR}/battleground.h" - "${TXT_MAP_SOURCE_DIR}/buyingstore.h" - "${TXT_MAP_SOURCE_DIR}/chat.h" - "${TXT_MAP_SOURCE_DIR}/chrif.h" - "${TXT_MAP_SOURCE_DIR}/clif.h" - "${TXT_MAP_SOURCE_DIR}/date.h" - "${TXT_MAP_SOURCE_DIR}/duel.h" - "${TXT_MAP_SOURCE_DIR}/guild.h" - "${TXT_MAP_SOURCE_DIR}/homunculus.h" - "${TXT_MAP_SOURCE_DIR}/instance.h" - "${TXT_MAP_SOURCE_DIR}/intif.h" - "${TXT_MAP_SOURCE_DIR}/itemdb.h" - "${TXT_MAP_SOURCE_DIR}/log.h" - "${TXT_MAP_SOURCE_DIR}/mail.h" - "${TXT_MAP_SOURCE_DIR}/map.h" - "${TXT_MAP_SOURCE_DIR}/mapreg.h" - "${TXT_MAP_SOURCE_DIR}/mercenary.h" - "${TXT_MAP_SOURCE_DIR}/mob.h" - "${TXT_MAP_SOURCE_DIR}/npc.h" - "${TXT_MAP_SOURCE_DIR}/party.h" - "${TXT_MAP_SOURCE_DIR}/path.h" - "${TXT_MAP_SOURCE_DIR}/pc.h" - "${TXT_MAP_SOURCE_DIR}/pet.h" - "${TXT_MAP_SOURCE_DIR}/quest.h" - "${TXT_MAP_SOURCE_DIR}/script.h" - "${TXT_MAP_SOURCE_DIR}/searchstore.h" - "${TXT_MAP_SOURCE_DIR}/skill.h" - "${TXT_MAP_SOURCE_DIR}/status.h" - "${TXT_MAP_SOURCE_DIR}/storage.h" - "${TXT_MAP_SOURCE_DIR}/trade.h" - "${TXT_MAP_SOURCE_DIR}/unit.h" - "${TXT_MAP_SOURCE_DIR}/vending.h" - ) -set( TXT_MAP_SOURCES - "${TXT_MAP_SOURCE_DIR}/atcommand.c" - "${TXT_MAP_SOURCE_DIR}/battle.c" - "${TXT_MAP_SOURCE_DIR}/battleground.c" - "${TXT_MAP_SOURCE_DIR}/buyingstore.c" - "${TXT_MAP_SOURCE_DIR}/chat.c" - "${TXT_MAP_SOURCE_DIR}/chrif.c" - "${TXT_MAP_SOURCE_DIR}/clif.c" - "${TXT_MAP_SOURCE_DIR}/date.c" - "${TXT_MAP_SOURCE_DIR}/duel.c" - "${TXT_MAP_SOURCE_DIR}/guild.c" - "${TXT_MAP_SOURCE_DIR}/homunculus.c" - "${TXT_MAP_SOURCE_DIR}/instance.c" - "${TXT_MAP_SOURCE_DIR}/intif.c" - "${TXT_MAP_SOURCE_DIR}/itemdb.c" - "${TXT_MAP_SOURCE_DIR}/log.c" - "${TXT_MAP_SOURCE_DIR}/mail.c" - "${TXT_MAP_SOURCE_DIR}/map.c" - "${TXT_MAP_SOURCE_DIR}/mapreg_txt.c" - "${TXT_MAP_SOURCE_DIR}/mercenary.c" - "${TXT_MAP_SOURCE_DIR}/mob.c" - "${TXT_MAP_SOURCE_DIR}/npc.c" - "${TXT_MAP_SOURCE_DIR}/npc_chat.c" - "${TXT_MAP_SOURCE_DIR}/party.c" - "${TXT_MAP_SOURCE_DIR}/path.c" - "${TXT_MAP_SOURCE_DIR}/pc.c" - "${TXT_MAP_SOURCE_DIR}/pet.c" - "${TXT_MAP_SOURCE_DIR}/quest.c" - "${TXT_MAP_SOURCE_DIR}/script.c" - "${TXT_MAP_SOURCE_DIR}/searchstore.c" - "${TXT_MAP_SOURCE_DIR}/skill.c" - "${TXT_MAP_SOURCE_DIR}/status.c" - "${TXT_MAP_SOURCE_DIR}/storage.c" - "${TXT_MAP_SOURCE_DIR}/trade.c" - "${TXT_MAP_SOURCE_DIR}/unit.c" - "${TXT_MAP_SOURCE_DIR}/vending.c" - ) -set( DEPENDENCIES common_base ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DTXT_ONLY" ) -if( WITH_PCRE ) - message( STATUS "Enabled PCRE code" ) - set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} ) - set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} ) - set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" ) -else() - message( STATUS "Disabled PCRE code" ) -endif() -set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_MAP_HEADERS} ${TXT_MAP_SOURCES} ) -source_group( common FILES ${COMMON_BASE_HEADERS} ) -source_group( map FILES ${TXT_MAP_HEADERS} ${TXT_MAP_SOURCES} ) -include_directories( ${INCLUDE_DIRS} ) -add_executable( map-server ${SOURCE_FILES} ) -add_dependencies( map-server ${DEPENDENCIES} ) -target_link_libraries( map-server ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( map-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_mapserver_txt DESCRIPTION "map-server (txt version)" DISPLAY_NAME "map-server" GROUP Runtime ) - install( TARGETS map-server - DESTINATION "." - COMPONENT Runtime_mapserver_txt ) -endif( INSTALL_COMPONENT_RUNTIME ) -set( TARGET_LIST ${TARGET_LIST} map-server CACHE INTERNAL "" ) -message( STATUS "Creating target map-server - done" ) -endif( BUILD_TXT_SERVERS ) diff --git a/src/txt-converter/CMakeLists.txt b/src/txt-converter/CMakeLists.txt deleted file mode 100644 index 7b1cfb6a8..000000000 --- a/src/txt-converter/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ - -# -# setup -# -set( CONVERTER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) -if( WITH_MYSQL ) - option( BUILD_CONVERTERS "build converter executables" OFF ) -else() - message( STATUS "Disabled converter targets (requires MYSQL)" ) -endif() - - -# -# targets -# -add_subdirectory( login ) -add_subdirectory( char ) diff --git a/src/txt-converter/Makefile.in b/src/txt-converter/Makefile.in deleted file mode 100644 index 50e89e34e..000000000 --- a/src/txt-converter/Makefile.in +++ /dev/null @@ -1,150 +0,0 @@ -LOGIN_CONVERTER_OBJ = \ - obj_login/login-converter.o \ - ../login/obj_txt/account_txt.o \ - ../login/obj_sql/account_sql.o \ - ../common/obj_all/minicore.o \ - ../common/obj_all/db.o \ - ../common/obj_all/ers.o \ - ../common/obj_all/lock.o \ - ../common/obj_all/malloc.o \ - ../common/obj_all/showmsg.o \ - ../common/obj_all/strlib.o \ - ../common/obj_all/timer.o \ - ../common/obj_all/utils.o \ - ../common/obj_sql/sql.o -LOGIN_CONVERTER_H = \ - ../login/account.h \ - ../common/cbasetypes.h \ - ../common/mmo.h \ - ../common/core.h \ - ../common/db.h \ - ../common/ers.h \ - ../common/lock.h \ - ../common/malloc.h \ - ../common/showmsg.h \ - ../common/strlib.h \ - ../common/timer.h \ - ../common/utils.h \ - ../common/sql.h - -CHAR_CONVERTER_OBJ = \ - obj_char/char-converter.o \ - obj_char/txt-char.o \ - obj_char/txt-int_pet.o \ - obj_char/txt-int_storage.o \ - obj_char/txt-inter.o \ - obj_char/txt-int_party.o \ - obj_char/txt-int_guild.o \ - obj_char/sql-char.o \ - obj_char/sql-int_pet.o \ - obj_char/sql-int_storage.o \ - obj_char/sql-inter.o \ - obj_char/sql-int_party.o \ - obj_char/sql-int_guild.o \ - obj_char/sql-int_mercenary.o \ - ../common/obj_all/minicore.o \ - ../common/obj_all/malloc.o \ - ../common/obj_all/strlib.o \ - ../common/obj_all/showmsg.o \ - ../common/obj_all/utils.o \ - ../common/obj_all/timer.o \ - ../common/obj_all/ers.o \ - ../common/obj_all/mapindex.o \ - ../common/obj_sql/sql.o - -CHAR_CONVERTER_H = \ - ../char/char.h \ - ../char/int_pet.h \ - ../char/int_storage.h \ - ../char/inter.h \ - ../char/int_party.h \ - ../char/int_guild.h \ - ../char_sql/char.h \ - ../char_sql/int_pet.h \ - ../char_sql/int_storage.h \ - ../char_sql/inter.h \ - ../char_sql/int_party.h \ - ../char_sql/int_guild.h \ - ../char_sql/int_mercenary.h \ - ../common/cbasetypes.h \ - ../common/mmo.h \ - ../common/core.h \ - ../common/malloc.h \ - ../common/strlib.h \ - ../common/showmsg.h \ - ../common/timer.h \ - ../common/utils.h \ - ../common/ers.h \ - ../common/mapindex.h \ - ../common/sql.h - -HAVE_MYSQL=@HAVE_MYSQL@ -ifeq ($(HAVE_MYSQL),yes) - LOGIN_CONVERTER_DEPENDS=obj_login $(LOGIN_CONVERTER_OBJ) - CHAR_CONVERTER_DEPENDS=obj_char $(CHAR_CONVERTER_OBJ) -else - LOGIN_CONVERTER_DEPENDS=needs_mysql - CHAR_CONVERTER_DEPENDS=needs_mysql -endif - -@SET_MAKE@ - -##################################################################### -.PHONY : all login-converter char-converter clean help - -all: login-converter char-converter - -login-converter: $(LOGIN_CONVERTER_DEPENDS) - @CC@ @LDFLAGS@ -o ../../tools/login-converter@EXEEXT@ $(LOGIN_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@ - -char-converter: $(CHAR_CONVERTER_DEPENDS) - @CC@ @LDFLAGS@ -o ../../tools/char-converter@EXEEXT@ $(CHAR_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@ - -clean: - rm -rf *.o obj_login obj_char ../../tools/login-converter@EXEEXT@ ../../tools/char-converter@EXEEXT@ - -help: - @echo "possible targets are 'login-converter' 'char-converter' 'all' 'clean' 'help'" - @echo "'login-converter' - login server converter" - @echo "'char-converter' - char server converter" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" - -##################################################################### - -needs_mysql: - @echo "MySQL not found or disabled by the configure script" - @exit 1 - -obj_login: - -mkdir obj_login - -obj_char: - -mkdir obj_char - -obj_login/%.o: %.c $(LOGIN_CONVERTER_H) - @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DWITH_TXT -DWITH_SQL -c $(OUTPUT_OPTION) $< - -obj_char/%.o: %.c $(CHAR_CONVERTER_H) - @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< - -obj_char/txt-%.o: ../char/%.c $(CHAR_CONVERTER_H) - @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< - -obj_char/sql-%.o: ../char_sql/%.c $(CHAR_CONVERTER_H) - @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< - -# missing common object files -../common/obj_all/%.o: - @$(MAKE) -C ../common sql - -../common/obj_sql/%.o: - @$(MAKE) -C ../common sql - -# missing login server files -../login/obj_txt/%.o: - @$(MAKE) -C ../login txt - -../login/obj_sql/%.o: - @$(MAKE) -C ../login sql diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c deleted file mode 100644 index 0d6ecea25..000000000 --- a/src/txt-converter/char-converter.c +++ /dev/null @@ -1,303 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/core.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/utils.h" - -#include "../char/char.h" -#include "../char/int_storage.h" -#include "../char/int_pet.h" -#include "../char/int_party.h" -#include "../char/int_guild.h" -#include "../char/inter.h" - -#include "../char_sql/char.h" -#include "../char_sql/int_storage.h" -#include "../char_sql/int_pet.h" -#include "../char_sql/int_party.h" -#include "../char_sql/int_guild.h" -#include "../char_sql/inter.h" - -#include -#include -#include - -#define CHAR_CONF_NAME "conf/char_athena.conf" -#define SQL_CONF_NAME "conf/inter_athena.conf" -#define INTER_CONF_NAME "conf/inter_athena.conf" -//-------------------------------------------------------- - -int convert_init(void) -{ - char line[65536]; - int ret; - int tmp_int[2], lineno, count; - char input; - FILE *fp; - - ShowWarning("Make sure you backup your databases before continuing!\n"); - ShowMessage("\n"); - - ShowNotice("Do you wish to convert your Character Database to SQL? (y/n) : "); - input = getchar(); - if(input == 'y' || input == 'Y') - { - struct character_data char_dat; - struct accreg reg; - - ShowStatus("Converting Character Database...\n"); - if( (fp = fopen(char_txt, "r")) == NULL ) - { - ShowError("Unable to open file [%s]!\n", char_txt); - return 0; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset(&char_dat, 0, sizeof(struct character_data)); - ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num); - if(ret > 0) { - count++; - parse_friend_txt(&char_dat.status); //Retrieve friends. - mmo_char_tosql(char_dat.status.char_id , &char_dat.status); - - memset(®, 0, sizeof(reg)); - reg.account_id = char_dat.status.account_id; - reg.char_id = char_dat.status.char_id; - reg.reg_num = char_dat.global_num; - memcpy(®.reg, &char_dat.global, reg.reg_num*sizeof(struct global_reg)); - inter_accreg_tosql(reg.account_id, reg.char_id, ®, 3); //Type 3: Character regs - } else { - ShowError("Error %d converting character line [%s] (at %s:%d).\n", ret, line, char_txt, lineno); - } - } - ShowStatus("Converted %d characters.\n", count); - fclose(fp); - ShowStatus("Converting Account variables Database...\n"); - if( (fp = fopen(accreg_txt, "r")) == NULL ) - { - ShowError("Unable to open file %s!", accreg_txt); - return 1; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset (®, 0, sizeof(struct accreg)); - if(inter_accreg_fromstr(line, ®) == 0 && reg.account_id > 0) { - count++; - inter_accreg_tosql(reg.account_id, 0, ®, 2); //Type 2: Account regs - } else { - ShowError("accreg reading: broken data [%s] at %s:%d\n", line, accreg_txt, lineno); - } - } - ShowStatus("Converted %d account registries.\n", count); - fclose(fp); - } - - while(getchar() != '\n'); - ShowMessage("\n"); - ShowNotice("Do you wish to convert your Storage Database to SQL? (y/n) : "); - input = getchar(); - if(input == 'y' || input == 'Y') - { - struct storage_data storage; - ShowMessage("\n"); - ShowStatus("Converting Storage Database...\n"); - if( (fp = fopen(storage_txt,"r")) == NULL ) - { - ShowError("can't read : %s\n", storage_txt); - return 0; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - int account_id; - - lineno++; - if( sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]) != 2 ) - continue; - - memset(&storage, 0, sizeof(struct storage_data)); - if( storage_fromstr(line,&account_id,&storage) ) - { - count++; - storage_tosql(account_id,&storage); //to sql. (dump) - } else - ShowError("Error parsing storage line [%s] (at %s:%d)\n", line, storage_txt, lineno); - } - ShowStatus("Converted %d storages.\n", count); - fclose(fp); - } - - //FIXME: CONVERT STATUS DATA HERE!!! - - while(getchar() != '\n'); - ShowMessage("\n"); - ShowNotice("Do you wish to convert your Pet Database to SQL? (y/n) : "); - input=getchar(); - if(input == 'y' || input == 'Y') - { - struct s_pet p; - ShowMessage("\n"); - ShowStatus("Converting Pet Database...\n"); - if( (fp = fopen(pet_txt, "r")) == NULL ) - { - ShowError("Unable to open file %s!", pet_txt); - return 1; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset (&p, 0, sizeof(struct s_pet)); - if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0) { - count++; - inter_pet_tosql(p.pet_id,&p); - } else { - ShowError("pet reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno); - } - } - ShowStatus("Converted %d pets.\n", count); - fclose(fp); - } - - //FIXME: CONVERT HOMUNCULUS DATA AND SKILLS HERE!!! - - while(getchar() != '\n'); - ShowMessage("\n"); - ShowNotice("Do you wish to convert your Party Database to SQL? (y/n) : "); - input=getchar(); - if(input == 'y' || input == 'Y') - { - struct party p; - ShowMessage("\n"); - ShowStatus("Converting Party Database...\n"); - if( (fp = fopen(party_txt, "r")) == NULL ) - { - ShowError("Unable to open file %s!", party_txt); - return 1; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset (&p, 0, sizeof(struct party)); - if(inter_party_fromstr(line, &p) == 0 && - p.party_id > 0 && - inter_party_tosql(&p, PS_CREATE, 0)) - count++; - else{ - ShowError("party reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno); - } - } - ShowStatus("Converted %d parties.\n", count); - fclose(fp); - } - - while(getchar() != '\n'); - ShowMessage("\n"); - ShowNotice("Do you wish to convert your Guilds and Castles Database to SQL? (y/n) : "); - input=getchar(); - if(input == 'y' || input == 'Y') - { - struct guild g; - struct guild_castle gc; - ShowMessage("\n"); - ShowStatus("Converting Guild Database...\n"); - if( (fp = fopen(guild_txt, "r")) == NULL ) - { - ShowError("Unable to open file %s!", guild_txt); - return 1; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset (&g, 0, sizeof(struct guild)); - if (inter_guild_fromstr(line, &g) == 0 && - g.guild_id > 0 && - inter_guild_tosql(&g,GS_MASK)) - count++; - else - ShowError("guild reading: broken data [%s] at %s:%d\n", line, guild_txt, lineno); - } - ShowStatus("Converted %d guilds.\n", count); - fclose(fp); - ShowStatus("Converting Guild Castles Database...\n"); - if( (fp = fopen(castle_txt, "r")) == NULL ) - { - ShowError("Unable to open file %s!", castle_txt); - return 1; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset(&gc, 0, sizeof(struct guild_castle)); - if (inter_guildcastle_fromstr(line, &gc) == 0) { - inter_guildcastle_tosql(&gc); - count++; - } - else - ShowError("guild castle reading: broken data [%s] at %s:%d\n", line, castle_txt, lineno); - } - ShowStatus("Converted %d guild castles.\n", count); - fclose(fp); - } - - while(getchar() != '\n'); - ShowMessage("\n"); - ShowNotice("Do you wish to convert your Guild Storage Database to SQL? (y/n) : "); - input=getchar(); - if(input == 'y' || input == 'Y') - { - struct guild_storage storage_; - ShowMessage("\n"); - ShowStatus("Converting Guild Storage Database...\n"); - if( (fp = fopen(guild_storage_txt, "r")) == NULL ) - { - ShowError("can't read : %s\n", guild_storage_txt); - return 0; - } - lineno = count = 0; - while(fgets(line, sizeof(line), fp)) - { - lineno++; - memset(&storage_, 0, sizeof(struct guild_storage)); - if (sscanf(line,"%d",&storage_.guild_id) == 1 && - storage_.guild_id > 0 && - guild_storage_fromstr(line,&storage_) == 0 - ) { - count++; - guild_storage_tosql(storage_.guild_id, &storage_); - } else - ShowError("Error parsing guild storage line [%s] (at %s:%d)\n", line, guild_storage_txt, lineno); - } - ShowStatus("Converted %d guild storages.\n", count); - fclose(fp); - } - - return 0; -} - -int do_init(int argc, char** argv) -{ - char_config_read( (argc > 1) ? argv[1] : CHAR_CONF_NAME); - mapindex_init(); - sql_config_read( (argc > 2) ? argv[2] : SQL_CONF_NAME); - inter_init_txt( (argc > 3) ? argv[3] : INTER_CONF_NAME); - inter_init_sql( (argc > 3) ? argv[3] : INTER_CONF_NAME); - convert_init(); - ShowStatus("Everything's been converted!\n"); - mapindex_final(); - return 0; -} - -void do_final(void) {} diff --git a/src/txt-converter/char/CMakeLists.txt b/src/txt-converter/char/CMakeLists.txt deleted file mode 100644 index ad3970d77..000000000 --- a/src/txt-converter/char/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ - -# -# char-converter -# -if( BUILD_CONVERTERS ) -message( STATUS "Creating target char-converter" ) -set( COMMON_HEADERS - ${COMMON_MINI_HEADERS} - "${COMMON_SOURCE_DIR}/mapindex.h" - "${COMMON_SOURCE_DIR}/sql.h" - "${COMMON_SOURCE_DIR}/timer.h" - ) -set( COMMON_SOURCES - ${COMMON_MINI_SOURCES} - "${COMMON_SOURCE_DIR}/mapindex.c" - "${COMMON_SOURCE_DIR}/sql.c" - "${COMMON_SOURCE_DIR}/timer.c" - ) -set( TXT_HEADERS - "${TXT_CHAR_SOURCE_DIR}/char.h" - "${TXT_CHAR_SOURCE_DIR}/int_pet.h" - "${TXT_CHAR_SOURCE_DIR}/int_storage.h" - "${TXT_CHAR_SOURCE_DIR}/inter.h" - "${TXT_CHAR_SOURCE_DIR}/int_party.h" - "${TXT_CHAR_SOURCE_DIR}/int_guild.h" - ) -set( TXT_SOURCES - "${TXT_CHAR_SOURCE_DIR}/char.c" - "${TXT_CHAR_SOURCE_DIR}/int_pet.c" - "${TXT_CHAR_SOURCE_DIR}/int_storage.c" - "${TXT_CHAR_SOURCE_DIR}/inter.c" - "${TXT_CHAR_SOURCE_DIR}/int_party.c" - "${TXT_CHAR_SOURCE_DIR}/int_guild.c" - ) -set( SQL_HEADERS - "${SQL_CHAR_SOURCE_DIR}/char.h" - "${SQL_CHAR_SOURCE_DIR}/int_pet.h" - "${SQL_CHAR_SOURCE_DIR}/int_storage.h" - "${SQL_CHAR_SOURCE_DIR}/inter.h" - "${SQL_CHAR_SOURCE_DIR}/int_party.h" - "${SQL_CHAR_SOURCE_DIR}/int_guild.h" - "${SQL_CHAR_SOURCE_DIR}/int_mercenary.h" - ) -set( SQL_SOURCES - "${SQL_CHAR_SOURCE_DIR}/char.c" - "${SQL_CHAR_SOURCE_DIR}/int_pet.c" - "${SQL_CHAR_SOURCE_DIR}/int_storage.c" - "${SQL_CHAR_SOURCE_DIR}/inter.c" - "${SQL_CHAR_SOURCE_DIR}/int_party.c" - "${SQL_CHAR_SOURCE_DIR}/int_guild.c" - "${SQL_CHAR_SOURCE_DIR}/int_mercenary.c" - ) -set( CONVERTER_SOURCES - "${CONVERTER_SOURCE_DIR}/char-converter.c" - ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} -DTXT_SQL_CONVERT" ) -set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${TXT_HEADERS} ${TXT_SOURCES} ${SQL_HEADERS} ${SQL_SOURCES} ${CONVERTER_SOURCES} ) -source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) -source_group( txt FILES ${TXT_HEADERS} ${TXT_SOURCES} ) -source_group( sql FILES ${SQL_HEADERS} ${SQL_SOURCES} ) -source_group( converter FILES ${CONVERTER_SOURCES} ) -include_directories( ${INCLUDE_DIRS} ) -add_executable( char-converter ${SOURCE_FILES} ) -target_link_libraries( char-converter ${LIBRARIES} ) -set_target_properties( char-converter PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_charconverter DESCRIPTION "char-converter" DISPLAY_NAME "char-converter" GROUP Runtime ) - install( TARGETS char-converter - DESTINATION "tools" - COMPONENT Runtime_charconverter ) -endif( INSTALL_COMPONENT_RUNTIME ) -set( TARGET_LIST ${TARGET_LIST} char-converter CACHE INTERNAL "" ) -message( STATUS "Creating target char-converter - done" ) -endif( BUILD_CONVERTERS ) diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c deleted file mode 100644 index d72d35ae2..000000000 --- a/src/txt-converter/login-converter.c +++ /dev/null @@ -1,108 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // struct mmo_account -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../login/account.h" -#include -#include - -#define LOGIN_CONF_NAME "conf/login_athena.conf" - -AccountDB* txtdb = NULL; -AccountDB* sqldb = NULL; - -//-------------------------------------------------------- - -int convert_login(void) -{ - AccountDBIterator* iter; - struct mmo_account acc; - - if( !txtdb->init(txtdb) || !sqldb->init(sqldb) ) - { - ShowFatalError("Initialization failed, unable to start conversion.\n"); - return 0; - } - - ShowStatus("Conversion started...\n"); - //TODO: do some counting & statistics - - iter = txtdb->iterator(txtdb); - while( iter->next(iter, &acc) ) - { - ShowInfo("Converting user (id: %d, name: %s, gm level: %d)...", acc.account_id, acc.userid, acc.level); - if( sqldb->create(sqldb, &acc) ) - ShowMessage(CL_GREEN "success.\n"); - else - ShowMessage(CL_RED "failed!\n"); - } - iter->destroy(iter); - - ShowStatus("Conversion finished.\n"); - - return 0; -} - -int login_config_read(const char* cfgName) -{ - int i; - char line[1024], w1[1024], w2[1024]; - FILE *fp; - - ShowStatus("Start reading login server configuration: %s\n", cfgName); - - fp=fopen(cfgName,"r"); - if(fp==NULL){ - ShowError("File not found: %s\n", cfgName); - return 1; - } - - while(fgets(line, sizeof(line), fp)) - { - if(line[0] == '/' && line[1] == '/') - continue; - - i=sscanf(line,"%[^:]:%s", w1, w2); - if(i!=2) - continue; - - txtdb->set_property(txtdb, w1, w2); - sqldb->set_property(sqldb, w1, w2); - - //support the import command, just like any other config - if( strcmpi(w1,"import") == 0 ) - login_config_read(w2); - } - - fclose(fp); - ShowStatus("End reading login server configuration...\n"); - return 0; -} - -int do_init(int argc, char** argv) -{ - int input; - - txtdb = account_db_txt(); - sqldb = account_db_sql(); - - login_config_read( (argc > 1) ? argv[1] : LOGIN_CONF_NAME ); - - ShowInfo("\nWarning : Make sure you backup your databases before continuing!\n"); - ShowInfo("\nDo you wish to convert your Login Database to SQL? (y/n) : "); - input = getchar(); - - if(input == 'y' || input == 'Y') - convert_login(); - - return 0; -} - -void do_final(void) -{ - txtdb->destroy(txtdb); - sqldb->destroy(sqldb); -} diff --git a/src/txt-converter/login/CMakeLists.txt b/src/txt-converter/login/CMakeLists.txt deleted file mode 100644 index 605050d60..000000000 --- a/src/txt-converter/login/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ - -# -# login-converter -# -if( BUILD_CONVERTERS ) -message( STATUS "Creating target login-converter" ) -set( COMMON_HEADERS - ${COMMON_MINI_HEADERS} - "${COMMON_SOURCE_DIR}/db.h" - "${COMMON_SOURCE_DIR}/ers.h" - "${COMMON_SOURCE_DIR}/lock.h" - "${COMMON_SOURCE_DIR}/sql.h" - "${COMMON_SOURCE_DIR}/timer.h" - "${COMMON_SOURCE_DIR}/utils.h" - ) -set( COMMON_SOURCES - ${COMMON_MINI_SOURCES} - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/ers.c" - "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/sql.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" - ) -set( TXT_HEADERS - "${TXT_LOGIN_SOURCE_DIR}/account.h" - ) -set( TXT_SOURCES - "${TXT_LOGIN_SOURCE_DIR}/account_txt.c" - ) -set( SQL_HEADERS - "${SQL_LOGIN_SOURCE_DIR}/account.h" - ) -set( SQL_SOURCES - "${SQL_LOGIN_SOURCE_DIR}/account_sql.c" - ) -set( CONVERTER_SOURCES - "${CONVERTER_SOURCE_DIR}/login-converter.c" - ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} -DWITH_TXT -DWITH_SQL" ) -set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${TXT_HEADERS} ${TXT_SOURCES} ${SQL_HEADERS} ${SQL_SOURCES} ${CONVERTER_SOURCES} ) -source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) -source_group( txt FILES ${TXT_HEADERS} ${TXT_SOURCES} ) -source_group( sql FILES ${SQL_HEADERS} ${SQL_SOURCES} ) -source_group( converter FILES ${CONVERTER_SOURCES} ) -include_directories( ${INCLUDE_DIRS} ) -add_executable( login-converter ${SOURCE_FILES} ) -target_link_libraries( login-converter ${LIBRARIES} ) -set_target_properties( login-converter PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_loginconverter DESCRIPTION "login-converter" DISPLAY_NAME "login-converter" GROUP Runtime ) - install( TARGETS login-converter - DESTINATION "tools" - COMPONENT Runtime_loginconverter ) -endif( INSTALL_COMPONENT_RUNTIME ) -set( TARGET_LIST ${TARGET_LIST} login-converter CACHE INTERNAL "" ) -message( STATUS "Creating target login-converter - done" ) -endif( BUILD_CONVERTERS ) diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index 1ed50b62f..e7fd17017 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -146,17 +146,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -174,17 +174,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/vcproj-10/char-server_sql.vcxproj.filters b/vcproj-10/char-server_sql.vcxproj.filters index a2bbf2d15..189c72e79 100644 --- a/vcproj-10/char-server_sql.vcxproj.filters +++ b/vcproj-10/char-server_sql.vcxproj.filters @@ -46,37 +46,37 @@ common - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql @@ -138,37 +138,37 @@ common - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql - + char_sql diff --git a/vcproj-10/char-server_txt.vcxproj b/vcproj-10/char-server_txt.vcxproj deleted file mode 100644 index ab79961a3..000000000 --- a/vcproj-10/char-server_txt.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-E3E9646175AF} - char-server_txt - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\ - $(ProjectName)\$(Configuration)\ - true - ..\ - $(ProjectName)\$(Configuration)\ - false - char-server - char-server - - - - Disabled - ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - false - false - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - 4800;%(DisableSpecificWarnings) - true - - - libcmtd.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)char-server.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)char-server.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - true - MultiThreaded - - - - - Level3 - ProgramDatabase - CompileAsC - 4800;%(DisableSpecificWarnings) - true - - - libcmt.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)char-server.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)char-server.pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/char-server_txt.vcxproj.filters b/vcproj-10/char-server_txt.vcxproj.filters deleted file mode 100644 index 0bb9773de..000000000 --- a/vcproj-10/char-server_txt.vcxproj.filters +++ /dev/null @@ -1,168 +0,0 @@ - - - - - 3rdparty - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - - - 3rdparty - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - char_txt - - - - - {3426d3df-b8f8-421a-9ecf-5929f527ebcd} - - - {ecf20235-c0df-43f9-a4c0-f2f992b3330f} - - - {36b5e281-2a86-4c66-bc78-f56c54f0b3c2} - - - \ No newline at end of file diff --git a/vcproj-10/login-server_txt.vcxproj b/vcproj-10/login-server_txt.vcxproj deleted file mode 100644 index f80d368b5..000000000 --- a/vcproj-10/login-server_txt.vcxproj +++ /dev/null @@ -1,175 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-E2E9646175AF} - login-server_txt - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\ - $(ProjectName)\$(Configuration)\ - true - ..\ - $(ProjectName)\$(Configuration)\ - false - login-server - login-server - - - - Disabled - ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_TXT;%(PreprocessorDefinitions) - false - false - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - 4100;4800;%(DisableSpecificWarnings) - true - - - libcmtd.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - NotSet - $(OutDir)login-server.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)login-server.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_TXT;%(PreprocessorDefinitions) - true - MultiThreaded - - - - - Level3 - ProgramDatabase - CompileAsC - 4100;4800;%(DisableSpecificWarnings) - true - - - libcmt.lib;oldnames.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)login-server.exe - %(AdditionalLibraryDirectories) - true - true - $(OutDir)login-server.pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/login-server_txt.vcxproj.filters b/vcproj-10/login-server_txt.vcxproj.filters deleted file mode 100644 index 447e7e772..000000000 --- a/vcproj-10/login-server_txt.vcxproj.filters +++ /dev/null @@ -1,144 +0,0 @@ - - - - - 3rdparty - - - login_txt - - - login_txt - - - login_txt - - - login_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - - - 3rdparty - - - login_txt - - - login_txt - - - login_txt - - - login_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - - - {be8a59c3-07c1-4edd-9114-964892214f9e} - - - {2b1ebf8e-ab6f-49be-b1f0-52d695ac9282} - - - {0719c3dc-e4e3-4235-b6d6-bbd3e7c258a5} - - - \ No newline at end of file diff --git a/vcproj-10/map-server_txt.vcxproj b/vcproj-10/map-server_txt.vcxproj deleted file mode 100644 index 83f16a8b5..000000000 --- a/vcproj-10/map-server_txt.vcxproj +++ /dev/null @@ -1,250 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-E1E9646175AF} - map-server_txt - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\ - $(ProjectName)\$(Configuration)\ - true - ..\ - $(ProjectName)\$(Configuration)\ - false - map-server - map-server - - - - Disabled - ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - false - false - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - 4018;4100;4800;%(DisableSpecificWarnings) - true - - - /FIXED:NO %(AdditionalOptions) - libcmtd.lib;oldnames.lib;ws2_32.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) - $(OutDir)map-server.exe - ..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) - true - true - $(OutDir)map-server.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;TXT_ONLY;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;%(PreprocessorDefinitions) - true - MultiThreaded - false - - - - - Level3 - ProgramDatabase - CompileAsC - 4018;4100;4800;%(DisableSpecificWarnings) - true - - - libcmt.lib;oldnames.lib;ws2_32.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) - $(OutDir)map-server.exe - ..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) - true - true - $(OutDir)map-server.pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/map-server_txt.vcxproj.filters b/vcproj-10/map-server_txt.vcxproj.filters deleted file mode 100644 index a90302f0c..000000000 --- a/vcproj-10/map-server_txt.vcxproj.filters +++ /dev/null @@ -1,345 +0,0 @@ - - - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - 3rdparty - - - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - common - - - map_txt - - - map_txt - - - map_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - map_txt - - - 3rdparty - - - - - {1a14e4e3-9844-4386-bf22-dd1fe7732bb5} - - - {3c87ae01-115b-4d3b-a856-a3b96ca7b469} - - - {b4ec69ed-50dd-4ac0-885f-a88bd617ebac} - - - \ No newline at end of file diff --git a/vcproj-10/txt-converter-char.vcxproj b/vcproj-10/txt-converter-char.vcxproj deleted file mode 100644 index 7064df852..000000000 --- a/vcproj-10/txt-converter-char.vcxproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-EAE9646175AF} - txt-converter-char - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\tools\ - $(ProjectName)\$(Configuration)\ - true - ..\tools\ - $(ProjectName)\$(Configuration)\ - false - char-converter - char-converter - - - - Disabled - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) - false - false - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - true - - - libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) - $(OutDir)char-converter.exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) - true - %(IgnoreSpecificDefaultLibraries) - true - $(OutDir)char-converter.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;TXT_SQL_CONVERT;%(PreprocessorDefinitions) - true - MultiThreaded - - - - - - - - - Level3 - ProgramDatabase - CompileAsC - true - - - libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) - $(OutDir)char-converter.exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) - true - %(IgnoreSpecificDefaultLibraries) - true - $(OutDir)char-converter.pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - $(IntDir)%(Filename)_sql.obj - $(IntDir)%(Filename)_sql.obj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/txt-converter-char.vcxproj.filters b/vcproj-10/txt-converter-char.vcxproj.filters deleted file mode 100644 index 4068225e6..000000000 --- a/vcproj-10/txt-converter-char.vcxproj.filters +++ /dev/null @@ -1,156 +0,0 @@ - - - - - converter - - - char - - - char_sql - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - char_sql - - - char - - - char_sql - - - char_sql - - - char_sql - - - char - - - char_sql - - - char - - - char - - - char_sql - - - char - - - - - char_sql - - - char - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - char_sql - - - char - - - char_sql - - - char_sql - - - char_sql - - - char_sql - - - char - - - char - - - char - - - char_sql - - - char - - - - - {8cd3ef2c-94f8-4117-9456-0718099b6cff} - - - {39dba2e0-24d6-4e27-bca0-512f4124aafd} - - - {9ff3fa33-e859-4bec-8ef5-f4b35906784c} - - - {9b273f25-9226-4784-8e88-3085194c0c8a} - - - \ No newline at end of file diff --git a/vcproj-10/txt-converter-login.vcxproj b/vcproj-10/txt-converter-login.vcxproj deleted file mode 100644 index 06c3a8b6c..000000000 --- a/vcproj-10/txt-converter-login.vcxproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {D356871D-58E1-450B-967A-E9E9646175AF} - txt-converter-login - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\tools\ - $(ProjectName)\$(Configuration)\ - true - ..\tools\ - $(ProjectName)\$(Configuration)\ - false - login-converter - login-converter - - - - Disabled - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) - false - false - - - EnableFastChecks - MultiThreadedDebug - true - - - - - Level3 - EditAndContinue - CompileAsC - true - - - libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) - $(OutDir)login-converter.exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) - true - %(IgnoreSpecificDefaultLibraries) - true - $(OutDir)login-converter.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - AnySuitable - true - Speed - true - true - true - ..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;MINICORE;WITH_TXT;WITH_SQL;%(PreprocessorDefinitions) - true - MultiThreaded - - - - - - - - - Level3 - ProgramDatabase - CompileAsC - true - - - libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) - $(OutDir)login-converter.exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) - true - %(IgnoreSpecificDefaultLibraries) - true - $(OutDir)login-converter.pdb - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcproj-10/txt-converter-login.vcxproj.filters b/vcproj-10/txt-converter-login.vcxproj.filters deleted file mode 100644 index 668acec99..000000000 --- a/vcproj-10/txt-converter-login.vcxproj.filters +++ /dev/null @@ -1,90 +0,0 @@ - - - - - login - - - login - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - converter - - - - - login - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - common - - - - - {23e12c5b-4a3f-49aa-880b-3cdd20026aaa} - - - {47a4218f-2ab2-4032-b56d-70593a821fb0} - - - {6d4aed21-4896-4192-8133-dd5f7ab3fb6d} - - - \ No newline at end of file diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 557b6e149..06c006cd4 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -357,91 +357,91 @@ Name="char_sql" > diff --git a/vcproj-9/char-server_txt.vcproj b/vcproj-9/char-server_txt.vcproj deleted file mode 100644 index be7ada4fc..000000000 --- a/vcproj-9/char-server_txt.vcproj +++ /dev/null @@ -1,417 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-9/login-server_txt.vcproj b/vcproj-9/login-server_txt.vcproj deleted file mode 100644 index 39c4bfdf5..000000000 --- a/vcproj-9/login-server_txt.vcproj +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj deleted file mode 100644 index e499c9035..000000000 --- a/vcproj-9/map-server_txt.vcproj +++ /dev/null @@ -1,681 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-9/txt-converter-char.vcproj b/vcproj-9/txt-converter-char.vcproj deleted file mode 100644 index ea0ee49eb..000000000 --- a/vcproj-9/txt-converter-char.vcproj +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vcproj-9/txt-converter-login.vcproj b/vcproj-9/txt-converter-login.vcproj deleted file mode 100644 index 26e640e6f..000000000 --- a/vcproj-9/txt-converter-login.vcproj +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2 From 526217d77d50dc27b0815e3d5895df7bfa38ff76 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Mon, 13 Feb 2012 01:19:04 +0000 Subject: - Added `libconfig` (configuration file library: http://www.hyperrealm.com/libconfig/): - Updated VS9/10 project files. - Updated `configure` & `Makefile`s. - New GM, Commands & Permissions system: - '''This is a backwards compatibility breaking update''', please read tid:58877 - Replaced GM levels with Player Groups. - Commands permissions & other privileges now depend on group, not GM level. - `@help` command improvements: requires "commandname" param and shows more detailed info about commands. - Modified GM whisper system to deliver messages basing on permissions, not GM level. - Remote trade request is now possible only if player is allowed to use `@trade` command as well. - Added a proper permission to use `/changemaptype` command. - `clif_displaymessage` is now capable of displaying multiline messages. - All `ACMD_FUNC`s are static now, and the only way to invoke them is with `is_atcommand()`; all client commands (starting with `/`) are now translated into corresponding atcommands (with exception of `/kick` used on monster, as there is no atcommand to kill single monster). - Removed nonsense "bot check" triggering when player blocked (`/ex`) Server. - Merged `@monster`, `@monsterbig` and `@monstersmall`. - Improved flow of atcommand execution to avoid revealing info about online players or existing commands to non-privileged players. - Merged `atcommand` and `charcommand` script functions (`charcommand` is aliased to `atcommand`). - Fixed `atcommand` script function reading unknown memory area (possible access violation). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15572 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/LICENSE | 674 ++++++++ 3rdparty/libconfig/Makefile.in | 24 + 3rdparty/libconfig/grammar.c | 2001 +++++++++++++++++++++++ 3rdparty/libconfig/grammar.h | 113 ++ 3rdparty/libconfig/libconfig-1.4.8 | 0 3rdparty/libconfig/libconfig.c | 1615 +++++++++++++++++++ 3rdparty/libconfig/libconfig.h | 320 ++++ 3rdparty/libconfig/parsectx.h | 47 + 3rdparty/libconfig/scanctx.c | 170 ++ 3rdparty/libconfig/scanctx.h | 61 + 3rdparty/libconfig/scanner.c | 2362 ++++++++++++++++++++++++++++ 3rdparty/libconfig/scanner.h | 326 ++++ 3rdparty/libconfig/strbuf.c | 57 + 3rdparty/libconfig/strbuf.h | 39 + 3rdparty/libconfig/wincompat.h | 89 ++ Makefile.in | 13 +- conf/atcommand_athena.conf | 813 +--------- conf/battle/gm.conf | 87 - conf/char_athena.conf | 6 +- conf/groups.conf | 274 ++++ conf/help.txt | 402 +++-- conf/help2.txt | 94 -- conf/import-tmpl/atcommand_conf.txt | 0 conf/log_athena.conf | 6 +- conf/login_athena.conf | 7 +- conf/msg_athena.conf | 12 +- configure | 288 +++- configure.in | 6 +- doc/atcommands.txt | 213 +++ doc/permissions.txt | 21 + sql-files/upgrade_svn15572.sql | 3 + src/char/Makefile.in | 20 +- src/char/char.c | 22 +- src/common/Makefile.in | 30 +- src/common/conf.c | 109 ++ src/common/conf.h | 13 + src/common/showmsg.c | 16 + src/common/showmsg.h | 3 + src/login/Makefile.in | 21 +- src/login/account.h | 2 +- src/login/account_sql.c | 12 +- src/login/login.c | 24 +- src/login/login.h | 4 +- src/map/Makefile.in | 24 +- src/map/atcommand.c | 1587 ++++++++----------- src/map/atcommand.h | 30 +- src/map/battle.c | 26 - src/map/battle.h | 27 - src/map/buyingstore.c | 10 +- src/map/chat.c | 4 +- src/map/chrif.c | 8 +- src/map/clif.c | 499 ++---- src/map/clif.h | 2 - src/map/intif.c | 34 +- src/map/intif.h | 2 +- src/map/log.c | 15 +- src/map/log.h | 4 +- src/map/mail.c | 8 +- src/map/party.c | 8 +- src/map/pc.c | 144 +- src/map/pc.h | 37 +- src/map/pc_groups.c | 459 ++++++ src/map/pc_groups.h | 20 + src/map/script.c | 59 +- src/map/skill.c | 13 +- src/map/storage.c | 8 +- src/map/trade.c | 30 +- src/map/vending.c | 4 +- src/tool/Makefile.in | 14 +- vcproj-10/char-server_sql.vcxproj | 20 +- vcproj-10/char-server_sql.vcxproj.filters | 54 +- vcproj-10/login-server_sql.vcxproj | 20 +- vcproj-10/login-server_sql.vcxproj.filters | 54 +- vcproj-10/map-server_sql.vcxproj | 24 +- vcproj-10/map-server_sql.vcxproj.filters | 85 +- vcproj-10/mapcache.vcxproj | 8 +- vcproj-9/char-server_sql.vcproj | 86 +- vcproj-9/login-server_sql.vcproj | 88 +- vcproj-9/map-server_sql.vcproj | 140 +- vcproj-9/mapcache.vcproj | 12 +- 80 files changed, 11240 insertions(+), 2846 deletions(-) create mode 100644 3rdparty/libconfig/LICENSE create mode 100644 3rdparty/libconfig/Makefile.in create mode 100644 3rdparty/libconfig/grammar.c create mode 100644 3rdparty/libconfig/grammar.h create mode 100644 3rdparty/libconfig/libconfig-1.4.8 create mode 100644 3rdparty/libconfig/libconfig.c create mode 100644 3rdparty/libconfig/libconfig.h create mode 100644 3rdparty/libconfig/parsectx.h create mode 100644 3rdparty/libconfig/scanctx.c create mode 100644 3rdparty/libconfig/scanctx.h create mode 100644 3rdparty/libconfig/scanner.c create mode 100644 3rdparty/libconfig/scanner.h create mode 100644 3rdparty/libconfig/strbuf.c create mode 100644 3rdparty/libconfig/strbuf.h create mode 100644 3rdparty/libconfig/wincompat.h create mode 100644 conf/groups.conf delete mode 100644 conf/help2.txt delete mode 100644 conf/import-tmpl/atcommand_conf.txt create mode 100644 doc/atcommands.txt create mode 100644 doc/permissions.txt create mode 100644 sql-files/upgrade_svn15572.sql create mode 100644 src/common/conf.c create mode 100644 src/common/conf.h create mode 100644 src/map/pc_groups.c create mode 100644 src/map/pc_groups.h (limited to 'configure') diff --git a/3rdparty/libconfig/LICENSE b/3rdparty/libconfig/LICENSE new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/3rdparty/libconfig/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in new file mode 100644 index 000000000..22642413d --- /dev/null +++ b/3rdparty/libconfig/Makefile.in @@ -0,0 +1,24 @@ + +LIBCONFIG_OBJ = libconfig.o grammar.o scanctx.o scanner.o strbuf.o +LIBCONFIG_H = libconfig.h grammar.h parsectx.h scanctx.h scanner.h strbuf.h wincompat.h + +@SET_MAKE@ + +##################################################################### +.PHONY : all clean help + +all: $(LIBCONFIG_OBJ) + +clean: + rm -rf *.o + +help: + @echo "possible targets are 'all' 'clean' 'help'" + @echo "'all' - builds $(LIBCONFIG_OBJ)" + @echo "'clean' - deletes $(LIBCONFIG_OBJ)" + @echo "'help' - outputs this message" + +##################################################################### + +%.o: %.c $(LIBCONFIG_H) + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/libconfig/grammar.c b/3rdparty/libconfig/grammar.c new file mode 100644 index 000000000..e95a569f6 --- /dev/null +++ b/3rdparty/libconfig/grammar.c @@ -0,0 +1,2001 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse libconfig_yyparse +#define yylex libconfig_yylex +#define yyerror libconfig_yyerror +#define yylval libconfig_yylval +#define yychar libconfig_yychar +#define yydebug libconfig_yydebug +#define yynerrs libconfig_yynerrs + + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 32 "grammar.y" + +#include +#include +#include "libconfig.h" +#ifdef WIN32 +#include "wincompat.h" + +/* prevent warnings about redefined malloc/free in generated code: */ +#ifndef _STDLIB_H +#define _STDLIB_H +#endif + +#include +#endif +#include "parsectx.h" +#include "scanctx.h" + +/* these delcarations are provided to suppress compiler warnings */ +extern int libconfig_yylex(); +extern int libconfig_yyget_lineno(); + +static const char *err_array_elem_type = "mismatched element type in array"; +static const char *err_duplicate_setting = "duplicate setting name"; + +#define _delete(P) free((void *)(P)) + +#define IN_ARRAY() \ + (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY)) + +#define IN_LIST() \ + (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST)) + +static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx, + config_setting_t *setting) +{ + setting->line = (unsigned int)libconfig_yyget_lineno(scanner); + setting->file = scanctx_current_filename(scan_ctx); +} + +#define CAPTURE_PARSE_POS(S) \ + capture_parse_pos(scanner, scan_ctx, (S)) + +void libconfig_yyerror(void *scanner, struct parse_context *ctx, + struct scan_context *scan_ctx, char const *s) +{ + if(ctx->config->error_text) return; + ctx->config->error_line = libconfig_yyget_lineno(scanner); + ctx->config->error_text = s; +} + + + +/* Line 189 of yacc.c */ +#line 134 "grammar.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 85 "grammar.y" + + int ival; + long long llval; + double fval; + char *sval; + + + +/* Line 214 of yacc.c */ +#line 223 "grammar.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 235 "grammar.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 35 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 23 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 20 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 39 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 47 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 277 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 8, 11, 12, 14, 15, + 17, 19, 20, 26, 27, 32, 33, 38, 40, 42, + 44, 46, 48, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 71, 72, 74, 76, 80, 81, 83, 84 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 24, 0, -1, -1, 25, -1, 28, -1, 25, 28, + -1, -1, 25, -1, -1, 20, -1, 17, -1, -1, + 10, 29, 11, 34, 27, -1, -1, 13, 31, 40, + 14, -1, -1, 15, 33, 38, 16, -1, 36, -1, + 30, -1, 32, -1, 41, -1, 9, -1, 35, 9, + -1, 3, -1, 4, -1, 6, -1, 5, -1, 7, + -1, 8, -1, 35, -1, 34, -1, 37, 17, 34, + -1, -1, 37, -1, 36, -1, 39, 17, 36, -1, + -1, 39, -1, -1, 18, 42, 26, 19, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 100, 100, 102, 106, 107, 110, 112, 115, 117, + 118, 123, 122, 142, 141, 165, 164, 187, 188, 189, + 190, 194, 195, 199, 219, 241, 263, 285, 307, 325, + 353, 354, 357, 359, 363, 364, 367, 369, 374, 373 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_HEX", + "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME", + "TOK_EQUALS", "TOK_NEWLINE", "TOK_ARRAY_START", "TOK_ARRAY_END", + "TOK_LIST_START", "TOK_LIST_END", "TOK_COMMA", "TOK_GROUP_START", + "TOK_GROUP_END", "TOK_SEMICOLON", "TOK_GARBAGE", "TOK_ERROR", "$accept", + "configuration", "setting_list", "setting_list_optional", + "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3", + "value", "string", "simple_value", "value_list", "value_list_optional", + "simple_value_list", "simple_value_list_optional", "group", "$@4", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 27, 29, 28, 31, 30, 33, 32, 34, 34, 34, + 34, 35, 35, 36, 36, 36, 36, 36, 36, 36, + 37, 37, 38, 38, 39, 39, 40, 40, 42, 41 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 1, 2, 0, 1, 0, 1, + 1, 0, 5, 0, 4, 0, 4, 1, 1, 1, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 0, 1, 1, 3, 0, 1, 0, 4 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 11, 0, 3, 4, 0, 1, 5, 0, 23, + 24, 26, 25, 27, 28, 21, 13, 15, 38, 18, + 19, 8, 29, 17, 20, 36, 32, 6, 10, 9, + 12, 22, 34, 37, 0, 30, 33, 0, 7, 0, + 0, 14, 0, 16, 39, 35, 31 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 39, 30, 4, 5, 19, 25, 20, + 26, 21, 22, 23, 36, 37, 33, 34, 24, 27 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -26 +static const yytype_int8 yypact[] = +{ + -8, -26, 12, -8, -26, 5, -26, -26, 0, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -6, 10, -26, -26, 23, 0, -8, -26, -26, + -26, -26, -26, 3, 7, -26, 6, 8, -8, 14, + 23, -26, 0, -26, -26, -26, -26 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -26, -26, -5, -26, -26, -3, -26, -26, -26, -26, + -26, -25, -26, -15, -26, -26, -26, -26, -26, -26 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 7, 35, 1, 9, 10, 11, 12, 13, 14, 15, + 32, 28, 6, 16, 29, 17, 8, 46, 18, 31, + 40, 41, 38, 42, 43, 45, 9, 10, 11, 12, + 13, 14, 15, 44, 0, 7 +}; + +static const yytype_int8 yycheck[] = +{ + 3, 26, 10, 3, 4, 5, 6, 7, 8, 9, + 25, 17, 0, 13, 20, 15, 11, 42, 18, 9, + 17, 14, 27, 17, 16, 40, 3, 4, 5, 6, + 7, 8, 9, 19, -1, 38 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 10, 24, 25, 28, 29, 0, 28, 11, 3, + 4, 5, 6, 7, 8, 9, 13, 15, 18, 30, + 32, 34, 35, 36, 41, 31, 33, 42, 17, 20, + 27, 9, 36, 39, 40, 34, 37, 38, 25, 26, + 17, 14, 17, 16, 19, 36, 34 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, scanner, ctx, scan_ctx); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + if (!yyvaluep) + return; + YYUSE (scanner); + YYUSE (ctx); + YYUSE (scan_ctx); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_reduce_print (yyvsp, yyrule, scanner, ctx, scan_ctx) + YYSTYPE *yyvsp; + int yyrule; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , scanner, ctx, scan_ctx); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, scanner, ctx, scan_ctx); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, scanner, ctx, scan_ctx) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + YYUSE (yyvaluep); + YYUSE (scanner); + YYUSE (ctx); + YYUSE (scan_ctx); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +int +yyparse (scanner, ctx, scan_ctx) + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 11: + +/* Line 1455 of yacc.c */ +#line 123 "grammar.y" + { + ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE); + + if(ctx->setting == NULL) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting); + YYABORT; + } + else + { + CAPTURE_PARSE_POS(ctx->setting); + } + } + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 142 "grammar.y" + { + if(IN_LIST()) + { + ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY); + CAPTURE_PARSE_POS(ctx->parent); + } + else + { + ctx->setting->type = CONFIG_TYPE_ARRAY; + ctx->parent = ctx->setting; + ctx->setting = NULL; + } + } + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 157 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 165 "grammar.y" + { + if(IN_LIST()) + { + ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST); + CAPTURE_PARSE_POS(ctx->parent); + } + else + { + ctx->setting->type = CONFIG_TYPE_LIST; + ctx->parent = ctx->setting; + ctx->setting = NULL; + } + } + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 180 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + case 21: + +/* Line 1455 of yacc.c */ +#line 194 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(1) - (1)].sval)); free((yyvsp[(1) - (1)].sval)); } + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 195 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(2) - (2)].sval)); free((yyvsp[(2) - (2)].sval)); } + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 200 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1, + (int)(yyvsp[(1) - (1)].ival)); + + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + CAPTURE_PARSE_POS(e); + } + } + else + config_setting_set_bool(ctx->setting, (int)(yyvsp[(1) - (1)].ival)); + } + break; + + case 24: + +/* Line 1455 of yacc.c */ +#line 220 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + config_setting_set_format(e, CONFIG_FORMAT_DEFAULT); + CAPTURE_PARSE_POS(e); + } + } + else + { + config_setting_set_int(ctx->setting, (yyvsp[(1) - (1)].ival)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT); + } + } + break; + + case 25: + +/* Line 1455 of yacc.c */ +#line 242 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + config_setting_set_format(e, CONFIG_FORMAT_DEFAULT); + CAPTURE_PARSE_POS(e); + } + } + else + { + config_setting_set_int64(ctx->setting, (yyvsp[(1) - (1)].llval)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT); + } + } + break; + + case 26: + +/* Line 1455 of yacc.c */ +#line 264 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + config_setting_set_format(e, CONFIG_FORMAT_HEX); + CAPTURE_PARSE_POS(e); + } + } + else + { + config_setting_set_int(ctx->setting, (yyvsp[(1) - (1)].ival)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX); + } + } + break; + + case 27: + +/* Line 1455 of yacc.c */ +#line 286 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + config_setting_set_format(e, CONFIG_FORMAT_HEX); + CAPTURE_PARSE_POS(e); + } + } + else + { + config_setting_set_int64(ctx->setting, (yyvsp[(1) - (1)].llval)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX); + } + } + break; + + case 28: + +/* Line 1455 of yacc.c */ +#line 308 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[(1) - (1)].fval)); + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + CAPTURE_PARSE_POS(e); + } + } + else + config_setting_set_float(ctx->setting, (yyvsp[(1) - (1)].fval)); + } + break; + + case 29: + +/* Line 1455 of yacc.c */ +#line 326 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + const char *s = parsectx_take_string(ctx); + config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s); + _delete(s); + + if(! e) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); + YYABORT; + } + else + { + CAPTURE_PARSE_POS(e); + } + } + else + { + const char *s = parsectx_take_string(ctx); + config_setting_set_string(ctx->setting, s); + _delete(s); + } + } + break; + + case 38: + +/* Line 1455 of yacc.c */ +#line 374 "grammar.y" + { + if(IN_LIST()) + { + ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP); + CAPTURE_PARSE_POS(ctx->parent); + } + else + { + ctx->setting->type = CONFIG_TYPE_GROUP; + ctx->parent = ctx->setting; + ctx->setting = NULL; + } + } + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 389 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + + +/* Line 1455 of yacc.c */ +#line 1788 "grammar.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (scanner, ctx, scan_ctx, yymsg); + } + else + { + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, scanner, ctx, scan_ctx); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, scanner, ctx, scan_ctx); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, scanner, ctx, scan_ctx); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 1675 of yacc.c */ +#line 395 "grammar.y" + + diff --git a/3rdparty/libconfig/grammar.h b/3rdparty/libconfig/grammar.h new file mode 100644 index 000000000..2ce199dde --- /dev/null +++ b/3rdparty/libconfig/grammar.h @@ -0,0 +1,113 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 1676 of yacc.c */ +#line 85 "grammar.y" + + int ival; + long long llval; + double fval; + char *sval; + + + +/* Line 1676 of yacc.c */ +#line 105 "grammar.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + + + diff --git a/3rdparty/libconfig/libconfig-1.4.8 b/3rdparty/libconfig/libconfig-1.4.8 new file mode 100644 index 000000000..e69de29bb diff --git a/3rdparty/libconfig/libconfig.c b/3rdparty/libconfig/libconfig.c new file mode 100644 index 000000000..e64213c16 --- /dev/null +++ b/3rdparty/libconfig/libconfig.c @@ -0,0 +1,1615 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifdef HAVE_CONFIG_H +#include "ac_config.h" +#endif + +#include "libconfig.h" +#include "grammar.h" +#include "scanner.h" +#include "scanctx.h" +#include "parsectx.h" +#include "wincompat.h" + +#include + +#ifdef HAVE_XLOCALE_H +#include +#endif + +#include +#include +#include + +#define PATH_TOKENS ":./" +#define CHUNK_SIZE 16 +#define FLOAT_PRECISION 10 + +#define _new(T) (T *)calloc(sizeof(T), 1) /* zeroed */ +#define _delete(P) free((void *)(P)) + +/* ------------------------------------------------------------------------- */ + +#ifndef LIBCONFIG_STATIC +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return(TRUE); +} + +#endif /* WIN32 */ +#endif /* LIBCONFIG_STATIC */ + +/* ------------------------------------------------------------------------- */ + +static const char *__io_error = "file I/O error"; + +static void __config_list_destroy(config_list_t *list); +static void __config_write_setting(const config_setting_t *setting, + FILE *stream, int depth, + unsigned short tab_width); + +extern int libconfig_yyparse(void *scanner, struct parse_context *ctx, + struct scan_context *scan_ctx); +extern int libconfig_yylex_init_extra(struct scan_context *scan_ctx, + yyscan_t *scanner); + +/* ------------------------------------------------------------------------- */ + +static void __config_locale_override(void) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + + _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); + setlocale(LC_NUMERIC, "C"); + +#elif defined(__APPLE__) + + locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL); + uselocale(loc); + +#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE)) + + locale_t loc = newlocale(LC_NUMERIC, "C", NULL); + uselocale(loc); + +#else + +#warning "No way to modify calling thread's locale!" + +#endif +} + +/* ------------------------------------------------------------------------- */ + +static void __config_locale_restore(void) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + + _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); + +#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE)) + + locale_t loc = uselocale(LC_GLOBAL_LOCALE); + freelocale(loc); + +#else + +#warning "No way to modify calling thread's locale!" + +#endif +} + +/* ------------------------------------------------------------------------- */ + +static int __config_name_compare(const char *a, const char *b) +{ + const char *p, *q; + + for(p = a, q = b; ; p++, q++) + { + int pd = ((! *p) || strchr(PATH_TOKENS, *p)); + int qd = ((! *q) || strchr(PATH_TOKENS, *q)); + + if(pd && qd) + break; + else if(pd) + return(-1); + else if(qd) + return(1); + else if(*p < *q) + return(-1); + else if(*p > *q) + return(1); + } + + return(0); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_indent(FILE *stream, int depth, unsigned short w) +{ + if(w) + fprintf(stream, "%*s", (depth - 1) * w, " "); + else + { + int i; + for(i = 0; i < (depth - 1); ++i) + fputc('\t', stream); + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_write_value(const config_value_t *value, int type, + int format, int depth, + unsigned short tab_width, FILE *stream) +{ + char fbuf[64]; + + switch(type) + { + /* boolean */ + case CONFIG_TYPE_BOOL: + fputs(value->ival ? "true" : "false", stream); + break; + + /* int */ + case CONFIG_TYPE_INT: + switch(format) + { + case CONFIG_FORMAT_HEX: + fprintf(stream, "0x%X", value->ival); + break; + + case CONFIG_FORMAT_DEFAULT: + default: + fprintf(stream, "%d", value->ival); + break; + } + break; + + /* 64-bit int */ + case CONFIG_TYPE_INT64: + switch(format) + { + case CONFIG_FORMAT_HEX: + fprintf(stream, "0x" INT64_HEX_FMT "L", value->llval); + break; + + case CONFIG_FORMAT_DEFAULT: + default: + fprintf(stream, INT64_FMT "L", value->llval); + break; + } + break; + + /* float */ + case CONFIG_TYPE_FLOAT: + { + char *q; + + snprintf(fbuf, sizeof(fbuf) - 3, "%.*g", FLOAT_PRECISION, value->fval); + + /* check for exponent */ + q = strchr(fbuf, 'e'); + if(! q) + { + /* no exponent */ + if(! strchr(fbuf, '.')) /* no decimal point */ + strcat(fbuf, ".0"); + else + { + /* has decimal point */ + char *p; + + for(p = fbuf + strlen(fbuf) - 1; p > fbuf; --p) + { + if(*p != '0') + { + *(++p) = '\0'; + break; + } + } + } + } + + fputs(fbuf, stream); + break; + } + + /* string */ + case CONFIG_TYPE_STRING: + { + char *p; + + fputc('\"', stream); + + if(value->sval) + { + for(p = value->sval; *p; p++) + { + int c = (int)*p & 0xFF; + switch(c) + { + case '\"': + case '\\': + fputc('\\', stream); + fputc(c, stream); + break; + + case '\n': + fputs("\\n", stream); + break; + + case '\r': + fputs("\\r", stream); + break; + + case '\f': + fputs("\\f", stream); + break; + + case '\t': + fputs("\\t", stream); + break; + + default: + if(c >= ' ') + fputc(c, stream); + else + fprintf(stream, "\\x%02X", c); + } + } + } + fputc('\"', stream); + break; + } + + /* list */ + case CONFIG_TYPE_LIST: + { + config_list_t *list = value->list; + + fprintf(stream, "( "); + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + { + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); + + if(len) + fputc(',', stream); + + fputc(' ', stream); + } + } + + fputc(')', stream); + break; + } + + /* array */ + case CONFIG_TYPE_ARRAY: + { + config_list_t *list = value->list; + + fprintf(stream, "[ "); + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + { + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); + + if(len) + fputc(',', stream); + + fputc(' ', stream); + } + } + + fputc(']', stream); + break; + } + + /* group */ + case CONFIG_TYPE_GROUP: + { + config_list_t *list = value->list; + + if(depth > 0) + { +#ifdef K_AND_R_STYLE /* Horrendous, but many people like it. */ + fputc(' ', stream); +#else + fputc('\n', stream); + + if(depth > 1) + __config_indent(stream, depth, tab_width); +#endif + fprintf(stream, "{\n"); + } + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + __config_write_setting(*s, stream, depth + 1, tab_width); + } + + if(depth > 1) + __config_indent(stream, depth, tab_width); + + if(depth > 0) + fputc('}', stream); + + break; + } + + default: + /* this shouldn't happen, but handle it gracefully... */ + fputs("???", stream); + break; + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_list_add(config_list_t *list, config_setting_t *setting) +{ + if((list->length % CHUNK_SIZE) == 0) + { + list->elements = (config_setting_t **)realloc( + list->elements, + (list->length + CHUNK_SIZE) * sizeof(config_setting_t *)); + } + + list->elements[list->length] = setting; + list->length++; +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *__config_list_search(config_list_t *list, + const char *name, + unsigned int *idx) +{ + config_setting_t **found = NULL; + unsigned int i; + + if(! list) + return(NULL); + + for(i = 0, found = list->elements; i < list->length; i++, found++) + { + if(! (*found)->name) + continue; + + if(! __config_name_compare(name, (*found)->name)) + { + if(idx) + *idx = i; + + return(*found); + } + } + + return(NULL); +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *__config_list_remove(config_list_t *list, int idx) +{ + config_setting_t *removed = *(list->elements + idx); + int offset = (idx * sizeof(config_setting_t *)); + int len = list->length - 1 - idx; + char *base = (char *)list->elements + offset; + + memmove(base, base + sizeof(config_setting_t *), + len * sizeof(config_setting_t *)); + + list->length--; + + /* possibly realloc smaller? */ + + return(removed); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_setting_destroy(config_setting_t *setting) +{ + if(setting) + { + if(setting->name) + _delete(setting->name); + + if(setting->type == CONFIG_TYPE_STRING) + _delete(setting->value.sval); + + else if((setting->type == CONFIG_TYPE_GROUP) + || (setting->type == CONFIG_TYPE_ARRAY) + || (setting->type == CONFIG_TYPE_LIST)) + { + if(setting->value.list) + __config_list_destroy(setting->value.list); + } + + if(setting->hook && setting->config->destructor) + setting->config->destructor(setting->hook); + + _delete(setting); + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_list_destroy(config_list_t *list) +{ + config_setting_t **p; + unsigned int i; + + if(! list) + return; + + if(list->elements) + { + for(p = list->elements, i = 0; i < list->length; p++, i++) + __config_setting_destroy(*p); + + _delete(list->elements); + } + + _delete(list); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_vector_checktype(const config_setting_t *vector, int type) +{ + /* if the array is empty, then it has no type yet */ + + if(! vector->value.list) + return(CONFIG_TRUE); + + if(vector->value.list->length == 0) + return(CONFIG_TRUE); + + /* if it's a list, any type is allowed */ + + if(vector->type == CONFIG_TYPE_LIST) + return(CONFIG_TRUE); + + /* otherwise the first element added determines the type of the array */ + + return((vector->value.list->elements[0]->type == type) + ? CONFIG_TRUE : CONFIG_FALSE); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_validate_name(const char *name) +{ + const char *p = name; + + if(*p == '\0') + return(CONFIG_FALSE); + + if(! isalpha(*p) && (*p != '*')) + return(CONFIG_FALSE); + + for(++p; *p; ++p) + { + if(! (isalpha(*p) || isdigit(*p) || strchr("*_-", (int)*p))) + return(CONFIG_FALSE); + } + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_read(config_t *config, FILE *stream, const char *filename, + const char *str) +{ + yyscan_t scanner; + struct scan_context scan_ctx; + struct parse_context parse_ctx; + YY_BUFFER_STATE buffer = NULL; + int r; + + /* Reinitialize the config */ + void (*destructor)(void *) = config->destructor; + const char *include_dir = config->include_dir; + unsigned short tab_width = config->tab_width; + unsigned short flags = config->flags; + + config->include_dir = NULL; + config_destroy(config); + config_init(config); + + config->destructor = destructor; + config->include_dir = include_dir; + config->tab_width = tab_width; + config->flags = flags; + + parsectx_init(&parse_ctx); + parse_ctx.config = config; + parse_ctx.parent = config->root; + parse_ctx.setting = config->root; + + __config_locale_override(); + + scanctx_init(&scan_ctx, filename); + scan_ctx.config = config; + libconfig_yylex_init_extra(&scan_ctx, &scanner); + + if(stream) + libconfig_yyrestart(stream, scanner); + else /* read from string */ + buffer = libconfig_yy_scan_string(str, scanner); + + libconfig_yyset_lineno(1, scanner); + r = libconfig_yyparse(scanner, &parse_ctx, &scan_ctx); + + if(r != 0) + { + YY_BUFFER_STATE buf; + + config->error_file = scanctx_current_filename(&scan_ctx); + config->error_type = CONFIG_ERR_PARSE; + + /* Unwind the include stack, freeing the buffers and closing the files. */ + while((buf = (YY_BUFFER_STATE)scanctx_pop_include(&scan_ctx)) != NULL) + libconfig_yy_delete_buffer(buf, scanner); + } + + libconfig_yylex_destroy(scanner); + config->filenames = scanctx_cleanup(&scan_ctx, &(config->num_filenames)); + parsectx_cleanup(&parse_ctx); + + __config_locale_restore(); + + return(r == 0 ? CONFIG_TRUE : CONFIG_FALSE); +} + +/* ------------------------------------------------------------------------- */ + +int config_read(config_t *config, FILE *stream) +{ + return(__config_read(config, stream, NULL, NULL)); +} + +/* ------------------------------------------------------------------------- */ + +int config_read_string(config_t *config, const char *str) +{ + return(__config_read(config, NULL, NULL, str)); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_write_setting(const config_setting_t *setting, + FILE *stream, int depth, + unsigned short tab_width) +{ + if(depth > 1) + __config_indent(stream, depth, tab_width); + + if(setting->name) + { + fputs(setting->name, stream); + fprintf(stream, " %c ", (setting->type == CONFIG_TYPE_GROUP ? ':' : '=')); + } + + __config_write_value(&(setting->value), setting->type, + config_setting_get_format(setting), + depth, tab_width, stream); + + if(depth > 0) + { + fputc(';', stream); + fputc('\n', stream); + } +} + +/* ------------------------------------------------------------------------- */ + +void config_write(const config_t *config, FILE *stream) +{ + __config_locale_override(); + + __config_write_setting(config->root, stream, 0, config->tab_width); + + __config_locale_restore(); +} + +/* ------------------------------------------------------------------------- */ + +int config_read_file(config_t *config, const char *filename) +{ + int ret; + FILE *stream = fopen(filename, "rt"); + if(! stream) + { + config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; + return(CONFIG_FALSE); + } + + ret = __config_read(config, stream, filename, NULL); + fclose(stream); + + return(ret); +} + +/* ------------------------------------------------------------------------- */ + +int config_write_file(config_t *config, const char *filename) +{ + FILE *f = fopen(filename, "wt"); + if(! f) + { + config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; + return(CONFIG_FALSE); + } + + config_write(config, f); + fclose(f); + config->error_type = CONFIG_ERR_NONE; + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +void config_destroy(config_t *config) +{ + unsigned int count = config->num_filenames; + const char **f; + + __config_setting_destroy(config->root); + + for(f = config->filenames; count > 0; ++f, --count) + _delete(*f); + + _delete(config->filenames); + _delete(config->include_dir); + + memset((void *)config, 0, sizeof(config_t)); +} + +/* ------------------------------------------------------------------------- */ + +void config_init(config_t *config) +{ + memset((void *)config, 0, sizeof(config_t)); + + config->root = _new(config_setting_t); + config->root->type = CONFIG_TYPE_GROUP; + config->root->config = config; + config->tab_width = 2; +} + +/* ------------------------------------------------------------------------- */ + +void config_set_auto_convert(config_t *config, int flag) +{ + if(flag) + config->flags |= CONFIG_OPTION_AUTOCONVERT; + else + config->flags &= ~CONFIG_OPTION_AUTOCONVERT; +} + +/* ------------------------------------------------------------------------- */ + +int config_get_auto_convert(const config_t *config) +{ + return((config->flags & CONFIG_OPTION_AUTOCONVERT) != 0); +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *config_setting_create(config_setting_t *parent, + const char *name, int type) +{ + config_setting_t *setting; + config_list_t *list; + + if((parent->type != CONFIG_TYPE_GROUP) + && (parent->type != CONFIG_TYPE_ARRAY) + && (parent->type != CONFIG_TYPE_LIST)) + return(NULL); + + setting = _new(config_setting_t); + setting->parent = parent; + setting->name = (name == NULL) ? NULL : strdup(name); + setting->type = type; + setting->config = parent->config; + setting->hook = NULL; + setting->line = 0; + + list = parent->value.list; + + if(! list) + list = parent->value.list = _new(config_list_t); + + __config_list_add(list, setting); + + return(setting); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_int(const config_setting_t *setting, + int *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_INT: + *value = setting->value.ival; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT64: + if((setting->value.llval > INT32_MAX) + || (setting->value.llval < INT32_MIN)) + *value = 0; + else + *value = (int)(setting->value.llval); + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + *value = (int)(setting->value.fval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_int(const config_setting_t *setting) +{ + int value = 0; + __config_setting_get_int(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_int64(const config_setting_t *setting, + long long *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_INT64: + *value = setting->value.llval; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + *value = (long long)(setting->value.ival); + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + *value = (long long)(setting->value.fval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +long long config_setting_get_int64(const config_setting_t *setting) +{ + long long value = 0; + __config_setting_get_int64(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_int(const config_setting_t *setting, + const char *name, int *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_int(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_int64(const config_setting_t *setting, + const char *name, long long *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_int64(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_float(const config_setting_t *setting, + double *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_FLOAT: + *value = setting->value.fval; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.ival); + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + case CONFIG_TYPE_INT64: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.llval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +double config_setting_get_float(const config_setting_t *setting) +{ + double value = 0.0; + __config_setting_get_float(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_float(const config_setting_t *setting, + const char *name, double *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_float(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_string(const config_setting_t *setting, + const char *name, const char **value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + if(config_setting_type(member) != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + *value = config_setting_get_string(member); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_bool(const config_setting_t *setting, + const char *name, int *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + if(config_setting_type(member) != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + *value = config_setting_get_bool(member); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_int(config_setting_t *setting, int value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_INT; + /* fall through */ + + case CONFIG_TYPE_INT: + setting->value.ival = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if(config_get_auto_convert(setting->config)) + { + setting->value.fval = (float)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_int64(config_setting_t *setting, long long value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_INT64; + /* fall through */ + + case CONFIG_TYPE_INT64: + setting->value.llval = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if((value > INT32_MAX) || (value < INT32_MIN)) + setting->value.ival = 0; + else + setting->value.ival = (int)value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if(config_get_auto_convert(setting->config)) + { + setting->value.fval = (float)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_float(config_setting_t *setting, double value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_FLOAT; + /* fall through */ + + case CONFIG_TYPE_FLOAT: + setting->value.fval = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + setting->value.ival = (int)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + case CONFIG_TYPE_INT64: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + setting->value.llval = (long long)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_bool(const config_setting_t *setting) +{ + return((setting->type == CONFIG_TYPE_BOOL) ? setting->value.ival : 0); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_bool(config_setting_t *setting, int value) +{ + if(setting->type == CONFIG_TYPE_NONE) + setting->type = CONFIG_TYPE_BOOL; + else if(setting->type != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + setting->value.ival = value; + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +const char *config_setting_get_string(const config_setting_t *setting) +{ + return((setting->type == CONFIG_TYPE_STRING) ? setting->value.sval : NULL); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_string(config_setting_t *setting, const char *value) +{ + if(setting->type == CONFIG_TYPE_NONE) + setting->type = CONFIG_TYPE_STRING; + else if(setting->type != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + if(setting->value.sval) + _delete(setting->value.sval); + + setting->value.sval = (value == NULL) ? NULL : strdup(value); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_format(config_setting_t *setting, short format) +{ + if(((setting->type != CONFIG_TYPE_INT) + && (setting->type != CONFIG_TYPE_INT64)) + || ((format != CONFIG_FORMAT_DEFAULT) && (format != CONFIG_FORMAT_HEX))) + return(CONFIG_FALSE); + + setting->format = format; + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +short config_setting_get_format(const config_setting_t *setting) +{ + return(setting->format != 0 ? setting->format + : setting->config->default_format); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_lookup_from(config_setting_t *setting, + const char *path) +{ + const char *p = path; + config_setting_t *found; + + for(;;) + { + while(*p && strchr(PATH_TOKENS, *p)) + p++; + + if(! *p) + break; + + if(*p == '[') + found = config_setting_get_elem(setting, atoi(++p)); + else + found = config_setting_get_member(setting, p); + + if(! found) + break; + + setting = found; + + while(! strchr(PATH_TOKENS, *p)) + p++; + } + + return(*p ? NULL : setting); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_lookup(const config_t *config, const char *path) +{ + return(config_lookup_from(config->root, path)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_string(const config_t *config, const char *path, + const char **value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + if(config_setting_type(s) != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + *value = config_setting_get_string(s); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_int(const config_t *config, const char *path, + int *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_int(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_int64(const config_t *config, const char *path, + long long *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_int64(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_float(const config_t *config, const char *path, + double *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_float(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_bool(const config_t *config, const char *path, int *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + if(config_setting_type(s) != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + *value = config_setting_get_bool(s); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_int_elem(const config_setting_t *vector, int idx) +{ + const config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_int(element) : 0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_int_elem(config_setting_t *vector, + int idx, int value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_INT)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_INT); + } + else + { + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + } + + if(! config_setting_set_int(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +long long config_setting_get_int64_elem(const config_setting_t *vector, + int idx) +{ + const config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_int64(element) : 0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_int64_elem(config_setting_t *vector, + int idx, long long value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_INT64)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_INT64); + } + else + { + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + } + + if(! config_setting_set_int64(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +double config_setting_get_float_elem(const config_setting_t *vector, int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_float(element) : 0.0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_float_elem(config_setting_t *vector, + int idx, double value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_FLOAT)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_FLOAT); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_float(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_bool_elem(const config_setting_t *vector, int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + if(! element) + return(CONFIG_FALSE); + + if(element->type != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + return(element->value.ival); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_bool_elem(config_setting_t *vector, + int idx, int value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_BOOL)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_BOOL); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_bool(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +const char *config_setting_get_string_elem(const config_setting_t *vector, + int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(element->type != CONFIG_TYPE_STRING) + return(NULL); + + return(element->value.sval); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_string_elem(config_setting_t *vector, + int idx, const char *value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_STRING)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_STRING); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_string(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_get_elem(const config_setting_t *vector, + unsigned int idx) +{ + config_list_t *list = vector->value.list; + + if(((vector->type != CONFIG_TYPE_ARRAY) + && (vector->type != CONFIG_TYPE_LIST) + && (vector->type != CONFIG_TYPE_GROUP)) || ! list) + return(NULL); + + if(idx >= list->length) + return(NULL); + + return(list->elements[idx]); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_get_member(const config_setting_t *setting, + const char *name) +{ + if(setting->type != CONFIG_TYPE_GROUP) + return(NULL); + + return(__config_list_search(setting->value.list, name, NULL)); +} + +/* ------------------------------------------------------------------------- */ + +void config_set_destructor(config_t *config, void (*destructor)(void *)) +{ + config->destructor = destructor; +} + +/* ------------------------------------------------------------------------- */ + +void config_set_include_dir(config_t *config, const char *include_dir) +{ + _delete(config->include_dir); + config->include_dir = strdup(include_dir); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_length(const config_setting_t *setting) +{ + if((setting->type != CONFIG_TYPE_GROUP) + && (setting->type != CONFIG_TYPE_ARRAY) + && (setting->type != CONFIG_TYPE_LIST)) + return(0); + + if(! setting->value.list) + return(0); + + return(setting->value.list->length); +} + +/* ------------------------------------------------------------------------- */ + +void config_setting_set_hook(config_setting_t *setting, void *hook) +{ + setting->hook = hook; +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_add(config_setting_t *parent, + const char *name, int type) +{ + if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST)) + return(NULL); + + if(! parent) + return(NULL); + + if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST)) + name = NULL; + + if(name) + { + if(! __config_validate_name(name)) + return(NULL); + } + + if(config_setting_get_member(parent, name) != NULL) + return(NULL); /* already exists */ + + return(config_setting_create(parent, name, type)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_remove(config_setting_t *parent, const char *name) +{ + unsigned int idx; + config_setting_t *setting; + + if(! parent) + return(CONFIG_FALSE); + + if(parent->type != CONFIG_TYPE_GROUP) + return(CONFIG_FALSE); + + if(! (setting = __config_list_search(parent->value.list, name, &idx))) + return(CONFIG_FALSE); + + __config_list_remove(parent->value.list, idx); + __config_setting_destroy(setting); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_remove_elem(config_setting_t *parent, unsigned int idx) +{ + config_list_t *list; + config_setting_t *removed = NULL; + + if(! parent) + return(CONFIG_FALSE); + + list = parent->value.list; + + if(((parent->type != CONFIG_TYPE_ARRAY) + && (parent->type != CONFIG_TYPE_LIST) + && (parent->type != CONFIG_TYPE_GROUP)) || ! list) + return(CONFIG_FALSE); + + if(idx >= list->length) + return(CONFIG_FALSE); + + removed = __config_list_remove(list, idx); + __config_setting_destroy(removed); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_index(const config_setting_t *setting) +{ + config_setting_t **found = NULL; + config_list_t *list; + int i; + + if(! setting->parent) + return(-1); + + list = setting->parent->value.list; + + for(i = 0, found = list->elements; i < (int)list->length; ++i, ++found) + { + if(*found == setting) + return(i); + } + + return(-1); +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/libconfig.h b/3rdparty/libconfig/libconfig.h new file mode 100644 index 000000000..683bda80b --- /dev/null +++ b/3rdparty/libconfig/libconfig.h @@ -0,0 +1,320 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_h +#define __libconfig_h + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#if defined(LIBCONFIG_STATIC) +#define LIBCONFIG_API +#elif defined(LIBCONFIG_EXPORTS) +#define LIBCONFIG_API __declspec(dllexport) +#else /* ! LIBCONFIG_EXPORTS */ +#define LIBCONFIG_API __declspec(dllimport) +#endif /* LIBCONFIG_STATIC */ +#else /* ! WIN32 */ +#define LIBCONFIG_API +#endif /* WIN32 */ + +#define LIBCONFIG_VER_MAJOR 1 +#define LIBCONFIG_VER_MINOR 4 +#define LIBCONFIG_VER_REVISION 8 + +#include + +#define CONFIG_TYPE_NONE 0 +#define CONFIG_TYPE_GROUP 1 +#define CONFIG_TYPE_INT 2 +#define CONFIG_TYPE_INT64 3 +#define CONFIG_TYPE_FLOAT 4 +#define CONFIG_TYPE_STRING 5 +#define CONFIG_TYPE_BOOL 6 +#define CONFIG_TYPE_ARRAY 7 +#define CONFIG_TYPE_LIST 8 + +#define CONFIG_FORMAT_DEFAULT 0 +#define CONFIG_FORMAT_HEX 1 + +#define CONFIG_OPTION_AUTOCONVERT 0x01 + +#define CONFIG_TRUE (1) +#define CONFIG_FALSE (0) + +typedef union config_value_t +{ + int ival; + long long llval; + double fval; + char *sval; + struct config_list_t *list; +} config_value_t; + +typedef struct config_setting_t +{ + char *name; + short type; + short format; + config_value_t value; + struct config_setting_t *parent; + struct config_t *config; + void *hook; + unsigned int line; + const char *file; +} config_setting_t; + +typedef enum +{ + CONFIG_ERR_NONE = 0, + CONFIG_ERR_FILE_IO = 1, + CONFIG_ERR_PARSE = 2 +} config_error_t; + +typedef struct config_list_t +{ + unsigned int length; + config_setting_t **elements; +} config_list_t; + +typedef struct config_t +{ + config_setting_t *root; + void (*destructor)(void *); + unsigned short flags; + unsigned short tab_width; + short default_format; + const char *include_dir; + const char *error_text; + const char *error_file; + int error_line; + config_error_t error_type; + const char **filenames; + unsigned int num_filenames; +} config_t; + +extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); +extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream); + +extern LIBCONFIG_API void config_set_default_format(config_t *config, + short format); + +extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag); +extern LIBCONFIG_API int config_get_auto_convert(const config_t *config); + +extern LIBCONFIG_API int config_read_string(config_t *config, const char *str); + +extern LIBCONFIG_API int config_read_file(config_t *config, + const char *filename); +extern LIBCONFIG_API int config_write_file(config_t *config, + const char *filename); + +extern LIBCONFIG_API void config_set_destructor(config_t *config, + void (*destructor)(void *)); +extern LIBCONFIG_API void config_set_include_dir(config_t *config, + const char *include_dir); + +extern LIBCONFIG_API void config_init(config_t *config); +extern LIBCONFIG_API void config_destroy(config_t *config); + +extern LIBCONFIG_API int config_setting_get_int( + const config_setting_t *setting); +extern LIBCONFIG_API long long config_setting_get_int64( + const config_setting_t *setting); +extern LIBCONFIG_API double config_setting_get_float( + const config_setting_t *setting); +extern LIBCONFIG_API int config_setting_get_bool( + const config_setting_t *setting); +extern LIBCONFIG_API const char *config_setting_get_string( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_lookup_int( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_int64( + const config_setting_t *setting, const char *name, long long *value); +extern LIBCONFIG_API int config_setting_lookup_float( + const config_setting_t *setting, const char *name, double *value); +extern LIBCONFIG_API int config_setting_lookup_bool( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_string( + const config_setting_t *setting, const char *name, const char **value); + +extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting, + long long value); +extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting, + double value); +extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting, + const char *value); + +extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting, + short format); +extern LIBCONFIG_API short config_setting_get_format( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_get_int_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API long long config_setting_get_int64_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API double config_setting_get_float_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API int config_setting_get_bool_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API const char *config_setting_get_string_elem( + const config_setting_t *setting, int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( + config_setting_t *setting, int idx, long long value); +extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( + config_setting_t *setting, int idx, double value); +extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( + config_setting_t *setting, int idx, const char *value); + +#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \ + ((C)->include_dir) + +#define /* int */ config_setting_type(/* const config_setting_t * */ S) \ + ((S)->type) + +#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_GROUP) +#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_ARRAY) +#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_LIST) + +#define /* int */ config_setting_is_aggregate( \ + /* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \ + || ((S)->type == CONFIG_TYPE_ARRAY)) + +#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_INT) \ + || ((S)->type == CONFIG_TYPE_INT64) \ + || ((S)->type == CONFIG_TYPE_FLOAT)) + +#define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \ + || config_setting_is_number(S)) + +#define /* const char * */ config_setting_name( \ + /* const config_setting_t * */ S) \ + ((S)->name) + +#define /* config_setting_t * */ config_setting_parent( \ + /* const config_setting_t * */ S) \ + ((S)->parent) + +#define /* int */ config_setting_is_root( \ + /* const config_setting_t * */ S) \ + ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE) + +extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_length( + const config_setting_t *setting); +extern LIBCONFIG_API config_setting_t *config_setting_get_elem( + const config_setting_t *setting, unsigned int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_get_member( + const config_setting_t *setting, const char *name); + +extern LIBCONFIG_API config_setting_t *config_setting_add( + config_setting_t *parent, const char *name, int type); +extern LIBCONFIG_API int config_setting_remove(config_setting_t *parent, + const char *name); +extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent, + unsigned int idx); +extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting, + void *hook); + +#define config_setting_get_hook(S) ((S)->hook) + +extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config, + const char *path); +extern LIBCONFIG_API config_setting_t *config_lookup_from( + config_setting_t *setting, const char *path); + +extern LIBCONFIG_API int config_lookup_int(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_int64(const config_t *config, + const char *path, + long long *value); +extern LIBCONFIG_API int config_lookup_float(const config_t *config, + const char *path, double *value); +extern LIBCONFIG_API int config_lookup_bool(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_string(const config_t *config, + const char *path, + const char **value); + +#define /* config_setting_t * */ config_root_setting( \ + /* const config_t * */ C) \ + ((C)->root) + +#define /* void */ config_set_default_format(/* config_t * */ C, \ + /* short */ F) \ + (C)->default_format = (F) + +#define /* short */ config_get_default_format(/* config_t * */ C) \ + ((C)->default_format) + +#define /* void */ config_set_tab_width(/* config_t * */ C, \ + /* unsigned short */ W) \ + (C)->tab_width = ((W) & 0x0F) + +#define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \ + ((C)->tab_width) + +#define /* unsigned short */ config_setting_source_line( \ + /* const config_setting_t * */ S) \ + ((S)->line) + +#define /* const char */ config_setting_source_file( \ + /* const config_setting_t * */ S) \ + ((S)->file) + +#define /* const char * */ config_error_text(/* const config_t * */ C) \ + ((C)->error_text) + +#define /* const char * */ config_error_file(/* const config_t * */ C) \ + ((C)->error_file) + +#define /* int */ config_error_line(/* const config_t * */ C) \ + ((C)->error_line) + +#define /* config_error_t */ config_error_type(/* const config_t * */ C) \ + ((C)->error_type) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __libconfig_h */ diff --git a/3rdparty/libconfig/parsectx.h b/3rdparty/libconfig/parsectx.h new file mode 100644 index 000000000..0beb1111c --- /dev/null +++ b/3rdparty/libconfig/parsectx.h @@ -0,0 +1,47 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_parsectx_h +#define __libconfig_parsectx_h + +#include "libconfig.h" +#include "strbuf.h" + +struct parse_context +{ + config_t *config; + config_setting_t *parent; + config_setting_t *setting; + char *name; + strbuf_t string; +}; + +#define parsectx_init(C) \ + memset((C), 0, sizeof(struct parse_context)) +#define parsectx_cleanup(C) \ + free((void *)(strbuf_release(&((C)->string)))) + +#define parsectx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) +#define parsectx_take_string(C) \ + strbuf_release(&((C)->string)) + +#endif /* __libconfig_parsectx_h */ diff --git a/3rdparty/libconfig/scanctx.c b/3rdparty/libconfig/scanctx.c new file mode 100644 index 000000000..7d7f4994c --- /dev/null +++ b/3rdparty/libconfig/scanctx.c @@ -0,0 +1,170 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#include "scanctx.h" +#include "wincompat.h" + +#include +#include +#include + +#define STRING_BLOCK_SIZE 64 +#define CHUNK_SIZE 32 + +/* ------------------------------------------------------------------------- */ + +static const char *err_bad_include = "cannot open include file"; +static const char *err_include_too_deep = "include file nesting too deep"; + +/* ------------------------------------------------------------------------- */ + +static const char *__scanctx_add_filename(struct scan_context *ctx, + const char *filename) +{ + unsigned int count = ctx->num_filenames; + const char **f; + + for(f = ctx->filenames; count > 0; ++f, --count) + { + if(!strcmp(*f, filename)) + { + free((void *)filename); + return(*f); /* already in list */ + } + } + + if((ctx->num_filenames % CHUNK_SIZE) == 0) + { + ctx->filenames = (const char **)realloc( + (void *)ctx->filenames, + (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *)); + } + + ctx->filenames[ctx->num_filenames] = filename; + ++ctx->num_filenames; + return(filename); +} + +/* ------------------------------------------------------------------------- */ + +void scanctx_init(struct scan_context *ctx, const char *top_filename) +{ + memset(ctx, 0, sizeof(struct scan_context)); + if(top_filename) + ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename)); +} + +/* ------------------------------------------------------------------------- */ + +const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames) +{ + int i; + + for(i = 0; i < ctx->depth; ++i) + fclose(ctx->streams[i]); + + free((void *)(strbuf_release(&(ctx->string)))); + + *num_filenames = ctx->num_filenames; + return(ctx->filenames); +} + +/* ------------------------------------------------------------------------- */ + +FILE *scanctx_push_include(struct scan_context *ctx, void *buffer, + const char **error) +{ + FILE *fp = NULL; + const char *file; + char *full_file = NULL; + + *error = NULL; + + if(ctx->depth == MAX_INCLUDE_DEPTH) + { + *error = err_include_too_deep; + return(NULL); + } + + file = scanctx_take_string(ctx); + if(ctx->config->include_dir) + { + full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) + + 2); + strcpy(full_file, ctx->config->include_dir); + strcat(full_file, FILE_SEPARATOR); + strcat(full_file, file); + } + + fp = fopen(full_file ? full_file : file, "rt"); + free((void *)full_file); + + if(fp) + { + ctx->streams[ctx->depth] = fp; + ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file); + ctx->buffers[ctx->depth] = buffer; + ++(ctx->depth); + } + else + { + free((void *)file); + *error = err_bad_include; + } + + return(fp); +} + +/* ------------------------------------------------------------------------- */ + +void *scanctx_pop_include(struct scan_context *ctx) +{ + void *buffer; + + if(ctx->depth == 0) + return(NULL); /* stack underflow */ + + --(ctx->depth); + buffer = ctx->buffers[ctx->depth]; + fclose(ctx->streams[ctx->depth]); + + return(buffer); +} + +/* ------------------------------------------------------------------------- */ + +char *scanctx_take_string(struct scan_context *ctx) +{ + char *r = strbuf_release(&(ctx->string)); + + return(r ? r : strdup("")); +} + +/* ------------------------------------------------------------------------- */ + +const char *scanctx_current_filename(struct scan_context *ctx) +{ + return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]); +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/scanctx.h b/3rdparty/libconfig/scanctx.h new file mode 100644 index 000000000..b8cc11e3d --- /dev/null +++ b/3rdparty/libconfig/scanctx.h @@ -0,0 +1,61 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_scanctx_h +#define __libconfig_scanctx_h + +#include "libconfig.h" +#include "strbuf.h" + +#include +#include + +#define MAX_INCLUDE_DEPTH 10 + +struct scan_context +{ + config_t *config; + const char *top_filename; + const char *files[MAX_INCLUDE_DEPTH]; + void *buffers[MAX_INCLUDE_DEPTH]; + FILE *streams[MAX_INCLUDE_DEPTH]; + int depth; + strbuf_t string; + const char **filenames; + unsigned int num_filenames; +}; + +extern void scanctx_init(struct scan_context *ctx, const char *top_filename); +extern const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames); + +extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer, + const char **error); +extern void *scanctx_pop_include(struct scan_context *ctx); + +#define scanctx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) + +extern char *scanctx_take_string(struct scan_context *ctx); + +extern const char *scanctx_current_filename(struct scan_context *ctx); + +#endif /* __libconfig_scanctx_h */ diff --git a/3rdparty/libconfig/scanner.c b/3rdparty/libconfig/scanner.c new file mode 100644 index 000000000..c2eb7d188 --- /dev/null +++ b/3rdparty/libconfig/scanner.c @@ -0,0 +1,2362 @@ +#line 2 "scanner.c" + +#line 4 "scanner.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE libconfig_yyrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE libconfig_yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via libconfig_yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void libconfig_yypop_buffer_state (yyscan_t yyscanner ); + +static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner ); +static void libconfig_yy_load_buffer_state (yyscan_t yyscanner ); +static void libconfig_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER libconfig_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void libconfig_yyfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer libconfig_yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + libconfig_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + libconfig_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define libconfig_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 41 +#define YY_END_OF_BUFFER 42 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[103] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 42, 40, + 21, 20, 20, 5, 40, 36, 37, 28, 40, 23, + 29, 40, 30, 30, 22, 38, 28, 28, 34, 35, + 24, 25, 21, 40, 3, 4, 3, 6, 14, 41, + 16, 19, 41, 21, 0, 39, 28, 29, 30, 29, + 0, 1, 0, 29, 0, 31, 0, 28, 28, 21, + 0, 0, 2, 6, 12, 0, 11, 10, 7, 8, + 9, 16, 18, 17, 0, 29, 29, 0, 0, 29, + 31, 32, 28, 28, 0, 0, 0, 29, 33, 28, + 26, 0, 13, 33, 27, 0, 0, 0, 0, 0, + + 15, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 4, 5, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 6, 7, 1, 1, 1, 1, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 18, 19, 1, + 20, 1, 1, 21, 22, 23, 23, 23, 24, 25, + 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, + 26, 28, 29, 30, 31, 26, 26, 32, 26, 26, + 33, 34, 35, 1, 36, 1, 22, 23, 37, 38, + + 39, 40, 26, 26, 41, 26, 26, 42, 26, 43, + 26, 26, 26, 44, 29, 45, 46, 26, 26, 32, + 26, 26, 47, 1, 48, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[49] = + { 0, + 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, + 1, 1, 3, 1, 1, 4, 4, 1, 1, 1, + 1, 4, 4, 4, 4, 3, 3, 3, 3, 3, + 3, 3, 1, 2, 1, 3, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[113] = + { 0, + 0, 47, 47, 48, 46, 47, 48, 49, 203, 204, + 200, 204, 204, 204, 198, 204, 204, 0, 45, 204, + 47, 50, 60, 74, 204, 204, 178, 28, 204, 204, + 204, 204, 64, 158, 204, 204, 183, 0, 204, 63, + 0, 204, 83, 195, 193, 204, 0, 88, 102, 98, + 62, 204, 190, 104, 119, 162, 0, 67, 65, 121, + 127, 124, 204, 0, 204, 0, 204, 204, 204, 204, + 204, 0, 204, 204, 108, 117, 122, 134, 132, 136, + 204, 139, 136, 116, 126, 0, 140, 142, 135, 130, + 0, 102, 204, 204, 0, 85, 72, 63, 98, 158, + + 204, 204, 169, 173, 177, 181, 183, 187, 191, 89, + 66, 63 + } ; + +static yyconst flex_int16_t yy_def[113] = + { 0, + 102, 1, 103, 103, 104, 104, 105, 105, 102, 102, + 102, 102, 102, 102, 106, 102, 102, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 107, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 108, 102, 102, + 109, 102, 102, 102, 106, 102, 107, 102, 102, 102, + 102, 102, 106, 102, 102, 102, 110, 107, 107, 102, + 102, 102, 102, 108, 102, 111, 102, 102, 102, 102, + 102, 109, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 110, 107, 107, 102, 112, 102, 102, 102, 107, + 107, 102, 102, 102, 107, 102, 102, 102, 102, 102, + + 102, 0, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +static yyconst flex_int16_t yy_nxt[253] = + { 0, + 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, + 19, 20, 19, 21, 22, 23, 24, 25, 26, 25, + 10, 18, 18, 18, 27, 18, 18, 18, 18, 28, + 18, 18, 29, 10, 30, 10, 18, 18, 18, 27, + 18, 18, 18, 18, 28, 18, 31, 32, 33, 36, + 36, 39, 39, 42, 42, 59, 37, 37, 48, 52, + 49, 49, 50, 50, 53, 60, 93, 34, 65, 86, + 51, 59, 75, 54, 75, 49, 49, 76, 76, 40, + 40, 43, 43, 55, 61, 51, 56, 54, 73, 49, + 49, 57, 82, 83, 66, 84, 67, 55, 55, 100, + + 56, 99, 68, 50, 50, 69, 70, 71, 83, 98, + 84, 51, 55, 50, 50, 54, 74, 49, 49, 77, + 77, 51, 60, 76, 76, 55, 51, 78, 56, 79, + 97, 79, 76, 76, 80, 80, 51, 77, 77, 91, + 55, 61, 78, 96, 87, 78, 87, 80, 80, 88, + 88, 80, 80, 95, 91, 88, 88, 88, 88, 100, + 78, 94, 92, 101, 90, 89, 85, 62, 95, 35, + 35, 35, 35, 38, 38, 38, 38, 41, 41, 41, + 41, 45, 45, 45, 45, 47, 47, 64, 81, 64, + 64, 72, 46, 72, 72, 46, 44, 63, 62, 58, + + 46, 44, 102, 9, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +static yyconst flex_int16_t yy_chk[253] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 5, 6, 7, 8, 28, 3, 4, 19, 22, + 19, 19, 21, 21, 22, 33, 112, 2, 40, 111, + 21, 28, 51, 23, 51, 23, 23, 51, 51, 5, + 6, 7, 8, 23, 33, 21, 23, 24, 43, 24, + 24, 23, 110, 58, 40, 59, 40, 24, 23, 99, + + 24, 98, 40, 48, 48, 40, 40, 40, 58, 97, + 59, 48, 24, 50, 50, 49, 43, 49, 49, 54, + 54, 50, 60, 75, 75, 49, 48, 54, 49, 55, + 96, 55, 76, 76, 55, 55, 50, 77, 77, 84, + 49, 60, 54, 92, 78, 77, 78, 79, 79, 78, + 78, 80, 80, 90, 84, 87, 87, 88, 88, 100, + 77, 89, 85, 100, 83, 82, 62, 61, 90, 103, + 103, 103, 103, 104, 104, 104, 104, 105, 105, 105, + 105, 106, 106, 106, 106, 107, 107, 108, 56, 108, + 108, 109, 53, 109, 109, 45, 44, 37, 34, 27, + + 15, 11, 9, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[42] = + { 0, +0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "scanner.l" +/* -*- mode: C -*- */ +/* -------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + . + ---------------------------------------------------------------------------- +*/ +#define YY_NO_UNISTD_H 1 +#line 35 "scanner.l" + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#include +#include +#include +#include "grammar.h" +#include "wincompat.h" +#include "parsectx.h" +#include "scanctx.h" + +#define YY_NO_INPUT // Suppress generation of useless input() function + +static unsigned long long fromhex(const char *s) +{ +#ifdef __MINGW32__ + + /* MinGW's strtoull() seems to be broken; it only returns the lower + * 32 bits... + */ + + const char *p = s; + unsigned long long val = 0; + + if(*p != '0') + return(0); + + ++p; + + if(*p != 'x' && *p != 'X') + return(0); + + for(++p; isxdigit(*p); ++p) + { + val <<= 4; + val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7))); + } + + return(val); + +#else /* ! __MINGW32__ */ + + return(strtoull(s, NULL, 16)); + +#endif /* __MINGW32__ */ +} + + +#line 626 "scanner.c" + +#define INITIAL 0 +#define COMMENT 1 +#define STRING 2 +#define INCLUDE 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#define YY_EXTRA_TYPE struct scan_context * + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int libconfig_yylex_init (yyscan_t* scanner); + +int libconfig_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int libconfig_yylex_destroy (yyscan_t yyscanner ); + +int libconfig_yyget_debug (yyscan_t yyscanner ); + +void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner ); + +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_in (yyscan_t yyscanner ); + +void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_out (yyscan_t yyscanner ); + +void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int libconfig_yyget_leng (yyscan_t yyscanner ); + +char *libconfig_yyget_text (yyscan_t yyscanner ); + +int libconfig_yyget_lineno (yyscan_t yyscanner ); + +void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner ); + +void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int libconfig_yywrap (yyscan_t yyscanner ); +#else +extern int libconfig_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int libconfig_yylex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int libconfig_yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 100 "scanner.l" + + +#line 869 "scanner.c" + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + libconfig_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + libconfig_yy_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 204 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 102 "scanner.l" +{ BEGIN COMMENT; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 103 "scanner.l" +{ BEGIN INITIAL; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 104 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 105 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 107 "scanner.l" +{ BEGIN STRING; } + YY_BREAK +case 6: +/* rule 6 can match eol */ +YY_RULE_SETUP +#line 108 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 109 "scanner.l" +{ scanctx_append_string(yyextra, "\n"); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 110 "scanner.l" +{ scanctx_append_string(yyextra, "\r"); } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 111 "scanner.l" +{ scanctx_append_string(yyextra, "\t"); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 112 "scanner.l" +{ scanctx_append_string(yyextra, "\f"); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 113 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 114 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 115 "scanner.l" +{ + char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), + 0 }; + scanctx_append_string(yyextra, c); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 120 "scanner.l" +{ + yylval->sval = scanctx_take_string(yyextra); + BEGIN INITIAL; + return(TOK_STRING); + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 126 "scanner.l" +{ BEGIN INCLUDE; } + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +#line 127 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 128 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 129 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 130 "scanner.l" +{ + const char *error; + FILE *fp = scanctx_push_include(yyextra, + (void *)YY_CURRENT_BUFFER, + &error); + if(fp) + { + yyin = fp; + libconfig_yy_switch_to_buffer(libconfig_yy_create_buffer(yyin,YY_BUF_SIZE,yyscanner),yyscanner); + } + else + { + yyextra->config->error_text = error; + yyextra->config->error_file = scanctx_current_filename( + yyextra); + yyextra->config->error_line = libconfig_yyget_lineno( + yyscanner); + return TOK_ERROR; + } + BEGIN INITIAL; + } + YY_BREAK +case 20: +/* rule 20 can match eol */ +YY_RULE_SETUP +#line 154 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 155 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 157 "scanner.l" +{ return(TOK_EQUALS); } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 158 "scanner.l" +{ return(TOK_COMMA); } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 159 "scanner.l" +{ return(TOK_GROUP_START); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 160 "scanner.l" +{ return(TOK_GROUP_END); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 161 "scanner.l" +{ yylval->ival = 1; return(TOK_BOOLEAN); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 162 "scanner.l" +{ yylval->ival = 0; return(TOK_BOOLEAN); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 163 "scanner.l" +{ yylval->sval = yytext; return(TOK_NAME); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 164 "scanner.l" +{ yylval->fval = atof(yytext); return(TOK_FLOAT); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 165 "scanner.l" +{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 166 "scanner.l" +{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 167 "scanner.l" +{ + yylval->ival = strtoul(yytext, NULL, 16); + return(TOK_HEX); + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 171 "scanner.l" +{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 172 "scanner.l" +{ return(TOK_ARRAY_START); } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 173 "scanner.l" +{ return(TOK_ARRAY_END); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 174 "scanner.l" +{ return(TOK_LIST_START); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 175 "scanner.l" +{ return(TOK_LIST_END); } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 176 "scanner.l" +{ return(TOK_SEMICOLON); } + YY_BREAK +case 39: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 177 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 178 "scanner.l" +{ return(TOK_GARBAGE); } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT): +case YY_STATE_EOF(STRING): +case YY_STATE_EOF(INCLUDE): +#line 180 "scanner.l" +{ + YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( + yyextra); + if(buf) + { + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner); + libconfig_yy_switch_to_buffer(buf,yyscanner); + } + else + yyterminate(); + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 191 "scanner.l" +ECHO; + YY_BREAK +#line 1227 "scanner.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * libconfig_yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( libconfig_yywrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of libconfig_yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + libconfig_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + libconfig_yyrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) libconfig_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 102); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + libconfig_yyrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( libconfig_yywrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void libconfig_yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + libconfig_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + libconfig_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + libconfig_yy_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * libconfig_yypop_buffer_state(); + * libconfig_yypush_buffer_state(new_buffer); + */ + libconfig_yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + libconfig_yy_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (libconfig_yywrap()) processing, but the only time this flag + * is looked at is after libconfig_yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void libconfig_yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE libconfig_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) libconfig_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + libconfig_yy_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with libconfig_yy_create_buffer() + * @param yyscanner The scanner object. + */ + void libconfig_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + libconfig_yyfree((void *) b->yy_ch_buf ,yyscanner ); + + libconfig_yyfree((void *) b ,yyscanner ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a libconfig_yyrestart() or at EOF. + */ + static void libconfig_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + libconfig_yy_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then libconfig_yy_init_buffer was _probably_ + * called from libconfig_yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void libconfig_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + libconfig_yy_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + libconfig_yyensure_buffer_stack(yyscanner); + + /* This block is copied from libconfig_yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from libconfig_yy_switch_to_buffer. */ + libconfig_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void libconfig_yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + libconfig_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE libconfig_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + libconfig_yy_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to libconfig_yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * libconfig_yy_scan_bytes() instead. + */ +YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return libconfig_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to libconfig_yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) libconfig_yyalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = libconfig_yy_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in libconfig_yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *libconfig_yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *libconfig_yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *libconfig_yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void libconfig_yyset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "libconfig_yyset_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void libconfig_yyset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "libconfig_yyset_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see libconfig_yy_switch_to_buffer + */ +void libconfig_yyset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void libconfig_yyset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int libconfig_yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void libconfig_yyset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void libconfig_yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* libconfig_yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int libconfig_yylex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* libconfig_yylex_init_extra has the same functionality as libconfig_yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to libconfig_yyalloc in + * the yyextra field. + */ + +int libconfig_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + libconfig_yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + libconfig_yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from libconfig_yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * libconfig_yylex_init() + */ + return 0; +} + +/* libconfig_yylex_destroy is for both reentrant and non-reentrant scanners. */ +int libconfig_yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + libconfig_yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + libconfig_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + libconfig_yyfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * libconfig_yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + libconfig_yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *libconfig_yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *libconfig_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void libconfig_yyfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see libconfig_yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 191 "scanner.l" diff --git a/3rdparty/libconfig/scanner.h b/3rdparty/libconfig/scanner.h new file mode 100644 index 000000000..baa6f771f --- /dev/null +++ b/3rdparty/libconfig/scanner.h @@ -0,0 +1,326 @@ +#ifndef libconfig_yyHEADER_H +#define libconfig_yyHEADER_H 1 +#define libconfig_yyIN_HEADER 1 + +#line 6 "scanner.h" + +#line 8 "scanner.h" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 33 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +int libconfig_yylex_init (yyscan_t* scanner); + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void libconfig_yypop_buffer_state (yyscan_t yyscanner ); + +YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void libconfig_yyfree (void * ,yyscan_t yyscanner ); + +#define libconfig_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +#define yytext_ptr yytext_r + +#ifdef YY_HEADER_EXPORT_START_CONDITIONS +#define INITIAL 0 +#define COMMENT 1 + +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int libconfig_yylex_destroy (yyscan_t yyscanner ); + +int libconfig_yyget_debug (yyscan_t yyscanner ); + +void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner ); + +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_in (yyscan_t yyscanner ); + +void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_out (yyscan_t yyscanner ); + +void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int libconfig_yyget_leng (yyscan_t yyscanner ); + +char *libconfig_yyget_text (yyscan_t yyscanner ); + +int libconfig_yyget_lineno (yyscan_t yyscanner ); + +void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner ); + +void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int libconfig_yywrap (yyscan_t yyscanner ); +#else +extern int libconfig_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int libconfig_yylex (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int libconfig_yylex (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +#line 130 "scanner.l" + +#line 325 "scanner.h" +#undef libconfig_yyIN_HEADER +#endif /* libconfig_yyHEADER_H */ diff --git a/3rdparty/libconfig/strbuf.c b/3rdparty/libconfig/strbuf.c new file mode 100644 index 000000000..d2a667a7c --- /dev/null +++ b/3rdparty/libconfig/strbuf.c @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#include "strbuf.h" + +#include +#include + +#define STRING_BLOCK_SIZE 64 + +/* ------------------------------------------------------------------------- */ + +char *strbuf_release(strbuf_t *buf) +{ + char *r = buf->string; + memset(buf, 0, sizeof(strbuf_t)); + return(r); +} + +/* ------------------------------------------------------------------------- */ + +void strbuf_append(strbuf_t *buf, const char *text) +{ + static const size_t mask = ~(STRING_BLOCK_SIZE - 1); + size_t len = strlen(text); + size_t newlen = buf->length + len + 1; /* add 1 for NUL */ + + if(newlen > buf->capacity) + { + buf->capacity = (newlen + (STRING_BLOCK_SIZE - 1)) & mask; + buf->string = (char *)realloc(buf->string, buf->capacity); + } + + strcpy(buf->string + buf->length, text); + buf->length += len; +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/strbuf.h b/3rdparty/libconfig/strbuf.h new file mode 100644 index 000000000..90afd44c8 --- /dev/null +++ b/3rdparty/libconfig/strbuf.h @@ -0,0 +1,39 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_strbuf_h +#define __libconfig_strbuf_h + +#include +#include + +typedef struct +{ + char *string; + size_t length; + size_t capacity; +} strbuf_t; + +char *strbuf_release(strbuf_t *buf); + +void strbuf_append(strbuf_t *buf, const char *text); + +#endif /* __libconfig_strbuf_h */ diff --git a/3rdparty/libconfig/wincompat.h b/3rdparty/libconfig/wincompat.h new file mode 100644 index 000000000..cfea2ec33 --- /dev/null +++ b/3rdparty/libconfig/wincompat.h @@ -0,0 +1,89 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __wincompat_h +#define __wincompat_h + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#define WIN32_LEAN_AND_MEAN +#include + +#define snprintf _snprintf + +#ifndef __MINGW32__ +#define atoll _atoi64 +#define strtoull _strtoui64 +#endif /* __MINGW32__ */ + +#endif + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ + || defined(__MINGW32__)) + +/* Why does gcc on MinGW use the Visual C++ style format directives + * for 64-bit integers? Inquiring minds want to know.... + */ + +#define INT64_FMT "%I64d" +#define UINT64_FMT "%I64u" + +#define INT64_HEX_FMT "%I64X" + +#define FILE_SEPARATOR "\\" + +#else /* defined(WIN32) || defined(__MINGW32__) */ + +#define INT64_FMT "%lld" +#define UINT64_FMT "%llu" + +#define INT64_HEX_FMT "%llX" + +#define FILE_SEPARATOR "/" + +#endif /* defined(WIN32) || defined(__MINGW32__) */ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + +#define INT64_CONST(I) (I ## i64) +#define UINT64_CONST(I) (I ## Ui64) + +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif + +#else /* defined(WIN32) && ! defined(__MINGW32__) */ + +#define INT64_CONST(I) (I ## LL) +#define UINT64_CONST(I) (I ## ULL) + +#endif /* defined(WIN32) && ! defined(__MINGW32__) */ + +#endif /* __wincompat_h */ diff --git a/Makefile.in b/Makefile.in index 02ca9b987..6fd5fff26 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,10 +4,10 @@ HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) ALL_DEPENDS=common_sql login_sql char_sql map_sql tools import SQL_DEPENDS=common_sql login_sql char_sql map_sql import - COMMON_SQL_DEPENDS=mt19937ar - LOGIN_SQL_DEPENDS=mt19937ar common_sql - CHAR_SQL_DEPENDS=mt19937ar common_sql - MAP_SQL_DEPENDS=mt19937ar common_sql + COMMON_SQL_DEPENDS=mt19937ar libconfig + LOGIN_SQL_DEPENDS=mt19937ar libconfig common_sql + CHAR_SQL_DEPENDS=mt19937ar libconfig common_sql + MAP_SQL_DEPENDS=mt19937ar libconfig common_sql CONVERTERS_DEPENDS=common_sql else ALL_DEPENDS=needs_mysql @@ -47,6 +47,9 @@ common_sql: $(COMMON_SQL_DEPENDS) mt19937ar: @$(MAKE) -C 3rdparty/mt19937ar +libconfig: + @$(MAKE) -C 3rdparty/libconfig + login_sql: $(LOGIN_SQL_DEPENDS) @$(MAKE) -C src/login sql @@ -74,6 +77,7 @@ import: clean: @$(MAKE) -C src/common $@ @$(MAKE) -C 3rdparty/mt19937ar $@ + @$(MAKE) -C 3rdparty/libconfig $@ @$(MAKE) -C src/login $@ @$(MAKE) -C src/char $@ @$(MAKE) -C src/map $@ @@ -85,6 +89,7 @@ help: @echo "possible targets are:" @echo "'common_sql' - builds object files used in SQL servers" @echo "'mt19937ar' - builds object file of Mersenne Twister MT19937" + @echo "'libconfig' - builds object files of libconfig @echo "'login_sql' - builds login server (SQL version)" @echo "'char_sql' - builds char server (SQL version)" @echo "'map_sql' - builds map server (SQL version)" diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index ce06e2b37..58813c1c7 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -1,753 +1,60 @@ -//-------------------------------------------------------------- -// rAthena atcommand/charcommand Configuration File -//-------------------------------------------------------------- - -// The symbol that will be used to recognize commands. -// You can set any one character except control-characters (0x00-0x1f), -// '%', '$' (party/guild chat speaking) and '/' (standard client commands). -// command_symbol represents @commands used locally -// char_symbol represents #commands used on other players. -command_symbol:@ -char_symbol:# - -// The following settings in this file use the format ": level(@),level(#)". -// They define the minimum GM level required to execute the associated command. -// @ = atcommand. most work only on yourself. -// # = charcommand. remote usage only. GMs will be able to use these on other players. -// Adjust values as you like. Note that to activate commands for normal players, -// (GM level 0), you also need to change the 'atcommand_gm_only' option to 'no'. -// To completely disable a command, set its required GM level to 100. - -// Default levels were chosen so that they form the following hierarchy: -// 0: Normal player -// -> no commands accessible -// 1: Super player -// -> some minor advantage: storage, petrename, etc... -// 10: Super player+ -// -> more powerful commands, like mobsearch and changegm -// 20: Mediator -// -> GM commands for finding players and moving to them (also kicking them) -// 40: Sub-GM -// -> GM commands for basic tasks, no significant impact on other players -// 50: Sub-GM+ -// -> GM commands to spawn mobs and create guilds -// 60: GM -// -> almost all commands available (except administration and mass commands) -// 80: GM Chief -// -> can do anything, except administration commands -// 99: Administrator -// -> can do anything! -// 100: Disabled -// -> commands that will not be available to anyone - -// Syntax of file: -// command: @level,#level [] - -// Syntax Example: -// command: 40,40 [alias,alias2,alias3,alias4] -// If it has more than 4 aliases you can keep adding, just like in the example below: - -// Example: -// blvl: 60,60 [lvup,blevel,baselvl,baselvup,baselevel,baselvlup] - -//-------------------------- -// 0: normal player commands -// None for security purposes. - -//------------------------- -// 1: Super player commands - -// Displays a list of @ commands available to the player. -commands: 1,1 - -// Displays a list of # commands available to the player. -charcommands: 1,1 - -// Displays the server rates. -rates: 1,1 - -// Show server uptime since last map server restart -uptime: 1,1 - -// Shows/Hides the "there is a delay after a skill" message. -showdelay: 1,1 - -// Displays current levels and % progress. -exp: 1,40 - -// To change your (own) email -// note: this command doesn't check email itself, but check structure of the email (xxx@xxx) -// if you want be sure of each e-mail disable this option (value: 100) -email: 1,60 - -// Show Monster info (rates, stats, drops, MVP stuff) -monsterinfo: 1,1 [mobinfo, mi] - -// Show Item info (type, price, etc) -iteminfo: 1,1 [ii] - -// Show who drops an item (mobs with highest drop rate) -whodrops: 1,1 - -// Syncs the player's position on the client with the one stored on the server. -refresh: 1,40 - -// Give server time. (4 same commands) -time: 1,1 [date,serverdate,servertime] - -// Displays SVN version of the server. -version: 1,1 - -// Suicide your character. -die: 1,1 - -// Enables you to rename your pet. -petrename: 1,50 - -// Organize a new party, with you as the party leader -party: 1,1 - -// Opens your Kafra storage wherever you are -storage: 1,1 - -// Opens your mailbox -mail: 1,1 - -// Opens auctions window -auction: 1,1 - -// Locate someone on a map, returns your coordinates if the person isn't on. -where: 1,1 - -// Duel organizing commands -duel: 1,1 -invite: 1,1 -accept: 1,1 -reject: 1,1 -leave: 1,1 - -// Main chat -main: 1,1 - -// Autorejecting Deals/Invites -noask: 1,1 - -// Displays remaining jail time -jailtime: 1,40 - -// Homunculus commands for players -hominfo: 1,40 -homstats: 1,40 - -// Kill Steal Protection -noks: 1,1 - -// Set Font -font: 1,1 - -//--------------------------- -// 10: Super player+ commands - -// Displays/Hides Experience gained messages -showexp: 10,10 - -// Displays/Hides Zeny gained messages -showzeny: 10,10 - -// Warps you to predefined locations in major cities. -go: 10,10 - -// Enables/disables autolooting from killed mobs. -autoloot: 10,10 - -// Enables/disables autolooting an item. -alootid: 10,10 - -// Allows you continue vending offline. -autotrade: 10,10 [at] - -// Change Guild Master of your Guild -changegm: 10,10 - -// Change the leader of your party. -changeleader: 10,10 - -// Change the party exp- and item share rules. -partyoption: 10,10 - -// Command what the player's pet will say. -pettalk: 10,10 - -// Command what the player's homunculus will say. -homtalk: 10,10 - -// Locates and displays the position of a certain mob on the current map. -mobsearch: 10,10 -// Locates and displays the position of a certain mob on your mini-map -showmobs: 10,10 -// Prints out in which maps a monster normally spawns at (does not count script-invoked mobs) -whereis: 10,10 - -// Resets a Star Gladiator's marked maps -feelreset: 10,60 - -//---------------------- -// 20: Mediator commands - -// Displays helpfile in rAthena base directory (2 same commands). -help: 20,20 [h] -help2: 20,20 [h2] - -// Warp yourself to a person (3 same commands + /shift). -goto: 20,20 [jumpto,warpto] - -// Displays the motd file to all players -gmotd: 20,20 - -// Follow a player (including warping to them) -follow: 20,20 - -// Sends a request to all connected GMs (via the gm whisper system) -request: 20,100 - -// Disconnects a user from the server (1 command + right click menu for GM "(name) force to quit"). -kick: 20,20 - -// Changes your appearance. -model: 20,50 - -// To get a peco to (un)ride (2 same commands). -mount: 20,50 [mountpeco] - -// Returns list of logged in characters with their position (2 same commands). -who: 20,20 [whois] - -// Returns list of logged in characters with their job. -who2: 20,20 - -// Returns list of logged in characters with their party/guild. -who3: 20,20 - -// Returns list of logged in characters with their position in a specifical map. -whomap: 20,20 - -// Returns list of logged in characters with their job in a specifical map. -whomap2: 20,20 - -// Returns list of logged in characters with their party/guild in a specifical map. -whomap3: 20,20 - -// Displays GMs online. For those who are higher GM level than yourself, -// only the name is shown, for the rest, it displays the same info of -// @who+@who2+who3 -whogm: 20,20 - -// Change your appearence to other players to a mob. -disguise: 20,60 - -// Restore your normal appearance. -undisguise: 20,20 - -// Displays the text as a normal message with the format "*name message*" -// instead of "name : message" (Like the /me command in IRC) -me: 20,20 - -// Changes your name to your choice temporarily. -fakename: 20,50 - -// Changes your size. -size: 20,50 - -// Can command what other npcs (by name) can say. -npctalk: 20,100 [npctalkc] - -//-------------------- -// 40: Sub-GM commands - -// Broadcast to the whole server. Using (1 command + /nb, /b). -broadcast: 40,40 - -// Broadcast to the map you are on (1 command + /lb, /nlb). -localbroadcast: 40,40 - -// Broadcast (with or without name) -kami: 40,40 -// Same as kami but with blue color -kamib: 40,40 -// Same as kami but you can choose the color (uses different packet) -kamic: 40,40 - -// Enables GvG on a map (2 same commands). -gvgon: 40,100 [gpvpon] - -// Turns GvG (Guild vs. Guild) off on a map (2 same commands). -gvgoff: 40,100 [gpvpoff] - -// Activate/Deactivate kill steal protection on a map -allowks: 40,100 - -// Modifies your HP/SP. -heal: 40,60 - -// GM Hide (total invisibility to characters and monsters) (1 command + /hide). -hide: 40,60 - -// Changes your job to one you specify (2 same commands). -job: 40,60 [jobchange] - -// Enables you to to jump randomly on a map (that you are already on). -jump: 40,40 - -// Warps you to your last save point (2 same commands). -load: 40,60 [return] - -// Warps you to a specific npc -tonpc: 40,40 - -// Saves a warp point. -memo: 40,40 - -// Set your character display options. (Visual effects of your character) -option: 40,60 - -// Sets the level of intemecy of your pet. -petfriendly: 40,50 - -// Sets hunger level of your pet. -pethungry: 40,50 - -// Turns PvP (Person vs. Person) off on a map. -pvpoff: 40,100 - -// Enables PvP on a map. -pvpon: 40,100 - -// Permanently adds a quest skill -questskill: 40,60 - -// Permanently removes a quest skill -lostskill: 40,60 - -// Sets the speed you can walk/attack at. Default is 150. -speed: 40,60 - -// Summons spirit spheres around you. -spiritball: 40,60 - -// Warp yourself to a certain map, at (x,y) coordinates (2 same commands) + also /mm or /mapmove. -warp: 40,60 [rura,mapmove] - -// Changes GM clothes color (2 same commands) -dye: 40,50 [ccolor] - -// Changes GM hair style (2 same commands) -hairstyle: 40,40 [hstyle] - -// Changes GM hair color (2 same commands) -haircolor: 40,50 [hcolor] - -// Deletes all your items. -itemreset: 40,60 - -// Does a skill/stat reset. -reset: 40,60 - -// Displays distribution of players on the server per map (% on each map which has players) -users: 40,40 - -// Deletes floor items in your range of sight -cleanmap: 40,40 - -// Kill all monsters in map (without drops) -killmonster2: 40,40 - -// Sets your spawn point (aka save point). -save: 40,60 - -// Do some visual effect on your character -effect: 40,40 - -// Do some visual effect on your character (misceffect) -misceffect: 40,40 - -// GM's magnifier -identify: 40,40 - -// Drop all your items -dropall: 40,60 - -// Store all your items -storeall: 40,60 - -// Allow other players to hit you out of PvP -killable: 40,60 - -// Look up a skill by name -skillid: 40,40 - -// Use a skill by id -useskill: 40,40 - -// What skills are required to get this skill -skilltree: 40,40 - -// Marriage commands -marry: 40,40 -divorce: 40,40 - -// Adopt a novice into a family -adopt: 40,40 - -// Play a Sound! -sound: 40,40 - -// Displays a player's storage -storagelist: 40,40 - -// Displays a player's cart contents -cartlist: 40,40 - -// Displays a player's items -itemlist: 40,40 - -// Displays a player's stats -stats: 40,40 - -//--------------------- -// 50: Sub-GM+ commands - -// Creates a new guild, with you as the guildmaster. -guild: 50,50 - -// Brings up your guild storage wherever you are. -gstorage: 50,60 - -// Spawns a monster, and a certain amount (2 same commands + /monster). -monster: 50,50 [spawn] - -// Spawns a smaller sized version of a monster. -monstersmall: 50,50 - -// Spawns a larger sized version of a monster. -monsterbig: 50,50 - -// Spawns mobs that treat you as their master (they disappear after some time) -summon: 50,50 - -// It will spawn a supportive clone of the given player. -clone: 50,50 - -// It will spawn a supportive clone of the given player that follows the creator around. -slaveclone: 50,50 - -// It will spawn an aggresive clone of the given player. -evilclone: 50,50 - -//---------------- -// 60: GM commands - -// Add or Remove Cash Points to/from yourself -cash: 60,60 - -// Add or Remove Kafra Points to/from yourself -points: 60,60 - -// Starts Guild Wars -agitstart: 60,100 - -// Ends Guild Wars -agitend: 60,100 - -// Resurects yourself. -alive: 60,60 - -// Raises your base level by specified amount (7 same commands). -blvl: 60,60 [lvup,blevel,baselvl,baselvup,baselevel,baselvlup] - -// Raises your job level by specified amount (6 same commands). -jlvl: 60,60 [jlevel,joblvl,joblvup,joblevel,joblvlup] - -// Changes the sex of yourself -changesex: 60,60 - -// Raises your guild level by specified amount (6 same commands). -glvl: 60,60 [glevel,guildlvl,guildlvup,guildlevel,guildlvlup] - -// Find an itemID based on item name -idsearch: 60,60 - -// Creates an item of your choosing, either Item ID or Name (1 command + /item). -item: 60,60 - -// Creates a complet item (card, etc...) of your choosing, either Item ID or Name. -item2: 60,60 - -// Deletes an item of your choosing, either Item ID or Name. -delitem: 60,60 - -// Kill another character without hitting them. -kill: 60,60 - -// Kill all monsters in map (with drops) -killmonster: 60,60 - -// Creates yourself a pet egg. -makeegg: 60,60 - -// Hatches an egg -hatch: 60,60 - -// Instantly kills player whose name is entered and deals insane damage to everything around -nuke: 60,60 - -// Enable hitting a player even when not in PvP -killer: 60,60 - -// Creates weapon of desired element. -produce: 60,60 - -// Warps a character to you (1 command + /recall). -recall: 60,60 - -// Refines all weapons in your items list. -refine: 60,80 - -// Will repair all broken items in inventory. -repairall: 60,60 - -// Change Status of your character -str: 60,60 -agi: 60,60 -vit: 60,60 -int: 60,60 -dex: 60,60 -luk: 60,60 - -// Gives all skills -allskill: 60,60 [allskills,skillall,skillsall] - -// Sets GM stats to maximum -allstats: 60,60 [allstat,statall,statsall] - -// Gives you stat points. -stpoint: 60,60 - -// Gives you skill points of desired amount. -skpoint: 60,60 - -// Warps all online character of a guild to you. (at least one member of that guild must be on.) -guildrecall: 60,60 - -// Warps all online character of a party to you. -// (at least one party member must be online.) -partyrecall: 60,60 - -// Allows you to spy on any Guilds Guild chat. -// (at least one member of that guild must be on.) -// NOTE: map server needs to be configured to enable spying to use this command (enable_spy: yes) -guildspy: 60,60 - -// Allows you to spy on any party's party chat. -// (at least one party member must be online.) -// NOTE: map server needs to be configured to enable spying to use this command (enable_spy: yes) -partyspy: 60,60 - -// Gives you zeny (or subtracts, if amount is negative) -zeny: 60,80 - -// Block a player indefinitely -block: 60,100 [charblock] - -// Unblock a player -unblock: 60,100 [charunblock] - -// Ban a player for a limited time -ban: 60,100 [banish,charban,charbanish] - -// Unban a player -unban: 60,100 [unbanish,charunban,charunbanish] - -// To send specified character in jails -jail: 60,100 - -// To discharge a jailed character (2 same commands) -unjail: 60,100 [discharge] - -// Timed jailing -jailfor: 60,60 - -// Create a static warp portal that lasts until the next reboot -addwarp: 60,60 - -// Open a trade window with any player -trade: 60,60 - -// Changes the player's appearance (headgear) -changelook: 60,60 - -// Homunculus commands for GMs -hlvl: 60,60 [homlevel,hlevel,homlvl,homlvup] -homevolve: 60,60 [homevolution] -makehomun: 60,60 -homfriendly: 60,60 -homhungry: 60,60 -// Re-calculates stats, as if the homun was sent back to level 1 and re-leveled -homshuffle: 60,60 - -// WoE 2 start/stop commands -agitstart2: 60,100 -agitend2: 60,100 - -// Resets player stats -streset: 60,60 - -// Resets player skills -skreset: 60,60 - -//---------------------- -// 80: GM Chief commands - -// Set the server to day. -day: 80,100 - -// Set the server to night. -night: 80,100 - -// Kills everyone on the server. -doom: 80,100 - -// Kills everyone on the map you are on. -doommap: 80,80 - -// Recalls Everyone To Your Coordinates -recallall: 80,80 - -// Revives all players on the map. -raisemap: 80,80 - -// Revives all players on the server. -raise: 80,100 - -// Hides a NPC. -hidenpc: 80,100 - -// Unhides a NPC. -shownpc: 80,100 - -// Loads an NPC script by path -loadnpc: 80,100 - -// Unloads a NPC -unloadnpc: 80,100 - -// Move a NPC -npcmove: 80,100 - -// turn skills on for a map -skillon: 80,100 - -// turn skills off for a map -skilloff: 80,100 - -// Mute a player (prevents talking, usage of skills and commands) -mute: 80,100 - -// Unmute a player -unmute: 80,100 - -//--------------------------- -// 99: Administrator commands - -// Disconnect all users from the server -kickall: 99,100 - -// Closes Map-Server -mapexit: 99,100 - -// Used for testing packet sends from the client (debug function) -send: 99,100 - -// Give information about terrain/area (debug function) -gat: 99,100 - -// Displays a status change without really applying it (debug function) -displaystatus: 99,100 - -// Displays the animation of a skill without really using it (debug function) -displayskill: 99,100 - -// Shows information about the map -mapinfo: 99,100 - -// Set Map Flags -mapflag: 99,100 - -// Re-load item database (admin command) -reloaditemdb: 99,100 - -// Re-load monsters database (admin command) -reloadmobdb: 99,100 - -// Re-load skills database (admin command) -reloadskilldb: 99,100 - -// Re-load scripts (admin command) -reloadscript: 99,100 - -// Change a battle_config flag without rebooting server -setbattleflag: 99,100 - -// Re-load gm command config (admin command) -reloadatcommand: 99,100 - -// Re-load battle config (admin command) -// Note that some player config settings won't take effect until relog -// (display exp, display zeny, display skill delay fail, ...) -reloadbattleconf: 99,100 - -// Re-load status database (admin command) -reloadstatusdb: 99,100 - -// Re-load player info database (admin command) -reloadpcdb: 99,100 - -// Re-load the Message of the Day (admin command) -reloadmotd: 99,100 - -// Changes the GM level of another character -// (lasts until reboot, or gm list reload) -adjgmlvl: 99,100 - -// Changes the required GM level of an @ command -// (effect lasts until restart or command reload) -adjcmdlvl: 99,100 - -// [Un]Disguise All Players (admin command) -disguiseall: 99,100 -undisguiseall: 99,100 - -// Mutes every player on screen (admin command) -mutearea: 99,100 [stfu] - -// Makes you immune to attacks (monsters/players/skills cannot target/hit you, admin command) -battleignore: 99,100 [monsterignore] - -//--------------------------------------------------------------- -// 99: Weather effects -snow: 99,100 -clouds: 99,100 -clouds2: 99,100 -fog: 99,100 -fireworks: 99,100 -sakura: 99,100 -leaves: 99,100 - -// Stop all weather effects -clearweather: 99,100 - -//--------------------------------------------------------------- -// 100: Disabled commands - -//--------------------- -// OTHER: not a command -import:conf/import/atcommand_conf.txt \ No newline at end of file +/* Atcommands and charcommands configuration file */ + +/* The symbol that will be used to recognize commands. +You can set any one character except: + - control-characters (0x00-0x1f), + - '%' (party chat symbol) + - '$' (guild chat symbol) + - '/' (client commands symbol) +atcommand_symbol represents @commands used locally. +charcommand_symbol represents #commands used on other players. +*/ + +atcommand_symbol : "@" +charcommand_symbol: "#" + +/* Command aliases +You can define aliases for any command. Aliases work just like original +command. +Format is + : ["", ...] +*/ + +aliases: { + mobinfo: ["monsterinfo", "mi"] + iteminfo: ["ii"] + time: ["date", "serverdate", "servertime"] + autotrade: ["at"] + help: ["h"] + jumpto: ["goto", "warpto"] + mount: ["mountpeco"] + who: ["whois"] + npctalk: ["npctalkc"] + gvgon: ["gpvpon"] + gvgoff: ["gpvpoff"] + jobchange: ["job"] + load: ["return"] + warp: ["rura", "mapmove"] + dye: ["ccolor"] + hairstyle: ["hstyle"] + haircolor: ["hcolor"] + monster: ["spawn"] + blvl: ["lvup", "blevel", "baselvl", "baselvup", "baselevel", "baselvlup"] + jlvl: ["jlevel", "joblvl", "joblvup", "joblevel", "joblvlup"] + glvl: ["glevel", "guildlvl", "guildlvup", "guildlevel", "guildlvlup"] + allskill: ["allskills", "skillall", "skillsall"] + allstats: ["allstat", "statall", "statsall"] + ban: ["banish"] + unban: ["unbanish"] + unjail: ["discharge"] + homlevel: ["hlvl", "hlevel", "homlvl", "homlvup"] + homevolution: ["homevolve"] + mutearea: ["stfu"] + monsterignore: ["battleignore"] + raise: ["revive"] +} + +/* Commands help file */ +help: { + @include "conf/help.txt" +} \ No newline at end of file diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index b7dc81909..fe07a6fc4 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -18,97 +18,10 @@ atcommand_slave_clone_limit: 25 // current map server. partial_name_scan: yes -// The level at which a player with access is considered a GM. -// An account with an access level lower than this is not effected -// by gm_can_drop_lv (battle_athena.conf). -lowest_gm_level: 1 - -// [GM] Can use all skills? (No or mimimum GM level) -gm_all_skill: no - -// [GM] Can equip anything? (No or minimum GM level, can cause client errors.) -gm_all_equipment: no - -// [GM] Can use skills without meeting the required conditions (items, etc...)? -// 'no' or minimum GM level to bypass requirements. -gm_skill_unconditional: no - -// [GM] Can join a password protected chat? (No or mimimum GM level) -gm_join_chat: no - -// [GM] Can't be kicked from a chat? (No or mimimum GM level) -gm_kick_chat: no - -// (@) GM Commands available only to GM's? (Note 1) -// set to 'No', Normal players (gm level 0) can use GM commands _IF_ you set the command level to 0. -// set to 'Yes', Normal players (gm level 0) can never use a GM command even if you set the command level to 0. -atcommand_gm_only: no - // (@) @allstats/@str/@agi/@vit/@int/@dex/@luk // allow gms to bypass the maximum stat parameter? ( if yes gm stats can go up to 32k ) default: no atcommand_max_stat_bypass: no -// Is the character of a GM account set as the object of a display by @ command etc. or not? -hide_GM_session: no - -// At what GM level can you see GMs and Account/Char IDs in the @who command? -who_display_aid: 40 - // Ban people that try trade dupe. // Duration of the ban, in minutes (default: 5). To disable the ban, set 0. ban_hack_trade: 5 - -// Set here minimum level of a (online) GM that can receive all informations about any player that try to hack, spoof a name, etc. -// Values are from 0 to 100. -// 100: disable information -// 0: send to any people, including normal players -// default: 60, according to GM definition in atcommand_athena.conf -hack_info_GM_level: 60 - -// The minimum GM level to bypass nowarp and nowarpto mapflags. -// This option is mainly used in commands which modify a character's -// map/coordinates (like @memo, @warp, @charwarp, @go, @jump, etc...). -// default: 20 (first level after normal player or super'normal' player) -any_warp_GM_min_level: 20 - -// The minimum level for a GM to be unable to distribute items. -// You should set this to the same level @item is set to in the atcommand.conf -// NEVER SET THIS VALUE TO 0, or you will block drop/trade for normal players -gm_cant_drop_min_lv: 1 - -//The trust level for your GMs. Any GMs ABOVE this level will be able to distribute items -//ie: Use Storage/Guild Storage, Drop Items, Use Vend, Trade items. -gm_cant_drop_max_lv: 0 - -// Minimum GM level to see the hp of every player? (Default: 60) -// no/0 can be used to disable it. -disp_hpmeter: 0 - -// Minimum GM level to view players equip regardless of their setting. -// (Default: 0 = Disabled). -gm_viewequip_min_lv: 0 - -// Can GMs invite non GMs to a party? (Note 1) -// set to 'No', GMs under the party invite trust level may not invite non GMs to a party. -// set to 'Yes', All GMs can invite any player to a party. -// Also, as long as this is off, players cannot invite GMs to a party as well. -gm_can_party: no - -//The trust level for GMs to invite to a party. Any GMs ABOVE OR EQUAL TO this level will be able to invite normal -//players into their party in addittion to other GMs. (regardless of gm_can_party) -gm_cant_party_min_lv: 20 - -// Players Titles (check msg_athena.conf for title strings) -// You may assign different titles for your Players and GMs -title_lvl1: 1 -title_lvl2: 10 -title_lvl3: 20 -title_lvl4: 40 -title_lvl5: 50 -title_lvl6: 60 -title_lvl7: 80 -title_lvl8: 99 - -// Minimum GM level required for client command /check (display character status) to work. -// Default: 60 -gm_check_minlevel: 60 diff --git a/conf/char_athena.conf b/conf/char_athena.conf index bc9e1ab1c..1b5e96a16 100644 --- a/conf/char_athena.conf +++ b/conf/char_athena.conf @@ -93,8 +93,10 @@ char_new_display: 0 // Maximum users able to connect to the server. Set to 0 for unlimited. max_connect_user: 0 -// Minimum GM level that is allowed to bypass the server limit of users. -gm_allow_level: 99 +// Group ID that is allowed to bypass the server limit of users. +// Default: -1 = nobody (there are no groups with ID < 0) +// See: conf/groups.conf +gm_allow_group: -1 // How often should the server save all files? (In seconds) // Note: Applies to all data files on TXT servers. diff --git a/conf/groups.conf b/conf/groups.conf new file mode 100644 index 000000000..d93d2aa09 --- /dev/null +++ b/conf/groups.conf @@ -0,0 +1,274 @@ +/* + +Player groups configuration file +--------------------------------- + +This file defines "player groups" and their privileges. + +Each group has its id and name, lists of available commands and other +permissions, and a list of other groups it inherits from. + + +Group settings +-------------- + +Unique group number. The only required field. + + +Any string. If empty, defaults to "Group ". It is used in several @who +commands. + + +Equivalent of GM level, which was used in revisions before r xxxxx. You can +set it to any number, but usually it's between 0 (default) and 99. Members of +groups with lower level can not perform some actions/commands (like @kick) on +members of groups with higher level. It is what script command getgmlevel() +returns. Group level can also be used to override trade restrictions +(db/item_trade.txt). + + +A group of settings + : +or + : [ , ] +First boolean value is for atcommand, second one for charcommand. If set to +true, group can use command. If only atcommand value is provided, false is +assumed for charcommand. If a command name is not included, false is assumed for +both atcommand and charcommand. +For a full list of available commands, see: doc/atcommands.txt. +Command names must not be aliases. + + +Boolean value. If true then all commands used by the group will be logged to +atcommandlog. If setting is omitted in a group definition, false is assumed. +Requires 'log_commands' to be enabled in 'conf/log_athena.conf'. + + +A group of settings + : +If a permission is not included, false is assumed. +For a full list of available permissions, see: doc/permissions.txt + + +A list of group names that given group will inherit commands and permissions +from. Group names are case-sensitive. + +Inheritance results +------------------- +Both multiple inheritance (Group 2 -> Group 1 and Group 3 -> Group 1) and +recursive inheritance (Group 3 -> Group 2 -> Group 1) are allowed. + +Inheritance rules should not create cycles (eg Group 1 inherits from Group 2, +and Group inherits from Group 1 at the same time). Configuration with cycles is +considered faulty and can't be processed fully by server. + +Command or permission is inherited ONLY if it's not already defined for the +group. +If group inherits from multiple groups, and the same command or permission is +defined for more than one of these groups, it's undefined which one will be +inherited. + +Syntax +------ +This config file uses libconfig syntax: +http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files + + +Upgrading from revisions before XXXXX +------------------------------------- + +*/ + +groups: ( +{ + id: 0 /* group 0 is the default group for every new account */ + name: "Player" + level: 0 + inherit: ( /*empty list*/ ) + commands: { + /* no commands by default */ + } + permissions: { + /* without this basic permissions regular players could not + trade or party */ + can_trade: true + can_party: true + } +}, +{ + id: 1 + name: "Super Player" + inherit: ( "Player" ) /* can do everything Players can and more */ + level: 0 + commands: { + /* informational commands */ + commands: true + charcommands: true + help: true + rates: true + uptime: true + showdelay: true + exp: true + mobinfo: true + iteminfo: true + whodrops: true + time: true + jailtime: true + hominfo: true + homstats: true + showexp: true + showzeny: true + whereis: true + /* feature commands */ + refresh: true + noask: true + noks: true + main: true + autoloot: true + alootid: true + autotrade: true + request: true + go: true + } + permissions: { + } +}, +{ + id: 2 + name: "Support" + inherit: ( "Super Player" ) + level: 1 + commands: { + version: true + where: true + jumpto: true + who: true + who2: true + who3: true + whomap: true + whomap2: true + whomap3: true + users: true + broadcast: true + localbroadcast: true + } + log_commands: true + permissions: { + receive_requests: true + view_equipment: true + } +}, +{ + id: 3 + name: "Script Manager" + inherit: ( "Support" ) + level: 1 + commands: { + tonpc: true + hidenpc: true + shownpc: true + loadnpc: true + unloadnpc: true + npcmove: true + addwarp: true + } + log_commands: true + permissions: { + any_warp: true + } +}, +{ + id: 4 + name: "Event Manager" + inherit: ( "Support" ) + level: 1 + commands: { + monster: true + monstersmall: true + monsterbig: true + killmonster2: true + cleanmap: true + item: [true, true] + zeny: [true, true] + disguise: [true, true] + undisguise: [true, true] + size: [true, true] + raise: true + raisemap: true + day: true + night: true + skillon: true + skilloff: true + pvpon: true + pvpoff: true + gvgon: true + gvgoff: true + allowks: true + me: true + marry: true + divorce: true + } + log_commands: true + permissions: { + can_trade: false + any_warp: true + } +}, +{ + id: 10 + name: "Law Enforcement" + inherit: ( "Support" ) + level: 2 + commands: { + hide: true + follow: true + kick: true + disguise: true + fakename: true + option: true + speed: true + warp: true + kill: true + recall: true + ban: true + block: true + jail: true + jailfor: true + mute: true + storagelist: true + cartlist: true + itemlist: true + stats: true + } + log_commands: true + permissions: { + join_chat: true + kick_chat: true + hide_session: true + who_display_aid: true + hack_info: true + any_warp: true + view_hpmeter: true + } +}, +{ + id: 99 + name: "Admin" + level: 99 + inherit: ( "Support", "Law Enforcement" ) + commands: { + } + log_commands: true + permissions: { + can_trade: true + can_party: true + all_skill: true + all_equipment: true + skill_unconditional: true + use_check: true + use_changemaptype: true + all_commands: true + } +} +) + diff --git a/conf/help.txt b/conf/help.txt index 13a958798..5a8f5871f 100644 --- a/conf/help.txt +++ b/conf/help.txt @@ -1,172 +1,230 @@ -// put at first, the minimum level to display the line - 1:To use one command, type it inside the message window where you usually type to chat. - 20:@h/@help - display this help guide. - 20:@h2/@help2 - displays the second help guide. - 1: - 1:--- MESSAGE CMD --- - 1:@main [on|off|message] - Turns on or off global chat (@main must be on to see global chat messages) - 1:@noask - Auto rejects Deals/Invites - 20:@gmotd - Broadcasts the Message of The Day file to all players. - 20:@me - Displays normal text as a message in this format: *name message* (like /me in mIRC) - 20:@fakename [Name] - Changes your name to your choice temporarly. - 20:@npctalk [NPC Name],[Message] - Forces a NPC to display a message in normal chat. - 40:/b/@broadcast - Broadcasts a GM message with name of the GM (in yellow) - 40:/nb /@kami - Broadcasts a GM message without name of the GM (in yellow) - 40:@kamib - Broadcasts a GM message without name of the GM (in blue) - 40:/lb/@localbroadcast - Broadcasts a GM message with name of the GM (in yellow) ONLY on your map - 40:/nlb - Broadcasts a GM message without name of the GM (in yellow) ONLY on your map - 1: - 1:--- INFORMATION CMD --- - 1:@commands - Displays a list of commands that you can use. - 1:@rates - Displays the server's current rates. - 1:@uptime - Displays how long the server has been online. - 1:@showdelay - Shows/Hides the "there is a delay after this skill" message. - 1:@exp - Displays current levels and % progress - 1:@mobinfo/@monsterinfo/@mi [Mob ID|Part of monster name] - Shows Monster Info (rates, stats, drops, MVP stuff) - 1:@iteminfo/@ii [Item ID|Part of item name] - Shows Item info (type, price, etc) - 1:@whodrops [Item ID|Part of item name] - Shows who drops an item (mobs with highest drop rates) - 1:@version - Displays SVN version of the server - 1:@email - to change your e-mail (characters protection) - 1:@where [char name] - Tells you the location of a character - 1:@time/@date/@server_date/@serverdate/@server_time/@servertime - Display the date/time of the server - 10:@showexp - Displays/Hides Experience gained. - 10:@showzeny - Displays/Hides Zeny gained. - 10:@mobsearch [Mob ID|Monster Name] - Shows the location of a certain mob on the current map. - 20:@who/@whois/@w [match_text] - Display a listing of who is online and their party/guild. - 20:@who2 [match_text] - Display a listing of who is online and their job. - 20:@who3 [match_text] - Display a listing of who is online and where. - 20:@whomap/@whomap2/@whomap3 [map] - like @who/@who2/@who3 but only for specifical map. - 20:@whogm [match_text] - Like @who+@who2+who3, but only for GM. - 40:@charcartlist - Displays all items of a player's cart. - 60: - 60:@guildspy - You will receive all messages of the guild channel (Chat logging must be enabled) - 60:@partyspy - You will receive all messages of the party channel (Chat logging must be enabled) - 99:@mapinfo [<0-3> [map]] - Give information about a map (general info +: 0: no more, 1: players, 2: NPC, 3: shops/chat). - 1: - 1:--- CHANGE GM STATE CMD --- - 1:@die - Kills yourself - 10:@go - Warps you to a city. - 10: -3: (Memo point 2) 1: morocc 5: izlude 9: yuno 13: niflheim - 10: -2: (Memo point 1) 2: geffen 6: aldebaran 10: amatsu 14: louyang - 10: -1: (Memo point 0) 3: payon 7: xmas (lutie) 11: gonryun 15: start point - 10: 0: prontera 4: alberta 8: comodo 12: umbala 16: prison/jail - 10: - 20:/shift/@jumpto/@warpto/@goto - Warps you to selected character - 20:@follow - follow a player - 20:@mountpeco - Give/remove you a peco (Class is required, but not skill) - 20:@disguise - Change your appearence to other players to a mob. - 20:@undisguise - Restore your normal appearance. - 20:@model - Changes your characters appearence. - 20:@size <1-3> Changes your size (1-Smallest 2-Biggest 3-Normal) - 40:/hide/@hide - Makes you character invisible (GM invisibility). Type /hide or@hide again become visible. - 40:@save - Sets respawn point to current spot - 40:@load/@return - Warps you to your save point - 40:/mm//mapmove/@warp/@rura/@mapmove - Warps you to the selected position - 40:@jump [x [y]]- Randomly warps you like a flywing. - 40:@job/@jobchange - Changes your job - 40: 0: Novice 18: Alchemist 4015: Paladin - 40: 1: Swordman 19: Bard 4016: Champion - 40: 2: Mage 20: Dancer 4017: Professor - 40: 3: Archer 23: Super Novice 4018: Stalker - 40: 4: Acolyte 4001: High Novice 4019: Creator - 40: 5: Merchant 4002: High Swordman 4020: Clown - 40: 6: Thief 4003: High Mage 4021: Gypsy - 40: 7: Knight 4004: High Archer 4046: Taekwon - 40: 8: Priest 4005: High Acolyte 4047: Star Gladiator - 40: 9: Wizard 4006: High Merchant 4049: Soul Linker - 40: 10: Blacksmith 4007: High Thief 24: Gunslinger - 40: 11: Hunter 4008: Lord Knight 25: Ninja - 40: 12: Assassin 4009: High Priest - 40: 14: Crusader 4010: High Wizard - 40: 15: Monk 4011: Whitesmith - 40: 16: Sage 4012: Sniper - 40: 17: Rogue 4013: Assassin Cross - 40: ---- Baby Classes ---- - 40: 4023: Baby 4024: Baby Swordman 4025: Baby Mage - 40: 4026: Baby Archer 4027: Baby Acolyte 4028: Baby Merchant - 40: 4029: Baby Thief 4030: Baby Knight 4031: Baby Priest - 40: 4032: Baby Wizard 4033: Baby Blacksmith 4034: Baby Hunter - 40: 4035: Baby Assassin 4037: Baby Crusader 4038: Baby Monk - 40: 4039: Baby Sage 4040: Baby Rogue 4041: Baby Alchemist - 40: 4042: Baby Bard 4043: Baby Dancer 4045: Super Baby - 40: - 40: (stackable) - 40: 1 Petrified (stackable) 01 Sight 32 Peco Peco riding 2048 Orc Head - 40: 2 Frozen 01 Poison 02 Hide 64 GM Perfect Hide 4096 Wedding Sprites - 40: 3 Stunned 02 Cursed 04 Cloak 128 Level 2 Cart 8192 Ruwach - 40: 4 Sleeping 04 Silenced 08 Level 1 Cart 256 Level 3 Cart - 40: 6 darkness 08 ??? 16 Falcon 512 Level 4 Cart - 40: 16 darkness 1024 Level 5 Cart - 40: - 40:@heal [ ] - Heals the desired amount of HP and SP. No value specified will do a full heal. - 40:@option - Adds different visual effects on or around your character - 40:@dye/@ccolor - Changes your characters appearence (only clothes color). - 40:@hairstyle/@hstyle - Changes your characters appearence (only hair style). - 40:@haircolor/@hcolor - Changes your characters appearence (only hair color). - 40:@speed <1-1000> - Changes you walking speed. 1 being the fastest and 1000 the slowest. Default 150. - 40:@effect [flag] - Give an efect to your character. - 40:@dropall - throws all your possession on the ground - 40:@storeall - puts all your possessions in storage - 40:@killable - make your character killable - 40:@memo [memo_position] - set/change a memo location (no position: display memo points). - 40:@spiritball - Gives you "spirit spheres" like from the skill "Call Spirits" - 40: (If the number you use is > 1000, your server may become instable or crash) - 40:@questskill <#> - Gives you the specified quest skill - 40:@lostskill <#> - Takes away the specified quest skill from you - 40:@skillid - look up a skill by name - 40:@useskill - use a skill on target - 40: Novice Swordsman Thief Merchant - 40: 142 = Emergency Care 144 = Moving HP Recovery 149 = Throw Sand 153 = Cart Revolution - 40: 143 = Act dead 145 = Attack Weak Point 150 = Back Sliding 154 = Change Cart - 40: Archer 146 = Auto Berserk 151 = Take Stone 155 = Crazy Uproar/Loud Voice - 40: 147 = Arrow Creation Acolyte 152 = Stone Throw Magician - 40: 148 = Charge Arrows 156 = Holy Light 157 = Energy Coat - 40: @skilltree < - 40: @marry , - marry two players - 40: @divorce - divorces the two players (you need just one name of them) - 60:@alive - Revives yourself from death - 60:@lvup/@blevel/@baselvlup - Raises your base level the desired number of levels. The max is 255 (User Defined). - 60:@joblvup/@jlevel/@joblvlup -Raises your job level the desired number of levels. The max is 50 For Basic Classes. For Super Novice and Advanced Classes it is 70. - 60:@allskill/@allskills/@skillall/@skillsall - Give you all skills. - 60:@stpoint - Gives you the desired number of stat points. - 60:@skpoint - Gives you the desired number of skill points. - 60:@zeny - Gives you desired amount of Zeny. - 60:@cash - Gives you the specified amount of cash points. - 60:@points - Gives you the specified amount of Kafra Points. - 60:@str,@agi,@vit,@int,@dex,@luk - Adds desired amount to any stat. For example "@str 10" raises your str by 10 - 60:@statall/@statsall/@allstats/@allstat [value] - Adds value in all stats (maximum if no value). - 60: @addwarp - 40: - 40:--- MONSTERS CMD --- - 40:@killmonster2 - kill all monsters of your map (without drops) - 50:/monster - Spawns 1 of the desired monster. - 50:@spawn/@monster/@summon [ [ [ []]]] - 50:@monster2 [ [ []]] - 50:@spawn/@monster/@summon/@monster2 "desired monster name" [ [ []]] - 50:@spawn/@monster/@summon/@monster2 "desired monster name" [ [ []]] - 50: Spawns the desired monster with any desired name. - 50:@monstersmall [Mob ID|Mob Name] - Spawns a smaller version of a monster. - 50:@monsterbig [Mob ID|Mob Name] - Spawns a larger version of a monster. - 60:@killmonster [map] - kill all monsters of the map (they drop) - 40: - 10:--- MISC CMD --- - 10:@autoloot [on|off|#] - Makes items go straight into your inventory. - 10:@autotrade/@at - Allows you to vend while you are offline. - 10:@changegm [Player Name] - Changes the leader of your guild (You must be guild leader) - 10:@changeleader [Player Name] - Changes the leader of your party (You must be party leader) - 20:@request [Message] - Sends a message to all connected GMs (via the gm whisper system) - 40:@sound [Path way to file in Data or GRF file] - Plays a sound from the data or grf file located on the client. - 50:@clone [Player Name] - Spawns a supportive clone of the given player. - 50:@slaveclone [Player Name] - Spawns a supportive clone of the given player that follows the creator around. - 50:@evilclone [Player Name] - Spawns an agressive clone of the given player. - 60:@changesex - Changes your gender. - 10: - 1:--- DUEL CMD --- - 1:@duel - Starts a duel. - 1:@invite - Invites a player to a duel. - 1:@accept - Accepts an invitation to a duel. - 1:@reject - Rejects an invitation to a duel. - 1:@leave - Leaves a duel. - 1: - 1:--- MAIL SYSTEM --- (SQL Only) - 1:@mail - Open mail box. +// This is help file that contains help messages for atcommands/charcommands. + +// Format: +// : "" + +// This file uses libconfig syntax. + +help: "Params: \n" "Shows help for specified command." +main: "Params: [on|off|]\n" "Turns on or off main (server-wide) chat. Sends message to main chat." +noask: "Auto rejects deals/invites." +gmotd: "Broadcasts the Message of The Day to all players." +me: "Params: \n" "Displays normal text as a message in this format: *name message* (like /me in mIRC)." +fakename: "Params: \n" "Changes your name to your choice temporarily." +npctalk: "Params: \n" "Forces a NPC to display a message in normal chat." +broadcast: "Params: \n" "Broadcasts a message with your name (in yellow)." +kami: "Params: \n" "Broadcasts a message without your name (in yellow)." +kamib: "Params: \n" "Broadcasts a message without your name (in blue)." +localbroadcast: "Params: \n" "Broadcasts a message with your name (in yellow) only on your map." +commands: "Displays a list of commands that you can use." +rates: "Displays the server's current rates." +uptime: "Displays how long the server has been online." +showdelay: "Shows/hides the \"There is a delay after this skill\" message." +exp: "Displays current levels and % progress." +mobinfo: "Params: |\n" "Shows monster info (stats, exp, drops etc)." +iteminfo: "Params: |\n" "Shows item info (type, price etc)." +whodrops: "Params: |\n" "Shows who drops an item (monster with highest drop rates)." +version: "Displays SVN version of the server." +email: "Params: \n" "Changes your account e-mail address." +where: "Params: \n" "Tells you the location of a character." +time: "Shows the date and time of the server." +showexp: "Displays/hides experience gained." +showzeny: "Displays/hides Zeny gained." +mobsearch: "Params: |\n" "Shows the location of a certain mob on the current map." +who: "Params: []\n" "Shows a list of online players and their party and guild." +who2: "Params: []\n" "Shows a list of online players and their job." +who3: "Params: []\n" "Shows a list of online players and their location." +whomap: "@whomap/@whomap2/@whomap3 [map] - like @who/@who2/@who3 but only for specifical map." +whogm: "Params: [match_text] - Like @who+@who2+who3, but only for GM." +guildspy: "Params: - You will receive all messages of the guild channel (Chat logging must be enabled)" +partyspy: "@partyspy - You will receive all messages of the party channel (Chat logging must be enabled)" +mapinfo: "Params: [<0-3> [map]] - Give information about a map (general info +: 0: no more, 1: players, 2: NPC, 3: shops/chat)." +die: "Kills yourself." +go: "Params: \n" "Warps you to a city.\n" + " -3: (Memo point 2) 1: morocc 5: izlude 9: yuno 13: niflheim \n" + " -2: (Memo point 1) 2: geffen 6: aldebaran 10: amatsu 14: louyang\n" + " -1: (Memo point 0) 3: payon 7: xmas (lutie) 11: gonryun 15: start point\n" + " 0: prontera 4: alberta 8: comodo 12: umbala 16: prison/jail\n" +jumpto: "Params: \n" "Warps you to selected character." +follow: "Params: \n" "Follow a player." +mount: "Give/remove you a peco (Class is required, but not skill)" +disguise: "Params: \n" "Change your appearence to other players to a mob." +undisguise: "Restore your normal appearance." +model: "Params: - Changes your characters appearence." +size: "Params: <1-3> Changes your size (1-Smallest 2-Biggest 3-Normal)" +hide: "Makes you character invisible (GM invisibility). Type again to become visible." +save: "Sets respawn point to current spot." +load: "Warps you to your save point." +warp: "Params: [ ]\n" "Warps you to the selected map and position." +jump: "Params: [ []]\n" "Randomly warps you like a flywing." +jobchange: "Params: \n" "Changes your job.\n" +" 0: Novice 18: Alchemist 4015: Paladin\n" +" 1: Swordman 19: Bard 4016: Champion\n" +" 2: Mage 20: Dancer 4017: Professor\n" +" 3: Archer 23: Super Novice 4018: Stalker\n" +" 4: Acolyte 4001: High Novice 4019: Creator\n" +" 5: Merchant 4002: High Swordman 4020: Clown\n" +" 6: Thief 4003: High Mage 4021: Gypsy\n" +" 7: Knight 4004: High Archer 4046: Taekwon\n" +" 8: Priest 4005: High Acolyte 4047: Star Gladiator\n" +" 9: Wizard 4006: High Merchant 4049: Soul Linker\n" +" 10: Blacksmith 4007: High Thief 24: Gunslinger\n" +" 11: Hunter 4008: Lord Knight 25: Ninja\n" +" 12: Assassin 4009: High Priest\n" +" 14: Crusader 4010: High Wizard\n" +" 15: Monk 4011: Whitesmith\n" +" 16: Sage 4012: Sniper\n" +" 17: Rogue 4013: Assassin Cross\n" +" ---- Baby Classes ----\n" +" 4023: Baby 4024: Baby Swordman 4025: Baby Mage\n" +" 4026: Baby Archer 4027: Baby Acolyte 4028: Baby Merchant\n" +" 4029: Baby Thief 4030: Baby Knight 4031: Baby Priest\n" +" 4032: Baby Wizard 4033: Baby Blacksmith 4034: Baby Hunter\n" +" 4035: Baby Assassin 4037: Baby Crusader 4038: Baby Monk\n" +" 4039: Baby Sage 4040: Baby Rogue 4041: Baby Alchemist\n" +" 4042: Baby Bard 4043: Baby Dancer 4045: Super Baby\n" +option: "Params: \n" "Adds different visual effects on or around your character.\n" +" (stackable) \n" +"1 Petrified (stackable) 01 Sight 32 Peco Peco riding 2048 Orc Head\n" +"2 Frozen 01 Poison 02 Hide 64 GM Perfect Hide 4096 Wedding Sprites\n" +"3 Stunned 02 Cursed 04 Cloak 128 Level 2 Cart 8192 Ruwach\n" +"4 Sleeping 04 Silenced 08 Level 1 Cart 256 Level 3 Cart\n" +"6 darkness 08 ??? 16 Falcon 512 Level 4 Cart\n" +" 16 darkness 1024 Level 5 Cart\n" +heal: "Params: [ ]\n" "Heals the desired amount of HP and SP. No value specified will do a full heal." +dye: "Params: \n" "Changes your characters clothes color." +hairstyle: "Params: \n" "Changes your hair style." +haircolor: "Params \n" "Changes your hair color." +speed: "Params: <1-1000>\n" "Changes you walking speed. 1 being the fastest and 1000 the slowest. Default is 150." +effect: "Params: []\n" "Give an effect to your character." +dropall: "Throws all your possession on the ground." +storeall: "Puts all your possessions in storage." +killable: "Make your character killable." +memo: "Params: [memo position]\n" "Set/change a memo location (no position: display memo points)." +spiritball: "Params: <1-100>\n" "Gives you \"spirit spheres\" like from the skill \"Call Spirits\".\n" +questskill: "Params: <#>\n" "Gives you the specified quest skill" +lostskill: "Params: <#>\n" "Takes away the specified quest skill from you\n" +" Novice Swordsman Thief Merchant\n" +" 142 = Emergency Care 144 = Moving HP Recovery 149 = Throw Sand 153 = Cart Revolution\n" +" 143 = Act dead 145 = Attack Weak Point 150 = Back Sliding 154 = Change Cart\n" +" Archer 146 = Auto Berserk 151 = Take Stone 155 = Crazy Uproar/Loud Voice\n" +" 147 = Arrow Creation Acolyte 152 = Stone Throw Magician\n" +" 148 = Charge Arrows 156 = Holy Light 157 = Energy Coat\n" +skillid: "Params: \n" "Look up a skill by name" +useskill: "Params: \n" "Use a skill on target" +skilltree: "Params: <" +marry: "Params: ,\n" "Marry two players." +divorce: "Params: \n" "Divorces the two players (you need just one name of them)" +alive: "Revives yourself from death." +blvl: "Params: \n" "Raises your base level the desired number of levels." +jlvl: "Params: \n" "Raises your job level the desired number of levels." +allskill: "Give you all skills." +stpoint: "Params: - Gives you the desired number of stat points." +skpoint: "Params: - Gives you the desired number of skill points." +zeny: "Params: - Gives you desired amount of Zeny." +cash: "Params: - Gives you the specified amount of cash points." +points: "Params: - Gives you the specified amount of Kafra Points." +str: "Params: \n" "Raises STR by given amount." +agi: "Params: \n" "Raises AGI by given amount." +dex: "Params: \n" "Raises DEX by given amount." +vit: "Params: \n" "Raises VIT by given amount." +int: "Params: \n" "Raises INT by given amount." +luk: "Params: \n" "Raises LUK by given amount." +allstats: "Params: \n" "Adds value in all stats (maximum if no value)." +addwarp: "Params: \n" +killmonster2: "Kills all monsters of your map (without drops)." +monster: "Params: [ [ [ []]]]\n" + "@monster2 [ [ []]]\n" +"@spawn/@monster/@summon/@monster2 \"desired monster name\" [ [ []]]\n" +"@spawn/@monster/@summon/@monster2 \"desired monster name\" [ [ []]]\n" +" Spawns the desired monster with any desired name." +monstersmall: "Params: [Mob ID|Mob Name]\n" "Spawns a smaller version of a monster." +monsterbig: "Params: [Mob ID|Mob Name]\n" "Spawns a larger version of a monster." +killmonster: "Params: [map]\n" "Kill all monsters of the map (they drop)" +autoloot: "Params: [on|off|#]\n" "Makes items go straight into your inventory." +autotrade: "Allows you to vend while you are offline." +changegm: "Params: [Player Name]\n" "Changes the leader of your guild (You must be guild leader)" +changeleader: "Params: [Player Name]\n" "Changes the leader of your party (You must be party leader)" +request: "Params: [Message]\n" "Sends a message to all connected GMs (via the gm whisper system)" +sound: "Params: [Path way to file in Data or GRF file]\n" "Plays a sound from the data or grf file located on the client." +clone: "Params: [Player Name]\n" "Spawns a supportive clone of the given player." +slaveclone: "Params: [Player Name]\n" "Spawns a supportive clone of the given player that follows the creator around." +evilclone: "Params: [Player Name]\n" "Spawns an agressive clone of the given player." +changesex: "Changes your gender." +duel: "Starts a duel." +invite: "Invites a player to a duel." +accept: "Accepts an invitation to a duel." +reject: "Rejects an invitation to a duel." +leave: "Leaves a duel." +mail: "Open mail box." +storage: "Opens storage." +itemreset: "Remove all your items." +guildstorage: "Opens guild storage." +idsearch: "Params: \n" "Search all items that name have part_of_item_name" +refine: "Params: <+/- amount>" +produce: "Params: <# of very's>\n" +" Element: 0=None 1=Ice 2=Earth 3=Fire 4=Wind\n" +" You can add up to 3 Star Crumbs and 1 element\n" +repairall: "Repair all items of your inventory" +item: "Params: \n" "Gives you the desired item." +item2: "Params: \n" "Gives you the desired item." +pvpon: "Turns pvp on on the current map" +pvpoff: "Turns pvp off on the current map" +gvgon: "Turns gvg on on the current map" +gvgoff: "Turns gvg off on the current map" +agitstart: "Starts War of Emperium" +agitend: "End War of Emperium" +party: "Params: \n" "Create a party." +guild: "Params: \n" "Create a guild." +glvl: "Params: <# of levels>\n" "Raise Guild by desired number of levels" +guildrecall: "Params: \n" "Warps all online characters of a guild to you." +partyrecall: "Params: \n" "Warps all online characters of a party to you." +petrename: "Re-enable pet rename" +pettalk: "Params: [Message]\n" "Makes your pet say a message." +petfriendly: "Params: <#>\n" "Set pet friendly amount (0-1000) 1000 = Max" +pethungry: "Params: <#>\n" "Set pet hungry amount (0-100) 100 = Max" +hatch: "Create a pet from your inventory eggs list." +makeegg: "Params: \n" "Gives pet egg for monster number in pet DB" +kick: "Params: \n" "Kicks specified character off the server" +unjail: "Params: \n" "Discharges specified character/prisoner" +kill: "Params: \n" "Kills specified character." +recall: "Params: \n" "Warps target character to you." +raise: "Params: \n" "Revives target character." +block: "Params: \n" "Blocks definitively a account" +unblock: "Params: \n" "Unblocks a account" +ban: "Params: