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 23 files changed, 7649 insertions(+) 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 (limited to '3rdparty') 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 -- cgit v1.2.3-70-g09d2 From 35f0c02465492591b17dfde0e0b26411db4a5c66 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 21 Nov 2010 13:44:10 +0000 Subject: * Added msinttypes (rev. 26, http://msinttypes.googlecode.com/svn/trunk/) portability framework for Visual C++ compilers (related bugreport:4059). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14478 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/msinttypes/include/inttypes.h | 305 +++++++++++++++++++++++++++++++++ 3rdparty/msinttypes/include/stdint.h | 247 ++++++++++++++++++++++++++ Changelog-Trunk.txt | 2 + src/common/cbasetypes.h | 13 +- vcproj-6/char-server_sql.dsp | 2 +- vcproj-6/char-server_txt.dsp | 2 +- vcproj-6/login-server_sql.dsp | 2 +- vcproj-6/login-server_txt.dsp | 2 +- vcproj-6/map-server_sql.dsp | 2 +- vcproj-6/map-server_txt.dsp | 2 +- vcproj-7.1/char-server_sql.vcproj | 4 +- vcproj-7.1/char-server_txt.vcproj | 4 +- vcproj-7.1/login-server_sql.vcproj | 4 +- vcproj-7.1/login-server_txt.vcproj | 2 + vcproj-7.1/map-server_sql.vcproj | 4 +- vcproj-7.1/map-server_txt.vcproj | 4 +- vcproj-7.1/mapcache.vcproj | 4 +- vcproj-8/char-server_sql.vcproj | 4 +- vcproj-8/char-server_txt.vcproj | 4 +- vcproj-8/ladmin.vcproj | 4 +- vcproj-8/login-server_sql.vcproj | 4 +- vcproj-8/login-server_txt.vcproj | 2 + vcproj-8/map-server_sql.vcproj | 4 +- vcproj-8/map-server_txt.vcproj | 4 +- vcproj-8/mapcache.vcproj | 4 +- vcproj-8/txt-converter-char.vcproj | 4 +- vcproj-8/txt-converter-login.vcproj | 4 +- vcproj-9/char-server_sql.vcproj | 4 +- vcproj-9/char-server_txt.vcproj | 4 +- vcproj-9/ladmin.vcproj | 4 +- vcproj-9/login-server_sql.vcproj | 4 +- vcproj-9/login-server_txt.vcproj | 2 + vcproj-9/map-server_sql.vcproj | 4 +- vcproj-9/map-server_txt.vcproj | 4 +- vcproj-9/mapcache.vcproj | 4 +- vcproj-9/txt-converter-char.vcproj | 4 +- vcproj-9/txt-converter-login.vcproj | 4 +- 37 files changed, 622 insertions(+), 59 deletions(-) create mode 100644 3rdparty/msinttypes/include/inttypes.h create mode 100644 3rdparty/msinttypes/include/stdint.h (limited to '3rdparty') diff --git a/3rdparty/msinttypes/include/inttypes.h b/3rdparty/msinttypes/include/inttypes.h new file mode 100644 index 000000000..4b3828a21 --- /dev/null +++ b/3rdparty/msinttypes/include/inttypes.h @@ -0,0 +1,305 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. 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. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "stdint.h" + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/3rdparty/msinttypes/include/stdint.h b/3rdparty/msinttypes/include/stdint.h new file mode 100644 index 000000000..d02608a59 --- /dev/null +++ b/3rdparty/msinttypes/include/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. 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. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 020e647a4..6ecb567de 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2010/11/21 + * Added msinttypes (rev. 26, http://msinttypes.googlecode.com/svn/trunk/) portability framework for Visual C++ compilers (related bugreport:4059). [Ai4rei] 2010/11/20 * Fixed @doom and @doommap spamming packets for the visual effect on invoker unnecessarily over whole map and server respectively. The effect is now displayed on each killed character (bugreport:871, since r311). [Ai4rei] * Fixed login-server account engine initialization not getting checked, whether it succeeds or not (bugreport:4361, since r12700, related r13000). [Ai4rei] diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 488e4db49..aee54a4bc 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -73,6 +73,11 @@ # define __attribute__(x) #endif +////////////////////////////////////////////////////////////////////////// +// portable printf/scanf format macros and integer definitions +// NOTE: Visual C++ uses and provided in /3rdparty +////////////////////////////////////////////////////////////////////////// +#include ////////////////////////////////////////////////////////////////////////// // typedefs to compensate type size change from 32bit to 64bit @@ -174,22 +179,20 @@ typedef int ssize_t; typedef __int64 int64; typedef signed __int64 sint64; typedef unsigned __int64 uint64; -#define LLCONST(a) (a##i64) #else typedef long long int64; typedef signed long long sint64; typedef unsigned long long uint64; -#define LLCONST(a) (a##ll) #endif #ifndef INT64_MIN -#define INT64_MIN (LLCONST(-9223372036854775807)-1) +#define INT64_MIN (INT64_C(-9223372036854775807)-1) #endif #ifndef INT64_MAX -#define INT64_MAX (LLCONST(9223372036854775807)) +#define INT64_MAX (INT64_C(9223372036854775807)) #endif #ifndef UINT64_MAX -#define UINT64_MAX (LLCONST(18446744073709551615u)) +#define UINT64_MAX (UINT64_C(18446744073709551615)) #endif diff --git a/vcproj-6/char-server_sql.dsp b/vcproj-6/char-server_sql.dsp index 02714fd0d..f055ec3bc 100644 --- a/vcproj-6/char-server_sql.dsp +++ b/vcproj-6/char-server_sql.dsp @@ -38,7 +38,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 /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 CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\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 diff --git a/vcproj-6/char-server_txt.dsp b/vcproj-6/char-server_txt.dsp index 9fa2e55dc..975f7cf8f 100644 --- a/vcproj-6/char-server_txt.dsp +++ b/vcproj-6/char-server_txt.dsp @@ -38,7 +38,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 /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 CPP /nologo /W2 /GX /O2 /I "..\3rdparty\msinttypes\include" /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 diff --git a/vcproj-6/login-server_sql.dsp b/vcproj-6/login-server_sql.dsp index cdb0356bd..7348d3361 100644 --- a/vcproj-6/login-server_sql.dsp +++ b/vcproj-6/login-server_sql.dsp @@ -38,7 +38,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 /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 CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\msinttypes\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 diff --git a/vcproj-6/login-server_txt.dsp b/vcproj-6/login-server_txt.dsp index 5a074475b..ee54b5b76 100644 --- a/vcproj-6/login-server_txt.dsp +++ b/vcproj-6/login-server_txt.dsp @@ -38,7 +38,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 /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" /Fp"tmp/login_txt/login-server_txt.pch" /YX /Fo"tmp/login_txt/" /Fd"tmp/login_txt/" /FD /c +# ADD CPP /nologo /W2 /GX /O2 /I "..\3rdparty\msinttypes\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D "__WIN32" /D FD_SETSIZE=4096 /D "DB_MANUAL_CAST_TO_UNION" /D "WITH_TXT" /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 diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp index 397bf3956..629fe4639 100644 --- a/vcproj-6/map-server_sql.dsp +++ b/vcproj-6/map-server_sql.dsp @@ -38,7 +38,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 /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 CPP /nologo /W2 /GX /O2 /I "..\3rdparty\mysql\include" /I "..\3rdparty\zlib\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\msinttypes\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 diff --git a/vcproj-6/map-server_txt.dsp b/vcproj-6/map-server_txt.dsp index bbb84716d..1359adc15 100644 --- a/vcproj-6/map-server_txt.dsp +++ b/vcproj-6/map-server_txt.dsp @@ -38,7 +38,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 /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 CPP /nologo /W2 /GX /O2 /I "..\3rdparty\zlib\include" /I "..\3rdparty\pcre\include" /I "..\3rdparty\msinttypes\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 diff --git a/vcproj-7.1/char-server_sql.vcproj b/vcproj-7.1/char-server_sql.vcproj index d9432e83e..67b4bcb87 100644 --- a/vcproj-7.1/char-server_sql.vcproj +++ b/vcproj-7.1/char-server_sql.vcproj @@ -20,7 +20,7 @@ Date: Sat, 25 Jun 2011 22:09:35 +0000 Subject: * Added Mersenne Twister MT19937 as a random number generator. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14865 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/mt19937ar/mt19937ar.c | 175 +++++++++++++++++ 3rdparty/mt19937ar/mt19937ar.h | 72 +++++++ 3rdparty/mt19937ar/mt19937ar.out | 403 +++++++++++++++++++++++++++++++++++++++ 3rdparty/mt19937ar/mtTest.c | 65 +++++++ 3rdparty/mt19937ar/readme-mt.txt | 79 ++++++++ Changelog-Trunk.txt | 2 + src/common/random.c | 83 ++++++++ src/common/random.h | 20 ++ 8 files changed, 899 insertions(+) create mode 100644 3rdparty/mt19937ar/mt19937ar.c create mode 100644 3rdparty/mt19937ar/mt19937ar.h create mode 100644 3rdparty/mt19937ar/mt19937ar.out create mode 100644 3rdparty/mt19937ar/mtTest.c create mode 100644 3rdparty/mt19937ar/readme-mt.txt create mode 100644 src/common/random.c create mode 100644 src/common/random.h (limited to '3rdparty') diff --git a/3rdparty/mt19937ar/mt19937ar.c b/3rdparty/mt19937ar/mt19937ar.c new file mode 100644 index 000000000..211aefde9 --- /dev/null +++ b/3rdparty/mt19937ar/mt19937ar.c @@ -0,0 +1,175 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + Copyright (C) 2005, Mutsuo Saito, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. 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. + + 3. The names of its contributors may not 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. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +#include +#include "mt19937ar.h" + +/* Period parameters */ +#define N 624 +#define M 397 +#define MATRIX_A 0x9908b0dfUL /* constant vector a */ +#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ + +static unsigned long mt[N]; /* the array for the state vector */ +static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ + +/* initializes mt[N] with a seed */ +void init_genrand(unsigned long s) +{ + mt[0]= s & 0xffffffffUL; + for (mti=1; mti> 30)) + mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + mt[mti] &= 0xffffffffUL; + /* for >32 bit machines */ + } +} + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +/* slight change for C++, 2004/2/26 */ +void init_by_array(unsigned long init_key[], int key_length) +{ + int i, j, k; + init_genrand(19650218UL); + i=1; j=0; + k = (N>key_length ? N : key_length); + for (; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; j++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + if (j>=key_length) j=0; + } + for (k=N-1; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) + - i; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + } + + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ +} + +/* generates a random number on [0,0xffffffff]-interval */ +unsigned long genrand_int32(void) +{ + unsigned long y; + static unsigned long mag01[2]={0x0UL, MATRIX_A}; + /* mag01[x] = x * MATRIX_A for x=0,1 */ + + if (mti >= N) { /* generate N words at one time */ + int kk; + + if (mti == N+1) /* if init_genrand() has not been called, */ + init_genrand(5489UL); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; + } + for (;kk> 1) ^ mag01[y & 0x1UL]; + } + y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; + + mti = 0; + } + + y = mt[mti++]; + + /* Tempering */ + y ^= (y >> 11); + y ^= (y << 7) & 0x9d2c5680UL; + y ^= (y << 15) & 0xefc60000UL; + y ^= (y >> 18); + + return y; +} + +/* generates a random number on [0,0x7fffffff]-interval */ +long genrand_int31(void) +{ + return (long)(genrand_int32()>>1); +} + +/* generates a random number on [0,1]-real-interval */ +double genrand_real1(void) +{ + return genrand_int32()*(1.0/4294967295.0); + /* divided by 2^32-1 */ +} + +/* generates a random number on [0,1)-real-interval */ +double genrand_real2(void) +{ + return genrand_int32()*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on (0,1)-real-interval */ +double genrand_real3(void) +{ + return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on [0,1) with 53-bit resolution*/ +double genrand_res53(void) +{ + unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; + return(a*67108864.0+b)*(1.0/9007199254740992.0); +} +/* These real versions are due to Isaku Wada, 2002/01/09 added */ diff --git a/3rdparty/mt19937ar/mt19937ar.h b/3rdparty/mt19937ar/mt19937ar.h new file mode 100644 index 000000000..8b98b8a5b --- /dev/null +++ b/3rdparty/mt19937ar/mt19937ar.h @@ -0,0 +1,72 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + Copyright (C) 2005, Mutsuo Saito + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. 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. + + 3. The names of its contributors may not 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. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +/* initializes mt[N] with a seed */ +void init_genrand(unsigned long s); + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +/* slight change for C++, 2004/2/26 */ +void init_by_array(unsigned long init_key[], int key_length); + +/* generates a random number on [0,0xffffffff]-interval */ +unsigned long genrand_int32(void); + +/* generates a random number on [0,0x7fffffff]-interval */ +long genrand_int31(void); + +/* These real versions are due to Isaku Wada, 2002/01/09 added */ +/* generates a random number on [0,1]-real-interval */ +double genrand_real1(void); + +/* generates a random number on [0,1)-real-interval */ +double genrand_real2(void); + +/* generates a random number on (0,1)-real-interval */ +double genrand_real3(void); + +/* generates a random number on [0,1) with 53-bit resolution*/ +double genrand_res53(void); diff --git a/3rdparty/mt19937ar/mt19937ar.out b/3rdparty/mt19937ar/mt19937ar.out new file mode 100644 index 000000000..47abd073e --- /dev/null +++ b/3rdparty/mt19937ar/mt19937ar.out @@ -0,0 +1,403 @@ +1000 outputs of genrand_int32() +1067595299 955945823 477289528 4107218783 4228976476 +3344332714 3355579695 227628506 810200273 2591290167 +2560260675 3242736208 646746669 1479517882 4245472273 +1143372638 3863670494 3221021970 1773610557 1138697238 +1421897700 1269916527 2859934041 1764463362 3874892047 +3965319921 72549643 2383988930 2600218693 3237492380 +2792901476 725331109 605841842 271258942 715137098 +3297999536 1322965544 4229579109 1395091102 3735697720 +2101727825 3730287744 2950434330 1661921839 2895579582 +2370511479 1004092106 2247096681 2111242379 3237345263 +4082424759 219785033 2454039889 3709582971 835606218 +2411949883 2735205030 756421180 2175209704 1873865952 +2762534237 4161807854 3351099340 181129879 3269891896 + 776029799 2218161979 3001745796 1866825872 2133627728 + 34862734 1191934573 3102311354 2916517763 1012402762 +2184831317 4257399449 2899497138 3818095062 3030756734 +1282161629 420003642 2326421477 2741455717 1278020671 +3744179621 271777016 2626330018 2560563991 3055977700 +4233527566 1228397661 3595579322 1077915006 2395931898 +1851927286 3013683506 1999971931 3006888962 1049781534 +1488758959 3491776230 104418065 2448267297 3075614115 +3872332600 891912190 3936547759 2269180963 2633455084 +1047636807 2604612377 2709305729 1952216715 207593580 +2849898034 670771757 2210471108 467711165 263046873 +3569667915 1042291111 3863517079 1464270005 2758321352 +3790799816 2301278724 3106281430 7974801 2792461636 + 555991332 621766759 1322453093 853629228 686962251 +1455120532 957753161 1802033300 1021534190 3486047311 +1902128914 3701138056 4176424663 1795608698 560858864 +3737752754 3141170998 1553553385 3367807274 711546358 +2475125503 262969859 251416325 2980076994 1806565895 + 969527843 3529327173 2736343040 2987196734 1649016367 +2206175811 3048174801 3662503553 3138851612 2660143804 +1663017612 1816683231 411916003 3887461314 2347044079 +1015311755 1203592432 2170947766 2569420716 813872093 +1105387678 1431142475 220570551 4243632715 4179591855 +2607469131 3090613241 282341803 1734241730 1391822177 +1001254810 827927915 1886687171 3935097347 2631788714 +3905163266 110554195 2447955646 3717202975 3304793075 +3739614479 3059127468 953919171 2590123714 1132511021 +3795593679 2788030429 982155079 3472349556 859942552 +2681007391 2299624053 647443547 233600422 608168955 +3689327453 1849778220 1608438222 3968158357 2692977776 +2851872572 246750393 3582818628 3329652309 4036366910 +1012970930 950780808 3959768744 2538550045 191422718 +2658142375 3276369011 2927737484 1234200027 1920815603 +3536074689 1535612501 2184142071 3276955054 428488088 +2378411984 4059769550 3913744741 2732139246 64369859 +3755670074 842839565 2819894466 2414718973 1010060670 +1839715346 2410311136 152774329 3485009480 4102101512 +2852724304 879944024 1785007662 2748284463 1354768064 +3267784736 2269127717 3001240761 3179796763 895723219 + 865924942 4291570937 89355264 1471026971 4114180745 +3201939751 2867476999 2460866060 3603874571 2238880432 +3308416168 2072246611 2755653839 3773737248 1709066580 +4282731467 2746170170 2832568330 433439009 3175778732 + 26248366 2551382801 183214346 3893339516 1928168445 +1337157619 3429096554 3275170900 1782047316 4264403756 +1876594403 4289659572 3223834894 1728705513 4068244734 +2867840287 1147798696 302879820 1730407747 1923824407 +1180597908 1569786639 198796327 560793173 2107345620 +2705990316 3448772106 3678374155 758635715 884524671 + 486356516 1774865603 3881226226 2635213607 1181121587 +1508809820 3178988241 1594193633 1235154121 326117244 +2304031425 937054774 2687415945 3192389340 2003740439 +1823766188 2759543402 10067710 1533252662 4132494984 + 82378136 420615890 3467563163 541562091 3535949864 +2277319197 3330822853 3215654174 4113831979 4204996991 +2162248333 3255093522 2219088909 2978279037 255818579 +2859348628 3097280311 2569721123 1861951120 2907080079 +2719467166 998319094 2521935127 2404125338 259456032 +2086860995 1839848496 1893547357 2527997525 1489393124 +2860855349 76448234 2264934035 744914583 2586791259 +1385380501 66529922 1819103258 1899300332 2098173828 +1793831094 276463159 360132945 4178212058 595015228 + 177071838 2800080290 1573557746 1548998935 378454223 +1460534296 1116274283 3112385063 3709761796 827999348 +3580042847 1913901014 614021289 4278528023 1905177404 + 45407939 3298183234 1184848810 3644926330 3923635459 +1627046213 3677876759 969772772 1160524753 1522441192 + 452369933 1527502551 832490847 1003299676 1071381111 +2891255476 973747308 4086897108 1847554542 3895651598 +2227820339 1621250941 2881344691 3583565821 3510404498 + 849362119 862871471 797858058 2867774932 2821282612 +3272403146 3997979905 209178708 1805135652 6783381 +2823361423 792580494 4263749770 776439581 3798193823 +2853444094 2729507474 1071873341 1329010206 1289336450 +3327680758 2011491779 80157208 922428856 1158943220 +1667230961 2461022820 2608845159 387516115 3345351910 +1495629111 4098154157 3156649613 3525698599 4134908037 + 446713264 2137537399 3617403512 813966752 1157943946 +3734692965 1680301658 3180398473 3509854711 2228114612 +1008102291 486805123 863791847 3189125290 1050308116 +3777341526 4291726501 844061465 1347461791 2826481581 + 745465012 2055805750 4260209475 2386693097 2980646741 + 447229436 2077782664 1232942813 4023002732 1399011509 +3140569849 2579909222 3794857471 900758066 2887199683 +1720257997 3367494931 2668921229 955539029 3818726432 +1105704962 3889207255 2277369307 2746484505 1761846513 +2413916784 2685127085 4240257943 1166726899 4215215715 +3082092067 3960461946 1663304043 2087473241 4162589986 +2507310778 1579665506 767234210 970676017 492207530 +1441679602 1314785090 3262202570 3417091742 1561989210 +3011406780 1146609202 3262321040 1374872171 1634688712 +1280458888 2230023982 419323804 3262899800 39783310 +1641619040 1700368658 2207946628 2571300939 2424079766 + 780290914 2715195096 3390957695 163151474 2309534542 +1860018424 555755123 280320104 1604831083 2713022383 +1728987441 3639955502 623065489 3828630947 4275479050 +3516347383 2343951195 2430677756 635534992 3868699749 + 808442435 3070644069 4282166003 2093181383 2023555632 +1568662086 3422372620 4134522350 3016979543 3259320234 +2888030729 3185253876 4258779643 1267304371 1022517473 + 815943045 929020012 2995251018 3371283296 3608029049 +2018485115 122123397 2810669150 1411365618 1238391329 +1186786476 3155969091 2242941310 1765554882 279121160 +4279838515 1641578514 3796324015 13351065 103516986 +1609694427 551411743 2493771609 1316337047 3932650856 +4189700203 463397996 2937735066 1855616529 2626847990 + 55091862 3823351211 753448970 4045045500 1274127772 +1124182256 92039808 2126345552 425973257 386287896 +2589870191 1987762798 4084826973 2172456685 3366583455 +3602966653 2378803535 2901764433 3716929006 3710159000 +2653449155 3469742630 3096444476 3932564653 2595257433 + 318974657 3146202484 853571438 144400272 3768408841 + 782634401 2161109003 570039522 1886241521 14249488 +2230804228 1604941699 3928713335 3921942509 2155806892 + 134366254 430507376 1924011722 276713377 196481886 +3614810992 1610021185 1785757066 851346168 3761148643 +2918835642 3364422385 3012284466 3735958851 2643153892 +3778608231 1164289832 205853021 2876112231 3503398282 +3078397001 3472037921 1748894853 2740861475 316056182 +1660426908 168885906 956005527 3984354789 566521563 +1001109523 1216710575 2952284757 3834433081 3842608301 +2467352408 3974441264 3256601745 1409353924 1329904859 +2307560293 3125217879 3622920184 3832785684 3882365951 +2308537115 2659155028 1450441945 3532257603 3186324194 +1225603425 1124246549 175808705 3009142319 2796710159 +3651990107 160762750 1902254979 1698648476 1134980669 + 497144426 3302689335 4057485630 3603530763 4087252587 + 427812652 286876201 823134128 1627554964 3745564327 +2589226092 4202024494 62878473 3275585894 3987124064 +2791777159 1916869511 2585861905 1375038919 1403421920 + 60249114 3811870450 3021498009 2612993202 528933105 +2757361321 3341402964 2621861700 273128190 4015252178 +3094781002 1621621288 2337611177 1796718448 1258965619 +4241913140 2138560392 3022190223 4174180924 450094611 +3274724580 617150026 2704660665 1469700689 1341616587 + 356715071 1188789960 2278869135 1766569160 2795896635 + 57824704 2893496380 1235723989 1630694347 3927960522 + 428891364 1814070806 2287999787 4125941184 3968103889 +3548724050 1025597707 1404281500 2002212197 92429143 +2313943944 2403086080 3006180634 3561981764 1671860914 +1768520622 1803542985 844848113 3006139921 1410888995 +1157749833 2125704913 1789979528 1799263423 741157179 +2405862309 767040434 2655241390 3663420179 2172009096 +2511931187 1680542666 231857466 1154981000 157168255 +1454112128 3505872099 1929775046 2309422350 2143329496 +2960716902 407610648 2938108129 2581749599 538837155 +2342628867 430543915 740188568 1937713272 3315215132 +2085587024 4030765687 766054429 3517641839 689721775 +1294158986 1753287754 4202601348 1974852792 33459103 +3568087535 3144677435 1686130825 4134943013 3005738435 +3599293386 426570142 754104406 3660892564 1964545167 + 829466833 821587464 1746693036 1006492428 1595312919 +1256599985 1024482560 1897312280 2902903201 691790057 +1037515867 3176831208 1968401055 2173506824 1089055278 +1748401123 2941380082 968412354 1818753861 2973200866 +3875951774 1119354008 3988604139 1647155589 2232450826 +3486058011 3655784043 3759258462 847163678 1082052057 + 989516446 2871541755 3196311070 3929963078 658187585 +3664944641 2175149170 2203709147 2756014689 2456473919 +3890267390 1293787864 2830347984 3059280931 4158802520 +1561677400 2586570938 783570352 1355506163 31495586 +3789437343 3340549429 2092501630 896419368 671715824 +3530450081 3603554138 1055991716 3442308219 1499434728 +3130288473 3639507000 17769680 2259741420 487032199 +4227143402 3693771256 1880482820 3924810796 381462353 +4017855991 2452034943 2736680833 2209866385 2128986379 + 437874044 595759426 641721026 1636065708 3899136933 + 629879088 3591174506 351984326 2638783544 2348444281 +2341604660 2123933692 143443325 1525942256 364660499 + 599149312 939093251 1523003209 106601097 376589484 +1346282236 1297387043 764598052 3741218111 933457002 +1886424424 3219631016 525405256 3014235619 323149677 +2038881721 4100129043 2851715101 2984028078 1888574695 +2014194741 3515193880 4180573530 3461824363 2641995497 +3179230245 2902294983 2217320456 4040852155 1784656905 +3311906931 87498458 2752971818 2635474297 2831215366 +3682231106 2920043893 3772929704 2816374944 309949752 +2383758854 154870719 385111597 1191604312 1840700563 + 872191186 2925548701 1310412747 2102066999 1504727249 +3574298750 1191230036 3330575266 3180292097 3539347721 + 681369118 3305125752 3648233597 950049240 4173257693 +1760124957 512151405 681175196 580563018 1169662867 +4015033554 2687781101 699691603 2673494188 1137221356 + 123599888 472658308 1053598179 1012713758 3481064843 +3759461013 3981457956 3830587662 1877191791 3650996736 + 988064871 3515461600 4089077232 2225147448 1249609188 +2643151863 3896204135 2416995901 1397735321 3460025646 + +1000 outputs of genrand_real2() +0.76275443 0.99000644 0.98670464 0.10143112 0.27933125 +0.69867227 0.94218740 0.03427201 0.78842173 0.28180608 +0.92179002 0.20785655 0.54534773 0.69644020 0.38107718 +0.23978165 0.65286910 0.07514568 0.22765211 0.94872929 +0.74557914 0.62664415 0.54708246 0.90959343 0.42043116 +0.86334511 0.19189126 0.14718544 0.70259889 0.63426346 +0.77408121 0.04531601 0.04605807 0.88595519 0.69398270 +0.05377184 0.61711170 0.05565708 0.10133577 0.41500776 +0.91810699 0.22320679 0.23353705 0.92871862 0.98897234 +0.19786706 0.80558809 0.06961067 0.55840445 0.90479405 +0.63288060 0.95009721 0.54948447 0.20645042 0.45000959 +0.87050869 0.70806991 0.19406895 0.79286390 0.49332866 +0.78483914 0.75145146 0.12341941 0.42030252 0.16728160 +0.59906494 0.37575460 0.97815160 0.39815952 0.43595080 +0.04952478 0.33917805 0.76509902 0.61034321 0.90654701 +0.92915732 0.85365931 0.18812377 0.65913428 0.28814566 +0.59476081 0.27835931 0.60722542 0.68310435 0.69387186 +0.03699800 0.65897714 0.17527003 0.02889304 0.86777366 +0.12352068 0.91439461 0.32022990 0.44445731 0.34903686 +0.74639273 0.65918367 0.92492794 0.31872642 0.77749724 +0.85413832 0.76385624 0.32744211 0.91326300 0.27458185 +0.22190155 0.19865383 0.31227402 0.85321225 0.84243342 +0.78544200 0.71854080 0.92503892 0.82703064 0.88306297 +0.47284073 0.70059042 0.48003761 0.38671694 0.60465770 +0.41747204 0.47163243 0.72750808 0.65830223 0.10955369 +0.64215401 0.23456345 0.95944940 0.72822249 0.40888451 +0.69980355 0.26677428 0.57333635 0.39791582 0.85377858 +0.76962816 0.72004885 0.90903087 0.51376506 0.37732665 +0.12691640 0.71249738 0.81217908 0.37037313 0.32772374 +0.14238259 0.05614811 0.74363008 0.39773267 0.94859135 +0.31452454 0.11730313 0.62962618 0.33334237 0.45547255 +0.10089665 0.56550662 0.60539371 0.16027624 0.13245301 +0.60959939 0.04671662 0.99356286 0.57660859 0.40269560 +0.45274629 0.06699735 0.85064246 0.87742744 0.54508392 +0.87242982 0.29321385 0.67660627 0.68230715 0.79052073 +0.48592054 0.25186266 0.93769755 0.28565487 0.47219067 +0.99054882 0.13155240 0.47110470 0.98556600 0.84397623 +0.12875246 0.90953202 0.49129015 0.23792727 0.79481194 +0.44337770 0.96564297 0.67749118 0.55684872 0.27286897 +0.79538393 0.61965356 0.22487929 0.02226018 0.49248200 +0.42247006 0.91797788 0.99250134 0.23449967 0.52531508 +0.10246337 0.78685622 0.34310922 0.89892996 0.40454552 +0.68608407 0.30752487 0.83601319 0.54956031 0.63777550 +0.82199797 0.24890696 0.48801123 0.48661910 0.51223987 +0.32969635 0.31075073 0.21393155 0.73453207 0.15565705 +0.58584522 0.28976728 0.97621478 0.61498701 0.23891470 +0.28518540 0.46809591 0.18371914 0.37597910 0.13492176 +0.66849449 0.82811466 0.56240330 0.37548956 0.27562998 +0.27521910 0.74096121 0.77176757 0.13748143 0.99747138 +0.92504502 0.09175241 0.21389176 0.21766512 0.31183245 +0.23271221 0.21207367 0.57903312 0.77523344 0.13242613 +0.31037988 0.01204835 0.71652949 0.84487594 0.14982178 +0.57423142 0.45677888 0.48420169 0.53465428 0.52667473 +0.46880526 0.49849733 0.05670710 0.79022476 0.03872047 +0.21697212 0.20443086 0.28949326 0.81678186 0.87629474 +0.92297064 0.27373097 0.84625273 0.51505586 0.00582792 +0.33295971 0.91848412 0.92537226 0.91760033 0.07541125 +0.71745848 0.61158698 0.00941650 0.03135554 0.71527471 +0.24821915 0.63636652 0.86159918 0.26450229 0.60160194 +0.35557725 0.24477500 0.07186456 0.51757096 0.62120362 +0.97981062 0.69954667 0.21065616 0.13382753 0.27693186 +0.59644095 0.71500764 0.04110751 0.95730081 0.91600724 +0.47704678 0.26183479 0.34706971 0.07545431 0.29398385 +0.93236070 0.60486023 0.48015011 0.08870451 0.45548581 +0.91872718 0.38142712 0.10668643 0.01397541 0.04520355 +0.93822273 0.18011940 0.57577277 0.91427606 0.30911399 +0.95853475 0.23611214 0.69619891 0.69601980 0.76765372 +0.58515930 0.49479057 0.11288752 0.97187699 0.32095365 +0.57563608 0.40760618 0.78703383 0.43261152 0.90877651 +0.84686346 0.10599030 0.72872803 0.19315490 0.66152912 +0.10210518 0.06257876 0.47950688 0.47062066 0.72701157 +0.48915116 0.66110261 0.60170685 0.24516994 0.12726050 +0.03451185 0.90864994 0.83494878 0.94800035 0.91035206 +0.14480751 0.88458997 0.53498312 0.15963215 0.55378627 +0.35171349 0.28719791 0.09097957 0.00667896 0.32309622 +0.87561479 0.42534520 0.91748977 0.73908457 0.41793223 +0.99279792 0.87908370 0.28458072 0.59132853 0.98672190 +0.28547393 0.09452165 0.89910674 0.53681109 0.37931425 +0.62683489 0.56609740 0.24801549 0.52948179 0.98328855 +0.66403523 0.55523786 0.75886666 0.84784685 0.86829981 +0.71448906 0.84670080 0.43922919 0.20771016 0.64157936 +0.25664246 0.73055695 0.86395782 0.65852932 0.99061803 +0.40280575 0.39146298 0.07291005 0.97200603 0.20555729 +0.59616495 0.08138254 0.45796388 0.33681125 0.33989127 +0.18717090 0.53545811 0.60550838 0.86520709 0.34290701 +0.72743276 0.73023855 0.34195926 0.65019733 0.02765254 +0.72575740 0.32709576 0.03420866 0.26061893 0.56997511 +0.28439072 0.84422744 0.77637570 0.55982168 0.06720327 +0.58449067 0.71657369 0.15819609 0.58042821 0.07947911 +0.40193792 0.11376012 0.88762938 0.67532159 0.71223735 +0.27829114 0.04806073 0.21144026 0.58830274 0.04140071 +0.43215628 0.12952729 0.94668759 0.87391019 0.98382450 +0.27750768 0.90849647 0.90962737 0.59269720 0.96102026 +0.49544979 0.32007095 0.62585546 0.03119821 0.85953001 +0.22017528 0.05834068 0.80731217 0.53799961 0.74166948 +0.77426600 0.43938444 0.54862081 0.58575513 0.15886492 +0.73214332 0.11649057 0.77463977 0.85788827 0.17061997 +0.66838056 0.96076133 0.07949296 0.68521946 0.89986254 +0.05667410 0.12741385 0.83470977 0.63969104 0.46612929 +0.10200126 0.01194925 0.10476340 0.90285217 0.31221221 +0.32980614 0.46041971 0.52024973 0.05425470 0.28330912 +0.60426543 0.00598243 0.97244013 0.21135841 0.78561597 +0.78428734 0.63422849 0.32909934 0.44771136 0.27380750 +0.14966697 0.18156268 0.65686758 0.28726350 0.97074787 +0.63676171 0.96649494 0.24526295 0.08297372 0.54257548 +0.03166785 0.33735355 0.15946671 0.02102971 0.46228045 +0.11892296 0.33408336 0.29875681 0.29847692 0.73767569 +0.02080745 0.62980060 0.08082293 0.22993106 0.25031439 +0.87787525 0.45150053 0.13673441 0.63407612 0.97907688 +0.52241942 0.50580158 0.06273902 0.05270283 0.77031811 +0.05113352 0.24393329 0.75036441 0.37436336 0.22877652 +0.59975358 0.85707591 0.88691457 0.85547165 0.36641027 +0.58720133 0.45462835 0.09243817 0.32981586 0.07820411 +0.25421519 0.36004706 0.60092307 0.46192412 0.36758683 +0.98424170 0.08019934 0.68594024 0.45826386 0.29962317 +0.79365413 0.89231296 0.49478547 0.87645944 0.23590734 +0.28106737 0.75026285 0.08136314 0.79582424 0.76010628 +0.82792971 0.27947652 0.72482861 0.82191216 0.46171689 +0.79189752 0.96043686 0.51609668 0.88995725 0.28998963 +0.55191845 0.03934737 0.83033700 0.49553013 0.98009549 +0.19017594 0.98347750 0.33452066 0.87144372 0.72106301 +0.71272114 0.71465963 0.88361677 0.85571283 0.73782329 +0.20920458 0.34855153 0.46766817 0.02780062 0.74898344 +0.03680650 0.44866557 0.77426312 0.91025891 0.25195236 +0.87319953 0.63265037 0.25552148 0.27422476 0.95217406 +0.39281839 0.66441573 0.09158900 0.94515992 0.07800798 +0.02507888 0.39901462 0.17382573 0.12141278 0.85502334 +0.19902911 0.02160210 0.44460522 0.14688742 0.68020336 +0.71323733 0.60922473 0.95400380 0.99611159 0.90897777 +0.41073520 0.66206647 0.32064685 0.62805003 0.50677209 +0.52690101 0.87473387 0.73918362 0.39826974 0.43683919 +0.80459118 0.32422684 0.01958019 0.95319576 0.98326137 +0.83931735 0.69060863 0.33671416 0.68062550 0.65152380 +0.33392969 0.03451730 0.95227244 0.68200635 0.85074171 +0.64721009 0.51234433 0.73402047 0.00969637 0.93835057 +0.80803854 0.31485260 0.20089527 0.01323282 0.59933780 +0.31584602 0.20209563 0.33754800 0.68604181 0.24443049 +0.19952227 0.78162632 0.10336988 0.11360736 0.23536740 +0.23262256 0.67803776 0.48749791 0.74658435 0.92156640 +0.56706407 0.36683221 0.99157136 0.23421374 0.45183767 +0.91609720 0.85573315 0.37706276 0.77042618 0.30891908 +0.40709595 0.06944866 0.61342849 0.88817388 0.58734506 +0.98711323 0.14744128 0.63242656 0.87704136 0.68347125 +0.84446569 0.43265239 0.25146321 0.04130111 0.34259839 +0.92697368 0.40878778 0.56990338 0.76204273 0.19820348 +0.66314909 0.02482844 0.06669207 0.50205581 0.26084093 +0.65139159 0.41650223 0.09733904 0.56344203 0.62651696 +0.67332139 0.58037374 0.47258086 0.21010758 0.05713135 +0.89390629 0.10781246 0.32037450 0.07628388 0.34227964 +0.42190597 0.58201860 0.77363549 0.49595133 0.86031236 +0.83906769 0.81098161 0.26694195 0.14215941 0.88210306 +0.53634237 0.12090720 0.82480459 0.75930318 0.31847147 +0.92768077 0.01037616 0.56201727 0.88107122 0.35925856 +0.85860762 0.61109408 0.70408301 0.58434977 0.92192494 +0.62667915 0.75988365 0.06858761 0.36156496 0.58057195 +0.13636150 0.57719713 0.59340255 0.63530602 0.22976282 +0.71915530 0.41162531 0.63979565 0.09931342 0.79344045 +0.10893790 0.84450224 0.23122236 0.99485593 0.73637397 +0.17276368 0.13357764 0.74965804 0.64991737 0.61990341 +0.41523170 0.05878239 0.05687301 0.05497131 0.42868366 +0.42571090 0.25810502 0.89642955 0.30439758 0.39310223 +0.11357431 0.04288255 0.23397550 0.11200634 0.85621396 +0.89733974 0.37508865 0.42077265 0.68597384 0.72781399 +0.19296476 0.61699087 0.31667128 0.67756410 0.00177323 +0.05725176 0.79474693 0.18885238 0.06724856 0.68193156 +0.42202167 0.22082041 0.28554673 0.64995708 0.87851940 +0.29124547 0.61009521 0.87374537 0.05743712 0.69902994 +0.81925115 0.45653873 0.37236821 0.31118709 0.52734307 +0.39672836 0.38185294 0.30163915 0.17374510 0.04913278 +0.90404879 0.25742801 0.58266467 0.97663209 0.79823377 +0.36437958 0.15206043 0.26529938 0.22690047 0.05839021 +0.84721160 0.18622435 0.37809403 0.55706977 0.49828704 +0.47659049 0.24289680 0.88477595 0.07807463 0.56245739 +0.73490635 0.21099431 0.13164942 0.75840044 0.66877037 +0.28988183 0.44046090 0.24967434 0.80048356 0.26029740 +0.30416821 0.64151867 0.52067892 0.12880774 0.85465381 +0.02690525 0.19149288 0.49630295 0.79682619 0.43566145 +0.00288078 0.81484193 0.03763639 0.68529083 0.01339574 +0.38405386 0.30537067 0.22994703 0.44000045 0.27217985 +0.53831243 0.02870435 0.86282045 0.61831306 0.09164956 +0.25609707 0.07445781 0.72185784 0.90058883 0.30070608 +0.94476583 0.56822213 0.21933909 0.96772793 0.80063440 +0.26307906 0.31183306 0.16501252 0.55436179 0.68562285 +0.23829083 0.86511559 0.57868991 0.81888344 0.20126869 +0.93172350 0.66028129 0.21786948 0.78515828 0.10262106 +0.35390326 0.79303876 0.63427924 0.90479631 0.31024934 +0.60635447 0.56198079 0.63573813 0.91854197 0.99701497 +0.83085849 0.31692291 0.01925964 0.97446405 0.98751283 +0.60944293 0.13751018 0.69519957 0.68956636 0.56969015 +0.46440193 0.88341765 0.36754434 0.89223647 0.39786427 +0.85055280 0.12749961 0.79452122 0.89449784 0.14567830 +0.45716830 0.74822309 0.28200437 0.42546044 0.17464886 +0.68308746 0.65496587 0.52935411 0.12736159 0.61523955 +0.81590528 0.63107864 0.39786553 0.20102294 0.53292914 +0.75485590 0.59847044 0.32861691 0.12125866 0.58917183 +0.07638293 0.86845380 0.29192617 0.03989733 0.52180460 +0.32503407 0.64071852 0.69516575 0.74254998 0.54587026 +0.48713246 0.32920155 0.08719954 0.63497059 0.54328459 +0.64178757 0.45583809 0.70694291 0.85212760 0.86074305 +0.33163422 0.85739792 0.59908488 0.74566046 0.72157152 diff --git a/3rdparty/mt19937ar/mtTest.c b/3rdparty/mt19937ar/mtTest.c new file mode 100644 index 000000000..b27406802 --- /dev/null +++ b/3rdparty/mt19937ar/mtTest.c @@ -0,0 +1,65 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + Copyright (C) 2005, Mutsuo Saito, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. 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. + + 3. The names of its contributors may not 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. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +#include +#include "mt19937ar.h" + +int main(void) +{ + int i; + unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4; + init_by_array(init, length); + printf("1000 outputs of genrand_int32()\n"); + for (i=0; i<1000; i++) { + printf("%10lu ", genrand_int32()); + if (i%5==4) printf("\n"); + } + printf("\n1000 outputs of genrand_real2()\n"); + for (i=0; i<1000; i++) { + printf("%10.8f ", genrand_real2()); + if (i%5==4) printf("\n"); + } + return 0; +} diff --git a/3rdparty/mt19937ar/readme-mt.txt b/3rdparty/mt19937ar/readme-mt.txt new file mode 100644 index 000000000..2d4c2e8a2 --- /dev/null +++ b/3rdparty/mt19937ar/readme-mt.txt @@ -0,0 +1,79 @@ +This is a Mersenne Twister pseudorandom number generator +with period 2^19937-1 with improved initialization scheme, +modified on 2002/1/26 by Takuji Nishimura and Makoto Matsumoto. +modified on 2005/4/26 by Mutsuo Saito + +Contents of this tar ball: +readme-mt.txt this file +mt19937ar.c the C source (ar: initialize by ARray) +mt19937ar.h the C header file for mt19937ar +mtTest.c the C test main program of mt19937ar.c +mt19937ar.out Test outputs of six types generators. 1000 for each + +1. Initialization + The initialization scheme for the previous versions of MT +(e.g. 1999/10/28 version or earlier) has a tiny problem, that +the most significant bits of the seed is not well reflected +to the state vector of MT. + +This version (2002/1/26) has two initialization schemes: +init_genrand(seed) and init_by_array(init_key, key_length). + +init_genrand(seed) initializes the state vector by using +one unsigned 32-bit integer "seed", which may be zero. + +init_by_array(init_key, key_length) initializes the state vector +by using an array init_key[] of unsigned 32-bit integers +of length key_kength. If key_length is smaller than 624, +then each array of 32-bit integers gives distinct initial +state vector. This is useful if you want a larger seed space +than 32-bit word. + +2. Generation +After initialization, the following type of pseudorandom numbers +are available. + +genrand_int32() generates unsigned 32-bit integers. +genrand_int31() generates unsigned 31-bit integers. +genrand_real1() generates uniform real in [0,1] (32-bit resolution). +genrand_real2() generates uniform real in [0,1) (32-bit resolution). +genrand_real3() generates uniform real in (0,1) (32-bit resolution). +genrand_res53() generates uniform real in [0,1) with 53-bit resolution. + +Note: the last five functions call the first one. +if you need more speed for these five functions, you may +suppress the function call by copying genrand_int32() and +replacing the last return(), following to these five functions. + +3. main() +main() is an example to initialize with an array of length 4, +then 1000 outputs of unsigned 32-bit integers, +then 1000 outputs of real [0,1) numbers. + +4. The outputs +The output of the mt19937ar.c is in the file mt19937ar.out. +If you revise or translate the code, check the output +by using this file. + +5. Cryptography +This generator is not cryptoraphically secure. +You need to use a one-way (or hash) function to obtain +a secure random sequence. + +6. Correspondence +See: +URL http://www.math.keio.ac.jp/matumoto/emt.html +email matumoto@math.keio.ac.jp, nisimura@sci.kj.yamagata-u.ac.jp + +7. Reference +M. Matsumoto and T. Nishimura, +"Mersenne Twister: A 623-Dimensionally Equidistributed Uniform +Pseudo-Random Number Generator", +ACM Transactions on Modeling and Computer Simulation, +Vol. 8, No. 1, January 1998, pp 3--30. + +------- +Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, +All rights reserved. +Copyright (C) 2005, Mutsuo Saito +All rights reserved. diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 06533ff68..29eccd9ee 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/06/25 + * Added Mersenne Twister MT19937 as a random number generator. [FlavioJS] 2011/06/23 * Made chrif_save always call pc_makesavestatus. (no reason to prevent the call, and was interfering with multi map-server; fixes bugreport:1400) [FlavioJS] 2011/06/22 diff --git a/src/common/random.c b/src/common/random.c new file mode 100644 index 000000000..b7f2c080c --- /dev/null +++ b/src/common/random.c @@ -0,0 +1,83 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/timer.h" // gettick +#include "random.h" +#if defined(WIN32) + #define WIN32_LEAN_AND_MEAN + #include +#elif defined(HAVE_GETPID) || defined(HAVE_GETTID) + #include + #include +#endif +#include // time +#include // init_genrand, genrand_int32, genrand_res53 + + +/// Initializes the random number generator with an appropriate seed. +void rnd_init(void) +{ + uint32 seed = gettick(); + seed += (uint32)time(NULL); +#if defined(WIN32) + seed += GetCurrentProcessId(); + seed += GetCurrentThreadId(); +#else +#if defined(HAVE_GETPID) + seed += (uint32)getpid(); +#endif // HAVE_GETPID +#if defined(HAVE_GETTID) + seed += (uint32)gettid(); +#endif // HAVE_GETTID +#endif + init_genrand(seed); +} + + +/// Initializes the random number generator. +void rnd_seed(uint32 seed) +{ + init_genrand(seed); +} + + +/// Generates a random number in the interval [0, UINT32_MAX] +uint32 rnd(void) +{ + return (uint32)genrand_int32(); +} + + +/// Generates a random number in the interval [0, dice_faces) +/// NOTE: interval is open ended, so dice_faces is excluded (unless it's 0) +uint32 rnd_roll(uint32 dice_faces) +{ + return (uint32)(rnd_uniform()*dice_faces); +} + + +/// Generates a random number in the interval [min, max] +/// Returns min if range is invalid. +int32 rnd_value(int32 min, int32 max) +{ + if( min >= max ) + return min; + return min + (int32)(rnd_uniform()*(max-min+1)); +} + + +/// Generates a random number in the interval [0.0, 1.0) +/// NOTE: interval is open ended, so 1.0 is excluded +double rnd_uniform(void) +{ + return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32 +} + + +/// Generates a random number in the interval [0.0, 1.0) with 53-bit resolution +/// NOTE: interval is open ended, so 1.0 is excluded +/// NOTE: 53 bits is the maximum precision of a double +double rnd_uniform53(void) +{ + return genrand_res53(); +} diff --git a/src/common/random.h b/src/common/random.h new file mode 100644 index 000000000..1bb8ecfb5 --- /dev/null +++ b/src/common/random.h @@ -0,0 +1,20 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _RANDOM_H_ +#define _RANDOM_H_ + +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + +void rnd_init(void); +void rnd_seed(uint32); + +uint32 rnd(void);// [0, UINT32_MAX] +uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces) +int32 rnd_value(int32 min, int32 max);// [min, max] +double rnd_uniform(void);// [0.0, 1.0) +double rnd_uniform53(void);// [0.0, 1.0) + +#endif /* _RANDOM_H_ */ -- 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 '3rdparty') 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 dd73c6ea546a8828653cdce38a52f575cbdd3b96 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Wed, 29 Jun 2011 12:26:51 +0000 Subject: * Added experimental support for CMake. (for now: basic build, no extras, only tested with VS10 and cygwin) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14872 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 6 + 3rdparty/msinttypes/CMakeLists.txt | 7 + 3rdparty/mt19937ar/CMakeLists.txt | 9 ++ 3rdparty/mysql/CMakeLists.txt | 110 +++++++++++++++ 3rdparty/mysql/FindMYSQL.cmake | 34 +++++ 3rdparty/pcre/CMakeLists.txt | 92 +++++++++++++ 3rdparty/pcre/FindPCRE.cmake | 35 +++++ 3rdparty/zlib/CMakeLists.txt | 90 ++++++++++++ CMakeLists.txt | 274 +++++++++++++++++++++++++++++++++++++ Changelog-Trunk.txt | 4 +- src/CMakeLists.txt | 9 ++ src/char/CMakeLists.txt | 64 +++++++++ src/char_sql/CMakeLists.txt | 68 +++++++++ src/common/CMakeLists.txt | 40 ++++++ src/login/CMakeLists.txt | 103 ++++++++++++++ src/map/CMakeLists.txt | 140 +++++++++++++++++++ src/tool/CMakeLists.txt | 49 +++++++ 17 files changed, 1133 insertions(+), 1 deletion(-) create mode 100644 3rdparty/CMakeLists.txt create mode 100644 3rdparty/msinttypes/CMakeLists.txt create mode 100644 3rdparty/mt19937ar/CMakeLists.txt create mode 100644 3rdparty/mysql/CMakeLists.txt create mode 100644 3rdparty/mysql/FindMYSQL.cmake create mode 100644 3rdparty/pcre/CMakeLists.txt create mode 100644 3rdparty/pcre/FindPCRE.cmake create mode 100644 3rdparty/zlib/CMakeLists.txt create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/char/CMakeLists.txt create mode 100644 src/char_sql/CMakeLists.txt create mode 100644 src/common/CMakeLists.txt create mode 100644 src/login/CMakeLists.txt create mode 100644 src/map/CMakeLists.txt create mode 100644 src/tool/CMakeLists.txt (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt new file mode 100644 index 000000000..6e5c759cc --- /dev/null +++ b/3rdparty/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_subdirectory( msinttypes ) +add_subdirectory( mt19937ar ) +add_subdirectory( mysql ) +add_subdirectory( pcre ) +add_subdirectory( zlib ) diff --git a/3rdparty/msinttypes/CMakeLists.txt b/3rdparty/msinttypes/CMakeLists.txt new file mode 100644 index 000000000..acf17f5b4 --- /dev/null +++ b/3rdparty/msinttypes/CMakeLists.txt @@ -0,0 +1,7 @@ + +if( WIN32 ) +find_path( MSINTTYPES_INCLUDE_DIRS "inttypes.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +mark_as_advanced( MSINTTYPES_INCLUDE_DIRS ) +endif() diff --git a/3rdparty/mt19937ar/CMakeLists.txt b/3rdparty/mt19937ar/CMakeLists.txt new file mode 100644 index 000000000..46f155b41 --- /dev/null +++ b/3rdparty/mt19937ar/CMakeLists.txt @@ -0,0 +1,9 @@ + +find_path( MT19937AR_INCLUDE_DIRS "mt19937ar.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}" + NO_DEFAULT_PATH ) +find_path( MT19937AR_SOURCE_DIR "mt19937ar.c" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}" + NO_DEFAULT_PATH ) +mark_as_advanced( MT19937AR_INCLUDE_DIRS ) +mark_as_advanced( MT19937AR_SOURCE_DIR ) diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt new file mode 100644 index 000000000..1c14d7395 --- /dev/null +++ b/3rdparty/mysql/CMakeLists.txt @@ -0,0 +1,110 @@ + +# +# local copy +# +if( WIN32 ) +message( STATUS "Detecting local MYSQL" ) +find_path( LOCAL_MYSQL_INCLUDE_DIRS "mysql.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +find_library( LOCAL_MYSQL_LIBRARIES + NAMES libmysql + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" + NO_DEFAULT_PATH ) +mark_as_advanced( LOCAL_MYSQL_LIBRARIES ) +mark_as_advanced( LOCAL_MYSQL_INCLUDE_DIRS ) + +if( LOCAL_MYSQL_LIBRARIES AND LOCAL_MYSQL_INCLUDE_DIRS ) + if( EXISTS "${LOCAL_MYSQL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${LOCAL_MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_SERVER_VERSION "${MYSQL_VERSION_H}" ) + message( STATUS "Found MYSQL: ${LOCAL_MYSQL_LIBRARIES} (found version ${MYSQL_SERVER_VERSION})" ) + else() + message( STATUS "Found MYSQL: ${LOCAL_MYSQL_LIBRARIES}" ) + endif() + set( HAVE_LOCAL_MYSQL ON + CACHE BOOL "mysql client is available as a local copy") +else() + foreach( _VAR LOCAL_MYSQL_LIBRARIES LOCAL_MYSQL_INCLUDE_DIRS ) + if( NOT "${_VAR}" ) + set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) + endif() + endforeach() + message( STATUS "Could NOT find MYSQL (missing: ${MISSING_VARS})" ) + unset( HAVE_LOCAL_MYSQL CACHE ) +endif() +message( STATUS "Detecting local MYSQL - done" ) +endif( WIN32 ) + + +# +# system +# +message( STATUS "Detecting system MYSQL" ) +find_program( MYSQL_CONFIG_EXECUTABLE "mysql_config" ) +mark_as_advanced( MYSQL_CONFIG_EXECUTABLE ) +if( MYSQL_CONFIG_EXECUTABLE ) + # use mysql_config data + message( "Found mysql_config: ${MYSQL_CONFIG_EXECUTABLE}" ) + execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --libs" + OUTPUT_VARIABLE MYSQL_LIBRARIES ) + execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --include" + OUTPUT_VARIABLE MYSQL_INCLUDE_DIRS ) + execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --version" + OUTPUT_VARIABLE MYSQL_VERSION ) + message( STATUS "Found MYSQL: ${MYSQL_LIBRARIES} (found version ${MYSQL_VERSION})" ) +else() + # find mysql package + set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) + find_package( MYSQL ) +endif() +set( SYSTEM_MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" + CACHE PATH "system mysql libraries" ) +set( SYSTEM_MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" + CACHE PATH "system mysql include directories" ) +mark_as_advanced( SYSTEM_MYSQL_LIBRARIES ) +mark_as_advanced( SYSTEM_MYSQL_INCLUDE_DIRS ) + +if( SYSTEM_MYSQL_LIBRARIES AND SYSTEM_MYSQL_INCLUDE_DIRS ) + set( HAVE_SYSTEM_MYSQL ON + CACHE BOOL "mysql client is available on the system" ) +endif() +message( STATUS "Detecting system MYSQL - done" ) + + +# options + +# +# configure +# +unset( MYSQL_LIBRARIES CACHE ) +unset( MYSQL_INCLUDE_DIRS CACHE ) +if( HAVE_LOCAL_MYSQL ) + set( USE_LOCAL_MYSQL ON + CACHE BOOL "use local copy of mysql" ) +else() + unset( USE_LOCAL_MYSQL CACHE ) +endif() +if( USE_LOCAL_MYSQL ) + message( STATUS "Configuring for local MYSQL" ) + set( MYSQL_LIBRARIES ${LOCAL_MYSQL_LIBRARIES} ) + set( MYSQL_INCLUDE_DIRS ${LOCAL_MYSQL_INCLUDE_DIRS} ) + message( STATUS "Configuring for local MYSQL - done" ) +elseif( HAVE_SYSTEM_MYSQL ) + message( STATUS "Configuring for system MYSQL" ) + set( MYSQL_LIBRARIES ${SYSTEM_MYSQL_LIBRARIES} ) + set( MYSQL_INCLUDE_DIRS ${SYSTEM_MYSQL_INCLUDE_DIRS} ) + message( STATUS "Configuring for system MYSQL - done" ) +endif() +if( USE_LOCAL_MYSQL OR HAVE_SYSTEM_MYSQL ) + set( USE_MYSQL ON + CACHE BOOL "use mysql" ) +else() + unset( USE_MYSQL CACHE ) +endif() +set( MYSQL_LIBRARIES ${MYSQL_LIBRARIES} + CACHE PATH "mysql libraries" ) +set( MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIRS} + CACHE PATH "mysql include directories" ) +mark_as_advanced( MYSQL_LIBRARIES ) +mark_as_advanced( MYSQL_INCLUDE_DIRS ) diff --git a/3rdparty/mysql/FindMYSQL.cmake b/3rdparty/mysql/FindMYSQL.cmake new file mode 100644 index 000000000..5ac264098 --- /dev/null +++ b/3rdparty/mysql/FindMYSQL.cmake @@ -0,0 +1,34 @@ +# - Find mysqlclient +# Find the native MySQL includes and library +# +# MYSQL_INCLUDE_DIR - where to find mysql.h, etc. +# MYSQL_LIBRARIES - List of libraries when using MySQL. +# MYSQL_FOUND - True if MySQL found. +# +# Based on: http://www.itk.org/Wiki/CMakeUserFindMySQL + +find_path( MYSQL_INCLUDE_DIR "mysql.h" + PATH_SUFFIXES "mysql" ) + +set( MYSQL_NAMES mysqlclient mysqlclient_r ) +find_library( MYSQL_LIBRARY + NAMES ${MYSQL_NAMES} + PATH_SUFFIXES "mysql" ) +mark_as_advanced( MYSQL_LIBRARY MYSQL_INCLUDE_DIR ) + +if( MYSQL_INCLUDE_DIR AND EXISTS "${MYSQL_INCLUDE_DIR}/mysql_version.h" ) + file( STRINGS "${MYSQL_INCLUDE_DIR}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL + REQUIRED_VARS MYSQL_LIBRARY MYSQL_INCLUDE_DIR + VERSION_VAR MYSQL_VERSION_STRING ) + +if( MYSQL_FOUND ) + set( MYSQL_LIBRARIES ${PCRE_LIBRARY} ) + set( MYSQL_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +endif() diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt new file mode 100644 index 000000000..0625999b1 --- /dev/null +++ b/3rdparty/pcre/CMakeLists.txt @@ -0,0 +1,92 @@ + +# +# local copy +# +if( WIN32 ) +message( STATUS "Detecting local PCRE" ) +find_path( LOCAL_PCRE_INCLUDE_DIRS "pcre.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +find_library( LOCAL_PCRE_LIBRARIES + NAMES pcre + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" + NO_DEFAULT_PATH ) +mark_as_advanced( LOCAL_PCRE_LIBRARIES ) +mark_as_advanced( LOCAL_PCRE_INCLUDE_DIRS ) + +if( LOCAL_PCRE_LIBRARIES AND LOCAL_PCRE_INCLUDE_DIRS ) + file( STRINGS "${LOCAL_PCRE_INCLUDE_DIRS}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + message( STATUS "Found PCRE: ${LOCAL_PCRE_LIBRARIES} (found version ${PCRE_MAJOR}.${PCRE_MINOR})" ) + set( HAVE_LOCAL_PCRE ON + CACHE BOOL "pcre is available as a local copy" ) +else() + foreach( _VAR LOCAL_PCRE_LIBRARIES LOCAL_PCRE_INCLUDE_DIRS ) + if( NOT "${_VAR}" ) + set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) + endif() + endforeach() + message( STATUS "Could NOT find PCRE (missing: ${MISSING_VARS})" ) + unset( HAVE_LOCAL_PCRE CACHE ) +endif() +message( STATUS "Detecting local PCRE - done" ) +endif( WIN32 ) + + +# +# system +# +message( STATUS "Detecting system PCRE" ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) +find_package( PCRE ) +set( SYSTEM_PCRE_LIBRARIES ${PCRE_LIBRARIES} + CACHE PATH "system pcre libraries" ) +set( SYSTEM_PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} + CACHE PATH "system pcre include directories" ) +mark_as_advanced( SYSTEM_PCRE_LIBRARIES ) +mark_as_advanced( SYSTEM_PCRE_INCLUDE_DIRS ) + +if( SYSTEM_PCRE_LIBRARIES AND SYSTEM_PCRE_INCLUDE_DIRS ) + set( HAVE_SYSTEM_PCRE ON + CACHE BOOL "pcre is available on the system" ) +else() + unset( HAVE_SYSTEM_PCRE CACHE ) +endif() +message( STATUS "Detecting system PCRE - done" ) + + +# +# configure +# +unset( PCRE_LIBRARIES CACHE ) +unset( PCRE_INCLUDE_DIRS CACHE ) +if( HAVE_LOCAL_PCRE ) + set( USE_LOCAL_PCRE ON + CACHE BOOL "use local copy of pcre" ) +else() + unset( USE_LOCAL_PCRE CACHE ) +endif() +if( USE_LOCAL_PCRE ) + message( STATUS "Configuring for local PCRE" ) + set( PCRE_LIBRARIES ${LOCAL_PCRE_LIBRARIES} ) + set( PCRE_INCLUDE_DIRS ${LOCAL_PCRE_INCLUDE_DIRS} ) + message( STATUS "Configuring for local PCRE - done" ) +elseif( HAVE_SYSTEM_PCRE ) + message( STATUS "Configuring for system PCRE" ) + set( PCRE_LIBRARIES ${SYSTEM_PCRE_LIBRARIES} ) + set( PCRE_INCLUDE_DIRS ${SYSTEM_PCRE_INCLUDE_DIRS} ) + message( STATUS "Configuring for system PCRE - done" ) +endif() +if( USE_LOCAL_PCRE OR HAVE_SYSTEM_PCRE ) + set( USE_PCRE ON + CACHE BOOL "use pcre" ) +else() + unset( USE_PCRE CACHE ) +endif() +set( PCRE_LIBRARIES ${PCRE_LIBRARIES} + CACHE PATH "pcre libraries" ) +set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} + CACHE PATH "pcre include directories" ) +mark_as_advanced( PCRE_LIBRARIES ) +mark_as_advanced( PCRE_INCLUDE_DIRS ) diff --git a/3rdparty/pcre/FindPCRE.cmake b/3rdparty/pcre/FindPCRE.cmake new file mode 100644 index 000000000..cb4d9177b --- /dev/null +++ b/3rdparty/pcre/FindPCRE.cmake @@ -0,0 +1,35 @@ +# - Find pcre +# Find the native PCRE includes and library +# +# PCRE_INCLUDE_DIRS - where to find pcre.h +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + + +find_path( PCRE_INCLUDE_DIR pcre.h ) + +set( PCRE_NAMES pcre ) +find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) +mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) + +if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) + file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + + set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) + set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) + set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE + REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR + VERSION_VAR PCRE_VERSION_STRING ) + +if( PCRE_FOUND ) + set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) + set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +endif() diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt new file mode 100644 index 000000000..849813be0 --- /dev/null +++ b/3rdparty/zlib/CMakeLists.txt @@ -0,0 +1,90 @@ + +# +# local copy +# +if( WIN32 ) +message( STATUS "Detecting local ZLIB" ) +find_path( LOCAL_ZLIB_INCLUDE_DIRS "zlib.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +find_library( LOCAL_ZLIB_LIBRARIES + NAMES zdll + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" + NO_DEFAULT_PATH ) +mark_as_advanced( LOCAL_ZLIB_LIBRARIES ) +mark_as_advanced( LOCAL_ZLIB_INCLUDE_DIRS ) + +if( LOCAL_ZLIB_LIBRARIES AND LOCAL_ZLIB_INCLUDE_DIRS ) + file( STRINGS "${LOCAL_ZLIB_INCLUDE_DIRS}/zlib.h" ZLIB_H REGEX "^#define[ \t]+ZLIB_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*ZLIB_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" ZLIB_VERSION "${ZLIB_H}" ) + message( STATUS "Found local ZLIB: ${LOCAL_ZLIB_LIBRARIES} (found version ${ZLIB_VERSION})" ) + set( HAVE_LOCAL_ZLIB ON + CACHE BOOL "zlib is available as a local copy" ) +else() + foreach( _VAR LOCAL_ZLIB_LIBRARIES LOCAL_ZLIB_INCLUDE_DIRS ) + if( NOT "${_VAR}" ) + set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) + endif() + endforeach() + message( STATUS "Could NOT find local ZLIB (missing: ${MISSING_VARS})" ) + unset( HAVE_LOCAL_ZLIB CACHE ) +endif() +message( STATUS "Detecting local ZLIB - done" ) +endif( WIN32 ) + + +# +# system +# +message( STATUS "Detecting system ZLIB" ) +find_package( ZLIB ) +set( SYSTEM_ZLIB_LIBRARIES ${ZLIB_LIBRARIES} + CACHE PATH "system zlib libraries" ) +set( SYSTEM_ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} + CACHE PATH "system zlib include directories" ) +mark_as_advanced( SYSTEM_ZLIB_LIBRARIES ) +mark_as_advanced( SYSTEM_ZLIB_INCLUDE_DIRS ) + +if( SYSTEM_ZLIB_LIBRARIES AND SYSTEM_ZLIB_INCLUDE_DIRS ) + set( HAVE_SYSTEM_ZLIB ON + CACHE BOOL "zlib is available on the system" ) +else() + unset( HAVE_SYSTEM_ZLIB CACHE ) +endif() +message( STATUS "Detecting system ZLIB - done" ) + + +# +# configure +# +unset( ZLIB_LIBRARIES CACHE ) +unset( ZLIB_INCLUDE_DIRS CACHE ) +if( HAVE_LOCAL_ZLIB ) + set( USE_LOCAL_ZLIB ON + CACHE BOOL "use local copy of zlib" ) +else() + unset( USE_LOCAL_ZLIB CACHE ) +endif() +if( USE_LOCAL_ZLIB ) + message( STATUS "Configuring for local ZLIB" ) + set( ZLIB_LIBRARIES ${LOCAL_ZLIB_LIBRARIES} ) + set( ZLIB_INCLUDE_DIRS ${LOCAL_ZLIB_INCLUDE_DIRS} ) + message( STATUS "Configuring for local ZLIB - done" ) +elseif( HAVE_SYSTEM_ZLIB ) + message( STATUS "Configuring for system ZLIB" ) + set( ZLIB_LIBRARIES ${SYSTEM_ZLIB_LIBRARIES} ) + set( ZLIB_INCLUDE_DIRS ${SYSTEM_ZLIB_INCLUDE_DIRS} ) + message( STATUS "Configuring for system ZLIB - done" ) +endif() +if( USE_LOCAL_ZLIB OR HAVE_SYSTEM_ZLIB ) + set( USE_ZLIB ON + CACHE BOOL "use zlib" ) +else() + unset( USE_ZLIB CACHE ) +endif() +set( ZLIB_LIBRARIES ${ZLIB_LIBRARIES} + CACHE PATH "zlib libraries" ) +set( ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} + CACHE PATH "zlib include directories" ) +mark_as_advanced( ZLIB_LIBRARIES ) +mark_as_advanced( ZLIB_INCLUDE_DIRS ) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..4f7c46987 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,274 @@ + +cmake_minimum_required( VERSION 2.8.4 ) +project( eAthena ) + + +# +# Prevent building in the source directory by default +# +if( ALLOW_SAME_DIRECTORY ) +elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" ) + option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF ) + message( FATAL_ERROR "Do not use the source directory to build your files, instead create a separate folder and build there.\nExample:\n mkdir build\n cd build\n cmake -G\"Unix Makefiles\" ..\n make install\nTo skip this check, set ALLOW_SAME_DIRECTORY to 1 or ON" ) +endif() + + +# +# Debug stuff +# +if( NOT SKIP_DEBUG ) +message( STATUS "DEBUG: # Variables That Change Behavior" ) +message( STATUS "DEBUG: BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}" ) +message( STATUS "DEBUG: CMAKE_BACKWARDS_COMPATIBILITY=${CMAKE_BACKWARDS_COMPATIBILITY}" ) +message( STATUS "DEBUG: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ) +message( STATUS "DEBUG: CMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE}" ) +message( STATUS "DEBUG: CMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" ) +message( STATUS "DEBUG: CMAKE_FIND_LIBRARY_PREFIXES=${CMAKE_FIND_LIBRARY_PREFIXES}" ) +message( STATUS "DEBUG: CMAKE_FIND_LIBRARY_SUFFIXES=${CMAKE_FIND_LIBRARY_SUFFIXES}" ) +message( STATUS "DEBUG: CMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}" ) +message( STATUS "DEBUG: CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" ) +message( STATUS "DEBUG: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" ) +message( STATUS "DEBUG: CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" ) +message( STATUS "DEBUG: CMAKE_MFC_FLAG=${CMAKE_MFC_FLAG}" ) +message( STATUS "DEBUG: CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" ) +message( STATUS "DEBUG: CMAKE_NOT_USING_CONFIG_FLAGS=${CMAKE_NOT_USING_CONFIG_FLAGS}" ) +message( STATUS "DEBUG: CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) +message( STATUS "DEBUG: CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}" ) +message( STATUS "DEBUG: CMAKE_SKIP_INSTALL_ALL_DEPENDENCY=${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_IGNORE_PATH=${CMAKE_SYSTEM_IGNORE_PATH}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_LIBRARY_PATH=${CMAKE_SYSTEM_LIBRARY_PATH}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_PROGRAM_PATH=${CMAKE_SYSTEM_PROGRAM_PATH}" ) +message( STATUS "DEBUG: CMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}" ) +message( STATUS "DEBUG: # Variables That Describe the System" ) +message( STATUS "DEBUG: APPLE=${APPLE}" ) +message( STATUS "DEBUG: BORLAND=${BORLAND}" ) +message( STATUS "DEBUG: CMAKE_CL_64=${CMAKE_CL_64}" ) +message( STATUS "DEBUG: CMAKE_COMPILER_2005=${CMAKE_COMPILER_2005}" ) +message( STATUS "DEBUG: CMAKE_HOST_APPLE=${CMAKE_HOST_APPLE}" ) +message( STATUS "DEBUG: CMAKE_HOST_SYSTEM=${CMAKE_HOST_SYSTEM}" ) +message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}" ) +message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR}" ) +message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_VERSION=${CMAKE_HOST_SYSTEM_VERSION}" ) +message( STATUS "DEBUG: CMAKE_HOST_UNIX=${CMAKE_HOST_UNIX}" ) +message( STATUS "DEBUG: CMAKE_HOST_WIN32=${CMAKE_HOST_WIN32}" ) +message( STATUS "DEBUG: CMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM=${CMAKE_SYSTEM}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}" ) +message( STATUS "DEBUG: CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}" ) +message( STATUS "DEBUG: CYGWIN=${CYGWIN}" ) +message( STATUS "DEBUG: MSVC=${MSVC}" ) +message( STATUS "DEBUG: MSVC80=${MSVC80}" ) +message( STATUS "DEBUG: MSVC_IDE=${MSVC_IDE}" ) +message( STATUS "DEBUG: MSVC_VERSION=${MSVC_VERSION}" ) +message( STATUS "DEBUG: UNIX=${UNIX}" ) +message( STATUS "DEBUG: WIN32=${WIN32}" ) +message( STATUS "DEBUG: XCODE_VERSION=${XCODE_VERSION}" ) +message( STATUS "DEBUG: # Variables that Control the Build" ) +message( STATUS "DEBUG: CMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) +message( STATUS "DEBUG: CMAKE_BUILD_WITH_INSTALL_RPATH=${CMAKE_BUILD_WITH_INSTALL_RPATH}" ) +message( STATUS "DEBUG: CMAKE_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX}" ) +message( STATUS "DEBUG: CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" ) +message( STATUS "DEBUG: CMAKE_INCLUDE_CURRENT_DIR=${CMAKE_INCLUDE_CURRENT_DIR}" ) +message( STATUS "DEBUG: CMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_NAME_DIR}" ) +message( STATUS "DEBUG: CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" ) +message( STATUS "DEBUG: CMAKE_INSTALL_RPATH_USE_LINK_PATH=${CMAKE_INSTALL_RPATH_USE_LINK_PATH}" ) +message( STATUS "DEBUG: CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" ) +message( STATUS "DEBUG: CMAKE_LIBRARY_PATH_FLAG=${CMAKE_LIBRARY_PATH_FLAG}" ) +message( STATUS "DEBUG: CMAKE_LINK_DEF_FILE_FLAG=${CMAKE_LINK_DEF_FILE_FLAG}" ) +message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_FILE_FLAG=${CMAKE_LINK_LIBRARY_FILE_FLAG}" ) +message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}" ) +message( STATUS "DEBUG: CMAKE_NO_BUILTIN_CHRPATH=${CMAKE_NO_BUILTIN_CHRPATH}" ) +message( STATUS "DEBUG: CMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) +message( STATUS "DEBUG: CMAKE_SKIP_BUILD_RPATH=${CMAKE_SKIP_BUILD_RPATH}" ) +message( STATUS "DEBUG: CMAKE_TRY_COMPILE_CONFIGURATION=${CMAKE_TRY_COMPILE_CONFIGURATION}" ) +message( STATUS "DEBUG: CMAKE_USE_RELATIVE_PATHS=${CMAKE_USE_RELATIVE_PATHS}" ) +message( STATUS "DEBUG: EXECUTABLE_OUTPUT_PATH=${EXECUTABLE_OUTPUT_PATH}" ) +message( STATUS "DEBUG: LIBRARY_OUTPUT_PATH=${LIBRARY_OUTPUT_PATH}" ) +message( STATUS "DEBUG: # Variables that Provide Information" ) +message( STATUS "DEBUG: CMAKE_AR=${CMAKE_AR}" ) +message( STATUS "DEBUG: CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" ) +message( STATUS "DEBUG: CMAKE_BUILD_TOOL=${CMAKE_BUILD_TOOL}" ) +message( STATUS "DEBUG: CMAKE_CACHEFILE_DIR=${CMAKE_CACHEFILE_DIR}" ) +message( STATUS "DEBUG: CMAKE_CACHE_MAJOR_VERSION=${CMAKE_CACHE_MAJOR_VERSION}" ) +message( STATUS "DEBUG: CMAKE_CACHE_MINOR_VERSION=${CMAKE_CACHE_MINOR_VERSION}" ) +message( STATUS "DEBUG: CMAKE_CACHE_PATCH_VERSION=${CMAKE_CACHE_PATCH_VERSION}" ) +message( STATUS "DEBUG: CMAKE_CFG_INTDIR=${CMAKE_CFG_INTDIR}" ) +message( STATUS "DEBUG: CMAKE_COMMAND=${CMAKE_COMMAND}" ) +message( STATUS "DEBUG: CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}" ) +message( STATUS "DEBUG: CMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}" ) +message( STATUS "DEBUG: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" ) +message( STATUS "DEBUG: CMAKE_CURRENT_LIST_DIR=${CMAKE_CURRENT_LIST_DIR}" ) +message( STATUS "DEBUG: CMAKE_CURRENT_LIST_FILE=${CMAKE_CURRENT_LIST_FILE}" ) +message( STATUS "DEBUG: CMAKE_CURRENT_LIST_LINE=${CMAKE_CURRENT_LIST_LINE}" ) +message( STATUS "DEBUG: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" ) +message( STATUS "DEBUG: CMAKE_DL_LIBS=${CMAKE_DL_LIBS}" ) +message( STATUS "DEBUG: CMAKE_EDIT_COMMAND=${CMAKE_EDIT_COMMAND}" ) +message( STATUS "DEBUG: CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_EXTRA_GENERATOR=${CMAKE_EXTRA_GENERATOR}" ) +message( STATUS "DEBUG: CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES=${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}" ) +message( STATUS "DEBUG: CMAKE_GENERATOR=${CMAKE_GENERATOR}" ) +message( STATUS "DEBUG: CMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}" ) +message( STATUS "DEBUG: CMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}" ) +message( STATUS "DEBUG: CMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_SUFFIX=${CMAKE_LINK_LIBRARY_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_MAJOR_VERSION=${CMAKE_MAJOR_VERSION}" ) +message( STATUS "DEBUG: CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" ) +message( STATUS "DEBUG: CMAKE_MINOR_VERSION=${CMAKE_MINOR_VERSION}" ) +message( STATUS "DEBUG: CMAKE_PARENT_LIST_FILE=${CMAKE_PARENT_LIST_FILE}" ) +message( STATUS "DEBUG: CMAKE_PATCH_VERSION=${CMAKE_PATCH_VERSION}" ) +message( STATUS "DEBUG: CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}" ) +message( STATUS "DEBUG: CMAKE_RANLIB=${CMAKE_RANLIB}" ) +message( STATUS "DEBUG: CMAKE_ROOT=${CMAKE_ROOT}" ) +message( STATUS "DEBUG: CMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}" ) +message( STATUS "DEBUG: CMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}" ) +message( STATUS "DEBUG: CMAKE_SHARED_MODULE_SUFFIX=${CMAKE_SHARED_MODULE_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) +message( STATUS "DEBUG: CMAKE_SKIP_RPATH=${CMAKE_SKIP_RPATH}" ) +message( STATUS "DEBUG: CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}" ) +message( STATUS "DEBUG: CMAKE_STANDARD_LIBRARIES=${CMAKE_STANDARD_LIBRARIES}" ) +message( STATUS "DEBUG: CMAKE_STATIC_LIBRARY_PREFIX=${CMAKE_STATIC_LIBRARY_PREFIX}" ) +message( STATUS "DEBUG: CMAKE_STATIC_LIBRARY_SUFFIX=${CMAKE_STATIC_LIBRARY_SUFFIX}" ) +message( STATUS "DEBUG: CMAKE_TWEAK_VERSION=${CMAKE_TWEAK_VERSION}" ) +message( STATUS "DEBUG: CMAKE_USING_VC_FREE_TOOLS=${CMAKE_USING_VC_FREE_TOOLS}" ) +message( STATUS "DEBUG: CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}" ) +message( STATUS "DEBUG: CMAKE_VERSION=${CMAKE_VERSION}" ) +message( STATUS "DEBUG: PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}" ) +message( STATUS "DEBUG: PROJECT_NAME=${PROJECT_NAME}" ) +message( STATUS "DEBUG: PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" ) +set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install CACHE PATH "test install to dir" FORCE ) +#set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "test install to source dir" FORCE ) +endif( NOT SKIP_DEBUG ) + + +# +# Global stuff +# +set( GLOBAL_LIBRARIES "" CACHE INTERNAL "" ) +set( GLOBAL_INCLUDE_DIRS "" CACHE INTERNAL "" ) +set( GLOBAL_DEFINITIONS "" CACHE INTERNAL "" ) +mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) +if( WIN32 ) + list( APPEND GLOBAL_DEFINITIONS FD_SETSIZE=4096 ) +endif() +if( MSVC ) + list( APPEND GLOBAL_DEFINITIONS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE DB_MANUAL_CAST_TO_UNION ) +endif() + + +# +# packetver +# +set( PACKETVER "" + CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) + +# +# install stuff +# +option( INSTALL_RUN_DATA "install files needed to run the project" ON ) +option( INSTALL_BUILD_DATA "install files needed to build the project" OFF ) +set( SVN_FOLDER_PATTERN "[\\.]svn" + CACHE PATH "pattern of svn folder that we exclude from instalations" ) +mark_as_advanced( SVN_FOLDER_PATTERN ) +if( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}" ) + set( INSTALLING_TO_SOURCE ON + CACHE INTERNAL "we are installing to the source folder, skip uneeded stuff" ) +else() + unset( INSTALLING_TO_SOURCE CACHE ) +endif() +set( LOCAL_BUILD_FILES + "CMakeLists.txt" + "configure" + "configure.in" + "eAthena-6.dsw" + "eAthena-7.1.sln" + "eAthena-8.sln" + "eAthena-9.sln" + "eAthena-10.sln" + ) +set( LOCAL_BUILD_DIRECTORIES + "3rdparty" + "src" + "vcproj-6" + "vcproj-7.1" + "vcproj-8" + "vcproj-9" + "vcproj-10" + ) +set( LOCAL_RUN_FILES + "athena-start" + "Changelog-Trunk.txt" + "char-server.sh" + "charserv-sql.bat" + "charserv.bat" + "dbghelp.dll" + "LICENSE" + "login-server.sh" + "logserv-sql.bat" + "logserv.bat" + "map-server.sh" + "mapserv-sql.bat" + "mapserv.bat" + "notice.txt" + "readme.html" + "runserver-sql.bat" + "runserver.bat" + "serv.bat" + "start" + ) +set( LOCAL_RUN_DIRECTORIES + "conf" + "db" + "doc" + "log" + "npc" + "plugins" + "readme" + "sql-files" + "tools" + ) +if( USE_LOCAL_MYSQL ) + list( APPEND LOCAL_RUN_FILES "libmysql.dll" ) +endif() +if( USE_LOCAL_PCRE ) + list( APPEND LOCAL_RUN_FILES "pcre3.dll" ) +endif() +if( USE_LOCAL_ZLIB ) + list( APPEND LOCAL_RUN_FILES "zlib1.dll" ) +endif() +function( INSTALL_DIRECTORY DIR DEST EXCLUDE_PATTERN ) + # warning: that slash(/) is important here, otherwise the whole directory (not its content) will be copied! + install( DIRECTORY ${DIR}/ + DESTINATION ${DEST} + PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE + PATTERN "${EXCLUDE_PATTERN}" EXCLUDE ) +endfunction() +function( INSTALL_DIRECTORIES DIRS EXCLUDE_PATTERN ) + foreach( DIR IN ITEMS ${DIRS} ) + INSTALL_DIRECTORY( ${DIR} ${DIR} "${EXCLUDE_PATTERN}" ) + endforeach() +endfunction() +if( NOT INSTALLING_TO_SOURCE ) + if( INSTALL_RUN_DATA ) + install( FILES ${LOCAL_RUN_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX} ) + INSTALL_DIRECTORIES( "${LOCAL_RUN_DIRECTORIES}" "conf/import-tmpl" ) + endif() + if( INSTALL_BUILD_DATA ) + install( FILES ${LOCAL_BUILD_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX} ) + INSTALL_DIRECTORIES( "${LOCAL_BUILD_DIRECTORIES}" "" ) + endif() +endif() +if( INSTALL_RUN_DATA ) + INSTALL_DIRECTORY( "save-tmpl" "save" "" ) + INSTALL_DIRECTORY( "conf/import-tmpl" "conf/import" "" ) +endif() + + +# +# subdirectories +# +add_subdirectory( 3rdparty ) +add_subdirectory( src ) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 02b9688fd..cc0b1d7ef 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,7 +1,9 @@ Date Added +2011/06/29 + * Added experimental support for CMake. (for now: basic build, no extras, only tested with VS10 and cygwin) [FlavioJS] 2011/06/27 - *Added common/random and 3rdparty/mt19937ar to project files, makefiles and configure script. [FlavioJS] + * 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/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..0bf5b0eb6 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_subdirectory( common ) +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 new file mode 100644 index 000000000..666070532 --- /dev/null +++ b/src/char/CMakeLists.txt @@ -0,0 +1,64 @@ + +# setup +set( MT19937AR_SOURCES +# "${MT19937AR_SOURCE_DIR}/mt19937ar.c" + ) +set( COMMON_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/ers.c" +# "${COMMON_SOURCE_DIR}/grfio.c" + "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" + "${COMMON_SOURCE_DIR}/mapindex.c" +# "${COMMON_SOURCE_DIR}/md5calc.c" +# "${COMMON_SOURCE_DIR}/nullpo.c" + "${COMMON_SOURCE_DIR}/plugins.c" +# "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/strlib.c" + "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( CHAR_SOURCES + "char.c" + "int_guild.c" + "int_homun.c" + "int_party.c" + "int_pet.c" + "int_status.c" + "int_storage.c" + "inter.c" + ) + + +# char txt +if( USE_ZLIB ) +message ( STATUS "Creating target char-server" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${CHAR_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ) +source_group( char FILES ${CHAR_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( char-server ${SOURCE_FILES} ) +target_link_libraries( char-server ${LIBRARIES} ) +set_target_properties( char-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS char-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target char-server - done" ) +else() +message ( STATUS "Skipping target char-server (requires ZLIB)" ) +endif() diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt new file mode 100644 index 000000000..d534ce89c --- /dev/null +++ b/src/char_sql/CMakeLists.txt @@ -0,0 +1,68 @@ + +# setup +set( MT19937AR_SOURCES +# "${MT19937AR_SOURCE_DIR}/mt19937ar.c" + ) +set( COMMON_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/ers.c" +# "${COMMON_SOURCE_DIR}/grfio.c" +# "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" + "${COMMON_SOURCE_DIR}/mapindex.c" +# "${COMMON_SOURCE_DIR}/md5calc.c" +# "${COMMON_SOURCE_DIR}/nullpo.c" + "${COMMON_SOURCE_DIR}/plugins.c" +# "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/sql.c" + "${COMMON_SOURCE_DIR}/strlib.c" + "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( CHAR_SOURCES + "char.c" + "int_auction.c" + "int_guild.c" + "int_homun.c" + "int_mail.c" + "int_mercenary.c" + "int_party.c" + "int_pet.c" + "int_quest.c" + "int_storage.c" + "inter.c" + ) + + +# char sql +if( USE_ZLIB AND USE_MYSQL ) +message ( STATUS "Creating target char-server_sql" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${CHAR_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ) +source_group( char FILES ${CHAR_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( char-server_sql ${SOURCE_FILES} ) +target_link_libraries( char-server_sql ${LIBRARIES} ) +set_target_properties( char-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS char-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target char-server_sql - done" ) +else() +message ( STATUS "Skipping target char-server_sql (requires ZLIB and MYSQL)" ) +endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 000000000..7a4443abc --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,40 @@ + +set( COMMON_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" + CACHE PATH "common include directories" ) +set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + CACHE PATH "common source directory" ) +mark_as_advanced( COMMON_INCLUDE_DIRS ) +mark_as_advanced( COMMON_SOURCE_DIR ) + + +# +# Find svnversion +# +message( STATUS "Detecting svnversion" ) +find_program( SVNVERSION_EXECUTABLE svnversion ) +mark_as_advanced( SVNVERSION_EXECUTABLE ) +message( STATUS "Detecting svnversion - done" ) + + +# +# Create svnversion.h +# +message( STATUS "Creating svnversion.h" ) +if( SVNVERSION_EXECUTABLE ) + execute_process( COMMAND ${SVNVERSION_EXECUTABLE} ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE SVNVERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) +endif() +if( SVNVERSION ) + file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h + "#ifndef SVNVERSION\n#define SVNVERSION ${SVNVERSION}\n#endif\n" ) +else() + file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "" ) +endif() +set( GLOBAL_INCLUDE_DIRS "${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "" ) +set( SVNVERSION ${SVNVERSION} + CACHE STRING "SVN version of the source code" ) +if( INSTALL_BUILD_DATA ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h DESTINATION ${CMAKE_INSTALL_PREFIX}/src/common ) +endif() +message( STATUS "Creating svnversion.h - done" ) diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt new file mode 100644 index 000000000..88d137507 --- /dev/null +++ b/src/login/CMakeLists.txt @@ -0,0 +1,103 @@ + +# setup +set( MT19937AR_SOURCES + "${MT19937AR_SOURCE_DIR}/mt19937ar.c" + ) +set( COMMON_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/ers.c" +# "${COMMON_SOURCE_DIR}/grfio.c" + "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" +# "${COMMON_SOURCE_DIR}/mapindex.c" + "${COMMON_SOURCE_DIR}/md5calc.c" +# "${COMMON_SOURCE_DIR}/nullpo.c" + "${COMMON_SOURCE_DIR}/plugins.c" + "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/strlib.c" + "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( COMMON_SQL_SOURCES + "${COMMON_SOURCE_DIR}/sql.c" + ) +set( LOGIN_SOURCES + "login.c" + ) +set( LOGIN_TXT_SOURCES + "account_txt.c" + "ipban_txt.c" + "loginlog_txt.c" + ) +set( LOGIN_SQL_SOURCES + "account_sql.c" + "ipban_sql.c" + "loginlog_sql.c" + ) + + +# +# login txt +# +if( USE_ZLIB ) +message ( STATUS "Creating target login-server" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_TXT ) +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${LOGIN_SOURCES} ${LOGIN_TXT_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ) +source_group( login FILES ${LOGIN_SOURCES} ${LOGIN_TXT_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( login-server ${SOURCE_FILES} ) +target_link_libraries( login-server ${LIBRARIES} ) +set_target_properties( login-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS login-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target login-server - done" ) +else() +message ( STATUS "Skipping target login-server (requires ZLIB)" ) +endif() + + +# login sql +if( USE_ZLIB AND USE_MYSQL ) +message ( STATUS "Creating target login-server_sql" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_SQL ) +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ${LOGIN_SOURCES} ${LOGIN_SQL_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ) +source_group( login FILES ${LOGIN_SOURCES} ${LOGIN_SQL_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( login-server_sql ${SOURCE_FILES} ) +target_link_libraries( login-server_sql ${LIBRARIES} ) +set_target_properties( login-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS login-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target login-server_sql - done" ) +else() +message ( STATUS "Skipping target login-server_sql (requires ZLIB and MYSQL)" ) +endif() diff --git a/src/map/CMakeLists.txt b/src/map/CMakeLists.txt new file mode 100644 index 000000000..e5589a30e --- /dev/null +++ b/src/map/CMakeLists.txt @@ -0,0 +1,140 @@ + +# setup +set( MT19937AR_SOURCES + "${MT19937AR_SOURCE_DIR}/mt19937ar.c" + ) +set( COMMON_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/ers.c" + "${COMMON_SOURCE_DIR}/grfio.c" + "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" + "${COMMON_SOURCE_DIR}/mapindex.c" + "${COMMON_SOURCE_DIR}/md5calc.c" + "${COMMON_SOURCE_DIR}/nullpo.c" + "${COMMON_SOURCE_DIR}/plugins.c" + "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/strlib.c" + "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( COMMON_SQL_SOURCES + "${COMMON_SOURCE_DIR}/sql.c" + ) +set( MAP_SOURCES + "atcommand.c" + "battle.c" + "battleground.c" + "buyingstore.c" + "chat.c" + "chrif.c" + "clif.c" + "date.c" + "duel.c" + "guild.c" + "homunculus.c" + "instance.c" + "intif.c" + "itemdb.c" + "log.c" + "mail.c" + "map.c" + "mercenary.c" + "mob.c" + "npc.c" + "npc_chat.c" + "party.c" + "path.c" + "pc.c" + "pet.c" + "quest.c" + "script.c" + "searchstore.c" + "skill.c" + "status.c" + "storage.c" + "trade.c" + "unit.c" + "vending.c" + ) +set( MAP_TXT_SOURCES + "mapreg_txt.c" + ) +set( MAP_SQL_SOURCES + "mapreg_sql.c" + ) + + +# map txt +if( USE_ZLIB ) +message ( STATUS "Creating target map-server" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) +if( USE_PCRE ) + message( STATUS "Using PCRE" ) + list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) + list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) +endif() +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${MAP_SOURCES} ${MAP_TXT_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ) +source_group( map FILES ${MAP_SOURCES} ${MAP_TXT_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( map-server ${SOURCE_FILES} ) +target_link_libraries( map-server ${LIBRARIES} ) +set_target_properties( map-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS map-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target map-server - done" ) +else() +message ( STATUS "Skipping target map-server (requires ZLIB; optional PCRE)" ) +endif() + + +# map sql +if( USE_ZLIB AND USE_MYSQL ) +message ( STATUS "Creating target map-server_sql" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +if( USE_PCRE ) + message( STATUS "Using PCRE" ) + list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) + list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) +endif() +if( PACKETVER ) + message( STATUS "Using PACKETVER=${PACKETVER}" ) + list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) +endif() +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ${MAP_SOURCES} ${MAP_SQL_SOURCES} ) +source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ) +source_group( map FILES ${MAP_SOURCES} ${MAP_SQL_SOURCES} ) +include_directories( ${INCLUDE_DIRS} ) +add_executable( map-server_sql ${SOURCE_FILES} ) +target_link_libraries( map-server_sql ${LIBRARIES} ) +set_target_properties( map-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS map-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target map-server_sql - done" ) +else() +message ( STATUS "Skipping target map-server_sql (requires ZLIB and MYSQL; optional PCRE)" ) +endif() diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt new file mode 100644 index 000000000..5b4880893 --- /dev/null +++ b/src/tool/CMakeLists.txt @@ -0,0 +1,49 @@ + +# setup +set( COMMON_SOURCES + "${COMMON_SOURCE_DIR}/core.c" +# "${COMMON_SOURCE_DIR}/db.c" +# "${COMMON_SOURCE_DIR}/ers.c" + "${COMMON_SOURCE_DIR}/grfio.c" +# "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" +# "${COMMON_SOURCE_DIR}/mapindex.c" +# "${COMMON_SOURCE_DIR}/md5calc.c" +# "${COMMON_SOURCE_DIR}/nullpo.c" +# "${COMMON_SOURCE_DIR}/plugins.c" +# "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" +# "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/strlib.c" +# "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( MAPCACHE_SOURCES + mapcache.c + ) + + +# mapcache +if( USE_ZLIB ) +message ( STATUS "Creating target mapcache" ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} MINICORE ) +if( WIN32 ) + list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) +endif() +set( SOURCE_FILES ${COMMON_SOURCES} ${MAPCACHE_SOURCES} ) +source_group( common FILES ${COMMON_SOURCES} ) +source_group( mapcache FILES ${MAPCACHE_SOURCES} ) +add_executable( mapcache ${SOURCE_FILES} ) +include_directories( ${INCLUDE_DIRS} ) +target_link_libraries( mapcache ${ZLIB_LIBRARIES} ) +set_target_properties( mapcache PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +if( INSTALL_RUN_DATA ) + install( TARGETS mapcache DESTINATION ${CMAKE_INSTALL_PREFIX} ) +endif() +message ( STATUS "Creating target mapcache - done" ) +else() +message ( STATUS "Skipping target mapcache (requires ZLIB)" ) +endif() -- cgit v1.2.3-70-g09d2 From 0361920446e9311979b5187abf123ba8e055d944 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Fri, 1 Jul 2011 15:43:58 +0000 Subject: * CMake: marked executables as different components and other miscellaneous changes. [FlavioJS] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14877 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 48 +++++++++++++++++++++++++++++ 3rdparty/mysql/CMakeLists.txt | 66 +++++++++++----------------------------- 3rdparty/pcre/CMakeLists.txt | 60 ++++++++++-------------------------- 3rdparty/zlib/CMakeLists.txt | 60 ++++++++++-------------------------- CMakeLists.txt | 71 ++++++++++++++++++++++++++++++++++++++----- Changelog-Trunk.txt | 2 ++ src/char/CMakeLists.txt | 8 ++++- src/char_sql/CMakeLists.txt | 8 ++++- src/login/CMakeLists.txt | 12 ++++++-- src/map/CMakeLists.txt | 14 +++++++-- src/tool/CMakeLists.txt | 4 ++- 11 files changed, 202 insertions(+), 151 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 6e5c759cc..0ea359186 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,4 +1,52 @@ +# macro to configure the use of local or system version of a package +# Uses: +# HAVE_LOCAL_${name} - is local version available? +# ${name}_LOCAL_LIBRARIES - libraries of the local version +# ${name}_LOCAL_INCLUDE_DIRS - include directories of the local version +# HAVE_SYSTEM_${name} - is system version available? +# ${name}_SYSTEM_LIBRARIES - libraries of the system version +# ${name}_SYSTEM_INCLUDE_DIRS - include directories of the system version +# Generates: +# USE_LOCAL_${name} - use the local version of the package (only when local is available) +# USE_${name} - use this package +# ${name}_LIBRARIES - libraries +# ${name}_INCLUDE_DIRS - include directories +macro( CONFIGURE_USE_LOCAL_OR_SYSTEM name ) + unset( ${name}_LIBRARIES CACHE ) + unset( ${name}_INCLUDE_DIRS CACHE ) + if( HAVE_LOCAL_${name} ) + set( USE_LOCAL_${name} ON + CACHE BOOL "use local version of ${name}" ) + else() + unset( USE_LOCAL_${name} CACHE ) + endif() + if( USE_LOCAL_${name} ) + message( STATUS "Configuring for local ${name}" ) + set( ${name}_LIBRARIES ${${name}_LOCAL_LIBRARIES} ) + set( ${name}_INCLUDE_DIRS ${${name}_LOCAL_INCLUDE_DIRS} ) + message( STATUS "Configuring for local ${name} - done" ) + elseif( HAVE_SYSTEM_${name} ) + message( STATUS "Configuring for system ${name}" ) + set( ${name}_LIBRARIES ${${name}_SYSTEM_LIBRARIES} ) + set( ${name}_INCLUDE_DIRS ${${name}_SYSTEM_INCLUDE_DIRS} ) + message( STATUS "Configuring for system ${name} - done" ) + endif() + if( USE_LOCAL_${name} OR HAVE_SYSTEM_${name} ) + set( USE_${name} ON + CACHE BOOL "use ${name}" ) + else() + unset( USE_${name} CACHE ) + endif() + set( ${name}_LIBRARIES ${${name}_LIBRARIES} + CACHE PATH "${name} libraries" ) + set( ${name}_INCLUDE_DIRS ${${name}_INCLUDE_DIRS} + CACHE PATH "${name} include directories" ) + mark_as_advanced( ${name}_LIBRARIES ) + mark_as_advanced( ${name}_INCLUDE_DIRS ) +endmacro( CONFIGURE_USE_LOCAL_OR_SYSTEM ) + + add_subdirectory( msinttypes ) add_subdirectory( mt19937ar ) add_subdirectory( mysql ) diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index 1c14d7395..902037f07 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -4,28 +4,28 @@ # if( WIN32 ) message( STATUS "Detecting local MYSQL" ) -find_path( LOCAL_MYSQL_INCLUDE_DIRS "mysql.h" +find_path( MYSQL_LOCAL_INCLUDE_DIRS "mysql.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) -find_library( LOCAL_MYSQL_LIBRARIES +find_library( MYSQL_LOCAL_LIBRARIES NAMES libmysql PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" NO_DEFAULT_PATH ) -mark_as_advanced( LOCAL_MYSQL_LIBRARIES ) -mark_as_advanced( LOCAL_MYSQL_INCLUDE_DIRS ) +mark_as_advanced( MYSQL_LOCAL_LIBRARIES ) +mark_as_advanced( MYSQL_LOCAL_INCLUDE_DIRS ) -if( LOCAL_MYSQL_LIBRARIES AND LOCAL_MYSQL_INCLUDE_DIRS ) - if( EXISTS "${LOCAL_MYSQL_INCLUDE_DIRS}/mysql_version.h" ) - file( STRINGS "${LOCAL_MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) +if( MYSQL_LOCAL_LIBRARIES AND MYSQL_LOCAL_INCLUDE_DIRS ) + if( EXISTS "${MYSQL_LOCAL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${MYSQL_LOCAL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_SERVER_VERSION "${MYSQL_VERSION_H}" ) - message( STATUS "Found MYSQL: ${LOCAL_MYSQL_LIBRARIES} (found version ${MYSQL_SERVER_VERSION})" ) + message( STATUS "Found MYSQL: ${MYSQL_LOCAL_LIBRARIES} (found version ${MYSQL_SERVER_VERSION})" ) else() - message( STATUS "Found MYSQL: ${LOCAL_MYSQL_LIBRARIES}" ) + message( STATUS "Found MYSQL: ${MYSQL_LOCAL_LIBRARIES}" ) endif() set( HAVE_LOCAL_MYSQL ON CACHE BOOL "mysql client is available as a local copy") else() - foreach( _VAR LOCAL_MYSQL_LIBRARIES LOCAL_MYSQL_INCLUDE_DIRS ) + foreach( _VAR MYSQL_LOCAL_LIBRARIES MYSQL_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) endif() @@ -55,56 +55,26 @@ if( MYSQL_CONFIG_EXECUTABLE ) message( STATUS "Found MYSQL: ${MYSQL_LIBRARIES} (found version ${MYSQL_VERSION})" ) else() # find mysql package + unset( MYSQL_LIBRARIES CACHE ) + unset( MYSQL_INCLUDE_DIRS CACHE ) set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) find_package( MYSQL ) endif() -set( SYSTEM_MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" +set( MYSQL_SYSTEM_LIBRARIES "${MYSQL_LIBRARIES}" CACHE PATH "system mysql libraries" ) -set( SYSTEM_MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" +set( MYSQL_SYSTEM_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" CACHE PATH "system mysql include directories" ) -mark_as_advanced( SYSTEM_MYSQL_LIBRARIES ) -mark_as_advanced( SYSTEM_MYSQL_INCLUDE_DIRS ) +mark_as_advanced( MYSQL_SYSTEM_LIBRARIES ) +mark_as_advanced( MYSQL_SYSTEM_INCLUDE_DIRS ) -if( SYSTEM_MYSQL_LIBRARIES AND SYSTEM_MYSQL_INCLUDE_DIRS ) +if( MYSQL_SYSTEM_LIBRARIES AND MYSQL_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_MYSQL ON CACHE BOOL "mysql client is available on the system" ) endif() message( STATUS "Detecting system MYSQL - done" ) -# options - # # configure # -unset( MYSQL_LIBRARIES CACHE ) -unset( MYSQL_INCLUDE_DIRS CACHE ) -if( HAVE_LOCAL_MYSQL ) - set( USE_LOCAL_MYSQL ON - CACHE BOOL "use local copy of mysql" ) -else() - unset( USE_LOCAL_MYSQL CACHE ) -endif() -if( USE_LOCAL_MYSQL ) - message( STATUS "Configuring for local MYSQL" ) - set( MYSQL_LIBRARIES ${LOCAL_MYSQL_LIBRARIES} ) - set( MYSQL_INCLUDE_DIRS ${LOCAL_MYSQL_INCLUDE_DIRS} ) - message( STATUS "Configuring for local MYSQL - done" ) -elseif( HAVE_SYSTEM_MYSQL ) - message( STATUS "Configuring for system MYSQL" ) - set( MYSQL_LIBRARIES ${SYSTEM_MYSQL_LIBRARIES} ) - set( MYSQL_INCLUDE_DIRS ${SYSTEM_MYSQL_INCLUDE_DIRS} ) - message( STATUS "Configuring for system MYSQL - done" ) -endif() -if( USE_LOCAL_MYSQL OR HAVE_SYSTEM_MYSQL ) - set( USE_MYSQL ON - CACHE BOOL "use mysql" ) -else() - unset( USE_MYSQL CACHE ) -endif() -set( MYSQL_LIBRARIES ${MYSQL_LIBRARIES} - CACHE PATH "mysql libraries" ) -set( MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIRS} - CACHE PATH "mysql include directories" ) -mark_as_advanced( MYSQL_LIBRARIES ) -mark_as_advanced( MYSQL_INCLUDE_DIRS ) +CONFIGURE_USE_LOCAL_OR_SYSTEM( MYSQL ) diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt index 0625999b1..ab1c83b6d 100644 --- a/3rdparty/pcre/CMakeLists.txt +++ b/3rdparty/pcre/CMakeLists.txt @@ -4,25 +4,25 @@ # if( WIN32 ) message( STATUS "Detecting local PCRE" ) -find_path( LOCAL_PCRE_INCLUDE_DIRS "pcre.h" +find_path( PCRE_LOCAL_INCLUDE_DIRS "pcre.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) -find_library( LOCAL_PCRE_LIBRARIES +find_library( PCRE_LOCAL_LIBRARIES NAMES pcre PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" NO_DEFAULT_PATH ) -mark_as_advanced( LOCAL_PCRE_LIBRARIES ) -mark_as_advanced( LOCAL_PCRE_INCLUDE_DIRS ) +mark_as_advanced( PCRE_LOCAL_LIBRARIES ) +mark_as_advanced( PCRE_LOCAL_INCLUDE_DIRS ) -if( LOCAL_PCRE_LIBRARIES AND LOCAL_PCRE_INCLUDE_DIRS ) - file( STRINGS "${LOCAL_PCRE_INCLUDE_DIRS}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) +if( PCRE_LOCAL_LIBRARIES AND PCRE_LOCAL_INCLUDE_DIRS ) + file( STRINGS "${PCRE_LOCAL_INCLUDE_DIRS}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) - message( STATUS "Found PCRE: ${LOCAL_PCRE_LIBRARIES} (found version ${PCRE_MAJOR}.${PCRE_MINOR})" ) + message( STATUS "Found PCRE: ${PCRE_LOCAL_LIBRARIES} (found version ${PCRE_MAJOR}.${PCRE_MINOR})" ) set( HAVE_LOCAL_PCRE ON CACHE BOOL "pcre is available as a local copy" ) else() - foreach( _VAR LOCAL_PCRE_LIBRARIES LOCAL_PCRE_INCLUDE_DIRS ) + foreach( _VAR PCRE_LOCAL_LIBRARIES PCRE_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) endif() @@ -39,15 +39,17 @@ endif( WIN32 ) # message( STATUS "Detecting system PCRE" ) set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) +unset( PCRE_LIBRARIES CACHE ) +unset( PCRE_INCLUDE_DIRS CACHE ) find_package( PCRE ) -set( SYSTEM_PCRE_LIBRARIES ${PCRE_LIBRARIES} +set( PCRE_SYSTEM_LIBRARIES ${PCRE_LIBRARIES} CACHE PATH "system pcre libraries" ) -set( SYSTEM_PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} +set( PCRE_SYSTEM_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} CACHE PATH "system pcre include directories" ) -mark_as_advanced( SYSTEM_PCRE_LIBRARIES ) -mark_as_advanced( SYSTEM_PCRE_INCLUDE_DIRS ) +mark_as_advanced( PCRE_SYSTEM_LIBRARIES ) +mark_as_advanced( PCRE_SYSTEM_INCLUDE_DIRS ) -if( SYSTEM_PCRE_LIBRARIES AND SYSTEM_PCRE_INCLUDE_DIRS ) +if( PCRE_SYSTEM_LIBRARIES AND PCRE_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_PCRE ON CACHE BOOL "pcre is available on the system" ) else() @@ -59,34 +61,4 @@ message( STATUS "Detecting system PCRE - done" ) # # configure # -unset( PCRE_LIBRARIES CACHE ) -unset( PCRE_INCLUDE_DIRS CACHE ) -if( HAVE_LOCAL_PCRE ) - set( USE_LOCAL_PCRE ON - CACHE BOOL "use local copy of pcre" ) -else() - unset( USE_LOCAL_PCRE CACHE ) -endif() -if( USE_LOCAL_PCRE ) - message( STATUS "Configuring for local PCRE" ) - set( PCRE_LIBRARIES ${LOCAL_PCRE_LIBRARIES} ) - set( PCRE_INCLUDE_DIRS ${LOCAL_PCRE_INCLUDE_DIRS} ) - message( STATUS "Configuring for local PCRE - done" ) -elseif( HAVE_SYSTEM_PCRE ) - message( STATUS "Configuring for system PCRE" ) - set( PCRE_LIBRARIES ${SYSTEM_PCRE_LIBRARIES} ) - set( PCRE_INCLUDE_DIRS ${SYSTEM_PCRE_INCLUDE_DIRS} ) - message( STATUS "Configuring for system PCRE - done" ) -endif() -if( USE_LOCAL_PCRE OR HAVE_SYSTEM_PCRE ) - set( USE_PCRE ON - CACHE BOOL "use pcre" ) -else() - unset( USE_PCRE CACHE ) -endif() -set( PCRE_LIBRARIES ${PCRE_LIBRARIES} - CACHE PATH "pcre libraries" ) -set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} - CACHE PATH "pcre include directories" ) -mark_as_advanced( PCRE_LIBRARIES ) -mark_as_advanced( PCRE_INCLUDE_DIRS ) +CONFIGURE_USE_LOCAL_OR_SYSTEM( PCRE ) diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 849813be0..3bb4304e7 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -4,24 +4,24 @@ # if( WIN32 ) message( STATUS "Detecting local ZLIB" ) -find_path( LOCAL_ZLIB_INCLUDE_DIRS "zlib.h" +find_path( ZLIB_LOCAL_INCLUDE_DIRS "zlib.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) -find_library( LOCAL_ZLIB_LIBRARIES +find_library( ZLIB_LOCAL_LIBRARIES NAMES zdll PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" NO_DEFAULT_PATH ) -mark_as_advanced( LOCAL_ZLIB_LIBRARIES ) -mark_as_advanced( LOCAL_ZLIB_INCLUDE_DIRS ) +mark_as_advanced( ZLIB_LOCAL_LIBRARIES ) +mark_as_advanced( ZLIB_LOCAL_INCLUDE_DIRS ) -if( LOCAL_ZLIB_LIBRARIES AND LOCAL_ZLIB_INCLUDE_DIRS ) - file( STRINGS "${LOCAL_ZLIB_INCLUDE_DIRS}/zlib.h" ZLIB_H REGEX "^#define[ \t]+ZLIB_VERSION[ \t]+\"[^\"]+\".*$" ) +if( ZLIB_LOCAL_LIBRARIES AND ZLIB_LOCAL_INCLUDE_DIRS ) + file( STRINGS "${ZLIB_LOCAL_INCLUDE_DIRS}/zlib.h" ZLIB_H REGEX "^#define[ \t]+ZLIB_VERSION[ \t]+\"[^\"]+\".*$" ) string( REGEX REPLACE "^.*ZLIB_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" ZLIB_VERSION "${ZLIB_H}" ) - message( STATUS "Found local ZLIB: ${LOCAL_ZLIB_LIBRARIES} (found version ${ZLIB_VERSION})" ) + message( STATUS "Found local ZLIB: ${ZLIB_LOCAL_LIBRARIES} (found version ${ZLIB_VERSION})" ) set( HAVE_LOCAL_ZLIB ON CACHE BOOL "zlib is available as a local copy" ) else() - foreach( _VAR LOCAL_ZLIB_LIBRARIES LOCAL_ZLIB_INCLUDE_DIRS ) + foreach( _VAR ZLIB_LOCAL_LIBRARIES ZLIB_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) endif() @@ -37,15 +37,17 @@ endif( WIN32 ) # system # message( STATUS "Detecting system ZLIB" ) +unset( ZLIB_LIBRARIES CACHE ) +unset( ZLIB_INCLUDE_DIRS CACHE ) find_package( ZLIB ) -set( SYSTEM_ZLIB_LIBRARIES ${ZLIB_LIBRARIES} +set( ZLIB_SYSTEM_LIBRARIES ${ZLIB_LIBRARIES} CACHE PATH "system zlib libraries" ) -set( SYSTEM_ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} +set( ZLIB_SYSTEM_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} CACHE PATH "system zlib include directories" ) -mark_as_advanced( SYSTEM_ZLIB_LIBRARIES ) -mark_as_advanced( SYSTEM_ZLIB_INCLUDE_DIRS ) +mark_as_advanced( ZLIB_SYSTEM_LIBRARIES ) +mark_as_advanced( ZLIB_SYSTEM_INCLUDE_DIRS ) -if( SYSTEM_ZLIB_LIBRARIES AND SYSTEM_ZLIB_INCLUDE_DIRS ) +if( ZLIB_SYSTEM_LIBRARIES AND ZLIB_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_ZLIB ON CACHE BOOL "zlib is available on the system" ) else() @@ -57,34 +59,4 @@ message( STATUS "Detecting system ZLIB - done" ) # # configure # -unset( ZLIB_LIBRARIES CACHE ) -unset( ZLIB_INCLUDE_DIRS CACHE ) -if( HAVE_LOCAL_ZLIB ) - set( USE_LOCAL_ZLIB ON - CACHE BOOL "use local copy of zlib" ) -else() - unset( USE_LOCAL_ZLIB CACHE ) -endif() -if( USE_LOCAL_ZLIB ) - message( STATUS "Configuring for local ZLIB" ) - set( ZLIB_LIBRARIES ${LOCAL_ZLIB_LIBRARIES} ) - set( ZLIB_INCLUDE_DIRS ${LOCAL_ZLIB_INCLUDE_DIRS} ) - message( STATUS "Configuring for local ZLIB - done" ) -elseif( HAVE_SYSTEM_ZLIB ) - message( STATUS "Configuring for system ZLIB" ) - set( ZLIB_LIBRARIES ${SYSTEM_ZLIB_LIBRARIES} ) - set( ZLIB_INCLUDE_DIRS ${SYSTEM_ZLIB_INCLUDE_DIRS} ) - message( STATUS "Configuring for system ZLIB - done" ) -endif() -if( USE_LOCAL_ZLIB OR HAVE_SYSTEM_ZLIB ) - set( USE_ZLIB ON - CACHE BOOL "use zlib" ) -else() - unset( USE_ZLIB CACHE ) -endif() -set( ZLIB_LIBRARIES ${ZLIB_LIBRARIES} - CACHE PATH "zlib libraries" ) -set( ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} - CACHE PATH "zlib include directories" ) -mark_as_advanced( ZLIB_LIBRARIES ) -mark_as_advanced( ZLIB_INCLUDE_DIRS ) +CONFIGURE_USE_LOCAL_OR_SYSTEM( ZLIB ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f7c46987..a56059956 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,10 @@ - +# "Getting Started with CMake", a tutorial video by Eric Wing. +# Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw +# Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg +# Part 3 of 6: http://www.youtube.com/watch?v=sz6cPhbuTk4 +# Part 4 of 6: http://www.youtube.com/watch?v=JICZOkyNXbg +# Part 5 of 6: http://www.youtube.com/watch?v=lAiuLHy4dCk +# Part 6 of 6: http://www.youtube.com/watch?v=fAtJNzDZdH8 cmake_minimum_required( VERSION 2.8.4 ) project( eAthena ) @@ -165,13 +171,43 @@ endif() set( PACKETVER "" CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) + +##################################################################### +# package stuff +# +if( OFF ) +set( CPACK_PACKAGE_NAME "eAthena" ) +set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" ) +set( CPACK_PACKAGE_FILE_NAME ) +set( CPACK_PACKAGE_INSTALL_DIRECTORY ) +set( CPACK_PROJECT_CONFIG_FILE ) +set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ) +set( CPACK_RESOURCE_FILE_README ) +set( CPACK_RESOURCE_FILE_WELCOME ) +set( CPACK_MONOLITHIC_INSTALL ON ) +set( CPACK_GENERATOR "ZIP" ) +set( CPACK_OUTPUT_CONFIG_FILE ) +set( CPACK_PACKAGE_EXECUTABLES ) +set( CPACK_STRIP_FILES ) +#source +set( CPACK_SOURCE_PACKAGE_FILE_NAME ) +set( CPACK_SOURCE_STRIP_FILES ) +set( CPACK_SOURCE_GENERATOR "ZIP" ) +set( CPACK_SOURCE_OUTPUT_CONFIG_FILE ) +set( CPACK_SOURCE_IGNORE_FILES ) +include(CPACK) +endif() + + # # install stuff # +set( COMPONENT_SOURCE "Source code, librarires and project files" CACHE INTERNAL "" ) +set( COMPONENT_BASE "Base files" CACHE INTERNAL "" ) option( INSTALL_RUN_DATA "install files needed to run the project" ON ) option( INSTALL_BUILD_DATA "install files needed to build the project" OFF ) set( SVN_FOLDER_PATTERN "[\\.]svn" - CACHE PATH "pattern of svn folder that we exclude from instalations" ) + CACHE STRING "pattern of svn folder that we exclude from instalations" ) mark_as_advanced( SVN_FOLDER_PATTERN ) if( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}" ) set( INSTALLING_TO_SOURCE ON @@ -252,18 +288,37 @@ function( INSTALL_DIRECTORIES DIRS EXCLUDE_PATTERN ) endforeach() endfunction() if( NOT INSTALLING_TO_SOURCE ) + # skipped if in-source if( INSTALL_RUN_DATA ) - install( FILES ${LOCAL_RUN_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX} ) - INSTALL_DIRECTORIES( "${LOCAL_RUN_DIRECTORIES}" "conf/import-tmpl" ) + # base + install( FILES ${LOCAL_RUN_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX} ) + foreach( DIR IN ITEMS ${LOCAL_RUN_DIRECTORIES} ) + install( DIRECTORY "${DIR}/" + DESTINATION "${DIR}" + PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE + PATTERN "conf/import-tmpl" EXCLUDE ) + endforeach() endif() if( INSTALL_BUILD_DATA ) - install( FILES ${LOCAL_BUILD_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX} ) - INSTALL_DIRECTORIES( "${LOCAL_BUILD_DIRECTORIES}" "" ) + # source + install( FILES ${LOCAL_BUILD_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX} ) + foreach( DIR IN ITEMS ${LOCAL_BUILD_DIRECTORIES} ) + install( DIRECTORY "${DIR}/" + DESTINATION "${DIR}" + PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) + endforeach() endif() endif() if( INSTALL_RUN_DATA ) - INSTALL_DIRECTORY( "save-tmpl" "save" "" ) - INSTALL_DIRECTORY( "conf/import-tmpl" "conf/import" "" ) + # base templates + install( DIRECTORY "save-tmpl/" + DESTINATION "save" + PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) + install( DIRECTORY "conf/import-tmpl/" + DESTINATION "conf/import" + PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) endif() diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index cc0b1d7ef..f8b235416 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/07/01 + * CMake: marked executables as different components and other miscellaneous changes. [FlavioJS] 2011/06/29 * Added experimental support for CMake. (for now: basic build, no extras, only tested with VS10 and cygwin) [FlavioJS] 2011/06/27 diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index 666070532..5c2d66c3c 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -1,5 +1,7 @@ +# # setup +# set( MT19937AR_SOURCES # "${MT19937AR_SOURCE_DIR}/mt19937ar.c" ) @@ -33,7 +35,9 @@ set( CHAR_SOURCES ) +# # char txt +# if( USE_ZLIB ) message ( STATUS "Creating target char-server" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) @@ -56,7 +60,9 @@ add_executable( char-server ${SOURCE_FILES} ) target_link_libraries( char-server ${LIBRARIES} ) set_target_properties( char-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS char-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS char-server + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "char-server" ) endif() message ( STATUS "Creating target char-server - done" ) else() diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt index d534ce89c..412393b21 100644 --- a/src/char_sql/CMakeLists.txt +++ b/src/char_sql/CMakeLists.txt @@ -1,5 +1,7 @@ +# # setup +# set( MT19937AR_SOURCES # "${MT19937AR_SOURCE_DIR}/mt19937ar.c" ) @@ -37,7 +39,9 @@ set( CHAR_SOURCES ) +# # char sql +# if( USE_ZLIB AND USE_MYSQL ) message ( STATUS "Creating target char-server_sql" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) @@ -60,7 +64,9 @@ add_executable( char-server_sql ${SOURCE_FILES} ) target_link_libraries( char-server_sql ${LIBRARIES} ) set_target_properties( char-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS char-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS char-server_sql + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "char-server_sql" ) endif() message ( STATUS "Creating target char-server_sql - done" ) else() diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt index 88d137507..b75878eed 100644 --- a/src/login/CMakeLists.txt +++ b/src/login/CMakeLists.txt @@ -1,5 +1,7 @@ +# # setup +# set( MT19937AR_SOURCES "${MT19937AR_SOURCE_DIR}/mt19937ar.c" ) @@ -64,7 +66,9 @@ add_executable( login-server ${SOURCE_FILES} ) target_link_libraries( login-server ${LIBRARIES} ) set_target_properties( login-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS login-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS login-server + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "login-server" ) endif() message ( STATUS "Creating target login-server - done" ) else() @@ -72,7 +76,9 @@ message ( STATUS "Skipping target login-server (requires ZLIB)" ) endif() +# # login sql +# if( USE_ZLIB AND USE_MYSQL ) message ( STATUS "Creating target login-server_sql" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) @@ -95,7 +101,9 @@ add_executable( login-server_sql ${SOURCE_FILES} ) target_link_libraries( login-server_sql ${LIBRARIES} ) set_target_properties( login-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS login-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS login-server_sql + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "login-server_sql" ) endif() message ( STATUS "Creating target login-server_sql - done" ) else() diff --git a/src/map/CMakeLists.txt b/src/map/CMakeLists.txt index e5589a30e..7189bbdd7 100644 --- a/src/map/CMakeLists.txt +++ b/src/map/CMakeLists.txt @@ -1,5 +1,7 @@ +# # setup +# set( MT19937AR_SOURCES "${MT19937AR_SOURCE_DIR}/mt19937ar.c" ) @@ -68,7 +70,9 @@ set( MAP_SQL_SOURCES ) +# # map txt +# if( USE_ZLIB ) message ( STATUS "Creating target map-server" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) @@ -96,7 +100,9 @@ add_executable( map-server ${SOURCE_FILES} ) target_link_libraries( map-server ${LIBRARIES} ) set_target_properties( map-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS map-server DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS map-server + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "map-server" ) endif() message ( STATUS "Creating target map-server - done" ) else() @@ -104,7 +110,9 @@ message ( STATUS "Skipping target map-server (requires ZLIB; optional PCRE)" ) endif() +# # map sql +# if( USE_ZLIB AND USE_MYSQL ) message ( STATUS "Creating target map-server_sql" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) @@ -132,7 +140,9 @@ add_executable( map-server_sql ${SOURCE_FILES} ) target_link_libraries( map-server_sql ${LIBRARIES} ) set_target_properties( map-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS map-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS map-server_sql + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "map-server_sql" ) endif() message ( STATUS "Creating target map-server_sql - done" ) else() diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index 5b4880893..4f69174b9 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -41,7 +41,9 @@ include_directories( ${INCLUDE_DIRS} ) target_link_libraries( mapcache ${ZLIB_LIBRARIES} ) set_target_properties( mapcache PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) - install( TARGETS mapcache DESTINATION ${CMAKE_INSTALL_PREFIX} ) + install( TARGETS mapcache + DESTINATION ${CMAKE_INSTALL_PREFIX} + COMPONENT "mapcache" ) endif() message ( STATUS "Creating target mapcache - done" ) else() -- cgit v1.2.3-70-g09d2 From 482beafefb9c50e5c1d3d16fd69b88cf2c9e84db Mon Sep 17 00:00:00 2001 From: flaviojs Date: Wed, 6 Jul 2011 20:40:38 +0000 Subject: * CMake: src/common builds static libraries common_base/common_sql, that are used as dependencies by the other targets. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14889 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/msinttypes/CMakeLists.txt | 1 + 3rdparty/mt19937ar/CMakeLists.txt | 7 + CMakeLists.txt | 254 +++++++++++++++++++------------------ Changelog-Trunk.txt | 1 + src/char/CMakeLists.txt | 88 +++++-------- src/char_sql/CMakeLists.txt | 98 ++++++-------- src/common/CMakeLists.txt | 135 ++++++++++++++++++-- src/login/CMakeLists.txt | 38 +----- src/login/sql/CMakeLists.txt | 46 ++++--- src/login/txt/CMakeLists.txt | 46 ++++--- src/map/CMakeLists.txt | 67 +--------- src/map/sql/CMakeLists.txt | 108 +++++++++++++--- src/map/txt/CMakeLists.txt | 108 +++++++++++++--- src/tool/CMakeLists.txt | 34 +++-- 14 files changed, 594 insertions(+), 437 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/msinttypes/CMakeLists.txt b/3rdparty/msinttypes/CMakeLists.txt index acf17f5b4..f17c6f596 100644 --- a/3rdparty/msinttypes/CMakeLists.txt +++ b/3rdparty/msinttypes/CMakeLists.txt @@ -4,4 +4,5 @@ find_path( MSINTTYPES_INCLUDE_DIRS "inttypes.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) mark_as_advanced( MSINTTYPES_INCLUDE_DIRS ) +set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MSINTTYPES_INCLUDE_DIRS} CACHE INTERNAL "" ) endif() diff --git a/3rdparty/mt19937ar/CMakeLists.txt b/3rdparty/mt19937ar/CMakeLists.txt index 46f155b41..08eff5790 100644 --- a/3rdparty/mt19937ar/CMakeLists.txt +++ b/3rdparty/mt19937ar/CMakeLists.txt @@ -7,3 +7,10 @@ find_path( MT19937AR_SOURCE_DIR "mt19937ar.c" NO_DEFAULT_PATH ) mark_as_advanced( MT19937AR_INCLUDE_DIRS ) mark_as_advanced( MT19937AR_SOURCE_DIR ) + +set( MT19937AR_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/mt19937ar.h" + CACHE INTERNAL "mt19937ar headers" ) +set( MT19937AR_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/mt19937ar.c" + CACHE INTERNAL "mt19937ar sources" ) diff --git a/CMakeLists.txt b/CMakeLists.txt index a56059956..59529c442 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,128 +23,128 @@ endif() # Debug stuff # if( NOT SKIP_DEBUG ) -message( STATUS "DEBUG: # Variables That Change Behavior" ) -message( STATUS "DEBUG: BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}" ) -message( STATUS "DEBUG: CMAKE_BACKWARDS_COMPATIBILITY=${CMAKE_BACKWARDS_COMPATIBILITY}" ) -message( STATUS "DEBUG: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ) -message( STATUS "DEBUG: CMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE}" ) -message( STATUS "DEBUG: CMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" ) -message( STATUS "DEBUG: CMAKE_FIND_LIBRARY_PREFIXES=${CMAKE_FIND_LIBRARY_PREFIXES}" ) -message( STATUS "DEBUG: CMAKE_FIND_LIBRARY_SUFFIXES=${CMAKE_FIND_LIBRARY_SUFFIXES}" ) -message( STATUS "DEBUG: CMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}" ) -message( STATUS "DEBUG: CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" ) -message( STATUS "DEBUG: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" ) -message( STATUS "DEBUG: CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" ) -message( STATUS "DEBUG: CMAKE_MFC_FLAG=${CMAKE_MFC_FLAG}" ) -message( STATUS "DEBUG: CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" ) -message( STATUS "DEBUG: CMAKE_NOT_USING_CONFIG_FLAGS=${CMAKE_NOT_USING_CONFIG_FLAGS}" ) -message( STATUS "DEBUG: CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) -message( STATUS "DEBUG: CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}" ) -message( STATUS "DEBUG: CMAKE_SKIP_INSTALL_ALL_DEPENDENCY=${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_IGNORE_PATH=${CMAKE_SYSTEM_IGNORE_PATH}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_LIBRARY_PATH=${CMAKE_SYSTEM_LIBRARY_PATH}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_PROGRAM_PATH=${CMAKE_SYSTEM_PROGRAM_PATH}" ) -message( STATUS "DEBUG: CMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}" ) -message( STATUS "DEBUG: # Variables That Describe the System" ) -message( STATUS "DEBUG: APPLE=${APPLE}" ) -message( STATUS "DEBUG: BORLAND=${BORLAND}" ) -message( STATUS "DEBUG: CMAKE_CL_64=${CMAKE_CL_64}" ) -message( STATUS "DEBUG: CMAKE_COMPILER_2005=${CMAKE_COMPILER_2005}" ) -message( STATUS "DEBUG: CMAKE_HOST_APPLE=${CMAKE_HOST_APPLE}" ) -message( STATUS "DEBUG: CMAKE_HOST_SYSTEM=${CMAKE_HOST_SYSTEM}" ) -message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}" ) -message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR}" ) -message( STATUS "DEBUG: CMAKE_HOST_SYSTEM_VERSION=${CMAKE_HOST_SYSTEM_VERSION}" ) -message( STATUS "DEBUG: CMAKE_HOST_UNIX=${CMAKE_HOST_UNIX}" ) -message( STATUS "DEBUG: CMAKE_HOST_WIN32=${CMAKE_HOST_WIN32}" ) -message( STATUS "DEBUG: CMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM=${CMAKE_SYSTEM}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}" ) -message( STATUS "DEBUG: CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}" ) -message( STATUS "DEBUG: CYGWIN=${CYGWIN}" ) -message( STATUS "DEBUG: MSVC=${MSVC}" ) -message( STATUS "DEBUG: MSVC80=${MSVC80}" ) -message( STATUS "DEBUG: MSVC_IDE=${MSVC_IDE}" ) -message( STATUS "DEBUG: MSVC_VERSION=${MSVC_VERSION}" ) -message( STATUS "DEBUG: UNIX=${UNIX}" ) -message( STATUS "DEBUG: WIN32=${WIN32}" ) -message( STATUS "DEBUG: XCODE_VERSION=${XCODE_VERSION}" ) -message( STATUS "DEBUG: # Variables that Control the Build" ) -message( STATUS "DEBUG: CMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) -message( STATUS "DEBUG: CMAKE_BUILD_WITH_INSTALL_RPATH=${CMAKE_BUILD_WITH_INSTALL_RPATH}" ) -message( STATUS "DEBUG: CMAKE_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX}" ) -message( STATUS "DEBUG: CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" ) -message( STATUS "DEBUG: CMAKE_INCLUDE_CURRENT_DIR=${CMAKE_INCLUDE_CURRENT_DIR}" ) -message( STATUS "DEBUG: CMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_NAME_DIR}" ) -message( STATUS "DEBUG: CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" ) -message( STATUS "DEBUG: CMAKE_INSTALL_RPATH_USE_LINK_PATH=${CMAKE_INSTALL_RPATH_USE_LINK_PATH}" ) -message( STATUS "DEBUG: CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" ) -message( STATUS "DEBUG: CMAKE_LIBRARY_PATH_FLAG=${CMAKE_LIBRARY_PATH_FLAG}" ) -message( STATUS "DEBUG: CMAKE_LINK_DEF_FILE_FLAG=${CMAKE_LINK_DEF_FILE_FLAG}" ) -message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_FILE_FLAG=${CMAKE_LINK_LIBRARY_FILE_FLAG}" ) -message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}" ) -message( STATUS "DEBUG: CMAKE_NO_BUILTIN_CHRPATH=${CMAKE_NO_BUILTIN_CHRPATH}" ) -message( STATUS "DEBUG: CMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) -message( STATUS "DEBUG: CMAKE_SKIP_BUILD_RPATH=${CMAKE_SKIP_BUILD_RPATH}" ) -message( STATUS "DEBUG: CMAKE_TRY_COMPILE_CONFIGURATION=${CMAKE_TRY_COMPILE_CONFIGURATION}" ) -message( STATUS "DEBUG: CMAKE_USE_RELATIVE_PATHS=${CMAKE_USE_RELATIVE_PATHS}" ) -message( STATUS "DEBUG: EXECUTABLE_OUTPUT_PATH=${EXECUTABLE_OUTPUT_PATH}" ) -message( STATUS "DEBUG: LIBRARY_OUTPUT_PATH=${LIBRARY_OUTPUT_PATH}" ) -message( STATUS "DEBUG: # Variables that Provide Information" ) -message( STATUS "DEBUG: CMAKE_AR=${CMAKE_AR}" ) -message( STATUS "DEBUG: CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" ) -message( STATUS "DEBUG: CMAKE_BUILD_TOOL=${CMAKE_BUILD_TOOL}" ) -message( STATUS "DEBUG: CMAKE_CACHEFILE_DIR=${CMAKE_CACHEFILE_DIR}" ) -message( STATUS "DEBUG: CMAKE_CACHE_MAJOR_VERSION=${CMAKE_CACHE_MAJOR_VERSION}" ) -message( STATUS "DEBUG: CMAKE_CACHE_MINOR_VERSION=${CMAKE_CACHE_MINOR_VERSION}" ) -message( STATUS "DEBUG: CMAKE_CACHE_PATCH_VERSION=${CMAKE_CACHE_PATCH_VERSION}" ) -message( STATUS "DEBUG: CMAKE_CFG_INTDIR=${CMAKE_CFG_INTDIR}" ) -message( STATUS "DEBUG: CMAKE_COMMAND=${CMAKE_COMMAND}" ) -message( STATUS "DEBUG: CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}" ) -message( STATUS "DEBUG: CMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}" ) -message( STATUS "DEBUG: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" ) -message( STATUS "DEBUG: CMAKE_CURRENT_LIST_DIR=${CMAKE_CURRENT_LIST_DIR}" ) -message( STATUS "DEBUG: CMAKE_CURRENT_LIST_FILE=${CMAKE_CURRENT_LIST_FILE}" ) -message( STATUS "DEBUG: CMAKE_CURRENT_LIST_LINE=${CMAKE_CURRENT_LIST_LINE}" ) -message( STATUS "DEBUG: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" ) -message( STATUS "DEBUG: CMAKE_DL_LIBS=${CMAKE_DL_LIBS}" ) -message( STATUS "DEBUG: CMAKE_EDIT_COMMAND=${CMAKE_EDIT_COMMAND}" ) -message( STATUS "DEBUG: CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_EXTRA_GENERATOR=${CMAKE_EXTRA_GENERATOR}" ) -message( STATUS "DEBUG: CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES=${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}" ) -message( STATUS "DEBUG: CMAKE_GENERATOR=${CMAKE_GENERATOR}" ) -message( STATUS "DEBUG: CMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}" ) -message( STATUS "DEBUG: CMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}" ) -message( STATUS "DEBUG: CMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_LINK_LIBRARY_SUFFIX=${CMAKE_LINK_LIBRARY_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_MAJOR_VERSION=${CMAKE_MAJOR_VERSION}" ) -message( STATUS "DEBUG: CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" ) -message( STATUS "DEBUG: CMAKE_MINOR_VERSION=${CMAKE_MINOR_VERSION}" ) -message( STATUS "DEBUG: CMAKE_PARENT_LIST_FILE=${CMAKE_PARENT_LIST_FILE}" ) -message( STATUS "DEBUG: CMAKE_PATCH_VERSION=${CMAKE_PATCH_VERSION}" ) -message( STATUS "DEBUG: CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}" ) -message( STATUS "DEBUG: CMAKE_RANLIB=${CMAKE_RANLIB}" ) -message( STATUS "DEBUG: CMAKE_ROOT=${CMAKE_ROOT}" ) -message( STATUS "DEBUG: CMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}" ) -message( STATUS "DEBUG: CMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}" ) -message( STATUS "DEBUG: CMAKE_SHARED_MODULE_SUFFIX=${CMAKE_SHARED_MODULE_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) -message( STATUS "DEBUG: CMAKE_SKIP_RPATH=${CMAKE_SKIP_RPATH}" ) -message( STATUS "DEBUG: CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}" ) -message( STATUS "DEBUG: CMAKE_STANDARD_LIBRARIES=${CMAKE_STANDARD_LIBRARIES}" ) -message( STATUS "DEBUG: CMAKE_STATIC_LIBRARY_PREFIX=${CMAKE_STATIC_LIBRARY_PREFIX}" ) -message( STATUS "DEBUG: CMAKE_STATIC_LIBRARY_SUFFIX=${CMAKE_STATIC_LIBRARY_SUFFIX}" ) -message( STATUS "DEBUG: CMAKE_TWEAK_VERSION=${CMAKE_TWEAK_VERSION}" ) -message( STATUS "DEBUG: CMAKE_USING_VC_FREE_TOOLS=${CMAKE_USING_VC_FREE_TOOLS}" ) -message( STATUS "DEBUG: CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}" ) -message( STATUS "DEBUG: CMAKE_VERSION=${CMAKE_VERSION}" ) -message( STATUS "DEBUG: PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}" ) -message( STATUS "DEBUG: PROJECT_NAME=${PROJECT_NAME}" ) -message( STATUS "DEBUG: PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" ) +message( "DEBUG: # Variables That Change Behavior" ) +message( "DEBUG: BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}" ) +message( "DEBUG: CMAKE_BACKWARDS_COMPATIBILITY=${CMAKE_BACKWARDS_COMPATIBILITY}" ) +message( "DEBUG: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ) +message( "DEBUG: CMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE}" ) +message( "DEBUG: CMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" ) +message( "DEBUG: CMAKE_FIND_LIBRARY_PREFIXES=${CMAKE_FIND_LIBRARY_PREFIXES}" ) +message( "DEBUG: CMAKE_FIND_LIBRARY_SUFFIXES=${CMAKE_FIND_LIBRARY_SUFFIXES}" ) +message( "DEBUG: CMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}" ) +message( "DEBUG: CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" ) +message( "DEBUG: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" ) +message( "DEBUG: CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" ) +message( "DEBUG: CMAKE_MFC_FLAG=${CMAKE_MFC_FLAG}" ) +message( "DEBUG: CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" ) +message( "DEBUG: CMAKE_NOT_USING_CONFIG_FLAGS=${CMAKE_NOT_USING_CONFIG_FLAGS}" ) +message( "DEBUG: CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) +message( "DEBUG: CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}" ) +message( "DEBUG: CMAKE_SKIP_INSTALL_ALL_DEPENDENCY=${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY}" ) +message( "DEBUG: CMAKE_SYSTEM_IGNORE_PATH=${CMAKE_SYSTEM_IGNORE_PATH}" ) +message( "DEBUG: CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}" ) +message( "DEBUG: CMAKE_SYSTEM_LIBRARY_PATH=${CMAKE_SYSTEM_LIBRARY_PATH}" ) +message( "DEBUG: CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}" ) +message( "DEBUG: CMAKE_SYSTEM_PROGRAM_PATH=${CMAKE_SYSTEM_PROGRAM_PATH}" ) +message( "DEBUG: CMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}" ) +message( "DEBUG: # Variables That Describe the System" ) +message( "DEBUG: APPLE=${APPLE}" ) +message( "DEBUG: BORLAND=${BORLAND}" ) +message( "DEBUG: CMAKE_CL_64=${CMAKE_CL_64}" ) +message( "DEBUG: CMAKE_COMPILER_2005=${CMAKE_COMPILER_2005}" ) +message( "DEBUG: CMAKE_HOST_APPLE=${CMAKE_HOST_APPLE}" ) +message( "DEBUG: CMAKE_HOST_SYSTEM=${CMAKE_HOST_SYSTEM}" ) +message( "DEBUG: CMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}" ) +message( "DEBUG: CMAKE_HOST_SYSTEM_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR}" ) +message( "DEBUG: CMAKE_HOST_SYSTEM_VERSION=${CMAKE_HOST_SYSTEM_VERSION}" ) +message( "DEBUG: CMAKE_HOST_UNIX=${CMAKE_HOST_UNIX}" ) +message( "DEBUG: CMAKE_HOST_WIN32=${CMAKE_HOST_WIN32}" ) +message( "DEBUG: CMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}" ) +message( "DEBUG: CMAKE_SYSTEM=${CMAKE_SYSTEM}" ) +message( "DEBUG: CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" ) +message( "DEBUG: CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}" ) +message( "DEBUG: CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}" ) +message( "DEBUG: CYGWIN=${CYGWIN}" ) +message( "DEBUG: MSVC=${MSVC}" ) +message( "DEBUG: MSVC80=${MSVC80}" ) +message( "DEBUG: MSVC_IDE=${MSVC_IDE}" ) +message( "DEBUG: MSVC_VERSION=${MSVC_VERSION}" ) +message( "DEBUG: UNIX=${UNIX}" ) +message( "DEBUG: WIN32=${WIN32}" ) +message( "DEBUG: XCODE_VERSION=${XCODE_VERSION}" ) +message( "DEBUG: # Variables that Control the Build" ) +message( "DEBUG: CMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) +message( "DEBUG: CMAKE_BUILD_WITH_INSTALL_RPATH=${CMAKE_BUILD_WITH_INSTALL_RPATH}" ) +message( "DEBUG: CMAKE_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX}" ) +message( "DEBUG: CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" ) +message( "DEBUG: CMAKE_INCLUDE_CURRENT_DIR=${CMAKE_INCLUDE_CURRENT_DIR}" ) +message( "DEBUG: CMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_NAME_DIR}" ) +message( "DEBUG: CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" ) +message( "DEBUG: CMAKE_INSTALL_RPATH_USE_LINK_PATH=${CMAKE_INSTALL_RPATH_USE_LINK_PATH}" ) +message( "DEBUG: CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" ) +message( "DEBUG: CMAKE_LIBRARY_PATH_FLAG=${CMAKE_LIBRARY_PATH_FLAG}" ) +message( "DEBUG: CMAKE_LINK_DEF_FILE_FLAG=${CMAKE_LINK_DEF_FILE_FLAG}" ) +message( "DEBUG: CMAKE_LINK_LIBRARY_FILE_FLAG=${CMAKE_LINK_LIBRARY_FILE_FLAG}" ) +message( "DEBUG: CMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}" ) +message( "DEBUG: CMAKE_NO_BUILTIN_CHRPATH=${CMAKE_NO_BUILTIN_CHRPATH}" ) +message( "DEBUG: CMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) +message( "DEBUG: CMAKE_SKIP_BUILD_RPATH=${CMAKE_SKIP_BUILD_RPATH}" ) +message( "DEBUG: CMAKE_TRY_COMPILE_CONFIGURATION=${CMAKE_TRY_COMPILE_CONFIGURATION}" ) +message( "DEBUG: CMAKE_USE_RELATIVE_PATHS=${CMAKE_USE_RELATIVE_PATHS}" ) +message( "DEBUG: EXECUTABLE_OUTPUT_PATH=${EXECUTABLE_OUTPUT_PATH}" ) +message( "DEBUG: LIBRARY_OUTPUT_PATH=${LIBRARY_OUTPUT_PATH}" ) +message( "DEBUG: # Variables that Provide Information" ) +message( "DEBUG: CMAKE_AR=${CMAKE_AR}" ) +message( "DEBUG: CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" ) +message( "DEBUG: CMAKE_BUILD_TOOL=${CMAKE_BUILD_TOOL}" ) +message( "DEBUG: CMAKE_CACHEFILE_DIR=${CMAKE_CACHEFILE_DIR}" ) +message( "DEBUG: CMAKE_CACHE_MAJOR_VERSION=${CMAKE_CACHE_MAJOR_VERSION}" ) +message( "DEBUG: CMAKE_CACHE_MINOR_VERSION=${CMAKE_CACHE_MINOR_VERSION}" ) +message( "DEBUG: CMAKE_CACHE_PATCH_VERSION=${CMAKE_CACHE_PATCH_VERSION}" ) +message( "DEBUG: CMAKE_CFG_INTDIR=${CMAKE_CFG_INTDIR}" ) +message( "DEBUG: CMAKE_COMMAND=${CMAKE_COMMAND}" ) +message( "DEBUG: CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}" ) +message( "DEBUG: CMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}" ) +message( "DEBUG: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" ) +message( "DEBUG: CMAKE_CURRENT_LIST_DIR=${CMAKE_CURRENT_LIST_DIR}" ) +message( "DEBUG: CMAKE_CURRENT_LIST_FILE=${CMAKE_CURRENT_LIST_FILE}" ) +message( "DEBUG: CMAKE_CURRENT_LIST_LINE=${CMAKE_CURRENT_LIST_LINE}" ) +message( "DEBUG: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" ) +message( "DEBUG: CMAKE_DL_LIBS=${CMAKE_DL_LIBS}" ) +message( "DEBUG: CMAKE_EDIT_COMMAND=${CMAKE_EDIT_COMMAND}" ) +message( "DEBUG: CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}" ) +message( "DEBUG: CMAKE_EXTRA_GENERATOR=${CMAKE_EXTRA_GENERATOR}" ) +message( "DEBUG: CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES=${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}" ) +message( "DEBUG: CMAKE_GENERATOR=${CMAKE_GENERATOR}" ) +message( "DEBUG: CMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}" ) +message( "DEBUG: CMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}" ) +message( "DEBUG: CMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) +message( "DEBUG: CMAKE_LINK_LIBRARY_SUFFIX=${CMAKE_LINK_LIBRARY_SUFFIX}" ) +message( "DEBUG: CMAKE_MAJOR_VERSION=${CMAKE_MAJOR_VERSION}" ) +message( "DEBUG: CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" ) +message( "DEBUG: CMAKE_MINOR_VERSION=${CMAKE_MINOR_VERSION}" ) +message( "DEBUG: CMAKE_PARENT_LIST_FILE=${CMAKE_PARENT_LIST_FILE}" ) +message( "DEBUG: CMAKE_PATCH_VERSION=${CMAKE_PATCH_VERSION}" ) +message( "DEBUG: CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}" ) +message( "DEBUG: CMAKE_RANLIB=${CMAKE_RANLIB}" ) +message( "DEBUG: CMAKE_ROOT=${CMAKE_ROOT}" ) +message( "DEBUG: CMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}" ) +message( "DEBUG: CMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}" ) +message( "DEBUG: CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}" ) +message( "DEBUG: CMAKE_SHARED_MODULE_SUFFIX=${CMAKE_SHARED_MODULE_SUFFIX}" ) +message( "DEBUG: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) +message( "DEBUG: CMAKE_SKIP_RPATH=${CMAKE_SKIP_RPATH}" ) +message( "DEBUG: CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}" ) +message( "DEBUG: CMAKE_STANDARD_LIBRARIES=${CMAKE_STANDARD_LIBRARIES}" ) +message( "DEBUG: CMAKE_STATIC_LIBRARY_PREFIX=${CMAKE_STATIC_LIBRARY_PREFIX}" ) +message( "DEBUG: CMAKE_STATIC_LIBRARY_SUFFIX=${CMAKE_STATIC_LIBRARY_SUFFIX}" ) +message( "DEBUG: CMAKE_TWEAK_VERSION=${CMAKE_TWEAK_VERSION}" ) +message( "DEBUG: CMAKE_USING_VC_FREE_TOOLS=${CMAKE_USING_VC_FREE_TOOLS}" ) +message( "DEBUG: CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}" ) +message( "DEBUG: CMAKE_VERSION=${CMAKE_VERSION}" ) +message( "DEBUG: PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}" ) +message( "DEBUG: PROJECT_NAME=${PROJECT_NAME}" ) +message( "DEBUG: PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" ) set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install CACHE PATH "test install to dir" FORCE ) #set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "test install to source dir" FORCE ) endif( NOT SKIP_DEBUG ) @@ -153,12 +153,13 @@ endif( NOT SKIP_DEBUG ) # # Global stuff # -set( GLOBAL_LIBRARIES "" CACHE INTERNAL "" ) -set( GLOBAL_INCLUDE_DIRS "" CACHE INTERNAL "" ) -set( GLOBAL_DEFINITIONS "" CACHE INTERNAL "" ) +set( GLOBAL_LIBRARIES CACHE INTERNAL "" ) +set( GLOBAL_INCLUDE_DIRS CACHE INTERNAL "" ) +set( GLOBAL_DEFINITIONS CACHE INTERNAL "" ) mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) if( WIN32 ) list( APPEND GLOBAL_DEFINITIONS FD_SETSIZE=4096 ) + list( APPEND GLOBAL_LIBRARIES "oldnames.lib" "ws2_32.lib" ) endif() if( MSVC ) list( APPEND GLOBAL_DEFINITIONS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE DB_MANUAL_CAST_TO_UNION ) @@ -170,6 +171,9 @@ endif() # set( PACKETVER "" CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) +if( PACKETVER ) + list( APPEND GLOBAL_DEFINITIONS PACKETVER=${PACKETVER} ) +endif() ##################################################################### diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 55b382539..b2747c3c7 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ Date Added * Changed grfio.c include order and moved zlib include from the header to the source. [FlavioJS] * Merged decode_zip/encode_zip from eapp's grfio to replace our direct use of zlib's uncompress/compress. * Fixed strict-aliasing warning in mapcache's GetFloat. + * CMake: src/common builds static libraries common_base/common_sql, that are used as dependencies by the other targets. 2011/07/05 * CMake: split txt and sql variants of login-server and map-server. [FlavioJS] 2011/07/04 diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index 5c2d66c3c..1f6f1ea11 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -1,70 +1,50 @@ # -# setup +# char txt # -set( MT19937AR_SOURCES -# "${MT19937AR_SOURCE_DIR}/mt19937ar.c" - ) -set( COMMON_SOURCES - "${COMMON_SOURCE_DIR}/core.c" - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/ers.c" -# "${COMMON_SOURCE_DIR}/grfio.c" - "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/malloc.c" - "${COMMON_SOURCE_DIR}/mapindex.c" -# "${COMMON_SOURCE_DIR}/md5calc.c" -# "${COMMON_SOURCE_DIR}/nullpo.c" - "${COMMON_SOURCE_DIR}/plugins.c" -# "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/strlib.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" +if( HAVE_common_base ) +message( STATUS "Creating target char-server" ) +set( TXT_CHAR_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/char.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_party.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_status.h" + "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.h" + "${CMAKE_CURRENT_SOURCE_DIR}/inter.h" ) -set( CHAR_SOURCES - "char.c" - "int_guild.c" - "int_homun.c" - "int_party.c" - "int_pet.c" - "int_status.c" - "int_storage.c" - "inter.c" +set( TXT_CHAR_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/char.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_homun.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_party.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_pet.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_status.c" + "${CMAKE_CURRENT_SOURCE_DIR}/int_storage.c" + "${CMAKE_CURRENT_SOURCE_DIR}/inter.c" ) - - -# -# char txt -# -if( USE_ZLIB ) -message ( STATUS "Creating target char-server" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEPENDENCIES common_base ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${CHAR_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ) -source_group( char FILES ${CHAR_SOURCES} ) +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} ) include_directories( ${INCLUDE_DIRS} ) add_executable( char-server ${SOURCE_FILES} ) -target_link_libraries( char-server ${LIBRARIES} ) +add_dependencies( char-server ${DEPENDENCIES} ) +target_link_libraries( char-server ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( char-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS char-server DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "char-server" ) endif() -message ( STATUS "Creating target char-server - done" ) +message( STATUS "Creating target char-server - done" ) +set( HAVE_char-server ON CACHE BOOL "char-server target is available" ) +mark_as_advanced( HAVE_char-server ) else() -message ( STATUS "Skipping target char-server (requires ZLIB)" ) +message( STATUS "Skipping target char-server (requires common_base)" ) +unset( HAVE_char-server CACHE ) endif() diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt index 412393b21..7d3b7ad7e 100644 --- a/src/char_sql/CMakeLists.txt +++ b/src/char_sql/CMakeLists.txt @@ -1,74 +1,56 @@ # -# setup +# char sql # -set( MT19937AR_SOURCES -# "${MT19937AR_SOURCE_DIR}/mt19937ar.c" - ) -set( COMMON_SOURCES - "${COMMON_SOURCE_DIR}/core.c" - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/ers.c" -# "${COMMON_SOURCE_DIR}/grfio.c" -# "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/malloc.c" - "${COMMON_SOURCE_DIR}/mapindex.c" -# "${COMMON_SOURCE_DIR}/md5calc.c" -# "${COMMON_SOURCE_DIR}/nullpo.c" - "${COMMON_SOURCE_DIR}/plugins.c" -# "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/sql.c" - "${COMMON_SOURCE_DIR}/strlib.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" +if( HAVE_common_sql ) +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( CHAR_SOURCES - "char.c" - "int_auction.c" - "int_guild.c" - "int_homun.c" - "int_mail.c" - "int_mercenary.c" - "int_party.c" - "int_pet.c" - "int_quest.c" - "int_storage.c" - "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" ) - - -# -# char sql -# -if( USE_ZLIB AND USE_MYSQL ) -message ( STATUS "Creating target char-server_sql" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +set( DEPENDENCIES common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${CHAR_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ) -source_group( char FILES ${CHAR_SOURCES} ) +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} ) -target_link_libraries( char-server_sql ${LIBRARIES} ) +add_dependencies( char-server_sql ${DEPENDENCIES} ) +target_link_libraries( char-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( char-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS char-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "char-server_sql" ) endif() -message ( STATUS "Creating target char-server_sql - done" ) +message( STATUS "Creating target char-server_sql - done" ) +set( HAVE_char-server_sql ON CACHE BOOL "char-server_sql target is available" ) +mark_as_advanced( HAVE_char-server_sql ) else() -message ( STATUS "Skipping target char-server_sql (requires ZLIB and MYSQL)" ) +message( STATUS "Skipping target char-server_sql (requires common_sql)" ) +unset( HAVE_char-server_sql CACHE ) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7a4443abc..0241dfbca 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,13 +1,5 @@ -set( COMMON_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" - CACHE PATH "common include directories" ) -set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" - CACHE PATH "common source directory" ) -mark_as_advanced( COMMON_INCLUDE_DIRS ) -mark_as_advanced( COMMON_SOURCE_DIR ) - - -# +##################################################################### # Find svnversion # message( STATUS "Detecting svnversion" ) @@ -31,10 +23,133 @@ if( SVNVERSION ) else() file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "" ) endif() -set( GLOBAL_INCLUDE_DIRS "${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "" ) +set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "" ) set( SVNVERSION ${SVNVERSION} CACHE STRING "SVN version of the source code" ) if( INSTALL_BUILD_DATA ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h DESTINATION ${CMAKE_INSTALL_PREFIX}/src/common ) endif() message( STATUS "Creating svnversion.h - done" ) + +##################################################################### +# setup +# +set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + CACHE PATH "common source directory" ) +mark_as_advanced( COMMON_SOURCE_DIR ) + +set( COMMON_ALL_HEADERS + "${CMAKE_CURRENT_BINARY_DIR}/svnversion.h" + "${COMMON_SOURCE_DIR}/cbasetypes.h" + "${COMMON_SOURCE_DIR}/mmo.h" + "${COMMON_SOURCE_DIR}/plugin.h" + "${COMMON_SOURCE_DIR}/version.h" + ) + +set( COMMON_MINI_HEADERS + ${COMMON_ALL_HEADERS} + "${COMMON_SOURCE_DIR}/core.h" + "${COMMON_SOURCE_DIR}/malloc.h" + "${COMMON_SOURCE_DIR}/showmsg.h" + "${COMMON_SOURCE_DIR}/strlib.h" + CACHE INTERNAL "" ) +set( COMMON_MINI_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/malloc.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/strlib.c" + CACHE INTERNAL "" ) +set( COMMON_MINI_DEFINITIONS MINICORE CACHE INTERNAL "" ) + + +# +# common_base +# +if( USE_ZLIB ) +message( STATUS "Creating target common_base" ) +set( COMMON_BASE_HEADERS + ${COMMON_ALL_HEADERS} + "${COMMON_SOURCE_DIR}/core.h" + "${COMMON_SOURCE_DIR}/db.h" + "${COMMON_SOURCE_DIR}/ers.h" + "${COMMON_SOURCE_DIR}/grfio.h" + "${COMMON_SOURCE_DIR}/lock.h" + "${COMMON_SOURCE_DIR}/malloc.h" + "${COMMON_SOURCE_DIR}/mapindex.h" + "${COMMON_SOURCE_DIR}/md5calc.h" + "${COMMON_SOURCE_DIR}/nullpo.h" + "${COMMON_SOURCE_DIR}/plugins.h" + "${COMMON_SOURCE_DIR}/random.h" + "${COMMON_SOURCE_DIR}/showmsg.h" + "${COMMON_SOURCE_DIR}/socket.h" + "${COMMON_SOURCE_DIR}/strlib.h" + "${COMMON_SOURCE_DIR}/timer.h" + "${COMMON_SOURCE_DIR}/utils.h" + CACHE INTERNAL "common_base headers" ) +set( COMMON_BASE_SOURCES + "${COMMON_SOURCE_DIR}/core.c" + "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/ers.c" + "${COMMON_SOURCE_DIR}/grfio.c" + "${COMMON_SOURCE_DIR}/lock.c" + "${COMMON_SOURCE_DIR}/malloc.c" + "${COMMON_SOURCE_DIR}/mapindex.c" + "${COMMON_SOURCE_DIR}/md5calc.c" + "${COMMON_SOURCE_DIR}/nullpo.c" + "${COMMON_SOURCE_DIR}/plugins.c" + "${COMMON_SOURCE_DIR}/random.c" + "${COMMON_SOURCE_DIR}/showmsg.c" + "${COMMON_SOURCE_DIR}/socket.c" + "${COMMON_SOURCE_DIR}/strlib.c" + "${COMMON_SOURCE_DIR}/timer.c" + "${COMMON_SOURCE_DIR}/utils.c" + CACHE INTERNAL "common_base sources" ) +set( LIBRARIES ${ZLIB_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +set( SOURCE_FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) +source_group( mt19937ar FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ) +source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) +add_library( common_base ${SOURCE_FILES} ) +target_link_libraries( common_base ${LIBRARIES} ) +set_target_properties( common_base PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +include_directories( ${INCLUDE_DIRS} ) +message( STATUS "Creating target common_base - done" ) +set( HAVE_common_base ON CACHE BOOL "common_base target is available" ) +mark_as_advanced( HAVE_common_base ) +else() +message( STATUS "Skipping target common_base (requires ZLIB)" ) +unset( HAVE_common_base CACHE ) +endif() + + +# +# common_sql +# +if( HAVE_common_base AND USE_MYSQL ) +message( STATUS "Creating target common_sql" ) +set( COMMON_SQL_HEADERS + ${COMMON_ALL_HEADERS} + "${CMAKE_CURRENT_SOURCE_DIR}/sql.h" + CACHE INTERNAL "common_sql headers" ) +set( COMMON_SQL_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/sql.c" + CACHE INTERNAL "common_sql sources" ) +set( DEPENDENCIES common_base ) +set( LIBRARIES ${MYSQL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +set( SOURCE_FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) +source_group( common FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) +add_library( common_sql ${SOURCE_FILES} ) +add_dependencies( common_sql ${DEPENDENCIES} ) +target_link_libraries( common_sql ${LIBRARIES} ${DEPENDENCIES} ) +set_target_properties( common_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +include_directories( ${INCLUDE_DIRS} ) +message( STATUS "Creating target common_sql - done" ) +set( HAVE_common_sql ON CACHE BOOL "common_sql target is available" ) +mark_as_advanced( HAVE_common_sql ) +else() +message( STATUS "Skipping target common_sql (requires common_base and MYSQL)" ) +unset( HAVE_common_sql CACHE ) +endif() diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt index 82390ebd8..afa4e5f20 100644 --- a/src/login/CMakeLists.txt +++ b/src/login/CMakeLists.txt @@ -2,43 +2,7 @@ # # setup # -set( MT19937AR_SOURCES - "${MT19937AR_SOURCE_DIR}/mt19937ar.c" - ) -set( COMMON_SOURCES - "${COMMON_SOURCE_DIR}/core.c" - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/ers.c" -# "${COMMON_SOURCE_DIR}/grfio.c" - "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/malloc.c" -# "${COMMON_SOURCE_DIR}/mapindex.c" - "${COMMON_SOURCE_DIR}/md5calc.c" -# "${COMMON_SOURCE_DIR}/nullpo.c" - "${COMMON_SOURCE_DIR}/plugins.c" - "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/strlib.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" - ) -set( COMMON_SQL_SOURCES - "${COMMON_SOURCE_DIR}/sql.c" - ) -set( LOGIN_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/login.c" - ) -set( LOGIN_TXT_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/account_txt.c" - "${CMAKE_CURRENT_SOURCE_DIR}/ipban_txt.c" - "${CMAKE_CURRENT_SOURCE_DIR}/loginlog_txt.c" - ) -set( LOGIN_SQL_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/account_sql.c" - "${CMAKE_CURRENT_SOURCE_DIR}/ipban_sql.c" - "${CMAKE_CURRENT_SOURCE_DIR}/loginlog_sql.c" - ) +set( LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # diff --git a/src/login/sql/CMakeLists.txt b/src/login/sql/CMakeLists.txt index 3cecb8840..50bf256e2 100644 --- a/src/login/sql/CMakeLists.txt +++ b/src/login/sql/CMakeLists.txt @@ -2,33 +2,41 @@ # # login sql # -if( USE_ZLIB AND USE_MYSQL ) -message ( STATUS "Creating target login-server_sql" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +if( HAVE_common_sql ) +message( STATUS "Creating target login-server_sql" ) +set( SQL_LOGIN_HEADERS + "${LOGIN_SOURCE_DIR}/account.h" + "${LOGIN_SOURCE_DIR}/ipban.h" + "${LOGIN_SOURCE_DIR}/login.h" + "${LOGIN_SOURCE_DIR}/loginlog.h" + ) +set( SQL_LOGIN_SOURCES + "${LOGIN_SOURCE_DIR}/account_sql.c" + "${LOGIN_SOURCE_DIR}/ipban_sql.c" + "${LOGIN_SOURCE_DIR}/login.c" + "${LOGIN_SOURCE_DIR}/loginlog_sql.c" + ) +set( DEPENDENCIES common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_SQL ) -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ${LOGIN_SOURCES} ${LOGIN_SQL_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ) -source_group( login FILES ${LOGIN_SOURCES} ${LOGIN_SQL_SOURCES} ) +set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) +source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) +source_group( login FILES ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) include_directories( ${INCLUDE_DIRS} ) add_executable( login-server_sql ${SOURCE_FILES} ) -target_link_libraries( login-server_sql ${LIBRARIES} ) +add_dependencies( login-server_sql ${DEPENDENCIES} ) +target_link_libraries( login-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( login-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS login-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "login-server_sql" ) endif() -message ( STATUS "Creating target login-server_sql - done" ) +message( STATUS "Creating target login-server_sql - done" ) +set( HAVE_login-server_sql ON CACHE BOOL "login-server_sql target is available" ) +mark_as_advanced( HAVE_login-server_sql ) else() -message ( STATUS "Skipping target login-server_sql (requires ZLIB and MYSQL)" ) +message( STATUS "Skipping target login-server_sql (requires common_sql)" ) +unset( HAVE_login-server_sql CACHE ) endif() diff --git a/src/login/txt/CMakeLists.txt b/src/login/txt/CMakeLists.txt index 0c567f9e2..dff7d322c 100644 --- a/src/login/txt/CMakeLists.txt +++ b/src/login/txt/CMakeLists.txt @@ -2,33 +2,41 @@ # # login txt # -if( USE_ZLIB ) -message ( STATUS "Creating target login-server" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +if( HAVE_common_base ) +message( STATUS "Creating target login-server" ) +set( TXT_LOGIN_HEADERS + "${LOGIN_SOURCE_DIR}/account.h" + "${LOGIN_SOURCE_DIR}/ipban.h" + "${LOGIN_SOURCE_DIR}/login.h" + "${LOGIN_SOURCE_DIR}/loginlog.h" + ) +set( TXT_LOGIN_SOURCES + "${LOGIN_SOURCE_DIR}/account_txt.c" + "${LOGIN_SOURCE_DIR}/ipban_txt.c" + "${LOGIN_SOURCE_DIR}/login.c" + "${LOGIN_SOURCE_DIR}/loginlog_txt.c" + ) +set( DEPENDENCIES common_base ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_TXT ) -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${LOGIN_SOURCES} ${LOGIN_TXT_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ) -source_group( login FILES ${LOGIN_SOURCES} ${LOGIN_TXT_SOURCES} ) +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} ) -target_link_libraries( login-server ${LIBRARIES} ) +add_dependencies( login-server ${DEPENDENCIES} ) +target_link_libraries( login-server ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( login-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS login-server DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "login-server" ) endif() -message ( STATUS "Creating target login-server - done" ) +message( STATUS "Creating target login-server - done" ) +set( HAVE_login-server ON CACHE BOOL "login-server target is available" ) +mark_as_advanced( HAVE_login-server ) else() -message ( STATUS "Skipping target login-server (requires ZLIB)" ) +message( STATUS "Skipping target login-server (requires common_base)" ) +unset( HAVE_login-server CACHE ) endif() diff --git a/src/map/CMakeLists.txt b/src/map/CMakeLists.txt index 4ff85fa19..9199702be 100644 --- a/src/map/CMakeLists.txt +++ b/src/map/CMakeLists.txt @@ -2,72 +2,7 @@ # # setup # -set( MT19937AR_SOURCES - "${MT19937AR_SOURCE_DIR}/mt19937ar.c" - ) -set( COMMON_SOURCES - "${COMMON_SOURCE_DIR}/core.c" - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/ers.c" - "${COMMON_SOURCE_DIR}/grfio.c" - "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/malloc.c" - "${COMMON_SOURCE_DIR}/mapindex.c" - "${COMMON_SOURCE_DIR}/md5calc.c" - "${COMMON_SOURCE_DIR}/nullpo.c" - "${COMMON_SOURCE_DIR}/plugins.c" - "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/strlib.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" - ) -set( COMMON_SQL_SOURCES - "${COMMON_SOURCE_DIR}/sql.c" - ) -set( MAP_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/atcommand.c" - "${CMAKE_CURRENT_SOURCE_DIR}/battle.c" - "${CMAKE_CURRENT_SOURCE_DIR}/battleground.c" - "${CMAKE_CURRENT_SOURCE_DIR}/buyingstore.c" - "${CMAKE_CURRENT_SOURCE_DIR}/chat.c" - "${CMAKE_CURRENT_SOURCE_DIR}/chrif.c" - "${CMAKE_CURRENT_SOURCE_DIR}/clif.c" - "${CMAKE_CURRENT_SOURCE_DIR}/date.c" - "${CMAKE_CURRENT_SOURCE_DIR}/duel.c" - "${CMAKE_CURRENT_SOURCE_DIR}/guild.c" - "${CMAKE_CURRENT_SOURCE_DIR}/homunculus.c" - "${CMAKE_CURRENT_SOURCE_DIR}/instance.c" - "${CMAKE_CURRENT_SOURCE_DIR}/intif.c" - "${CMAKE_CURRENT_SOURCE_DIR}/itemdb.c" - "${CMAKE_CURRENT_SOURCE_DIR}/log.c" - "${CMAKE_CURRENT_SOURCE_DIR}/mail.c" - "${CMAKE_CURRENT_SOURCE_DIR}/map.c" - "${CMAKE_CURRENT_SOURCE_DIR}/mercenary.c" - "${CMAKE_CURRENT_SOURCE_DIR}/mob.c" - "${CMAKE_CURRENT_SOURCE_DIR}/npc.c" - "${CMAKE_CURRENT_SOURCE_DIR}/npc_chat.c" - "${CMAKE_CURRENT_SOURCE_DIR}/party.c" - "${CMAKE_CURRENT_SOURCE_DIR}/path.c" - "${CMAKE_CURRENT_SOURCE_DIR}/pc.c" - "${CMAKE_CURRENT_SOURCE_DIR}/pet.c" - "${CMAKE_CURRENT_SOURCE_DIR}/quest.c" - "${CMAKE_CURRENT_SOURCE_DIR}/script.c" - "${CMAKE_CURRENT_SOURCE_DIR}/searchstore.c" - "${CMAKE_CURRENT_SOURCE_DIR}/skill.c" - "${CMAKE_CURRENT_SOURCE_DIR}/status.c" - "${CMAKE_CURRENT_SOURCE_DIR}/storage.c" - "${CMAKE_CURRENT_SOURCE_DIR}/trade.c" - "${CMAKE_CURRENT_SOURCE_DIR}/unit.c" - "${CMAKE_CURRENT_SOURCE_DIR}/vending.c" - ) -set( MAP_TXT_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/mapreg_txt.c" - ) -set( MAP_SQL_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/mapreg_sql.c" - ) +set( MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index 13b1af32c..c7922f276 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -2,38 +2,108 @@ # # map sql # -if( USE_ZLIB AND USE_MYSQL ) -message ( STATUS "Creating target map-server_sql" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) +if( HAVE_common_sql ) +message( STATUS "Creating target map-server_sql" ) +set( SQL_MAP_HEADERS + "${MAP_SOURCE_DIR}/atcommand.h" + "${MAP_SOURCE_DIR}/battle.h" + "${MAP_SOURCE_DIR}/battleground.h" + "${MAP_SOURCE_DIR}/buyingstore.h" + "${MAP_SOURCE_DIR}/chat.h" + "${MAP_SOURCE_DIR}/chrif.h" + "${MAP_SOURCE_DIR}/clif.h" + "${MAP_SOURCE_DIR}/date.h" + "${MAP_SOURCE_DIR}/duel.h" + "${MAP_SOURCE_DIR}/guild.h" + "${MAP_SOURCE_DIR}/homunculus.h" + "${MAP_SOURCE_DIR}/instance.h" + "${MAP_SOURCE_DIR}/intif.h" + "${MAP_SOURCE_DIR}/itemdb.h" + "${MAP_SOURCE_DIR}/log.h" + "${MAP_SOURCE_DIR}/mail.h" + "${MAP_SOURCE_DIR}/map.h" + "${MAP_SOURCE_DIR}/mapreg.h" + "${MAP_SOURCE_DIR}/mercenary.h" + "${MAP_SOURCE_DIR}/mob.h" + "${MAP_SOURCE_DIR}/npc.h" + "${MAP_SOURCE_DIR}/party.h" + "${MAP_SOURCE_DIR}/path.h" + "${MAP_SOURCE_DIR}/pc.h" + "${MAP_SOURCE_DIR}/pet.h" + "${MAP_SOURCE_DIR}/quest.h" + "${MAP_SOURCE_DIR}/script.h" + "${MAP_SOURCE_DIR}/searchstore.h" + "${MAP_SOURCE_DIR}/skill.h" + "${MAP_SOURCE_DIR}/status.h" + "${MAP_SOURCE_DIR}/storage.h" + "${MAP_SOURCE_DIR}/trade.h" + "${MAP_SOURCE_DIR}/unit.h" + "${MAP_SOURCE_DIR}/vending.h" + ) +set( SQL_MAP_SOURCES + "${MAP_SOURCE_DIR}/atcommand.c" + "${MAP_SOURCE_DIR}/battle.c" + "${MAP_SOURCE_DIR}/battleground.c" + "${MAP_SOURCE_DIR}/buyingstore.c" + "${MAP_SOURCE_DIR}/chat.c" + "${MAP_SOURCE_DIR}/chrif.c" + "${MAP_SOURCE_DIR}/clif.c" + "${MAP_SOURCE_DIR}/date.c" + "${MAP_SOURCE_DIR}/duel.c" + "${MAP_SOURCE_DIR}/guild.c" + "${MAP_SOURCE_DIR}/homunculus.c" + "${MAP_SOURCE_DIR}/instance.c" + "${MAP_SOURCE_DIR}/intif.c" + "${MAP_SOURCE_DIR}/itemdb.c" + "${MAP_SOURCE_DIR}/log.c" + "${MAP_SOURCE_DIR}/mail.c" + "${MAP_SOURCE_DIR}/map.c" + "${MAP_SOURCE_DIR}/mapreg_sql.c" + "${MAP_SOURCE_DIR}/mercenary.c" + "${MAP_SOURCE_DIR}/mob.c" + "${MAP_SOURCE_DIR}/npc.c" + "${MAP_SOURCE_DIR}/npc_chat.c" + "${MAP_SOURCE_DIR}/party.c" + "${MAP_SOURCE_DIR}/path.c" + "${MAP_SOURCE_DIR}/pc.c" + "${MAP_SOURCE_DIR}/pet.c" + "${MAP_SOURCE_DIR}/quest.c" + "${MAP_SOURCE_DIR}/script.c" + "${MAP_SOURCE_DIR}/searchstore.c" + "${MAP_SOURCE_DIR}/skill.c" + "${MAP_SOURCE_DIR}/status.c" + "${MAP_SOURCE_DIR}/storage.c" + "${MAP_SOURCE_DIR}/trade.c" + "${MAP_SOURCE_DIR}/unit.c" + "${MAP_SOURCE_DIR}/vending.c" + ) +set( DEPENDENCIES common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) if( USE_PCRE ) message( STATUS "Using PCRE" ) list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) + list( APPEND DEFINITIONS PCRE_SUPPORT ) endif() -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ${MAP_SOURCES} ${MAP_SQL_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ${COMMON_SQL_SOURCES} ) -source_group( map FILES ${MAP_SOURCES} ${MAP_SQL_SOURCES} ) +set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_MAP_HEADERS} ${SQL_MAP_SOURCES} ) +source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) +source_group( map FILES ${SQL_MAP_HEADERS} ${SQL_MAP_SOURCES} ) include_directories( ${INCLUDE_DIRS} ) add_executable( map-server_sql ${SOURCE_FILES} ) -target_link_libraries( map-server_sql ${LIBRARIES} ) +add_dependencies( map-server_sql ${DEPENDENCIES} ) +target_link_libraries( map-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( map-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS map-server_sql DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "map-server_sql" ) endif() -message ( STATUS "Creating target map-server_sql - done" ) +message( STATUS "Creating target map-server_sql - done" ) +set( HAVE_map-server_sql ON CACHE BOOL "map-server_sql target is available" ) +mark_as_advanced( HAVE_map-server_sql ) else() -message ( STATUS "Skipping target map-server_sql (requires ZLIB and MYSQL; optional PCRE)" ) +message( STATUS "Skipping target map-server_sql (requires common_sql; optional PCRE)" ) +unset( HAVE_map-server_sql CACHE ) endif() diff --git a/src/map/txt/CMakeLists.txt b/src/map/txt/CMakeLists.txt index f62885b7a..544e00c87 100644 --- a/src/map/txt/CMakeLists.txt +++ b/src/map/txt/CMakeLists.txt @@ -2,38 +2,108 @@ # # map txt # -if( USE_ZLIB ) -message ( STATUS "Creating target map-server" ) -set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) +if( HAVE_common_base ) +message( STATUS "Creating target map-server" ) +set( TXT_MAP_HEADERS + "${MAP_SOURCE_DIR}/atcommand.h" + "${MAP_SOURCE_DIR}/battle.h" + "${MAP_SOURCE_DIR}/battleground.h" + "${MAP_SOURCE_DIR}/buyingstore.h" + "${MAP_SOURCE_DIR}/chat.h" + "${MAP_SOURCE_DIR}/chrif.h" + "${MAP_SOURCE_DIR}/clif.h" + "${MAP_SOURCE_DIR}/date.h" + "${MAP_SOURCE_DIR}/duel.h" + "${MAP_SOURCE_DIR}/guild.h" + "${MAP_SOURCE_DIR}/homunculus.h" + "${MAP_SOURCE_DIR}/instance.h" + "${MAP_SOURCE_DIR}/intif.h" + "${MAP_SOURCE_DIR}/itemdb.h" + "${MAP_SOURCE_DIR}/log.h" + "${MAP_SOURCE_DIR}/mail.h" + "${MAP_SOURCE_DIR}/map.h" + "${MAP_SOURCE_DIR}/mapreg.h" + "${MAP_SOURCE_DIR}/mercenary.h" + "${MAP_SOURCE_DIR}/mob.h" + "${MAP_SOURCE_DIR}/npc.h" + "${MAP_SOURCE_DIR}/party.h" + "${MAP_SOURCE_DIR}/path.h" + "${MAP_SOURCE_DIR}/pc.h" + "${MAP_SOURCE_DIR}/pet.h" + "${MAP_SOURCE_DIR}/quest.h" + "${MAP_SOURCE_DIR}/script.h" + "${MAP_SOURCE_DIR}/searchstore.h" + "${MAP_SOURCE_DIR}/skill.h" + "${MAP_SOURCE_DIR}/status.h" + "${MAP_SOURCE_DIR}/storage.h" + "${MAP_SOURCE_DIR}/trade.h" + "${MAP_SOURCE_DIR}/unit.h" + "${MAP_SOURCE_DIR}/vending.h" + ) +set( TXT_MAP_SOURCES + "${MAP_SOURCE_DIR}/atcommand.c" + "${MAP_SOURCE_DIR}/battle.c" + "${MAP_SOURCE_DIR}/battleground.c" + "${MAP_SOURCE_DIR}/buyingstore.c" + "${MAP_SOURCE_DIR}/chat.c" + "${MAP_SOURCE_DIR}/chrif.c" + "${MAP_SOURCE_DIR}/clif.c" + "${MAP_SOURCE_DIR}/date.c" + "${MAP_SOURCE_DIR}/duel.c" + "${MAP_SOURCE_DIR}/guild.c" + "${MAP_SOURCE_DIR}/homunculus.c" + "${MAP_SOURCE_DIR}/instance.c" + "${MAP_SOURCE_DIR}/intif.c" + "${MAP_SOURCE_DIR}/itemdb.c" + "${MAP_SOURCE_DIR}/log.c" + "${MAP_SOURCE_DIR}/mail.c" + "${MAP_SOURCE_DIR}/map.c" + "${MAP_SOURCE_DIR}/mapreg_txt.c" + "${MAP_SOURCE_DIR}/mercenary.c" + "${MAP_SOURCE_DIR}/mob.c" + "${MAP_SOURCE_DIR}/npc.c" + "${MAP_SOURCE_DIR}/npc_chat.c" + "${MAP_SOURCE_DIR}/party.c" + "${MAP_SOURCE_DIR}/path.c" + "${MAP_SOURCE_DIR}/pc.c" + "${MAP_SOURCE_DIR}/pet.c" + "${MAP_SOURCE_DIR}/quest.c" + "${MAP_SOURCE_DIR}/script.c" + "${MAP_SOURCE_DIR}/searchstore.c" + "${MAP_SOURCE_DIR}/skill.c" + "${MAP_SOURCE_DIR}/status.c" + "${MAP_SOURCE_DIR}/storage.c" + "${MAP_SOURCE_DIR}/trade.c" + "${MAP_SOURCE_DIR}/unit.c" + "${MAP_SOURCE_DIR}/vending.c" + ) +set( DEPENDENCIES common_base ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) if( USE_PCRE ) message( STATUS "Using PCRE" ) list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) + list( APPEND DEFINITIONS PCRE_SUPPORT ) endif() -if( PACKETVER ) - message( STATUS "Using PACKETVER=${PACKETVER}" ) - list( APPEND DEFINITIONS PACKETVER=${PACKETVER} ) -endif() -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${MT19937AR_SOURCES} ${COMMON_SOURCES} ${MAP_SOURCES} ${MAP_TXT_SOURCES} ) -source_group( 3rdparty FILES ${MT19937AR_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ) -source_group( map FILES ${MAP_SOURCES} ${MAP_TXT_SOURCES} ) +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} ) -target_link_libraries( map-server ${LIBRARIES} ) +add_dependencies( map-server ${DEPENDENCIES} ) +target_link_libraries( map-server ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( map-server PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( INSTALL_RUN_DATA ) install( TARGETS map-server DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "map-server" ) endif() -message ( STATUS "Creating target map-server - done" ) +message( STATUS "Creating target map-server - done" ) +set( HAVE_map-server ON CACHE BOOL "map-server target is available" ) +mark_as_advanced( HAVE_map-server ) else() -message ( STATUS "Skipping target map-server (requires ZLIB; optional PCRE)" ) +message( STATUS "Skipping target map-server (requires common_base; optional PCRE)" ) +unset( HAVE_map-server CACHE ) endif() diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index 4f69174b9..e39b174dd 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -25,16 +25,25 @@ set( MAPCACHE_SOURCES # mapcache if( USE_ZLIB ) -message ( STATUS "Creating target mapcache" ) +message( STATUS "Creating target mapcache" ) +set( COMMON_HEADERS + ${COMMON_MINI_HEADERS} + "${COMMON_SOURCE_DIR}/grfio.h" + "${COMMON_SOURCE_DIR}/utils.h" + ) +set( COMMON_SOURCES + ${COMMON_MINI_SOURCES} + "${COMMON_SOURCE_DIR}/grfio.c" + "${COMMON_SOURCE_DIR}/utils.c" + ) +set( MAPCACHE_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c" + ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} MINICORE ) -if( WIN32 ) - list( APPEND LIBRARIES "oldnames.lib" "ws2_32.lib" ) - list( APPEND INCLUDE_DIRS ${MSINTTYPES_INCLUDE_DIRS} ) -endif() -set( SOURCE_FILES ${COMMON_SOURCES} ${MAPCACHE_SOURCES} ) -source_group( common FILES ${COMMON_SOURCES} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) +set( DEFINITIONS ${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} ) +set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${MAPCACHE_SOURCES} ) +source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) source_group( mapcache FILES ${MAPCACHE_SOURCES} ) add_executable( mapcache ${SOURCE_FILES} ) include_directories( ${INCLUDE_DIRS} ) @@ -45,7 +54,10 @@ if( INSTALL_RUN_DATA ) DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT "mapcache" ) endif() -message ( STATUS "Creating target mapcache - done" ) +message( STATUS "Creating target mapcache - done" ) +set( HAVE_mapcache ON CACHE BOOL "mapcache target is available" ) +mark_as_advanced( HAVE_mapcache ) else() -message ( STATUS "Skipping target mapcache (requires ZLIB)" ) +message( STATUS "Skipping target mapcache (requires ZLIB)" ) +unset( HAVE_mapcache CACHE ) endif() -- cgit v1.2.3-70-g09d2 From 76d7c8ad887ac7b9dfdb495fe26ef8d4d8dfe370 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Thu, 7 Jul 2011 03:21:42 +0000 Subject: * CMake: normalized variable names, added ability to create a package/installer. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14890 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 20 +-- 3rdparty/mysql/CMakeLists.txt | 6 +- 3rdparty/pcre/CMakeLists.txt | 4 +- 3rdparty/zlib/CMakeLists.txt | 4 +- CMakeLists.txt | 380 ++++++++++++++++-------------------------- Changelog-Trunk.txt | 1 + src/char/CMakeLists.txt | 7 +- src/char_sql/CMakeLists.txt | 7 +- src/common/CMakeLists.txt | 25 +-- src/login/sql/CMakeLists.txt | 7 +- src/login/txt/CMakeLists.txt | 7 +- src/map/sql/CMakeLists.txt | 9 +- src/map/txt/CMakeLists.txt | 9 +- src/tool/CMakeLists.txt | 35 +--- 14 files changed, 206 insertions(+), 315 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 0ea359186..3e7cb4cc4 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -8,20 +8,20 @@ # ${name}_SYSTEM_LIBRARIES - libraries of the system version # ${name}_SYSTEM_INCLUDE_DIRS - include directories of the system version # Generates: -# USE_LOCAL_${name} - use the local version of the package (only when local is available) -# USE_${name} - use this package +# WITH_LOCAL_${name} - use the local version of the package (only when local is available) +# WITH_${name} - use this package # ${name}_LIBRARIES - libraries # ${name}_INCLUDE_DIRS - include directories -macro( CONFIGURE_USE_LOCAL_OR_SYSTEM name ) +macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) unset( ${name}_LIBRARIES CACHE ) unset( ${name}_INCLUDE_DIRS CACHE ) if( HAVE_LOCAL_${name} ) - set( USE_LOCAL_${name} ON + set( WITH_LOCAL_${name} ON CACHE BOOL "use local version of ${name}" ) else() - unset( USE_LOCAL_${name} CACHE ) + unset( WITH_LOCAL_${name} CACHE ) endif() - if( USE_LOCAL_${name} ) + if( WITH_LOCAL_${name} ) message( STATUS "Configuring for local ${name}" ) set( ${name}_LIBRARIES ${${name}_LOCAL_LIBRARIES} ) set( ${name}_INCLUDE_DIRS ${${name}_LOCAL_INCLUDE_DIRS} ) @@ -32,11 +32,11 @@ macro( CONFIGURE_USE_LOCAL_OR_SYSTEM name ) set( ${name}_INCLUDE_DIRS ${${name}_SYSTEM_INCLUDE_DIRS} ) message( STATUS "Configuring for system ${name} - done" ) endif() - if( USE_LOCAL_${name} OR HAVE_SYSTEM_${name} ) - set( USE_${name} ON + if( WITH_LOCAL_${name} OR HAVE_SYSTEM_${name} ) + set( WITH_${name} ON CACHE BOOL "use ${name}" ) else() - unset( USE_${name} CACHE ) + unset( WITH_${name} CACHE ) endif() set( ${name}_LIBRARIES ${${name}_LIBRARIES} CACHE PATH "${name} libraries" ) @@ -44,7 +44,7 @@ macro( CONFIGURE_USE_LOCAL_OR_SYSTEM name ) CACHE PATH "${name} include directories" ) mark_as_advanced( ${name}_LIBRARIES ) mark_as_advanced( ${name}_INCLUDE_DIRS ) -endmacro( CONFIGURE_USE_LOCAL_OR_SYSTEM ) +endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) add_subdirectory( msinttypes ) diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index 902037f07..3f792281c 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -24,6 +24,7 @@ if( MYSQL_LOCAL_LIBRARIES AND MYSQL_LOCAL_INCLUDE_DIRS ) endif() set( HAVE_LOCAL_MYSQL ON CACHE BOOL "mysql client is available as a local copy") + mark_as_advanced( HAVE_LOCAL_MYSQL ) else() foreach( _VAR MYSQL_LOCAL_LIBRARIES MYSQL_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) @@ -70,6 +71,9 @@ mark_as_advanced( MYSQL_SYSTEM_INCLUDE_DIRS ) if( MYSQL_SYSTEM_LIBRARIES AND MYSQL_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_MYSQL ON CACHE BOOL "mysql client is available on the system" ) + mark_as_advanced( HAVE_SYSTEM_MYSQL ) +else() + unset( HAVE_SYSTEM_MYSQL CACHE ) endif() message( STATUS "Detecting system MYSQL - done" ) @@ -77,4 +81,4 @@ message( STATUS "Detecting system MYSQL - done" ) # # configure # -CONFIGURE_USE_LOCAL_OR_SYSTEM( MYSQL ) +CONFIGURE_WITH_LOCAL_OR_SYSTEM( MYSQL ) diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt index ab1c83b6d..70448d40e 100644 --- a/3rdparty/pcre/CMakeLists.txt +++ b/3rdparty/pcre/CMakeLists.txt @@ -21,6 +21,7 @@ if( PCRE_LOCAL_LIBRARIES AND PCRE_LOCAL_INCLUDE_DIRS ) message( STATUS "Found PCRE: ${PCRE_LOCAL_LIBRARIES} (found version ${PCRE_MAJOR}.${PCRE_MINOR})" ) set( HAVE_LOCAL_PCRE ON CACHE BOOL "pcre is available as a local copy" ) + mark_as_advanced( HAVE_LOCAL_PCRE ) else() foreach( _VAR PCRE_LOCAL_LIBRARIES PCRE_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) @@ -52,6 +53,7 @@ mark_as_advanced( PCRE_SYSTEM_INCLUDE_DIRS ) if( PCRE_SYSTEM_LIBRARIES AND PCRE_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_PCRE ON CACHE BOOL "pcre is available on the system" ) + mark_as_advanced( HAVE_SYSTEM_PCRE ) else() unset( HAVE_SYSTEM_PCRE CACHE ) endif() @@ -61,4 +63,4 @@ message( STATUS "Detecting system PCRE - done" ) # # configure # -CONFIGURE_USE_LOCAL_OR_SYSTEM( PCRE ) +CONFIGURE_WITH_LOCAL_OR_SYSTEM( PCRE ) diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 3bb4304e7..4002908f5 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -20,6 +20,7 @@ if( ZLIB_LOCAL_LIBRARIES AND ZLIB_LOCAL_INCLUDE_DIRS ) message( STATUS "Found local ZLIB: ${ZLIB_LOCAL_LIBRARIES} (found version ${ZLIB_VERSION})" ) set( HAVE_LOCAL_ZLIB ON CACHE BOOL "zlib is available as a local copy" ) + mark_as_advanced( HAVE_LOCAL_ZLIB ) else() foreach( _VAR ZLIB_LOCAL_LIBRARIES ZLIB_LOCAL_INCLUDE_DIRS ) if( NOT "${_VAR}" ) @@ -50,6 +51,7 @@ mark_as_advanced( ZLIB_SYSTEM_INCLUDE_DIRS ) if( ZLIB_SYSTEM_LIBRARIES AND ZLIB_SYSTEM_INCLUDE_DIRS ) set( HAVE_SYSTEM_ZLIB ON CACHE BOOL "zlib is available on the system" ) + mark_as_advanced( HAVE_SYSTEM_ZLIB ) else() unset( HAVE_SYSTEM_ZLIB CACHE ) endif() @@ -59,4 +61,4 @@ message( STATUS "Detecting system ZLIB - done" ) # # configure # -CONFIGURE_USE_LOCAL_OR_SYSTEM( ZLIB ) +CONFIGURE_WITH_LOCAL_OR_SYSTEM( ZLIB ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59529c442..953c804ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ # Part 4 of 6: http://www.youtube.com/watch?v=JICZOkyNXbg # Part 5 of 6: http://www.youtube.com/watch?v=lAiuLHy4dCk # Part 6 of 6: http://www.youtube.com/watch?v=fAtJNzDZdH8 +# +# You can use notepad++ for syntax highlighting. +# Naming conventions: +# WITH_* : option to use an external package or not +# ENABLE_* : option to use an internal feature/code or not +# HAVE_* : internal variable indicating if we have and are using something cmake_minimum_required( VERSION 2.8.4 ) project( eAthena ) @@ -19,218 +25,134 @@ elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" ) endif() -# -# Debug stuff -# -if( NOT SKIP_DEBUG ) -message( "DEBUG: # Variables That Change Behavior" ) -message( "DEBUG: BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}" ) -message( "DEBUG: CMAKE_BACKWARDS_COMPATIBILITY=${CMAKE_BACKWARDS_COMPATIBILITY}" ) -message( "DEBUG: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ) -message( "DEBUG: CMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE}" ) -message( "DEBUG: CMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" ) -message( "DEBUG: CMAKE_FIND_LIBRARY_PREFIXES=${CMAKE_FIND_LIBRARY_PREFIXES}" ) -message( "DEBUG: CMAKE_FIND_LIBRARY_SUFFIXES=${CMAKE_FIND_LIBRARY_SUFFIXES}" ) -message( "DEBUG: CMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}" ) -message( "DEBUG: CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" ) -message( "DEBUG: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" ) -message( "DEBUG: CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" ) -message( "DEBUG: CMAKE_MFC_FLAG=${CMAKE_MFC_FLAG}" ) -message( "DEBUG: CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" ) -message( "DEBUG: CMAKE_NOT_USING_CONFIG_FLAGS=${CMAKE_NOT_USING_CONFIG_FLAGS}" ) -message( "DEBUG: CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) -message( "DEBUG: CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}" ) -message( "DEBUG: CMAKE_SKIP_INSTALL_ALL_DEPENDENCY=${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY}" ) -message( "DEBUG: CMAKE_SYSTEM_IGNORE_PATH=${CMAKE_SYSTEM_IGNORE_PATH}" ) -message( "DEBUG: CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}" ) -message( "DEBUG: CMAKE_SYSTEM_LIBRARY_PATH=${CMAKE_SYSTEM_LIBRARY_PATH}" ) -message( "DEBUG: CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}" ) -message( "DEBUG: CMAKE_SYSTEM_PROGRAM_PATH=${CMAKE_SYSTEM_PROGRAM_PATH}" ) -message( "DEBUG: CMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}" ) -message( "DEBUG: # Variables That Describe the System" ) -message( "DEBUG: APPLE=${APPLE}" ) -message( "DEBUG: BORLAND=${BORLAND}" ) -message( "DEBUG: CMAKE_CL_64=${CMAKE_CL_64}" ) -message( "DEBUG: CMAKE_COMPILER_2005=${CMAKE_COMPILER_2005}" ) -message( "DEBUG: CMAKE_HOST_APPLE=${CMAKE_HOST_APPLE}" ) -message( "DEBUG: CMAKE_HOST_SYSTEM=${CMAKE_HOST_SYSTEM}" ) -message( "DEBUG: CMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}" ) -message( "DEBUG: CMAKE_HOST_SYSTEM_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR}" ) -message( "DEBUG: CMAKE_HOST_SYSTEM_VERSION=${CMAKE_HOST_SYSTEM_VERSION}" ) -message( "DEBUG: CMAKE_HOST_UNIX=${CMAKE_HOST_UNIX}" ) -message( "DEBUG: CMAKE_HOST_WIN32=${CMAKE_HOST_WIN32}" ) -message( "DEBUG: CMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}" ) -message( "DEBUG: CMAKE_SYSTEM=${CMAKE_SYSTEM}" ) -message( "DEBUG: CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" ) -message( "DEBUG: CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}" ) -message( "DEBUG: CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}" ) -message( "DEBUG: CYGWIN=${CYGWIN}" ) -message( "DEBUG: MSVC=${MSVC}" ) -message( "DEBUG: MSVC80=${MSVC80}" ) -message( "DEBUG: MSVC_IDE=${MSVC_IDE}" ) -message( "DEBUG: MSVC_VERSION=${MSVC_VERSION}" ) -message( "DEBUG: UNIX=${UNIX}" ) -message( "DEBUG: WIN32=${WIN32}" ) -message( "DEBUG: XCODE_VERSION=${XCODE_VERSION}" ) -message( "DEBUG: # Variables that Control the Build" ) -message( "DEBUG: CMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" ) -message( "DEBUG: CMAKE_BUILD_WITH_INSTALL_RPATH=${CMAKE_BUILD_WITH_INSTALL_RPATH}" ) -message( "DEBUG: CMAKE_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX}" ) -message( "DEBUG: CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" ) -message( "DEBUG: CMAKE_INCLUDE_CURRENT_DIR=${CMAKE_INCLUDE_CURRENT_DIR}" ) -message( "DEBUG: CMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_NAME_DIR}" ) -message( "DEBUG: CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" ) -message( "DEBUG: CMAKE_INSTALL_RPATH_USE_LINK_PATH=${CMAKE_INSTALL_RPATH_USE_LINK_PATH}" ) -message( "DEBUG: CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" ) -message( "DEBUG: CMAKE_LIBRARY_PATH_FLAG=${CMAKE_LIBRARY_PATH_FLAG}" ) -message( "DEBUG: CMAKE_LINK_DEF_FILE_FLAG=${CMAKE_LINK_DEF_FILE_FLAG}" ) -message( "DEBUG: CMAKE_LINK_LIBRARY_FILE_FLAG=${CMAKE_LINK_LIBRARY_FILE_FLAG}" ) -message( "DEBUG: CMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}" ) -message( "DEBUG: CMAKE_NO_BUILTIN_CHRPATH=${CMAKE_NO_BUILTIN_CHRPATH}" ) -message( "DEBUG: CMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) -message( "DEBUG: CMAKE_SKIP_BUILD_RPATH=${CMAKE_SKIP_BUILD_RPATH}" ) -message( "DEBUG: CMAKE_TRY_COMPILE_CONFIGURATION=${CMAKE_TRY_COMPILE_CONFIGURATION}" ) -message( "DEBUG: CMAKE_USE_RELATIVE_PATHS=${CMAKE_USE_RELATIVE_PATHS}" ) -message( "DEBUG: EXECUTABLE_OUTPUT_PATH=${EXECUTABLE_OUTPUT_PATH}" ) -message( "DEBUG: LIBRARY_OUTPUT_PATH=${LIBRARY_OUTPUT_PATH}" ) -message( "DEBUG: # Variables that Provide Information" ) -message( "DEBUG: CMAKE_AR=${CMAKE_AR}" ) -message( "DEBUG: CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" ) -message( "DEBUG: CMAKE_BUILD_TOOL=${CMAKE_BUILD_TOOL}" ) -message( "DEBUG: CMAKE_CACHEFILE_DIR=${CMAKE_CACHEFILE_DIR}" ) -message( "DEBUG: CMAKE_CACHE_MAJOR_VERSION=${CMAKE_CACHE_MAJOR_VERSION}" ) -message( "DEBUG: CMAKE_CACHE_MINOR_VERSION=${CMAKE_CACHE_MINOR_VERSION}" ) -message( "DEBUG: CMAKE_CACHE_PATCH_VERSION=${CMAKE_CACHE_PATCH_VERSION}" ) -message( "DEBUG: CMAKE_CFG_INTDIR=${CMAKE_CFG_INTDIR}" ) -message( "DEBUG: CMAKE_COMMAND=${CMAKE_COMMAND}" ) -message( "DEBUG: CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}" ) -message( "DEBUG: CMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}" ) -message( "DEBUG: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" ) -message( "DEBUG: CMAKE_CURRENT_LIST_DIR=${CMAKE_CURRENT_LIST_DIR}" ) -message( "DEBUG: CMAKE_CURRENT_LIST_FILE=${CMAKE_CURRENT_LIST_FILE}" ) -message( "DEBUG: CMAKE_CURRENT_LIST_LINE=${CMAKE_CURRENT_LIST_LINE}" ) -message( "DEBUG: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" ) -message( "DEBUG: CMAKE_DL_LIBS=${CMAKE_DL_LIBS}" ) -message( "DEBUG: CMAKE_EDIT_COMMAND=${CMAKE_EDIT_COMMAND}" ) -message( "DEBUG: CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}" ) -message( "DEBUG: CMAKE_EXTRA_GENERATOR=${CMAKE_EXTRA_GENERATOR}" ) -message( "DEBUG: CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES=${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}" ) -message( "DEBUG: CMAKE_GENERATOR=${CMAKE_GENERATOR}" ) -message( "DEBUG: CMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}" ) -message( "DEBUG: CMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}" ) -message( "DEBUG: CMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) -message( "DEBUG: CMAKE_LINK_LIBRARY_SUFFIX=${CMAKE_LINK_LIBRARY_SUFFIX}" ) -message( "DEBUG: CMAKE_MAJOR_VERSION=${CMAKE_MAJOR_VERSION}" ) -message( "DEBUG: CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" ) -message( "DEBUG: CMAKE_MINOR_VERSION=${CMAKE_MINOR_VERSION}" ) -message( "DEBUG: CMAKE_PARENT_LIST_FILE=${CMAKE_PARENT_LIST_FILE}" ) -message( "DEBUG: CMAKE_PATCH_VERSION=${CMAKE_PATCH_VERSION}" ) -message( "DEBUG: CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}" ) -message( "DEBUG: CMAKE_RANLIB=${CMAKE_RANLIB}" ) -message( "DEBUG: CMAKE_ROOT=${CMAKE_ROOT}" ) -message( "DEBUG: CMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}" ) -message( "DEBUG: CMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}" ) -message( "DEBUG: CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}" ) -message( "DEBUG: CMAKE_SHARED_MODULE_SUFFIX=${CMAKE_SHARED_MODULE_SUFFIX}" ) -message( "DEBUG: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) -message( "DEBUG: CMAKE_SKIP_RPATH=${CMAKE_SKIP_RPATH}" ) -message( "DEBUG: CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}" ) -message( "DEBUG: CMAKE_STANDARD_LIBRARIES=${CMAKE_STANDARD_LIBRARIES}" ) -message( "DEBUG: CMAKE_STATIC_LIBRARY_PREFIX=${CMAKE_STATIC_LIBRARY_PREFIX}" ) -message( "DEBUG: CMAKE_STATIC_LIBRARY_SUFFIX=${CMAKE_STATIC_LIBRARY_SUFFIX}" ) -message( "DEBUG: CMAKE_TWEAK_VERSION=${CMAKE_TWEAK_VERSION}" ) -message( "DEBUG: CMAKE_USING_VC_FREE_TOOLS=${CMAKE_USING_VC_FREE_TOOLS}" ) -message( "DEBUG: CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}" ) -message( "DEBUG: CMAKE_VERSION=${CMAKE_VERSION}" ) -message( "DEBUG: PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}" ) -message( "DEBUG: PROJECT_NAME=${PROJECT_NAME}" ) -message( "DEBUG: PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" ) -set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install CACHE PATH "test install to dir" FORCE ) -#set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "test install to source dir" FORCE ) -endif( NOT SKIP_DEBUG ) - - # # Global stuff # set( GLOBAL_LIBRARIES CACHE INTERNAL "" ) set( GLOBAL_INCLUDE_DIRS CACHE INTERNAL "" ) set( GLOBAL_DEFINITIONS CACHE INTERNAL "" ) -mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) +mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) if( WIN32 ) - list( APPEND GLOBAL_DEFINITIONS FD_SETSIZE=4096 ) - list( APPEND GLOBAL_LIBRARIES "oldnames.lib" "ws2_32.lib" ) + list( APPEND GLOBAL_DEFINITIONS FD_SETSIZE=4096 ) + list( APPEND GLOBAL_LIBRARIES "oldnames.lib" "ws2_32.lib" ) endif() if( MSVC ) - list( APPEND GLOBAL_DEFINITIONS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE DB_MANUAL_CAST_TO_UNION ) + list( APPEND GLOBAL_DEFINITIONS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE DB_MANUAL_CAST_TO_UNION ) endif() # -# packetver +# Find svnversion +# +message( STATUS "Detecting svnversion" ) +find_program( SVNVERSION_EXECUTABLE svnversion ) +mark_as_advanced( SVNVERSION_EXECUTABLE ) +message( STATUS "Detecting svnversion - done" ) + + +# +# Find Subversion +# +message( STATUS "Detecting Subversion" ) +find_package( Subversion ) +message( STATUS "Detecting Subversion - done" ) + + +# +# PACKETVER # -set( PACKETVER "" - CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) +set( PACKETVER CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) if( PACKETVER ) - list( APPEND GLOBAL_DEFINITIONS PACKETVER=${PACKETVER} ) + list( APPEND GLOBAL_DEFINITIONS PACKETVER=${PACKETVER} ) +endif() + + +# +# SVNVERSION +# +if( SVNVERSION_EXECUTABLE ) + execute_process( COMMAND ${SVNVERSION_EXECUTABLE} ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE SVNVERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX REPLACE "[^1234567890MSexported]" "_" SVNVERSION ${SVNVERSION} ) +endif() +if( Subversion_FOUND AND SVNVERSION ) + Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} eAthena ) + if( eAthena_WC_URL ) + string( REGEX MATCH "[^/]+$" BRANCH ${eAthena_WC_URL} ) + set( SVNVERSION "${BRANCH}-${SVNVERSION}" ) + endif() endif() ##################################################################### # package stuff # -if( OFF ) set( CPACK_PACKAGE_NAME "eAthena" ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" ) -set( CPACK_PACKAGE_FILE_NAME ) -set( CPACK_PACKAGE_INSTALL_DIRECTORY ) -set( CPACK_PROJECT_CONFIG_FILE ) +set( CPACK_PACKAGE_VERSION ${SVNVERSION} ) set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ) -set( CPACK_RESOURCE_FILE_README ) -set( CPACK_RESOURCE_FILE_WELCOME ) -set( CPACK_MONOLITHIC_INSTALL ON ) -set( CPACK_GENERATOR "ZIP" ) -set( CPACK_OUTPUT_CONFIG_FILE ) -set( CPACK_PACKAGE_EXECUTABLES ) -set( CPACK_STRIP_FILES ) -#source -set( CPACK_SOURCE_PACKAGE_FILE_NAME ) -set( CPACK_SOURCE_STRIP_FILES ) -set( CPACK_SOURCE_GENERATOR "ZIP" ) -set( CPACK_SOURCE_OUTPUT_CONFIG_FILE ) -set( CPACK_SOURCE_IGNORE_FILES ) -include(CPACK) -endif() +#set( CPACK_MONOLITHIC_INSTALL ON ) +include( CPACK ) + +set( Runtime "Runtime files" CACHE INTERNAL "" ) +set( Runtime_base "configurations, dbs, npcs, docs, ..." CACHE INTERNAL "" ) +set( Runtime_templates "conf/import and save (generated from conf/import-tmpl and save-tmpl)" CACHE INTERNAL "" ) +cpack_add_component_group( Runtime DESCRIPTION ${Runtime} DISPLAY_NAME "Runtime" ) +cpack_add_component( Runtime_base DESCRIPTION ${Runtime_base} DISPLAY_NAME "Base files" GROUP Runtime ) +cpack_add_component( Runtime_templates DESCRIPTION ${Runtime_templates} DISPLAY_NAME "Base templates" GROUP Runtime ) + +set( Development "Development files" CACHE INTERNAL "" ) +set( Development_base "projects, 3rdparty, sources, templates" CACHE INTERNAL "" ) +cpack_add_component_group( Development DESCRIPTION ${Development} DISPLAY_NAME "Development" ) +cpack_add_component( Development_base DESCRIPTION ${Development_base} DISPLAY_NAME "Base files" GROUP Development ) # # install stuff # -set( COMPONENT_SOURCE "Source code, librarires and project files" CACHE INTERNAL "" ) -set( COMPONENT_BASE "Base files" CACHE INTERNAL "" ) -option( INSTALL_RUN_DATA "install files needed to run the project" ON ) -option( INSTALL_BUILD_DATA "install files needed to build the project" OFF ) -set( SVN_FOLDER_PATTERN "[\\.]svn" - CACHE STRING "pattern of svn folder that we exclude from instalations" ) -mark_as_advanced( SVN_FOLDER_PATTERN ) -if( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}" ) - set( INSTALLING_TO_SOURCE ON - CACHE INTERNAL "we are installing to the source folder, skip uneeded stuff" ) -else() - unset( INSTALLING_TO_SOURCE CACHE ) +option( WITH_COMPONENT_RUNTIME "install files needed to run the project" ON ) +option( WITH_COMPONENT_DEVELOPMENT "install files needed to build the project" OFF ) +option( INSTALL_TO_PATH "copy files to INSTALL_PATH" OFF ) +option( INSTALL_TO_SOURCE "copy files to source directory (${CMAKE_CURRENT_SOURCE_DIR})" OFF ) +option( INSTALL_TO_SUBDIR "copy files to subdirectory (${CMAKE_CURRENT_BINARY_DIR}/install)" OFF ) +set( INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install path (only used when INSTALL_TO_PATH is set)" ) +mark_as_advanced( CMAKE_INSTALL_PREFIX ) +if( INSTALL_TO_PATH AND NOT ("${INSTALL_TO}" STREQUAL "path") )# changed to path + set_property( CACHE INSTALL_TO_SOURCE INSTALL_TO_SUBDIR PROPERTY VALUE OFF ) +elseif( INSTALL_TO_SOURCE AND NOT ("${INSTALL_TO}" STREQUAL "source") )# changed to source + set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SUBDIR PROPERTY VALUE OFF ) +elseif( INSTALL_TO_SUBDIR AND NOT ("${INSTALL_TO}" STREQUAL "subdir") )# changed to subdir + set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SOURCE PROPERTY VALUE OFF ) +elseif( NOT INSTALL_TO_PATH AND NOT INSTALL_TO_SOURCE AND NOT INSTALL_TO_SUBDIR )# default + set_property( CACHE INSTALL_TO_SUBDIR PROPERTY VALUE ON ) +endif() +if( INSTALL_TO_PATH ) + set( INSTALL_TO "path" CACHE INTERNAL "" ) + set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${INSTALL_PATH}" ) +elseif( INSTALL_TO_SOURCE ) + set( INSTALL_TO "source" CACHE INTERNAL "" ) + set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_SOURCE_DIR}" ) +elseif( INSTALL_TO_SUBDIR ) + set( INSTALL_TO "subdir" CACHE INTERNAL "" ) + set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/install" ) endif() -set( LOCAL_BUILD_FILES - "CMakeLists.txt" - "configure" - "configure.in" - "eAthena-6.dsw" - "eAthena-7.1.sln" - "eAthena-8.sln" - "eAthena-9.sln" - "eAthena-10.sln" +set( SVN_FOLDER_PATTERN "[\\.]svn" CACHE STRING "pattern of svn folder that we exclude from instalations" ) +mark_as_advanced( SVN_FOLDER_PATTERN ) +set( DEVELOPMENT_FILES + "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + "${CMAKE_CURRENT_SOURCE_DIR}/configure" + "${CMAKE_CURRENT_SOURCE_DIR}/configure.in" + "${CMAKE_CURRENT_SOURCE_DIR}/eAthena-6.dsw" + "${CMAKE_CURRENT_SOURCE_DIR}/eAthena-7.1.sln" + "${CMAKE_CURRENT_SOURCE_DIR}/eAthena-8.sln" + "${CMAKE_CURRENT_SOURCE_DIR}/eAthena-9.sln" + "${CMAKE_CURRENT_SOURCE_DIR}/eAthena-10.sln" ) -set( LOCAL_BUILD_DIRECTORIES +set( DEVELOPMENT_DIRECTORIES "3rdparty" + "conf/import-tmpl" + "save-tmpl" "src" "vcproj-6" "vcproj-7.1" @@ -238,28 +160,31 @@ set( LOCAL_BUILD_DIRECTORIES "vcproj-9" "vcproj-10" ) -set( LOCAL_RUN_FILES - "athena-start" - "Changelog-Trunk.txt" - "char-server.sh" - "charserv-sql.bat" - "charserv.bat" - "dbghelp.dll" - "LICENSE" - "login-server.sh" - "logserv-sql.bat" - "logserv.bat" - "map-server.sh" - "mapserv-sql.bat" - "mapserv.bat" - "notice.txt" - "readme.html" - "runserver-sql.bat" - "runserver.bat" - "serv.bat" - "start" +set( RUNTIME_FILES + "${CMAKE_CURRENT_SOURCE_DIR}/athena-start" + "${CMAKE_CURRENT_SOURCE_DIR}/Changelog-Trunk.txt" + "${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" ) -set( LOCAL_RUN_DIRECTORIES +set( RUNTIME_DIRECTORIES "conf" "db" "doc" @@ -270,58 +195,41 @@ set( LOCAL_RUN_DIRECTORIES "sql-files" "tools" ) -if( USE_LOCAL_MYSQL ) - list( APPEND LOCAL_RUN_FILES "libmysql.dll" ) -endif() -if( USE_LOCAL_PCRE ) - list( APPEND LOCAL_RUN_FILES "pcre3.dll" ) -endif() -if( USE_LOCAL_ZLIB ) - list( APPEND LOCAL_RUN_FILES "zlib1.dll" ) -endif() -function( INSTALL_DIRECTORY DIR DEST EXCLUDE_PATTERN ) - # warning: that slash(/) is important here, otherwise the whole directory (not its content) will be copied! - install( DIRECTORY ${DIR}/ - DESTINATION ${DEST} - PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE - PATTERN "${EXCLUDE_PATTERN}" EXCLUDE ) -endfunction() -function( INSTALL_DIRECTORIES DIRS EXCLUDE_PATTERN ) - foreach( DIR IN ITEMS ${DIRS} ) - INSTALL_DIRECTORY( ${DIR} ${DIR} "${EXCLUDE_PATTERN}" ) - endforeach() -endfunction() -if( NOT INSTALLING_TO_SOURCE ) - # skipped if in-source - if( INSTALL_RUN_DATA ) - # base - install( FILES ${LOCAL_RUN_FILES} - DESTINATION ${CMAKE_INSTALL_PREFIX} ) - foreach( DIR IN ITEMS ${LOCAL_RUN_DIRECTORIES} ) +if( INSTALL_TO_SOURCE )# skip, already in the source dir +else() + if( WITH_COMPONENT_RUNTIME ) + install( FILES ${RUNTIME_FILES} + DESTINATION "." + COMPONENT Runtime_base ) + foreach( DIR IN ITEMS ${RUNTIME_DIRECTORIES} ) install( DIRECTORY "${DIR}/" DESTINATION "${DIR}" + COMPONENT Runtime_base PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE PATTERN "conf/import-tmpl" EXCLUDE ) endforeach() endif() - if( INSTALL_BUILD_DATA ) - # source - install( FILES ${LOCAL_BUILD_FILES} - DESTINATION ${CMAKE_INSTALL_PREFIX} ) - foreach( DIR IN ITEMS ${LOCAL_BUILD_DIRECTORIES} ) + if( WITH_COMPONENT_DEVELOPMENT ) + install( FILES ${DEVELOPMENT_FILES} + DESTINATION "." + COMPONENT Development_base ) + foreach( DIR IN ITEMS ${DEVELOPMENT_DIRECTORIES} ) install( DIRECTORY "${DIR}/" DESTINATION "${DIR}" + COMPONENT Development_base PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) endforeach() endif() endif() -if( INSTALL_RUN_DATA ) - # base templates +if( WITH_COMPONENT_RUNTIME ) + # templates install( DIRECTORY "save-tmpl/" DESTINATION "save" + COMPONENT Runtime_templates PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) install( DIRECTORY "conf/import-tmpl/" DESTINATION "conf/import" + COMPONENT Runtime_templates PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE ) endif() diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b2747c3c7..37acba5cf 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,7 @@ Date Added * Merged decode_zip/encode_zip from eapp's grfio to replace our direct use of zlib's uncompress/compress. * Fixed strict-aliasing warning in mapcache's GetFloat. * CMake: src/common builds static libraries common_base/common_sql, that are used as dependencies by the other targets. + * CMake: normalized variable names, added ability to create a package/installer. 2011/07/05 * CMake: split txt and sql variants of login-server and map-server. [FlavioJS] 2011/07/04 diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index 1f6f1ea11..9e0cbd9f4 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -36,10 +36,11 @@ 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_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_charserver_txt DESCRIPTION "char-server (txt version)" DISPLAY_NAME "char-server" GROUP Runtime ) install( TARGETS char-server - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "char-server" ) + DESTINATION "." + COMPONENT Runtime_charserver_txt ) endif() message( STATUS "Creating target char-server - done" ) set( HAVE_char-server ON CACHE BOOL "char-server target is available" ) diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt index 7d3b7ad7e..f2d1cd0f0 100644 --- a/src/char_sql/CMakeLists.txt +++ b/src/char_sql/CMakeLists.txt @@ -42,10 +42,11 @@ 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_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_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 ${CMAKE_INSTALL_PREFIX} - COMPONENT "char-server_sql" ) + DESTINATION "." + COMPONENT Runtime_charserver_sql ) endif() message( STATUS "Creating target char-server_sql - done" ) set( HAVE_char-server_sql ON CACHE BOOL "char-server_sql target is available" ) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0241dfbca..21feb53f9 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,22 +1,8 @@ -##################################################################### -# Find svnversion -# -message( STATUS "Detecting svnversion" ) -find_program( SVNVERSION_EXECUTABLE svnversion ) -mark_as_advanced( SVNVERSION_EXECUTABLE ) -message( STATUS "Detecting svnversion - done" ) - - # # Create svnversion.h # message( STATUS "Creating svnversion.h" ) -if( SVNVERSION_EXECUTABLE ) - execute_process( COMMAND ${SVNVERSION_EXECUTABLE} ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE SVNVERSION - OUTPUT_STRIP_TRAILING_WHITESPACE ) -endif() if( SVNVERSION ) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "#ifndef SVNVERSION\n#define SVNVERSION ${SVNVERSION}\n#endif\n" ) @@ -26,11 +12,14 @@ endif() set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "" ) set( SVNVERSION ${SVNVERSION} CACHE STRING "SVN version of the source code" ) -if( INSTALL_BUILD_DATA ) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h DESTINATION ${CMAKE_INSTALL_PREFIX}/src/common ) +if( WITH_COMPONENT_DEVELOPMENT ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h + DESTINATION "src/common" + COMPONENT Development_base ) endif() message( STATUS "Creating svnversion.h - done" ) + ##################################################################### # setup # @@ -65,7 +54,7 @@ set( COMMON_MINI_DEFINITIONS MINICORE CACHE INTERNAL "" ) # # common_base # -if( USE_ZLIB ) +if( WITH_ZLIB ) message( STATUS "Creating target common_base" ) set( COMMON_BASE_HEADERS ${COMMON_ALL_HEADERS} @@ -126,7 +115,7 @@ endif() # # common_sql # -if( HAVE_common_base AND USE_MYSQL ) +if( HAVE_common_base AND WITH_MYSQL ) message( STATUS "Creating target common_sql" ) set( COMMON_SQL_HEADERS ${COMMON_ALL_HEADERS} diff --git a/src/login/sql/CMakeLists.txt b/src/login/sql/CMakeLists.txt index 50bf256e2..ac7d464c9 100644 --- a/src/login/sql/CMakeLists.txt +++ b/src/login/sql/CMakeLists.txt @@ -28,10 +28,11 @@ add_executable( login-server_sql ${SOURCE_FILES} ) add_dependencies( login-server_sql ${DEPENDENCIES} ) target_link_libraries( login-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( login-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_loginserver_sql DESCRIPTION "login-server (sql version)" DISPLAY_NAME "login-server_sql" GROUP Runtime ) install( TARGETS login-server_sql - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "login-server_sql" ) + DESTINATION "." + COMPONENT Runtime_loginserver_sql ) endif() message( STATUS "Creating target login-server_sql - done" ) set( HAVE_login-server_sql ON CACHE BOOL "login-server_sql target is available" ) diff --git a/src/login/txt/CMakeLists.txt b/src/login/txt/CMakeLists.txt index dff7d322c..9d57103e9 100644 --- a/src/login/txt/CMakeLists.txt +++ b/src/login/txt/CMakeLists.txt @@ -28,10 +28,11 @@ 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_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_loginserver_txt DESCRIPTION "login-server (txt version)" DISPLAY_NAME "login-server" GROUP Runtime ) install( TARGETS login-server - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "login-server" ) + DESTINATION "." + COMPONENT Runtime_loginserver_txt ) endif() message( STATUS "Creating target login-server - done" ) set( HAVE_login-server ON CACHE BOOL "login-server target is available" ) diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index c7922f276..74598423a 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -81,7 +81,7 @@ set( DEPENDENCIES common_sql ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) -if( USE_PCRE ) +if( WITH_PCRE ) message( STATUS "Using PCRE" ) list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) @@ -95,10 +95,11 @@ add_executable( map-server_sql ${SOURCE_FILES} ) add_dependencies( map-server_sql ${DEPENDENCIES} ) target_link_libraries( map-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( map-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_mapserver_sql DESCRIPTION "map-server (sql version)" DISPLAY_NAME "map-server_sql" GROUP Runtime ) install( TARGETS map-server_sql - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "map-server_sql" ) + DESTINATION "." + COMPONENT Runtime_mapserver_sql ) endif() message( STATUS "Creating target map-server_sql - done" ) set( HAVE_map-server_sql ON CACHE BOOL "map-server_sql target is available" ) diff --git a/src/map/txt/CMakeLists.txt b/src/map/txt/CMakeLists.txt index 544e00c87..d58866f96 100644 --- a/src/map/txt/CMakeLists.txt +++ b/src/map/txt/CMakeLists.txt @@ -81,7 +81,7 @@ set( DEPENDENCIES common_base ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) -if( USE_PCRE ) +if( WITH_PCRE ) message( STATUS "Using PCRE" ) list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) @@ -95,10 +95,11 @@ 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_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_mapserver_txt DESCRIPTION "map-server (txt version)" DISPLAY_NAME "map-server" GROUP Runtime ) install( TARGETS map-server - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "map-server" ) + DESTINATION "." + COMPONENT Runtime_mapserver_txt ) endif() message( STATUS "Creating target map-server - done" ) set( HAVE_map-server ON CACHE BOOL "map-server target is available" ) diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index e39b174dd..a23637e3d 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -1,30 +1,8 @@ -# setup -set( COMMON_SOURCES - "${COMMON_SOURCE_DIR}/core.c" -# "${COMMON_SOURCE_DIR}/db.c" -# "${COMMON_SOURCE_DIR}/ers.c" - "${COMMON_SOURCE_DIR}/grfio.c" -# "${COMMON_SOURCE_DIR}/lock.c" - "${COMMON_SOURCE_DIR}/malloc.c" -# "${COMMON_SOURCE_DIR}/mapindex.c" -# "${COMMON_SOURCE_DIR}/md5calc.c" -# "${COMMON_SOURCE_DIR}/nullpo.c" -# "${COMMON_SOURCE_DIR}/plugins.c" -# "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" -# "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/strlib.c" -# "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" - ) -set( MAPCACHE_SOURCES - mapcache.c - ) - - +# # mapcache -if( USE_ZLIB ) +# +if( WITH_ZLIB ) message( STATUS "Creating target mapcache" ) set( COMMON_HEADERS ${COMMON_MINI_HEADERS} @@ -49,10 +27,11 @@ add_executable( mapcache ${SOURCE_FILES} ) include_directories( ${INCLUDE_DIRS} ) target_link_libraries( mapcache ${ZLIB_LIBRARIES} ) set_target_properties( mapcache PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) -if( INSTALL_RUN_DATA ) +if( WITH_COMPONENT_RUNTIME ) + cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime ) install( TARGETS mapcache - DESTINATION ${CMAKE_INSTALL_PREFIX} - COMPONENT "mapcache" ) + DESTINATION "." + COMPONENT Runtime_mapcache ) endif() message( STATUS "Creating target mapcache - done" ) set( HAVE_mapcache ON CACHE BOOL "mapcache target is available" ) -- cgit v1.2.3-70-g09d2 From ab9b60f5c4501eb8d7bec4a053d73fc723ea31b5 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Sat, 9 Jul 2011 07:39:27 +0000 Subject: * CMake: added search for math library, made CPack existence optional, updated the search for mysqlclient and corrected misspelled variables (tested with FreeBSD-8.2-i386) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14893 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/mysql/CMakeLists.txt | 23 ++++------------------- 3rdparty/mysql/FindMYSQL.cmake | 39 ++++++++++++++++++++------------------- CMakeLists.txt | 32 ++++++++++++++++++++++++++++---- Changelog-Trunk.txt | 1 + src/tool/CMakeLists.txt | 2 +- 5 files changed, 54 insertions(+), 43 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index 3f792281c..f4996907f 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -42,25 +42,10 @@ endif( WIN32 ) # system # message( STATUS "Detecting system MYSQL" ) -find_program( MYSQL_CONFIG_EXECUTABLE "mysql_config" ) -mark_as_advanced( MYSQL_CONFIG_EXECUTABLE ) -if( MYSQL_CONFIG_EXECUTABLE ) - # use mysql_config data - message( "Found mysql_config: ${MYSQL_CONFIG_EXECUTABLE}" ) - execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --libs" - OUTPUT_VARIABLE MYSQL_LIBRARIES ) - execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --include" - OUTPUT_VARIABLE MYSQL_INCLUDE_DIRS ) - execute_process( COMMAND "${MYSQL_CONFIG_EXECUTABLE} --version" - OUTPUT_VARIABLE MYSQL_VERSION ) - message( STATUS "Found MYSQL: ${MYSQL_LIBRARIES} (found version ${MYSQL_VERSION})" ) -else() - # find mysql package - unset( MYSQL_LIBRARIES CACHE ) - unset( MYSQL_INCLUDE_DIRS CACHE ) - set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) - find_package( MYSQL ) -endif() +unset( MYSQL_LIBRARIES CACHE ) +unset( MYSQL_INCLUDE_DIRS CACHE ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) +find_package( MYSQL ) set( MYSQL_SYSTEM_LIBRARIES "${MYSQL_LIBRARIES}" CACHE PATH "system mysql libraries" ) set( MYSQL_SYSTEM_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" diff --git a/3rdparty/mysql/FindMYSQL.cmake b/3rdparty/mysql/FindMYSQL.cmake index 5ac264098..0a07f3612 100644 --- a/3rdparty/mysql/FindMYSQL.cmake +++ b/3rdparty/mysql/FindMYSQL.cmake @@ -1,23 +1,29 @@ # - Find mysqlclient # Find the native MySQL includes and library # -# MYSQL_INCLUDE_DIR - where to find mysql.h, etc. -# MYSQL_LIBRARIES - List of libraries when using MySQL. -# MYSQL_FOUND - True if MySQL found. +# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. +# MYSQL_LIBRARIES - mysqlclient library. +# MYSQL_FOUND - True if mysqlclient is found. # -# Based on: http://www.itk.org/Wiki/CMakeUserFindMySQL -find_path( MYSQL_INCLUDE_DIR "mysql.h" - PATH_SUFFIXES "mysql" ) +find_path( MYSQL_INCLUDE_DIRS "mysql.h" + PATHS + "/usr/include/mysql" + "/usr/local/include/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/include" + "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) -set( MYSQL_NAMES mysqlclient mysqlclient_r ) -find_library( MYSQL_LIBRARY - NAMES ${MYSQL_NAMES} - PATH_SUFFIXES "mysql" ) -mark_as_advanced( MYSQL_LIBRARY MYSQL_INCLUDE_DIR ) +find_library( MYSQL_LIBRARIES + NAMES "mysqlclient" "mysqlclient_r" + PATHS + "/usr/lib/mysql" + "/usr/local/lib/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/lib" + "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) +mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) -if( MYSQL_INCLUDE_DIR AND EXISTS "${MYSQL_INCLUDE_DIR}/mysql_version.h" ) - file( STRINGS "${MYSQL_INCLUDE_DIR}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) +if( MYSQL_INCLUDE_DIRS AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) endif() @@ -25,10 +31,5 @@ endif() # all listed variables are TRUE include( FindPackageHandleStandardArgs ) FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL - REQUIRED_VARS MYSQL_LIBRARY MYSQL_INCLUDE_DIR + REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS VERSION_VAR MYSQL_VERSION_STRING ) - -if( MYSQL_FOUND ) - set( MYSQL_LIBRARIES ${PCRE_LIBRARY} ) - set( MYSQL_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 953c804ff..523d445ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ endif() message( STATUS "Detecting svnversion" ) find_program( SVNVERSION_EXECUTABLE svnversion ) mark_as_advanced( SVNVERSION_EXECUTABLE ) +if( SVNVERSION_EXECUTABLE ) + message( STATUS "Found svnversion: ${SVNVERSION_EXECUTABLE}" ) +endif() message( STATUS "Detecting svnversion - done" ) @@ -58,6 +61,19 @@ find_package( Subversion ) message( STATUS "Detecting Subversion - done" ) +# +# Find math library (FreeBSD) +# +message( STATUS "Detecting math library" ) +find_library( M_LIBRARIES m ) +mark_as_advanced( M_LIBRARIES ) +if( M_LIBRARIES ) + message( STATUS "Found m: ${M_LIBRARIES}" ) + list( APPEND GLOBAL_LIBRARIES ${M_LIBRARIES} ) +endif() +message( STATUS "Detecting math library - done" ) + + # # PACKETVER # @@ -93,7 +109,15 @@ set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" ) set( CPACK_PACKAGE_VERSION ${SVNVERSION} ) set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ) #set( CPACK_MONOLITHIC_INSTALL ON ) -include( CPACK ) +include( CPACK OPTIONAL RESULT_VARIABLE HAVE_CPACK ) +if( NOT HAVE_CPACK ) + # empty replacements + macro( cpack_add_component_group ) + endmacro() + macro( cpack_add_component ) + endmacro() + message( STATUS "CPACK not found, package creation disabled" ) +endif() set( Runtime "Runtime files" CACHE INTERNAL "" ) set( Runtime_base "configurations, dbs, npcs, docs, ..." CACHE INTERNAL "" ) @@ -111,10 +135,10 @@ cpack_add_component( Development_base DESCRIPTION ${Development_base} DISPLAY_NA # # install stuff # -option( WITH_COMPONENT_RUNTIME "install files needed to run the project" ON ) -option( WITH_COMPONENT_DEVELOPMENT "install files needed to build the project" OFF ) +option( WITH_COMPONENT_RUNTIME "install/package files needed to run the project" ON ) +option( WITH_COMPONENT_DEVELOPMENT "install/package files needed to build the project" OFF ) option( INSTALL_TO_PATH "copy files to INSTALL_PATH" OFF ) -option( INSTALL_TO_SOURCE "copy files to source directory (${CMAKE_CURRENT_SOURCE_DIR})" OFF ) +option( INSTALL_TO_SOURCE "copy files to source directory, skips what is already there (${CMAKE_CURRENT_SOURCE_DIR})" OFF ) option( INSTALL_TO_SUBDIR "copy files to subdirectory (${CMAKE_CURRENT_BINARY_DIR}/install)" OFF ) set( INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install path (only used when INSTALL_TO_PATH is set)" ) mark_as_advanced( CMAKE_INSTALL_PREFIX ) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index e5e1b81cc..fe07980c3 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,7 @@ Date Added 2011/07/09 + * CMake: added search for math library, made CPack existence optional, updated the search for mysqlclient and corrected misspelled variables (tested with FreeBSD-8.2-i386) [FlavioJS] * Removed duplicate entries for Gunslinger and Ninja in msg_athena.conf (since r5506). [Ai4rei] 2011/07/07 * Replaced compress/uncompress inline code (encode_zip/decode_zip) with the respective zlib library calls while keeping 3rdparty calls inside common code (follow up to r14888, related r14808). [Ai4rei] diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index a23637e3d..e45586915 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -25,7 +25,7 @@ source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) source_group( mapcache FILES ${MAPCACHE_SOURCES} ) add_executable( mapcache ${SOURCE_FILES} ) include_directories( ${INCLUDE_DIRS} ) -target_link_libraries( mapcache ${ZLIB_LIBRARIES} ) +target_link_libraries( mapcache ${LIBRARIES} ) set_target_properties( mapcache PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime ) -- cgit v1.2.3-70-g09d2 From f817e3714747b39a364e99c536e0b802b24fd2c3 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Sun, 10 Jul 2011 15:29:57 +0000 Subject: * CMake: lowered required version to 2.8.3 and moved custom cmake modules to 3rdparty/cmake. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14897 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 1 + 3rdparty/cmake/FindMYSQL.cmake | 35 +++++++++++++++++++++++++++++++++++ 3rdparty/cmake/FindPCRE.cmake | 35 +++++++++++++++++++++++++++++++++++ 3rdparty/mysql/CMakeLists.txt | 1 - 3rdparty/mysql/FindMYSQL.cmake | 35 ----------------------------------- 3rdparty/pcre/CMakeLists.txt | 1 - 3rdparty/pcre/FindPCRE.cmake | 35 ----------------------------------- CMakeLists.txt | 27 +++++++++++++++++++++++++-- Changelog-Trunk.txt | 1 + 9 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 3rdparty/cmake/FindMYSQL.cmake create mode 100644 3rdparty/cmake/FindPCRE.cmake delete mode 100644 3rdparty/mysql/FindMYSQL.cmake delete mode 100644 3rdparty/pcre/FindPCRE.cmake (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 3e7cb4cc4..a63321033 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -47,6 +47,7 @@ macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} ) add_subdirectory( msinttypes ) add_subdirectory( mt19937ar ) add_subdirectory( mysql ) diff --git a/3rdparty/cmake/FindMYSQL.cmake b/3rdparty/cmake/FindMYSQL.cmake new file mode 100644 index 000000000..0a07f3612 --- /dev/null +++ b/3rdparty/cmake/FindMYSQL.cmake @@ -0,0 +1,35 @@ +# - Find mysqlclient +# Find the native MySQL includes and library +# +# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. +# MYSQL_LIBRARIES - mysqlclient library. +# MYSQL_FOUND - True if mysqlclient is found. +# + +find_path( MYSQL_INCLUDE_DIRS "mysql.h" + PATHS + "/usr/include/mysql" + "/usr/local/include/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/include" + "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) + +find_library( MYSQL_LIBRARIES + NAMES "mysqlclient" "mysqlclient_r" + PATHS + "/usr/lib/mysql" + "/usr/local/lib/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/lib" + "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) +mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) + +if( MYSQL_INCLUDE_DIRS AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL + REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS + VERSION_VAR MYSQL_VERSION_STRING ) diff --git a/3rdparty/cmake/FindPCRE.cmake b/3rdparty/cmake/FindPCRE.cmake new file mode 100644 index 000000000..cb4d9177b --- /dev/null +++ b/3rdparty/cmake/FindPCRE.cmake @@ -0,0 +1,35 @@ +# - Find pcre +# Find the native PCRE includes and library +# +# PCRE_INCLUDE_DIRS - where to find pcre.h +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + + +find_path( PCRE_INCLUDE_DIR pcre.h ) + +set( PCRE_NAMES pcre ) +find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) +mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) + +if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) + file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + + set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) + set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) + set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE + REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR + VERSION_VAR PCRE_VERSION_STRING ) + +if( PCRE_FOUND ) + set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) + set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +endif() diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index f4996907f..e85fd626d 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -44,7 +44,6 @@ endif( WIN32 ) message( STATUS "Detecting system MYSQL" ) unset( MYSQL_LIBRARIES CACHE ) unset( MYSQL_INCLUDE_DIRS CACHE ) -set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) find_package( MYSQL ) set( MYSQL_SYSTEM_LIBRARIES "${MYSQL_LIBRARIES}" CACHE PATH "system mysql libraries" ) diff --git a/3rdparty/mysql/FindMYSQL.cmake b/3rdparty/mysql/FindMYSQL.cmake deleted file mode 100644 index 0a07f3612..000000000 --- a/3rdparty/mysql/FindMYSQL.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# - Find mysqlclient -# Find the native MySQL includes and library -# -# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. -# MYSQL_LIBRARIES - mysqlclient library. -# MYSQL_FOUND - True if mysqlclient is found. -# - -find_path( MYSQL_INCLUDE_DIRS "mysql.h" - PATHS - "/usr/include/mysql" - "/usr/local/include/mysql" - "$ENV{PROGRAMFILES}/MySQL/*/include" - "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) - -find_library( MYSQL_LIBRARIES - NAMES "mysqlclient" "mysqlclient_r" - PATHS - "/usr/lib/mysql" - "/usr/local/lib/mysql" - "$ENV{PROGRAMFILES}/MySQL/*/lib" - "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) -mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) - -if( MYSQL_INCLUDE_DIRS AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" ) - file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) - string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) -endif() - -# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if -# all listed variables are TRUE -include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL - REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS - VERSION_VAR MYSQL_VERSION_STRING ) diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt index 70448d40e..57465a46c 100644 --- a/3rdparty/pcre/CMakeLists.txt +++ b/3rdparty/pcre/CMakeLists.txt @@ -39,7 +39,6 @@ endif( WIN32 ) # system # message( STATUS "Detecting system PCRE" ) -set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) unset( PCRE_LIBRARIES CACHE ) unset( PCRE_INCLUDE_DIRS CACHE ) find_package( PCRE ) diff --git a/3rdparty/pcre/FindPCRE.cmake b/3rdparty/pcre/FindPCRE.cmake deleted file mode 100644 index cb4d9177b..000000000 --- a/3rdparty/pcre/FindPCRE.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# - Find pcre -# Find the native PCRE includes and library -# -# PCRE_INCLUDE_DIRS - where to find pcre.h -# PCRE_LIBRARIES - List of libraries when using pcre. -# PCRE_FOUND - True if pcre found. - - -find_path( PCRE_INCLUDE_DIR pcre.h ) - -set( PCRE_NAMES pcre ) -find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) -mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) - -if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) - file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) - string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) - string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) - - set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) - set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) - set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) -endif() - -# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if -# all listed variables are TRUE -include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE - REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR - VERSION_VAR PCRE_VERSION_STRING ) - -if( PCRE_FOUND ) - set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) - set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 523d445ef..1163ccddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,5 @@ +##################################################################### +# # "Getting Started with CMake", a tutorial video by Eric Wing. # Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw # Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg @@ -11,8 +13,30 @@ # WITH_* : option to use an external package or not # ENABLE_* : option to use an internal feature/code or not # HAVE_* : internal variable indicating if we have and are using something -cmake_minimum_required( VERSION 2.8.4 ) +# +# Example (build in subdir 'build' and install to source dir): +# mkdir build +# cd build +# cmake -G"Unix Makefiles" -DINSTALL_TO_SOURCE:bool=ON .. +# make install +# cd .. +# rm -rf build +# +##################################################################### + + +#cmake_minimum_required( VERSION 2.8.4 ) +# Functional changes from 2.8.3 to 2.8.4: +# string(SUBSTRING) works with length -1 as "rest of string" +# changes to some CPack generators +# CYGWIN no longer defines WIN32 +# CMP0017: Prefer files from the CMake module directory when including from there. +set( CMAKE_LEGACY_CYGWIN_WIN32 0 ) +cmake_minimum_required( VERSION 2.8.3 ) project( eAthena ) +if( CYGWIN ) + unset( WIN32 ) +endif() # @@ -261,5 +285,4 @@ endif() # # subdirectories # -add_subdirectory( 3rdparty ) add_subdirectory( src ) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4d512c8da..2840900ee 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -2,6 +2,7 @@ Date Added 2011/07/10 * Temporary fix for bugreport:4961 (unintended conversion from signed to unsigned). [FlavioJS] + * CMake: lowered required version to 2.8.3 and moved custom cmake modules to 3rdparty/cmake. 2011/07/09 * Added script command 'getmercinfo' for retrieving information about a mercenary of an online character. [Ai4rei] * CMake: added search for math library, made CPack existence optional, updated the search for mysqlclient and corrected misspelled variables (tested with FreeBSD-8.2-i386) [FlavioJS] -- cgit v1.2.3-70-g09d2 From 9349df4e5fa122fd74d632d4227f8c1a1f32c36d Mon Sep 17 00:00:00 2001 From: flaviojs Date: Tue, 12 Jul 2011 06:39:46 +0000 Subject: * CMake: set project language to C, added module FindFunctionLibrary, added search for dl library. (tested with debian-wheezy-i386) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14902 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 2 +- 3rdparty/cmake/FindFunctionLibrary.cmake | 47 +++++++++++++++++++ 3rdparty/msinttypes/CMakeLists.txt | 3 +- CMakeLists.txt | 79 +++++++++++++++++++------------- Changelog-Trunk.txt | 2 + src/char/CMakeLists.txt | 4 +- src/char_sql/CMakeLists.txt | 4 +- src/common/CMakeLists.txt | 10 ++-- src/login/sql/CMakeLists.txt | 4 +- src/login/txt/CMakeLists.txt | 4 +- src/map/sql/CMakeLists.txt | 10 ++-- src/map/txt/CMakeLists.txt | 10 ++-- src/tool/CMakeLists.txt | 4 +- src/txt-converter/char/CMakeLists.txt | 4 +- src/txt-converter/login/CMakeLists.txt | 4 +- 15 files changed, 128 insertions(+), 63 deletions(-) create mode 100644 3rdparty/cmake/FindFunctionLibrary.cmake (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index a63321033..ebbac481a 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -47,7 +47,7 @@ macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) -set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake CACHE INTERNAL "" ) add_subdirectory( msinttypes ) add_subdirectory( mt19937ar ) add_subdirectory( mysql ) diff --git a/3rdparty/cmake/FindFunctionLibrary.cmake b/3rdparty/cmake/FindFunctionLibrary.cmake new file mode 100644 index 000000000..f1d32001e --- /dev/null +++ b/3rdparty/cmake/FindFunctionLibrary.cmake @@ -0,0 +1,47 @@ +# - Check which library is needed to link a C function +# find_function_library( [ ...] ) +# +# Check which library provides the . +# Sets to 0 if found in the global libraries. +# Sets to the library path if found in the provided libraries. +# Raises a FATAL_ERROR if not found. +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link +include( CheckFunctionExists ) + +macro( find_function_library FUNC VAR ) + if( "${VAR}" MATCHES "^${VAR}$" ) + CHECK_FUNCTION_EXISTS( ${FUNC} ${VAR} ) + if( ${VAR} ) + message( STATUS "Found ${FUNC} in global libraries" ) + set( ${VAR} 0 CACHE INTERNAL "Found ${FUNC} in global libraries" )# global + else() + foreach( LIB IN ITEMS ${ARGN} ) + message( STATUS "Looking for ${FUNC} in ${LIB}" ) + find_library( ${LIB}_LIBRARY ${LIB} ) + mark_as_advanced( ${LIB}_LIBRARY ) + if( ${LIB}_LIBRARY ) + unset( ${VAR} CACHE ) + set( CMAKE_REQUIRED_LIBRARIES ${${LIB}_LIBRARY} ) + CHECK_FUNCTION_EXISTS( ${FUNC} ${VAR} ) + set( CMAKE_REQUIRED_LIBRARIES ) + if( ${VAR} ) + message( STATUS "Found ${FUNC} in ${LIB}: ${${LIB}_LIBRARY}" ) + set( ${VAR} ${${LIB}_LIBRARY} CACHE INTERNAL "Found ${FUNC} in ${LIB}" )# lib + break() + endif() + endif() + endforeach() + if( NOT ${VAR} ) + message( FATAL_ERROR "Function ${FUNC} not found" ) + endif() + endif() + endif() +endmacro( find_function_library ) + diff --git a/3rdparty/msinttypes/CMakeLists.txt b/3rdparty/msinttypes/CMakeLists.txt index f17c6f596..f7a662fe8 100644 --- a/3rdparty/msinttypes/CMakeLists.txt +++ b/3rdparty/msinttypes/CMakeLists.txt @@ -4,5 +4,6 @@ find_path( MSINTTYPES_INCLUDE_DIRS "inttypes.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) mark_as_advanced( MSINTTYPES_INCLUDE_DIRS ) -set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MSINTTYPES_INCLUDE_DIRS} CACHE INTERNAL "" ) +message( STATUS "Adding global include directory: ${MSINTTYPES_INCLUDE_DIRS}" ) +set_property( CACHE GLOBAL_INCLUDE_DIRS PROPERTY VALUE ${GLOBAL_INCLUDE_DIRS} ${MSINTTYPES_INCLUDE_DIRS} ) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index fb94c7c72..1b6d3ebc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,14 +14,6 @@ # ENABLE_* : option to use an internal feature/code or not # HAVE_* : internal variable indicating if we have and are using something # -# Example (build in subdir 'build' and install to source dir): -# mkdir build -# cd build -# cmake -G"Unix Makefiles" -DINSTALL_TO_SOURCE:bool=ON .. -# make install -# cd .. -# rm -rf build -# ##################################################################### @@ -33,7 +25,7 @@ # CMP0017: Prefer files from the CMake module directory when including from there. set( CMAKE_LEGACY_CYGWIN_WIN32 0 ) cmake_minimum_required( VERSION 2.8.3 ) -project( eAthena ) +project( eAthena C ) if( CYGWIN ) unset( WIN32 ) endif() @@ -45,23 +37,30 @@ endif() if( ALLOW_SAME_DIRECTORY ) elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" ) option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF ) - message( FATAL_ERROR "Do not use the source directory to build your files, instead create a separate folder and build there.\nExample:\n mkdir build\n cd build\n cmake -G\"Unix Makefiles\" ..\n make install\nTo skip this check, set ALLOW_SAME_DIRECTORY to 1 or ON" ) + message( FATAL_ERROR + "Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n" + "Example: (build in subdir 'build' and install to source dir)\n" + " mkdir build && cd build\n" + " cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE:bool=ON ..\n" + " make install\n" + " cd .. && rm -rf build\n" + "To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY:bool=ON)" ) endif() # # Global stuff # -set( GLOBAL_LIBRARIES CACHE INTERNAL "" ) -set( GLOBAL_INCLUDE_DIRS CACHE INTERNAL "" ) -set( GLOBAL_DEFINITIONS CACHE INTERNAL "" ) +set( GLOBAL_LIBRARIES ${LINK_LIBRARIES} CACHE INTERNAL "" )# list (comma separated values) +set( GLOBAL_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} CACHE INTERNAL "" )# list (comma separated values) +set( GLOBAL_DEFINITIONS ${COMPILE_DEFINITIONS} CACHE INTERNAL "" )# string (space separated values -DFOO=bar) mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) if( WIN32 ) - list( APPEND GLOBAL_DEFINITIONS FD_SETSIZE=4096 ) - list( APPEND GLOBAL_LIBRARIES "oldnames.lib" "ws2_32.lib" ) + set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DFD_SETSIZE=4096" ) + set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} "oldnames.lib" "ws2_32.lib" ) endif() if( MSVC ) - list( APPEND GLOBAL_DEFINITIONS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE DB_MANUAL_CAST_TO_UNION ) + set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DDB_MANUAL_CAST_TO_UNION" ) endif() @@ -84,20 +83,6 @@ message( STATUS "Detecting Subversion" ) find_package( Subversion ) message( STATUS "Detecting Subversion - done" ) - -# -# Find math library (FreeBSD) -# -message( STATUS "Detecting math library" ) -find_library( M_LIBRARIES m ) -mark_as_advanced( M_LIBRARIES ) -if( M_LIBRARIES ) - message( STATUS "Found m: ${M_LIBRARIES}" ) - list( APPEND GLOBAL_LIBRARIES ${M_LIBRARIES} ) -endif() -message( STATUS "Detecting math library - done" ) - - # # PACKETVER # @@ -126,11 +111,41 @@ endif() # -# 3rdparty +# 3rdparty and library tests # add_subdirectory( 3rdparty ) +include( FindFunctionLibrary ) +# +# math library (FreeBSD/Linux) +# +message( STATUS "Detecting m library (math)" ) +set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) +find_function_library( floor FUNCTION_FLOOR_LIBRARIES m ) +mark_as_advanced( FUNCTION_FLOOR_LIBRARIES ) +if( FUNCTION_FLOOR_LIBRARIES ) + message( STATUS "Adding global library: ${FUNCTION_FLOOR_LIBRARIES}" ) + list( APPEND GLOBAL_LIBRARIES ${FUNCTION_FLOOR_LIBRARIES} ) +endif() +message( STATUS "Detecting m library (math) - done" ) + + +# +# dynamic loading library (Linux) +# +if( NOT WIN32 ) +message( STATUS "Detecting dl library (dynamic loading)" ) +set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) +find_function_library( dlopen FUNCTION_DLOPEN_LIBRARIES dl ) +mark_as_advanced( FUNCTION_DLOPEN_LIBRARIES ) +if( FUNCTION_DLOPEN_LIBRARIES ) + message( STATUS "Adding global library: ${FUNCTION_DLOPEN_LIBRARIES}" ) + list( APPEND GLOBAL_LIBRARIES ${FUNCTION_DLOPEN_LIBRARIES} ) +endif() +message( STATUS "Detecting dl library (dynamic loading) - done" ) +endif() + ##################################################################### # package stuff @@ -302,7 +317,7 @@ add_subdirectory( src ) if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) message( WARNING "64bit should work, but is not recommended." ) elseif( NOT CMAKE_SIZEOF_VOID_P EQUAL 4 ) - message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})" ) + message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" ) endif() list( LENGTH TARGET_LIST _LEN ) if( _LEN EQUAL 0 ) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 85adf16ea..24de77fcb 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/07/12 + * CMake: set project language to C, added module FindFunctionLibrary, added search for dl library. (tested with debian-wheezy-i386) [FlavioJS] 2011/07/11 * Rev. 14901 Added bonus3 bAddClassDropItem, care of Epoque. [L0ne_W0lf] 2011/07/10 diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index 559718c26..29bfeb6fe 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -33,7 +33,7 @@ set( TXT_CHAR_SOURCES set( DEPENDENCIES common_base ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) +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} ) @@ -41,7 +41,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( char-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_charserver_txt DESCRIPTION "char-server (txt version)" DISPLAY_NAME "char-server" GROUP Runtime ) install( TARGETS char-server diff --git a/src/char_sql/CMakeLists.txt b/src/char_sql/CMakeLists.txt index 6090d3406..12c5b078f 100644 --- a/src/char_sql/CMakeLists.txt +++ b/src/char_sql/CMakeLists.txt @@ -39,7 +39,7 @@ set( SQL_CHAR_SOURCES set( DEPENDENCIES common_sql ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +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} ) @@ -47,7 +47,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( char-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_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 diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index a389a0b58..3fb95e5e0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -48,7 +48,7 @@ set( COMMON_MINI_SOURCES "${COMMON_SOURCE_DIR}/showmsg.c" "${COMMON_SOURCE_DIR}/strlib.c" CACHE INTERNAL "" ) -set( COMMON_MINI_DEFINITIONS MINICORE CACHE INTERNAL "" ) +set( COMMON_MINI_DEFINITIONS "-DMINICORE" CACHE INTERNAL "" ) # @@ -95,13 +95,13 @@ set( COMMON_BASE_SOURCES CACHE INTERNAL "common_base sources" ) set( LIBRARIES ${ZLIB_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) set( SOURCE_FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) source_group( mt19937ar FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) add_library( common_base ${SOURCE_FILES} ) target_link_libraries( common_base ${LIBRARIES} ) -set_target_properties( common_base PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( common_base PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) include_directories( ${INCLUDE_DIRS} ) set( HAVE_common_base ON CACHE BOOL "common_base target is available" ) mark_as_advanced( HAVE_common_base ) @@ -128,13 +128,13 @@ set( COMMON_SQL_SOURCES set( DEPENDENCIES common_base ) set( LIBRARIES ${MYSQL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) set( SOURCE_FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) source_group( common FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) add_library( common_sql ${SOURCE_FILES} ) add_dependencies( common_sql ${DEPENDENCIES} ) target_link_libraries( common_sql ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( common_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( common_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) include_directories( ${INCLUDE_DIRS} ) set( HAVE_common_sql ON CACHE BOOL "common_sql target is available" ) mark_as_advanced( HAVE_common_sql ) diff --git a/src/login/sql/CMakeLists.txt b/src/login/sql/CMakeLists.txt index ed23ba684..85ad44e94 100644 --- a/src/login/sql/CMakeLists.txt +++ b/src/login/sql/CMakeLists.txt @@ -19,7 +19,7 @@ set( SQL_LOGIN_SOURCES set( DEPENDENCIES common_sql ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_SQL ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DWITH_SQL" ) set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) source_group( login FILES ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) @@ -27,7 +27,7 @@ include_directories( ${INCLUDE_DIRS} ) add_executable( login-server_sql ${SOURCE_FILES} ) add_dependencies( login-server_sql ${DEPENDENCIES} ) target_link_libraries( login-server_sql ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( login-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( login-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_loginserver_sql DESCRIPTION "login-server (sql version)" DISPLAY_NAME "login-server_sql" GROUP Runtime ) install( TARGETS login-server_sql diff --git a/src/login/txt/CMakeLists.txt b/src/login/txt/CMakeLists.txt index 195de250e..a8d1246b7 100644 --- a/src/login/txt/CMakeLists.txt +++ b/src/login/txt/CMakeLists.txt @@ -19,7 +19,7 @@ set( TXT_LOGIN_SOURCES set( DEPENDENCIES common_base ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} WITH_TXT ) +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} ) @@ -27,7 +27,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( login-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_loginserver_txt DESCRIPTION "login-server (txt version)" DISPLAY_NAME "login-server" GROUP Runtime ) install( TARGETS login-server diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index ae16148d4..591e3e65b 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -80,12 +80,12 @@ set( SQL_MAP_SOURCES set( DEPENDENCIES common_sql ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) if( WITH_PCRE ) message( STATUS "Using PCRE" ) - list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) - list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) - list( APPEND DEFINITIONS PCRE_SUPPORT ) + set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} ) + set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} ) + set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" ) endif() set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_MAP_HEADERS} ${SQL_MAP_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) @@ -94,7 +94,7 @@ include_directories( ${INCLUDE_DIRS} ) add_executable( map-server_sql ${SOURCE_FILES} ) add_dependencies( map-server_sql ${DEPENDENCIES} ) target_link_libraries( map-server_sql ${LIBRARIES} ${DEPENDENCIES} ) -set_target_properties( map-server_sql PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( map-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapserver_sql DESCRIPTION "map-server (sql version)" DISPLAY_NAME "map-server_sql" GROUP Runtime ) install( TARGETS map-server_sql diff --git a/src/map/txt/CMakeLists.txt b/src/map/txt/CMakeLists.txt index 4e3bfbb0c..878ab68d2 100644 --- a/src/map/txt/CMakeLists.txt +++ b/src/map/txt/CMakeLists.txt @@ -80,12 +80,12 @@ set( TXT_MAP_SOURCES set( DEPENDENCIES common_base ) set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} TXT_ONLY ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DTXT_ONLY" ) if( WITH_PCRE ) message( STATUS "Using PCRE" ) - list( APPEND LIBRARIES ${PCRE_LIBRARIES} ) - list( APPEND INCLUDE_DIRS ${PCRE_INCLUDE_DIRS} ) - list( APPEND DEFINITIONS PCRE_SUPPORT ) + set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} ) + set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} ) + set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" ) endif() set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_MAP_HEADERS} ${TXT_MAP_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ) @@ -94,7 +94,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( map-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapserver_txt DESCRIPTION "map-server (txt version)" DISPLAY_NAME "map-server" GROUP Runtime ) install( TARGETS map-server diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index df22e150a..26595b404 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -19,14 +19,14 @@ set( MAPCACHE_SOURCES ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS}" ) set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${MAPCACHE_SOURCES} ) source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) source_group( mapcache FILES ${MAPCACHE_SOURCES} ) add_executable( mapcache ${SOURCE_FILES} ) include_directories( ${INCLUDE_DIRS} ) target_link_libraries( mapcache ${LIBRARIES} ) -set_target_properties( mapcache PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( mapcache PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime ) install( TARGETS mapcache diff --git a/src/txt-converter/char/CMakeLists.txt b/src/txt-converter/char/CMakeLists.txt index dab0df76a..ecdc28091 100644 --- a/src/txt-converter/char/CMakeLists.txt +++ b/src/txt-converter/char/CMakeLists.txt @@ -55,7 +55,7 @@ set( CONVERTER_SOURCES ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} TXT_SQL_CONVERT ) +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} ) @@ -64,7 +64,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( char-converter PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_charconverter DESCRIPTION "char-converter" DISPLAY_NAME "char-converter" GROUP Runtime ) install( TARGETS char-converter diff --git a/src/txt-converter/login/CMakeLists.txt b/src/txt-converter/login/CMakeLists.txt index 8ae7665f4..8cf333438 100644 --- a/src/txt-converter/login/CMakeLists.txt +++ b/src/txt-converter/login/CMakeLists.txt @@ -39,7 +39,7 @@ set( CONVERTER_SOURCES ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS ${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} WITH_TXT WITH_SQL ) +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} ) @@ -48,7 +48,7 @@ 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_DEFINITIONS "${DEFINITIONS}" ) +set_target_properties( login-converter PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( WITH_COMPONENT_RUNTIME ) cpack_add_component( Runtime_loginconverter DESCRIPTION "login-converter" DISPLAY_NAME "login-converter" GROUP Runtime ) install( TARGETS login-converter -- cgit v1.2.3-70-g09d2 From a0383842abeb49c65c05832b51161dfaecc67fcb Mon Sep 17 00:00:00 2001 From: flaviojs Date: Tue, 12 Jul 2011 22:01:45 +0000 Subject: * CMake: added search for math.h, added search for socket/nsl library. (tested with Solaris-201011-x86) * Added missing include to socket.c. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14903 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/cmake/FindMYSQL.cmake | 2 ++ 3rdparty/cmake/FindPCRE.cmake | 5 +++-- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++++++----- Changelog-Trunk.txt | 2 ++ src/common/socket.c | 3 +++ 5 files changed, 46 insertions(+), 7 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/cmake/FindMYSQL.cmake b/3rdparty/cmake/FindMYSQL.cmake index 0a07f3612..c18e8d637 100644 --- a/3rdparty/cmake/FindMYSQL.cmake +++ b/3rdparty/cmake/FindMYSQL.cmake @@ -10,6 +10,7 @@ find_path( MYSQL_INCLUDE_DIRS "mysql.h" PATHS "/usr/include/mysql" "/usr/local/include/mysql" + "/usr/mysql/include/mysql" "$ENV{PROGRAMFILES}/MySQL/*/include" "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) @@ -18,6 +19,7 @@ find_library( MYSQL_LIBRARIES PATHS "/usr/lib/mysql" "/usr/local/lib/mysql" + "/usr/mysql/lib/mysql" "$ENV{PROGRAMFILES}/MySQL/*/lib" "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) diff --git a/3rdparty/cmake/FindPCRE.cmake b/3rdparty/cmake/FindPCRE.cmake index cb4d9177b..2215451d1 100644 --- a/3rdparty/cmake/FindPCRE.cmake +++ b/3rdparty/cmake/FindPCRE.cmake @@ -6,8 +6,9 @@ # PCRE_FOUND - True if pcre found. -find_path( PCRE_INCLUDE_DIR pcre.h ) - +find_path( PCRE_INCLUDE_DIR pcre.h + PATHS + "/usr/include/pcre" ) set( PCRE_NAMES pcre ) find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b6d3ebc6..41752f489 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,11 +40,12 @@ elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" ) message( FATAL_ERROR "Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n" "Example: (build in subdir 'build' and install to source dir)\n" + " rm -f CMakeCache.txt\n" " mkdir build && cd build\n" - " cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE:bool=ON ..\n" + " cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n" " make install\n" " cd .. && rm -rf build\n" - "To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY:bool=ON)" ) + "To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY=ON)" ) endif() @@ -96,17 +97,23 @@ endif() # SVNVERSION # if( SVNVERSION_EXECUTABLE ) + message( STATUS "Getting svn version" ) execute_process( COMMAND ${SVNVERSION_EXECUTABLE} ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE SVNVERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) string( REGEX REPLACE "[^1234567890MSexported]" "_" SVNVERSION ${SVNVERSION} ) + message( STATUS "Found version: ${SVNVERSION}" ) + message( STATUS "Getting svn version - done" ) endif() if( Subversion_FOUND AND SVNVERSION ) + message( STATUS "Getting svn branch" ) Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} eAthena ) if( eAthena_WC_URL ) string( REGEX MATCH "[^/]+$" BRANCH ${eAthena_WC_URL} ) set( SVNVERSION "${BRANCH}-${SVNVERSION}" ) + message( STATUS "Found branch: ${BRANCH}" ) endif() + message( STATUS "Getting svn branch - done" ) endif() @@ -115,15 +122,19 @@ endif() # add_subdirectory( 3rdparty ) include( FindFunctionLibrary ) +include( CheckIncludeFile ) # -# math library (FreeBSD/Linux) +# math library (FreeBSD/Linux/Solaris) # message( STATUS "Detecting m library (math)" ) +CHECK_INCLUDE_FILE( math.h HAVE_MATH_H ) +if( NOT HAVE_MATH_H ) + message( FATAL_ERROR "math.h not found" ) +endif() set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) find_function_library( floor FUNCTION_FLOOR_LIBRARIES m ) -mark_as_advanced( FUNCTION_FLOOR_LIBRARIES ) if( FUNCTION_FLOOR_LIBRARIES ) message( STATUS "Adding global library: ${FUNCTION_FLOOR_LIBRARIES}" ) list( APPEND GLOBAL_LIBRARIES ${FUNCTION_FLOOR_LIBRARIES} ) @@ -138,7 +149,6 @@ if( NOT WIN32 ) message( STATUS "Detecting dl library (dynamic loading)" ) set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) find_function_library( dlopen FUNCTION_DLOPEN_LIBRARIES dl ) -mark_as_advanced( FUNCTION_DLOPEN_LIBRARIES ) if( FUNCTION_DLOPEN_LIBRARIES ) message( STATUS "Adding global library: ${FUNCTION_DLOPEN_LIBRARIES}" ) list( APPEND GLOBAL_LIBRARIES ${FUNCTION_DLOPEN_LIBRARIES} ) @@ -147,6 +157,27 @@ message( STATUS "Detecting dl library (dynamic loading) - done" ) endif() +# +# socket/nsl library (Solaris) +# +if( NOT WIN32 ) +message( STATUS "Detecting socket/nsl library (networking)" ) +set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) +find_function_library( bind FUNCTION_BIND_LIBRARIES socket ) +if( FUNCTION_BIND_LIBRARIES ) + message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" ) + list( APPEND GLOBAL_LIBRARIES ${FUNCTION_BIND_LIBRARIES} ) +endif() +set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) +find_function_library( gethostbyname FUNCTION_GETHOSTBYNAME_LIBRARIES nsl ) +if( FUNCTION_GETHOSTBYNAME_LIBRARIES ) + message( STATUS "Adding global library: ${FUNCTION_GETHOSTBYNAME_LIBRARIES}" ) + list( APPEND GLOBAL_LIBRARIES ${FUNCTION_GETHOSTBYNAME_LIBRARIES} ) +endif() +message( STATUS "Detecting socket/nsl library (networking) - done" ) +endif() + + ##################################################################### # package stuff # diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 24de77fcb..14ec4601f 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -2,6 +2,8 @@ Date Added 2011/07/12 * CMake: set project language to C, added module FindFunctionLibrary, added search for dl library. (tested with debian-wheezy-i386) [FlavioJS] + * CMake: added search for math.h, added search for socket/nsl library. (tested with Solaris-201011-x86) + * Added missing include to socket.c. 2011/07/11 * Rev. 14901 Added bonus3 bAddClassDropItem, care of Epoque. [L0ne_W0lf] 2011/07/10 diff --git a/src/common/socket.c b/src/common/socket.c index 81ea19468..84cbaf1ea 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -32,6 +32,9 @@ #ifndef SIOCGIFCONF #include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] #endif + #ifndef FIONBIO + #include // FIONBIO on Solaris [FlavioJS] + #endif #ifdef HAVE_SETRLIMIT #include -- cgit v1.2.3-70-g09d2 From ce4806100ca775d9086115f7f57beb0138f8c2f1 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Wed, 13 Jul 2011 01:58:32 +0000 Subject: * CMake: added search for ws2_32 library. (tested with MinGW/MSYS) * Added missing pcre library for MinGW. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14904 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/msinttypes/CMakeLists.txt | 2 +- 3rdparty/pcre/lib/libpcre.dll.a | Bin 0 -> 19068 bytes CMakeLists.txt | 18 ++++++++++-------- Changelog-Trunk.txt | 2 ++ 4 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 3rdparty/pcre/lib/libpcre.dll.a (limited to '3rdparty') diff --git a/3rdparty/msinttypes/CMakeLists.txt b/3rdparty/msinttypes/CMakeLists.txt index f7a662fe8..c11c1d72a 100644 --- a/3rdparty/msinttypes/CMakeLists.txt +++ b/3rdparty/msinttypes/CMakeLists.txt @@ -1,5 +1,5 @@ -if( WIN32 ) +if( MSVC ) find_path( MSINTTYPES_INCLUDE_DIRS "inttypes.h" PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" NO_DEFAULT_PATH ) diff --git a/3rdparty/pcre/lib/libpcre.dll.a b/3rdparty/pcre/lib/libpcre.dll.a new file mode 100644 index 000000000..fe69e4e57 Binary files /dev/null and b/3rdparty/pcre/lib/libpcre.dll.a differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 41752f489..2960b822d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,12 @@ elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" ) "Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n" "Example: (build in subdir 'build' and install to source dir)\n" " rm -f CMakeCache.txt\n" - " mkdir build && cd build\n" + " mkdir build\n" + " cd build\n" " cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n" " make install\n" - " cd .. && rm -rf build\n" + " cd ..\n" + " rm -rf build\n" "To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY=ON)" ) endif() @@ -58,9 +60,9 @@ set( GLOBAL_DEFINITIONS ${COMPILE_DEFINITIONS} CACHE INTERNAL "" )# string (spa mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS ) if( WIN32 ) set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DFD_SETSIZE=4096" ) - set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} "oldnames.lib" "ws2_32.lib" ) endif() if( MSVC ) + set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} "oldnames.lib" "ws2_32.lib" ) set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DDB_MANUAL_CAST_TO_UNION" ) endif() @@ -158,12 +160,12 @@ endif() # -# socket/nsl library (Solaris) +# socket/nsl/ws2_32 library (Solaris/MinGW) # -if( NOT WIN32 ) -message( STATUS "Detecting socket/nsl library (networking)" ) +if( NOT MSVC ) +message( STATUS "Detecting socket/nsl/ws2_32 library (networking)" ) set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ) -find_function_library( bind FUNCTION_BIND_LIBRARIES socket ) +find_function_library( bind FUNCTION_BIND_LIBRARIES socket ws2_32 ) if( FUNCTION_BIND_LIBRARIES ) message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" ) list( APPEND GLOBAL_LIBRARIES ${FUNCTION_BIND_LIBRARIES} ) @@ -174,7 +176,7 @@ if( FUNCTION_GETHOSTBYNAME_LIBRARIES ) message( STATUS "Adding global library: ${FUNCTION_GETHOSTBYNAME_LIBRARIES}" ) list( APPEND GLOBAL_LIBRARIES ${FUNCTION_GETHOSTBYNAME_LIBRARIES} ) endif() -message( STATUS "Detecting socket/nsl library (networking) - done" ) +message( STATUS "Detecting socket/nsl/ws2_32 library (networking) - done" ) endif() diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 14ec4601f..3d5d32577 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ Date Added * CMake: set project language to C, added module FindFunctionLibrary, added search for dl library. (tested with debian-wheezy-i386) [FlavioJS] * CMake: added search for math.h, added search for socket/nsl library. (tested with Solaris-201011-x86) * Added missing include to socket.c. + * CMake: added search for ws2_32 library. (tested with MinGW/MSYS) + * Added missing pcre library for MinGW. 2011/07/11 * Rev. 14901 Added bonus3 bAddClassDropItem, care of Epoque. [L0ne_W0lf] 2011/07/10 -- cgit v1.2.3-70-g09d2 From 6fc804e12ad7db569e82229cc11a361066cec682 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Thu, 8 Sep 2011 19:47:26 +0000 Subject: * Fix C++ compilation issues. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14955 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/msinttypes/include/stdint.h | 4 ++++ Changelog-Trunk.txt | 2 ++ src/char/char.c | 4 ++-- src/char_sql/char.c | 2 +- src/common/cbasetypes.h | 29 +++++++++++++++++++++++++++++ src/common/db.h | 6 +++--- src/common/grfio.c | 8 ++++---- src/common/grfio.h | 4 ++-- src/common/plugin.h | 2 +- src/common/strlib.c | 4 ++-- src/login/account_txt.c | 8 ++++---- src/map/clif.c | 2 +- src/map/map.c | 8 ++++---- src/map/mob.c | 26 +++++++++++++++----------- src/map/npc.c | 2 +- src/map/npc_chat.c | 14 +++++++------- src/map/script.c | 2 +- src/map/searchstore.c | 4 ++-- src/map/status.c | 2 +- src/map/status.h | 2 +- src/plugins/sig.c | 7 ++++++- src/tool/mapcache.c | 2 +- 22 files changed, 94 insertions(+), 50 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/msinttypes/include/stdint.h b/3rdparty/msinttypes/include/stdint.h index d02608a59..cbb023bf9 100644 --- a/3rdparty/msinttypes/include/stdint.h +++ b/3rdparty/msinttypes/include/stdint.h @@ -47,8 +47,12 @@ // or compiler give many errors like this: // error C2733: second C linkage of overloaded function 'wmemchr' not allowed #ifdef __cplusplus +#if _MSC_VER < 1300 +extern "C++" { +#else extern "C" { #endif +#endif # include #ifdef __cplusplus } diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index d10207c3c..7ad1e3d79 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/09/08 + * Fix C++ compilation issues. [FlavioJS] 2011/09/05 * Add consistency checks to the shortlist. [FlavioJS] * Restrict intif_quest_save to sql only. txt char-server doesn't support the packet and disconnects the map-server. diff --git a/src/char/char.c b/src/char/char.c index 6e7100403..dfcbc9230 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -436,7 +436,7 @@ int search_character_online(int aid, int cid) { //Look for online character. struct online_char_data* character; - character = idb_get(online_char_db, aid); + character = (struct online_char_data*)idb_get(online_char_db, aid); if(character && character->char_id == cid && character->server > -1) @@ -2208,7 +2208,7 @@ 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); - safestrncpy(sd->birthdate, RFIFOP(fd,51), sizeof(sd->birthdate)); + safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate)); // continued from char_auth_ok... if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level ) diff --git a/src/char_sql/char.c b/src/char_sql/char.c index f7c9e0fa0..0654be60a 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -1964,7 +1964,7 @@ 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); - safestrncpy(sd->birthdate, RFIFOP(fd,51), sizeof(sd->birthdate)); + safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate)); // continued from char_auth_ok... if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level ) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 27420edbf..58acad2c7 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -77,6 +77,12 @@ // portable printf/scanf format macros and integer definitions // NOTE: Visual C++ uses and provided in /3rdparty ////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +#define __STDC_CONSTANT_MACROS +#define __STDC_FORMAT_MACROS +#define __STDC_LIMIT_MACROS +#endif + #include #include #include @@ -326,4 +332,27 @@ typedef char bool; #endif #endif + +////////////////////////////////////////////////////////////////////////// +// Set a pointer variable to a pointer value. +#ifdef __cplusplus +template +void SET_POINTER(T1*&var, T2* p) +{ + var = static_cast(p); +} +template +void SET_FUNCPOINTER(T1& var, T2 p) +{ + char ASSERT_POINTERSIZE[sizeof(T1) == sizeof(void*) && sizeof(T2) == sizeof(void*)?1:-1];// 1 if true, -1 if false + union{ T1 out; T2 in; } tmp;// /!\ WARNING casting a pointer to a function pointer is against the C++ standard + tmp.in = p; + var = tmp.out; +} +#else +#define SET_POINTER(var,p) (var) = (p) +#define SET_FUNCPOINTER(var,p) (var) = (p) +#endif + + #endif /* _CBASETYPES_H_ */ diff --git a/src/common/db.h b/src/common/db.h index d33b8ec2e..e5515803c 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -994,8 +994,8 @@ void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... ); do{ \ if( (__n) > VECTOR_CAPACITY(__vec) ) \ { /* increase size */ \ - if( VECTOR_CAPACITY(__vec) == 0 ) VECTOR_DATA(__vec) = aMalloc((__n)*sizeof(VECTOR_FIRST(__vec))); /* allocate new */ \ - else VECTOR_DATA(__vec) = aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec))); /* reallocate */ \ + if( VECTOR_CAPACITY(__vec) == 0 ) SET_POINTER(VECTOR_DATA(__vec), aMalloc((__n)*sizeof(VECTOR_FIRST(__vec)))); /* allocate new */ \ + else SET_POINTER(VECTOR_DATA(__vec), aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec)))); /* reallocate */ \ memset(VECTOR_DATA(__vec)+VECTOR_LENGTH(__vec), 0, (VECTOR_CAPACITY(__vec)-VECTOR_LENGTH(__vec))*sizeof(VECTOR_FIRST(__vec))); /* clear new data */ \ VECTOR_CAPACITY(__vec) = (__n); /* update capacity */ \ } \ @@ -1007,7 +1007,7 @@ void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... ); } \ else if( (__n) < VECTOR_CAPACITY(__vec) ) \ { /* reduce size */ \ - VECTOR_DATA(__vec) = aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec))); /* reallocate */ \ + SET_POINTER(VECTOR_DATA(__vec), aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec)))); /* reallocate */ \ VECTOR_CAPACITY(__vec) = (__n); /* update capacity */ \ if( VECTOR_LENGTH(__vec) > (__n) ) VECTOR_LENGTH(__vec) = (__n); /* update length */ \ } \ diff --git a/src/common/grfio.c b/src/common/grfio.c index cb242fe5d..1d1ce756f 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -223,17 +223,17 @@ unsigned long grfio_crc32 (const unsigned char* buf, unsigned int len) /////////////////////////////////////////////////////////////////////////////// /// Grf data sub : zip decode -int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) { - return uncompress(dest, destLen, source, sourceLen); + return uncompress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen); } /////////////////////////////////////////////////////////////////////////////// /// Grf data sub : zip encode -int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) { - return compress(dest, destLen, source, sourceLen); + return compress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen); } diff --git a/src/common/grfio.h b/src/common/grfio.h index d0baa6609..0fc9f958d 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -14,7 +14,7 @@ char *grfio_find_file(char *fname); int grfio_size(char*); // GRFIO data file size get unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); -int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); -int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); +int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); +int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); #endif /* _GRFIO_H_ */ diff --git a/src/common/plugin.h b/src/common/plugin.h index a367d2537..ec6399c57 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -50,7 +50,7 @@ typedef void Plugin_Event_Func(void); #define PLUGIN_MAP 8 #define PLUGIN_CORE 16 -#define IMPORT_SYMBOL(s,n) (s) = plugin_call_table[n] +#define IMPORT_SYMBOL(s,n) SET_FUNCPOINTER((s), plugin_call_table[n]) #define SYMBOL_SERVER_TYPE 0 #define SYMBOL_SERVER_NAME 1 diff --git a/src/common/strlib.c b/src/common/strlib.c index 097f499e6..7f79a5ef0 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -245,7 +245,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char* string, size_t maxlen) { - const char* end = memchr (string, '\0', maxlen); + const char* end = (const char*)memchr(string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; } #endif @@ -980,7 +980,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc // allocate enough memory for the maximum requested amount of columns plus the reserved one fields_length = maxcols+1; - fields = aMalloc(fields_length*sizeof(char*)); + fields = (char**)aMalloc(fields_length*sizeof(char*)); // process rows one by one while( fgets(line, sizeof(line), fp) ) diff --git a/src/login/account_txt.c b/src/login/account_txt.c index 821e26df5..79e22ac3b 100644 --- a/src/login/account_txt.c +++ b/src/login/account_txt.c @@ -283,7 +283,7 @@ static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc) return false; // check if the account_id is free - tmp = idb_get(accounts, account_id); + 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); @@ -316,7 +316,7 @@ static bool account_db_txt_remove(AccountDB* self, const int account_id) DBMap* accounts = db->accounts; //TODO: find out if this really works - struct mmo_account* tmp = idb_remove(accounts, account_id); + 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); @@ -337,7 +337,7 @@ static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc) int account_id = acc->account_id; // retrieve previous data - struct mmo_acount* tmp = idb_get(accounts, account_id); + struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id); if( tmp == NULL ) {// error condition - entry not found return false; @@ -360,7 +360,7 @@ static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, co DBMap* accounts = db->accounts; // retrieve data - struct mmo_account* tmp = idb_get(accounts, account_id); + struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id); if( tmp == NULL ) {// entry not found return false; diff --git a/src/map/clif.c b/src/map/clif.c index 5e8ef2367..5d6a828d3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11160,7 +11160,7 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) return; } - guild_change_emblem(sd, emblem_len, emblem); + guild_change_emblem(sd, emblem_len, (const char*)emblem); } /*========================================== diff --git a/src/map/map.c b/src/map/map.c index 559cab96d..39077de6c 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2676,7 +2676,7 @@ static char *map_init_mapcache(FILE *fp) fseek(fp, 0, SEEK_SET); // Allocate enough space - CREATE(buffer, unsigned char, size); + CREATE(buffer, char, size); // No memory? Return.. nullpo_ret(buffer); @@ -2699,7 +2699,7 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer) int i; struct map_cache_main_header *header = (struct map_cache_main_header *)buffer; struct map_cache_map_info *info = NULL; - unsigned char *p = buffer + sizeof(struct map_cache_main_header); + char *p = buffer + sizeof(struct map_cache_main_header); for(i = 0; i < header->map_count; i++) { info = (struct map_cache_map_info *)p; @@ -2906,8 +2906,8 @@ int map_readallmaps (void) int i; FILE* fp=NULL; int maps_removed = 0; - unsigned char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made - unsigned char map_cache_decode_buffer[MAX_MAP_SIZE]; + char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made + char map_cache_decode_buffer[MAX_MAP_SIZE]; if( enable_grf ) ShowStatus("Loading maps (using GRF files)...\n"); diff --git a/src/map/mob.c b/src/map/mob.c index c20672a13..5272b17e8 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3964,6 +3964,21 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) static const struct { char str[32]; enum MobSkillState id; + } state[] = { + { "any", MSS_ANY }, //All states except Dead + { "idle", MSS_IDLE }, + { "walk", MSS_WALK }, + { "loot", MSS_LOOT }, + { "dead", MSS_DEAD }, + { "attack", MSS_BERSERK }, //Retaliating attack + { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs) + { "chase", MSS_RUSH }, //Chase escaping target + { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs) + { "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow + }; + static const struct { + char str[32]; + int id; } cond1[] = { { "always", MSC_ALWAYS }, { "myhpltmaxrate", MSC_MYHPLTMAXRATE }, @@ -4001,17 +4016,6 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) { "blind", SC_BLIND }, { "hiding", SC_HIDING }, { "sight", SC_SIGHT }, - }, state[] = { - { "any", MSS_ANY }, //All states except Dead - { "idle", MSS_IDLE }, - { "walk", MSS_WALK }, - { "loot", MSS_LOOT }, - { "dead", MSS_DEAD }, - { "attack", MSS_BERSERK }, //Retaliating attack - { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs) - { "chase", MSS_RUSH }, //Chase escaping target - { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs) - { "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow }, target[] = { { "target", MST_TARGET }, { "randomtarget", MST_RANDOM }, diff --git a/src/map/npc.c b/src/map/npc.c index dd3a671b0..ceb1f3f1d 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2340,7 +2340,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch nd->speed = 200; nd->src_id = src_id; nd->bl.type = BL_NPC; - nd->subtype = type; + nd->subtype = (enum npc_subtype)type; switch( type ) { case SCRIPT: diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 99fa40a20..77c875a7e 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -73,8 +73,8 @@ struct pcrematch_entry { struct pcrematch_entry* next; char* pattern; - pcre* pcre; - pcre_extra* pcre_extra; + pcre* pcre_; + pcre_extra* pcre_extra_; char* label; }; @@ -108,8 +108,8 @@ struct npc_parse { */ void finalize_pcrematch_entry(struct pcrematch_entry* e) { - pcre_free(e->pcre); - pcre_free(e->pcre_extra); + pcre_free(e->pcre_); + pcre_free(e->pcre_extra_); aFree(e->pattern); aFree(e->label); } @@ -316,8 +316,8 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c struct pcrematch_entry *e = create_pcrematch_entry(s); e->pattern = aStrdup(pattern); e->label = aStrdup(label); - e->pcre = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL); - e->pcre_extra = pcre_study(e->pcre, 0, &err); + e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL); + e->pcre_extra_ = pcre_study(e->pcre_, 0, &err); } /** @@ -373,7 +373,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap) int offsets[2*10 + 10]; // 1/3 reserved for temp space requred by pcre_exec // perform pattern match - int r = pcre_exec(e->pcre, e->pcre_extra, msg, len, 0, 0, offsets, ARRAYLENGTH(offsets)); + int r = pcre_exec(e->pcre_, e->pcre_extra_, msg, len, 0, 0, offsets, ARRAYLENGTH(offsets)); if (r > 0) { // save out the matched strings diff --git a/src/map/script.c b/src/map/script.c index 66b61a419..0da5e21aa 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -901,7 +901,7 @@ int add_word(const char* p) disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alfanumeric characters, and valid variable prefixes/postfixes.", p); // Duplicate the word - word = aMalloc(len+1); + word = (char*)aMalloc(len+1); memcpy(word, p, len); word[len] = 0; diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 76f0d4e2e..c59c13bed 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -184,7 +184,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned searchstore_clear(sd); // allocate max. amount of results - sd->searchstore.items = aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults); + sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults); // search s.search_sd = sd; @@ -215,7 +215,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned if( sd->searchstore.count ) { // reclaim unused memory - sd->searchstore.items = aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count); + sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count); // present results clif_search_store_info_ack(sd); diff --git a/src/map/status.c b/src/map/status.c index 00708428e..89ad5c483 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2723,7 +2723,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str /// Recalculates parts of an object's battle status according to the specified flags. /// @param flag bitfield of values from enum scb_flag -void status_calc_bl_main(struct block_list *bl, enum scb_flag flag) +void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { const struct status_data *b_status = status_get_base_status(bl); struct status_data *status = status_get_status_data(bl); diff --git a/src/map/status.h b/src/map/status.h index c7ad8a9cf..d3f5a2f48 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1293,7 +1293,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap); int status_change_clear(struct block_list* bl, int type); int status_change_clear_buffs(struct block_list* bl, int type); -#define status_calc_bl(bl, flag) status_calc_bl_(bl, flag, false) +#define status_calc_bl(bl, flag) status_calc_bl_(bl, (enum scb_flag)(flag), false) #define status_calc_mob(md, first) status_calc_bl_(&(md)->bl, SCB_ALL, first) #define status_calc_pet(pd, first) status_calc_bl_(&(pd)->bl, SCB_ALL, first) #define status_calc_pc(sd, first) status_calc_bl_(&(sd)->bl, SCB_ALL, first) diff --git a/src/plugins/sig.c b/src/plugins/sig.c index 9db0638ca..e0d10ba43 100644 --- a/src/plugins/sig.c +++ b/src/plugins/sig.c @@ -88,7 +88,12 @@ sigfunc *compat_signal(int signo, sigfunc *func) */ #ifdef CYGWIN #define FOPEN_ freopen + #ifdef __cplusplus + extern "C" void cygwin_stackdump(); + #else extern void cygwin_stackdump(); + #endif + #else #define FOPEN_(fn,m,s) fopen(fn,m) #endif @@ -186,7 +191,7 @@ int sig_final () */ int sig_init () { - void (*func) = sig_dump; + void (*func)(int) = sig_dump; #ifdef CYGWIN // test if dumper is enabled char *buf = getenv ("CYGWIN"); if (buf && strstr(buf, "error_start") != NULL) diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index f1a7559f1..b3bfec01b 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -246,7 +246,7 @@ void process_args(int argc, char *argv[]) } -int do_init(int argc, char *argv[]) +int do_init(int argc, char** argv) { FILE *list; char line[1024]; -- 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 '3rdparty') 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: Mon, 30 Jan 2012 20:17:55 +0000 Subject: - Removed more trailing tabs. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15527 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/mysql/include/m_ctype.h | 2 +- db/pre-re/skill_require_db.txt | 6 +- db/re/skill_require_db.txt | 6 +- doc/ea_job_system.txt | 2 +- doc/item_bonus.txt | 2 +- doc/pccommand_list.txt | 4 +- npc/cities/comodo.txt | 2 +- npc/cities/geffen.txt | 4 +- npc/cities/hugel.txt | 2 +- npc/cities/izlude.txt | 2 +- npc/cities/lutie.txt | 2 +- npc/cities/yuno.txt | 2 +- npc/custom/banks/bank.txt | 2 +- npc/custom/eAAC_Scripts/kafraExpress/config.txt | 4 +- .../kafraExpress/global_functionsKE.txt | 3 +- .../eAAC_Scripts/kafraExpress/ke_jobswap.txt | 2 +- npc/custom/eAAC_Scripts/kafraExpress/ke_refine.txt | 4 +- npc/custom/eAAC_Scripts/kafraExpress/ke_shop.txt | 2 +- .../eAAC_Scripts/kafraExpress/ke_warp_dungeon.txt | 40 +++++------ npc/custom/eAAC_Scripts/kafraExpress/readme.txt | 2 +- npc/custom/jobs/jobmaster.txt | 2 +- npc/custom/marriage.txt | 2 +- npc/events/christmas_2008.txt | 8 +-- npc/events/event_skill_reset.txt | 2 +- npc/events/halloween_2006.txt | 2 +- npc/events/halloween_2008.txt | 2 +- npc/events/halloween_2009.txt | 4 +- npc/events/idul_fitri.txt | 2 +- npc/events/twintowers.txt | 4 +- npc/events/valentinesday_2009.txt | 6 +- npc/guild/agit_controller.txt | 2 +- npc/guild/agit_template.txt | 6 +- npc/jobs/1-1/thief.txt | 6 +- npc/jobs/1-1e/gunslinger.txt | 2 +- npc/jobs/2-1/hunter.txt | 2 +- npc/jobs/2-1e/StarGladiator.txt | 4 +- npc/jobs/3-1/warlock.txt | 4 +- npc/jobs/3-2/wanderer.txt | 82 +++++++++++----------- npc/jobs/novice/novice.txt | 6 +- npc/merchants/buying_shops.txt | 2 +- npc/merchants/cashheadgear_dye.txt | 2 +- npc/merchants/clothes_dyer.txt | 2 +- npc/merchants/icecream.txt | 2 +- npc/merchants/refine.txt | 4 +- npc/other/arena/arena_lvl50.txt | 32 ++++----- npc/other/arena/arena_lvl60.txt | 36 +++++----- npc/other/arena/arena_lvl70.txt | 38 +++++----- npc/other/arena/arena_lvl80.txt | 40 +++++------ npc/other/arena/arena_party.txt | 10 +-- npc/other/bulletin_boards.txt | 2 +- npc/other/comodo_gambling.txt | 2 +- npc/other/hugel_bingo.txt | 2 +- npc/other/mercenary_rent.txt | 4 +- npc/quests/Dandelion_Request.txt | 4 +- npc/quests/Kiel_Hyre_Quest.txt | 6 +- npc/quests/Lvl4_weapon_quest.txt | 2 +- npc/quests/bunnyband.txt | 2 +- npc/quests/first_class/tu_archer.txt | 4 +- npc/quests/first_class/tu_merchant.txt | 6 +- npc/quests/first_class/tu_sword.txt | 4 +- npc/quests/gunslinger_quests.txt | 4 +- npc/quests/newgears/2005_headgears.txt | 6 +- npc/quests/ninja_quests.txt | 4 +- npc/quests/quests_comodo.txt | 2 +- npc/quests/quests_ein.txt | 6 +- npc/quests/quests_gonryun.txt | 2 +- npc/quests/quests_hugel.txt | 10 +-- npc/quests/quests_juperos.txt | 12 ++-- npc/quests/quests_lighthalzen.txt | 14 ++-- npc/quests/quests_louyang.txt | 2 +- npc/quests/quests_moscovia.txt | 8 +-- npc/quests/quests_nameless.txt | 4 +- npc/quests/quests_rachel.txt | 2 +- npc/quests/quests_umbala.txt | 6 +- npc/quests/quiz/quiz_qt.txt | 6 +- npc/quests/seals/brisingamen_seal.txt | 2 +- npc/quests/skills/crusader_skills.txt | 2 +- src/char/char.c | 4 +- src/char/int_guild.c | 4 +- src/common/showmsg.c | 14 ++-- src/common/utils.c | 4 +- src/login/account_sql.c | 2 +- src/login/login.c | 2 +- src/map/atcommand.c | 10 +-- src/map/battle.c | 16 ++--- src/map/battle.h | 2 +- src/map/chrif.c | 2 +- src/map/chrif.h | 2 +- src/map/clif.c | 8 +-- src/map/homunculus.c | 2 +- src/map/instance.c | 2 +- src/map/itemdb.c | 6 +- src/map/map.c | 4 +- src/map/map.h | 2 +- src/map/mob.c | 16 ++--- src/map/npc.c | 12 ++-- src/map/pc.c | 8 +-- src/map/pc.h | 2 +- src/map/pet.c | 6 +- src/map/quest.c | 2 +- src/map/script.c | 30 ++++---- src/map/skill.c | 26 +++---- src/map/status.c | 26 +++---- src/map/status.h | 8 +-- src/map/storage.c | 2 +- src/map/unit.c | 6 +- src/plugins/console.c | 2 +- src/plugins/dbghelpplug.c | 2 +- 108 files changed, 387 insertions(+), 388 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/mysql/include/m_ctype.h b/3rdparty/mysql/include/m_ctype.h index 54ae41bf2..7d058d89d 100644 --- a/3rdparty/mysql/include/m_ctype.h +++ b/3rdparty/mysql/include/m_ctype.h @@ -76,7 +76,7 @@ extern MY_UNICASE_INFO *my_unicase_turkish[256]; #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_CS_CSSORT 1024 /* if case sensitive sort order */ #define MY_CHARSET_UNDEFINED 0 diff --git a/db/pre-re/skill_require_db.txt b/db/pre-re/skill_require_db.txt index 5e56d7b44..ee6964fc1 100644 --- a/db/pre-re/skill_require_db.txt +++ b/db/pre-re/skill_require_db.txt @@ -73,7 +73,7 @@ 61,0,0,3,0,0,0,0:1:2:3:4:5:6:7:8:9:10:12:13:14:15:16:17:18:19:20:21:22,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //KN_AUTOCOUNTER#ƒI?ƒgƒJƒEƒ“ƒ^?# 62,0,0,13:14:15:16:17:18:19:20:21:22,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //KN_BOWLINGBASH#ƒ{ƒEƒŠƒ“ƒOƒoƒbƒVƒ…# -66,0,0,13:16:19:22:25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_IMPOSITIO#ƒCƒ€ƒ|ƒVƒeƒBƒIƒ}ƒkƒX# +66,0,0,13:16:19:22:25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_IMPOSITIO#ƒCƒ€ƒ|ƒVƒeƒBƒIƒ}ƒkƒX# 67,0,0,8,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_SUFFRAGIUM#ƒTƒtƒ‰ƒMƒEƒ€# 68,0,0,14:18:22:26:30,0,0,0,99,0,0,none,0,523,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_ASPERSIO#ƒAƒXƒyƒ‹ƒVƒI# 69,0,0,20,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_BENEDICTIO#¹?~•Ÿ# @@ -121,7 +121,7 @@ 124,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_REMOVETRAP#ƒŠƒ€?ƒuƒgƒ‰ƒbƒv# 125,0,0,1,0,0,0,99,0,0,none,0,1065,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_TALKIEBOX#ƒg?ƒL?ƒ{ƒbƒNƒX# -129,0,0,10:13:16:19:22,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_BLITZBEAT#ƒuƒŠƒbƒcƒr?ƒg# +129,0,0,10:13:16:19:22,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_BLITZBEAT#ƒuƒŠƒbƒcƒr?ƒg# 130,0,0,8,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_DETECTING#ƒfƒBƒeƒNƒeƒBƒ“ƒO# 131,0,0,10,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_SPRINGTRAP#ƒXƒvƒŠƒ“ƒOƒgƒ‰ƒbƒv# @@ -168,7 +168,7 @@ 232,0,0,20,0,0,0,99,0,0,none,0,7137,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CANNIBALIZE#ƒoƒCƒIƒvƒ‰ƒ“ƒg# 233,0,0,10,0,0,0,99,0,0,none,0,7138,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_SPHEREMINE#ƒXƒtƒBƒA?ƒ}ƒCƒ“# 234,0,0,30,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_WEAPON#ƒPƒ~ƒJƒ‹ƒEƒFƒ|ƒ“ƒ`ƒƒ?ƒW# -235,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_SHIELD#ƒPƒ~ƒJƒ‹ƒV?ƒ‹ƒhƒ`ƒƒ?ƒW# +235,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_SHIELD#ƒPƒ~ƒJƒ‹ƒV?ƒ‹ƒhƒ`ƒƒ?ƒW# 236,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_ARMOR#ƒPƒ~ƒJƒ‹ƒA?ƒ}?ƒ`ƒƒ?ƒW# 237,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_HELM#ƒPƒ~ƒJƒ‹ƒwƒ‹ƒ€ƒ`ƒƒ?ƒW# diff --git a/db/re/skill_require_db.txt b/db/re/skill_require_db.txt index f153ec5f6..5fcb94aba 100644 --- a/db/re/skill_require_db.txt +++ b/db/re/skill_require_db.txt @@ -73,7 +73,7 @@ 61,0,0,3,0,0,0,0:1:2:3:4:5:6:7:8:9:10:12:13:14:15:16:17:18:19:20:21:22,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //KN_AUTOCOUNTER#ƒI?ƒgƒJƒEƒ“ƒ^?# 62,0,0,13:14:15:16:17:18:19:20:21:22,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //KN_BOWLINGBASH#ƒ{ƒEƒŠƒ“ƒOƒoƒbƒVƒ…# -66,0,0,13:16:19:22:25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_IMPOSITIO#ƒCƒ€ƒ|ƒVƒeƒBƒIƒ}ƒkƒX# +66,0,0,13:16:19:22:25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_IMPOSITIO#ƒCƒ€ƒ|ƒVƒeƒBƒIƒ}ƒkƒX# 67,0,0,8,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_SUFFRAGIUM#ƒTƒtƒ‰ƒMƒEƒ€# 68,0,0,14:18:22:26:30,0,0,0,99,0,0,none,0,523,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_ASPERSIO#ƒAƒXƒyƒ‹ƒVƒI# 69,0,0,20,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //PR_BENEDICTIO#¹?~•Ÿ# @@ -121,7 +121,7 @@ 124,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_REMOVETRAP#ƒŠƒ€?ƒuƒgƒ‰ƒbƒv# 125,0,0,1,0,0,0,99,0,0,none,0,1065,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_TALKIEBOX#ƒg?ƒL?ƒ{ƒbƒNƒX# -129,0,0,10:13:16:19:22,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_BLITZBEAT#ƒuƒŠƒbƒcƒr?ƒg# +129,0,0,10:13:16:19:22,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_BLITZBEAT#ƒuƒŠƒbƒcƒr?ƒg# 130,0,0,8,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_DETECTING#ƒfƒBƒeƒNƒeƒBƒ“ƒO# 131,0,0,10,0,0,0,99,0,0,falcon,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //HT_SPRINGTRAP#ƒXƒvƒŠƒ“ƒOƒgƒ‰ƒbƒv# @@ -168,7 +168,7 @@ 232,0,0,20,0,0,0,99,0,0,none,0,7137,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CANNIBALIZE#ƒoƒCƒIƒvƒ‰ƒ“ƒg# 233,0,0,10,0,0,0,99,0,0,none,0,7138,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_SPHEREMINE#ƒXƒtƒBƒA?ƒ}ƒCƒ“# 234,0,0,30,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_WEAPON#ƒPƒ~ƒJƒ‹ƒEƒFƒ|ƒ“ƒ`ƒƒ?ƒW# -235,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_SHIELD#ƒPƒ~ƒJƒ‹ƒV?ƒ‹ƒhƒ`ƒƒ?ƒW# +235,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_SHIELD#ƒPƒ~ƒJƒ‹ƒV?ƒ‹ƒhƒ`ƒƒ?ƒW# 236,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_ARMOR#ƒPƒ~ƒJƒ‹ƒA?ƒ}?ƒ`ƒƒ?ƒW# 237,0,0,25,0,0,0,99,0,0,none,0,7139,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //AM_CP_HELM#ƒPƒ~ƒJƒ‹ƒwƒ‹ƒ€ƒ`ƒƒ?ƒW# diff --git a/doc/ea_job_system.txt b/doc/ea_job_system.txt index a2bd01991..229216a9e 100644 --- a/doc/ea_job_system.txt +++ b/doc/ea_job_system.txt @@ -170,7 +170,7 @@ About Novices and Super Novices: EAJ_NOVICE -> Novice EAJ_NOVICE|EAJL_2_1 -> EAJ_SUPER_NOVICE EAJ_NOVICE|EAJL_UPPER -> EAJ_NOVICE_HIGH - EAJ_NOVICE|EAJL_BABY -> EAJ_BABY + EAJ_NOVICE|EAJL_BABY -> EAJ_BABY EAJ_NOVICE|EAJL_BABY|EAJL_2_1 -> EAJ_SUPER_BABY So as you can see, on this job system, the Super Novice is treated as the 2-1 job of a Novice, and the Novice job it's at the same level of the other 1st jobs. Even though that may seem like a hindrance, it makes it very easy to add a check to discard Novice types from a quest: diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt index c6789775e..e0a9c3fbf 100644 --- a/doc/item_bonus.txt +++ b/doc/item_bonus.txt @@ -325,7 +325,7 @@ bonus2 bAddSkillBlow,x,y; Pushback the target by y cells when using skill x (su bonus bSPDrainValue,n; When hitting a monster by physical attack, you gain n SP (use negative numbers so the user loses SP) bonus2 bSPDrainValue,n,x; When hitting a monster by physical attack, ... - x: + x: 0=you gain n SP, 1=you drain n SP from target bonus2 bIgnoreDefRate,n,x; Disregard x% of the target's DEF if the target belongs to race n; diff --git a/doc/pccommand_list.txt b/doc/pccommand_list.txt index 5690941a3..9bf97d270 100644 --- a/doc/pccommand_list.txt +++ b/doc/pccommand_list.txt @@ -135,7 +135,7 @@ can be getmapxy, something like this: - script PCDieEvent -1,{ if (getmapxy(@mapname$,@mapx,@mapy,0) == -1) goto L_Finish; if (@mapname$ == "valkyrie") || (@mapname$ == "amatsu") { -killmonster "valkyrie","All"; +killmonster "valkyrie","All"; announce "Deep Voice: You have failed.... you have another opportunity though...",bc_self,0x660033; if (killtest != 0) enablenpc "Outern Voices"; if (killedonce == 1) end; @@ -152,7 +152,7 @@ L_Finish: OnPCDieEvent: if (getmapxy(@mapname$,@mapx,@mapy,0) == -1) goto L_Finish; if (@mapname$ == "valkyrie") || (@mapname$ == "amatsu") { -killmonster "valkyrie","All"; +killmonster "valkyrie","All"; announce "Deep Voice: You have failed.... you have another opportunity though...",bc_self,0x660033; if (killtest != 0) enablenpc "Outern Voices"; if (killedonce == 1) end; diff --git a/npc/cities/comodo.txt b/npc/cities/comodo.txt index f9f5f42a9..5dbf99f89 100644 --- a/npc/cities/comodo.txt +++ b/npc/cities/comodo.txt @@ -151,7 +151,7 @@ cmd_in02,174,126,4 script Loyar#cmd 83,{ mes "and it makes me want to play "; mes "some more. Alright, let's go!"; next; - switch(rand(1,3)) { + switch(rand(1,3)) { case 1: mes "[Loyar]"; mes "Hmm... Maybe I better"; diff --git a/npc/cities/geffen.txt b/npc/cities/geffen.txt index 9e953cfd2..f5cff90d3 100644 --- a/npc/cities/geffen.txt +++ b/npc/cities/geffen.txt @@ -346,7 +346,7 @@ OnTouch: break; } set .@Main_gauche_hap,.@input * 9400; - if (Zeny < .@Main_gauche_hap) { + if (Zeny < .@Main_gauche_hap) { mes "[Suspicious Guy]"; mes "Short on zeny?"; mes "When the greatest deal in your life is right before your eyes?! Tragic, truly tragic..."; @@ -1347,7 +1347,7 @@ geffen_in,109,72,2 script Monster Scholar 90,{ mes "[Estheres]"; mes "Still, if you want to seek out strong monsters, you can cross the bridge to the West and fight Kobolds."; next; - mes "[Estheres]"; + mes "[Estheres]"; if (BaseLevel > 40) mes "You look strong enough for that kind of challenge. But if you see anyone more reckless cross the Western bridge, you might want to give them a warning."; else diff --git a/npc/cities/hugel.txt b/npc/cities/hugel.txt index fdb85d481..9b3ba6aa2 100644 --- a/npc/cities/hugel.txt +++ b/npc/cities/hugel.txt @@ -185,7 +185,7 @@ hu_in01,23,311,4 script Party Supplies Shop 898,{ mes "[Shopkeeper]"; mes "Thank you, please come again."; close; - } + } } hu_in01,18,94,0 script A Part-Timer#1 49,{ diff --git a/npc/cities/izlude.txt b/npc/cities/izlude.txt index 66199333d..bff881900 100644 --- a/npc/cities/izlude.txt +++ b/npc/cities/izlude.txt @@ -458,7 +458,7 @@ izlude,124,178,2 script Soldier#izlude 105,{ close; } -// Inside Izlude +// Inside Izlude //============================================================ izlude_in,125,164,2 script Aaron#izlude 65,{ mes "[Aaron]"; diff --git a/npc/cities/lutie.txt b/npc/cities/lutie.txt index fd8da5dd1..603450fb8 100644 --- a/npc/cities/lutie.txt +++ b/npc/cities/lutie.txt @@ -385,7 +385,7 @@ xmas,176,236,4 script Uncle Hairy 712,{ mes "[Cantata]"; mes "^3355FFThachentze^000000, that lovely pickle maker, knows more about it. So if you're curious, you should go talk to her. Alrighty then, Merry Christmas!"; set xmas_npc,5; - close; + close; }else{ mes "[Cantata]"; mes "Oh yeah? Heard about me from Poze, did you? Haw haw haw! Yeah, I know a little bit about Snowysnow. In fact, I may even be his weak point, since..."; diff --git a/npc/cities/yuno.txt b/npc/cities/yuno.txt index a9a7395ef..31c57bdc2 100644 --- a/npc/cities/yuno.txt +++ b/npc/cities/yuno.txt @@ -323,7 +323,7 @@ yuno,334,182,4 script Juno Soldier#6juno 105,{ mes "[Juno Soldier]"; mes "Its use is limited to the Sage class, and it increases the chance of inflicting critical attacks. So, for Sages, that dagger can be very useful, as well as make them look stylish in battle."; close; -} +} yuno,263,320,4 script Juno Soldier#7juno 105,{ mes "[Juno Soldier]"; diff --git a/npc/custom/banks/bank.txt b/npc/custom/banks/bank.txt index 7c610ec13..33fc558f9 100644 --- a/npc/custom/banks/bank.txt +++ b/npc/custom/banks/bank.txt @@ -69,7 +69,7 @@ switch(select("I'd like to make a deposit.:I'd like to make a withdrawl.:What's else if (@withdrawl > #bankstorage) { mes "I show you only have ^00FF00" + #bankstorage +"^000000 zeny in your account!"; close; - } + } else if ((@cost > Zeny) && ((Zeny + @withdrawl) > @cost)) { mes "[Banker]"; mes "You don't have the Zeny for the transaction fee right now. Would you like me to take the fee directly from your withdrawl?"; diff --git a/npc/custom/eAAC_Scripts/kafraExpress/config.txt b/npc/custom/eAAC_Scripts/kafraExpress/config.txt index e3efab224..6ff968655 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/config.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/config.txt @@ -234,7 +234,7 @@ OnLoadRefine: end; //------------------------------------------------------------------------------- //Config for the Renting Module - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------- OnLoadRent: set $@kert_cartOnly, 0; //Set to 1 to enable only cart rental, 0 enables all add-ons. set $@kert_cartCost, 1000; //Cost to rent a Cart. @@ -252,7 +252,7 @@ OnLoadShop: end; //------------------------------------------------------------------------------- //Config for the Stat Market Module - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------- OnLoadStatMarket: set $@kesm_stBuyPrice,10000; //Cost of buying stat points set $@kesm_stSellPrice,0; //Return cash for selling stat points diff --git a/npc/custom/eAAC_Scripts/kafraExpress/global_functionsKE.txt b/npc/custom/eAAC_Scripts/kafraExpress/global_functionsKE.txt index 16931e5ea..d1a5d65a5 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/global_functionsKE.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/global_functionsKE.txt @@ -197,8 +197,7 @@ function script GF_getJobId { } if (@classId >= Job_Novice_High && @classId <= Job_Paladin2) set @classId, @classId -Job_Novice_High; - else - if (@classId >= Job_Baby && @classId <= Job_Super_Baby) + else if (@classId >= Job_Baby && @classId <= Job_Super_Baby) set @classId, @classId -Job_Baby; if (@type == 1) diff --git a/npc/custom/eAAC_Scripts/kafraExpress/ke_jobswap.txt b/npc/custom/eAAC_Scripts/kafraExpress/ke_jobswap.txt index 6d10ed043..198650da5 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/ke_jobswap.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/ke_jobswap.txt @@ -378,7 +378,7 @@ function SF_revertJob { if ($@kejs_announce) announce strcharinfo(0)+" has changed from "+jobname(@thisJobId)+" to "+@newjob$+"...",16; return 1; -} +} //SubFunction: SF_getJobNames(Qty) //Fills an array @names$ with the job names taken from the array "classes", diff --git a/npc/custom/eAAC_Scripts/kafraExpress/ke_refine.txt b/npc/custom/eAAC_Scripts/kafraExpress/ke_refine.txt index d9ac1613b..c8a949839 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/ke_refine.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/ke_refine.txt @@ -266,7 +266,7 @@ function SF_purify { set @rough, 990; set @qty, 10; break; - case 7: //Ice + case 7: //Ice set @item, 995; set @rough, 991; set @qty, 10; @@ -276,7 +276,7 @@ function SF_purify { set @rough, 992; set @qty, 10; break; - case 9: //Earth + case 9: //Earth set @item, 997; set @rough, 993; set @qty, 10; diff --git a/npc/custom/eAAC_Scripts/kafraExpress/ke_shop.txt b/npc/custom/eAAC_Scripts/kafraExpress/ke_shop.txt index 0d103715d..e627d0c61 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/ke_shop.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/ke_shop.txt @@ -54,7 +54,7 @@ function script F_keShop { "- Buy items", "- Sell items" ); - break; + break; } if (@kmenu == 1) return; diff --git a/npc/custom/eAAC_Scripts/kafraExpress/ke_warp_dungeon.txt b/npc/custom/eAAC_Scripts/kafraExpress/ke_warp_dungeon.txt index 8cbf48a54..199494184 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/ke_warp_dungeon.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/ke_warp_dungeon.txt @@ -504,7 +504,7 @@ function SF_byalan { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"izlu2dun",114,84; break; case 3: @@ -516,7 +516,7 @@ function SF_byalan { case 5: callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun03",32,63; break; - case 6: + case 6: callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun04",26,27; break; } @@ -585,7 +585,7 @@ function SF_clockTower { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"aldebaran",140,130; break; case 3: @@ -633,10 +633,10 @@ function SF_coalMine { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"mjolnir_02",89,358; break; - case 3: + case 3: callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"mjo_dun02",376,342; break; case 4: @@ -668,10 +668,10 @@ function SF_culvert { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"prt_fild05",274,208; break; - case 3: + case 3: callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"prt_sewb2",19,19; break; case 4: @@ -772,7 +772,7 @@ function SF_gefenia { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"gefenia01",60,169; break; case 3: @@ -847,7 +847,7 @@ function SF_glastHeim { "- Underground Cave Level 2 ("+@cost7+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"glast_01",206,136; break; @@ -947,7 +947,7 @@ function SF_hiddenTemple { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"prt_fild01",136,361; break; case 3: @@ -980,7 +980,7 @@ function SF_juperos { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"jupe_cave",55,52; break; case 3: @@ -1010,7 +1010,7 @@ function SF_kiehl { "- Level 2 ("+@cost2+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"yuno_fild08",80,179; break; @@ -1041,7 +1041,7 @@ function SF_iceCave { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"ra_fild01",233,319; break; case 3: @@ -1073,7 +1073,7 @@ function SF_lightHalzen { "- Level 3 ("+@cost3+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: //This is the Rekkenber building entrance, which officially is only a dungeon exit. callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"lighthalzen",74,72; @@ -1109,7 +1109,7 @@ function SF_louYang { ); }; switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"louyang",41,267; break; case 3: @@ -1169,7 +1169,7 @@ function SF_odin { "- Level 3 ("+@cost3+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"odin_tem01",91,145; break; @@ -1232,7 +1232,7 @@ function SF_payon { "- Level 5 ("+@cost5+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"pay_arche",41,133; break; @@ -1277,7 +1277,7 @@ function SF_pyramid { "- Basement 2 ("+@cost3+"z)" ); } - switch (@submenu) { + switch (@submenu) { case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"moc_ruins",62,162; break; @@ -1457,7 +1457,7 @@ function SF_thanatosTower { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"tha_scene01",139,201; break; case 3: @@ -1555,7 +1555,7 @@ function SF_turtleIsland { ); } switch (@submenu) { - case 2: + case 2: callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"tur_dun01",153,47; break; case 3: diff --git a/npc/custom/eAAC_Scripts/kafraExpress/readme.txt b/npc/custom/eAAC_Scripts/kafraExpress/readme.txt index 8c371d458..5bce41399 100644 --- a/npc/custom/eAAC_Scripts/kafraExpress/readme.txt +++ b/npc/custom/eAAC_Scripts/kafraExpress/readme.txt @@ -183,7 +183,7 @@ For example, the renting module's configuration segment is: //------------------------------------------------------------------------------- //Config for the Renting Module - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------- OnLoadRent: set $@kert_cartOnly, 0; //Set to 1 to enable only cart rental, 0 enables all add-ons. set $@kert_cartCost, 2000; //Cost to rent a Cart. diff --git a/npc/custom/jobs/jobmaster.txt b/npc/custom/jobs/jobmaster.txt index 15c384547..ff364159a 100644 --- a/npc/custom/jobs/jobmaster.txt +++ b/npc/custom/jobs/jobmaster.txt @@ -146,7 +146,7 @@ prontera,153,193,6 script Job Master 123,{ case Job_Thief: set @job_opt[0], Job_Assassin; set @job_opt[1], Job_Rogue; - break; + break; default: set @job_opt[0], Job_Star_Gladiator; set @job_opt[1], Job_Soul_Linker; diff --git a/npc/custom/marriage.txt b/npc/custom/marriage.txt index dbfcd5794..0f21c46e7 100644 --- a/npc/custom/marriage.txt +++ b/npc/custom/marriage.txt @@ -530,7 +530,7 @@ function SF_Register { mes "Come back when you are ready."; close; } -} +} function SF_WedProgress { if (strcharinfo(0) == $wed_groom$) { diff --git a/npc/events/christmas_2008.txt b/npc/events/christmas_2008.txt index 25cbc2b53..48c25732f 100644 --- a/npc/events/christmas_2008.txt +++ b/npc/events/christmas_2008.txt @@ -590,7 +590,7 @@ prontera,226,306,4 script Caroller#iROxmas08 79,{ } else if (.@SantaCardNpc == 3) { cutin "���Ʈ��ī��",4; - } + } next; set .@SantaCardTurn,.@SantaCardTurn+1; if (.@SantaCardP == .@SantaCardNpc) { @@ -635,10 +635,10 @@ prontera,226,306,4 script Caroller#iROxmas08 79,{ getitem 595,3; } else if (.@SantaCardPrize == 3) { - getitem 593,3; + getitem 593,3; } else if (.@SantaCardPrize == 4) { - getitem 12236,3; + getitem 12236,3; } else if (.@SantaCardPrize == 5) { getitem 538,10; @@ -780,7 +780,7 @@ xmas_in,89,92,4 script Louise Kim#iROxmas08 714,{ mes "[Louise Kim]"; mes "If you bring me all that stuff, I can make you a glamorous Santa costume."; next; - if (countitem(2301) < 1 || countitem(501) < 3 || countitem(523) < 1 || countitem(7175) < 4 || countitem(7174) < 1) { + if (countitem(2301) < 1 || countitem(501) < 3 || countitem(523) < 1 || countitem(7175) < 4 || countitem(7174) < 1) { mes "[Louise Kim]"; mes "If you were to bring me all the stuff, I would make you a wonderful costume, for free..."; next; diff --git a/npc/events/event_skill_reset.txt b/npc/events/event_skill_reset.txt index 6f5e80cff..d5f7fbfe4 100644 --- a/npc/events/event_skill_reset.txt +++ b/npc/events/event_skill_reset.txt @@ -63,7 +63,7 @@ yuno,138,187,4 script Hypnotist Teacher 124,{ mes "if you ever want a reset!!"; close; -L_Info: +L_Info: mes @npcname$; mes "This skill reset is not FREE OF CHARGE!!"; mes "Expense for the reset of skill is ^D5A50020000 Zeny x BaseLv^000000."; diff --git a/npc/events/halloween_2006.txt b/npc/events/halloween_2006.txt index 167bce60a..0dd1792a4 100644 --- a/npc/events/halloween_2006.txt +++ b/npc/events/halloween_2006.txt @@ -1068,7 +1068,7 @@ prontera,155,285,3 script Familiar#06_hw01::HWFamiDup 799,{ mes "Ok."; mes "Actually, it's useless to have a special ticket to Nifflheim."; close; - } + } mes "[Familiar]"; mes "Ok."; mes "If you want to ask something, give a piece of pumpkin pie to Loli Ruri."; diff --git a/npc/events/halloween_2008.txt b/npc/events/halloween_2008.txt index 903ec125f..a4844da1b 100644 --- a/npc/events/halloween_2008.txt +++ b/npc/events/halloween_2008.txt @@ -195,7 +195,7 @@ payon,162,176,4 script Halloween Magician#iRO08 704,{ getitem 617,1; goto Enough; } - break; + break; case 5: if(countitem(7941) < 200) { goto NotEnough; diff --git a/npc/events/halloween_2009.txt b/npc/events/halloween_2009.txt index 2e5586de4..c3d314d7a 100644 --- a/npc/events/halloween_2009.txt +++ b/npc/events/halloween_2009.txt @@ -156,7 +156,7 @@ OnTouch: mes "Fine. I have no choice but to trick you!"; sc_start SC_Stun,5000,0; close; - } + } case 3: if(countitem(538) > 0) { mes "[Trick or Treater]"; @@ -177,7 +177,7 @@ OnTouch: mes "Fine. I have no choice but to trick you!"; sc_start SC_Stun,5000,0; close; - } + } case 4: mes "[Trick or Treater]"; mes "At least a Candy, a Candy Cane or a Well-baked Cookie is all I ask for a treat."; diff --git a/npc/events/idul_fitri.txt b/npc/events/idul_fitri.txt index ee9e85f90..8b0121fcf 100644 --- a/npc/events/idul_fitri.txt +++ b/npc/events/idul_fitri.txt @@ -68,7 +68,7 @@ prontera,146,92,3 script Cellerb 58,{ emotion e_thx; close; - case 2: + case 2: mes @npcname$; mes "Oh well, maybe you will participate in tommorow's quest."; emotion e_hmm; diff --git a/npc/events/twintowers.txt b/npc/events/twintowers.txt index 7557b7c6e..942807222 100644 --- a/npc/events/twintowers.txt +++ b/npc/events/twintowers.txt @@ -33,7 +33,7 @@ prontera,146,92,4 script Twin Towers#tt1::Twin-Towers 812,{ next; menu "I shall accept your offer.",YES,"I'll ask for your service next time.",NO; - NO: + NO: mes "[Twin Towers]"; mes "Er, what a pity. Traveling by yourself is still the best evidence of adventure."; mes "Isn't this proving that you are still young?"; @@ -48,7 +48,7 @@ prontera,146,92,4 script Twin Towers#tt1::Twin-Towers 812,{ mes "Forget all your troubles, and create a splendid legend in this wonderful world."; mes "This is such a wonderful world, and you'll always be a great adventurer!"; close; - YES: + YES: mes "[Twin Towers]"; mes "The flaming passion of an adventurer,"; mes "The desire to explore the unknown realms,"; diff --git a/npc/events/valentinesday_2009.txt b/npc/events/valentinesday_2009.txt index ce9d2ad7e..db072b401 100644 --- a/npc/events/valentinesday_2009.txt +++ b/npc/events/valentinesday_2009.txt @@ -123,7 +123,7 @@ prontera,164,174,4 script Trader#Val09 58,{ next; mes "[Marco Bassinio]"; mes "You're not saying that you want an empty chocolate box without any chocolate in it, am I right?"; - close; + close; } if (!checkweight(12744,1)) { mes "[Marco Bassinio]"; @@ -292,7 +292,7 @@ prontera,147,171,5 script Packs Trader#Val09 58,{ getitem 7948,.@input; next; break; - } + } case 4: mes "[Packs Trader]"; mes "Goodbye!"; @@ -503,7 +503,7 @@ prontera,157,185,4 script Valentine Vote Manager#v 113,{ mes "[Valentine Vote Manager]"; mes "The current record shows... "+$Val09name_F$+" is the female vote leader who's registered the total of "+$Val09votes_F+" rings."; next; - break; + break; case 3: mes "[Valentine Vote Manager]"; diff --git a/npc/guild/agit_controller.txt b/npc/guild/agit_controller.txt index 4d21e1e82..27376df86 100644 --- a/npc/guild/agit_controller.txt +++ b/npc/guild/agit_controller.txt @@ -78,7 +78,7 @@ S_DisplayOwners: } else { Announce "The [" + GetCastleName(.@maps$[.@i]) + "] castle is currently unoccupied.",bc_all|bc_woe; - } + } } end; } diff --git a/npc/guild/agit_template.txt b/npc/guild/agit_template.txt index 1e35719d7..34d5e7dae 100644 --- a/npc/guild/agit_template.txt +++ b/npc/guild/agit_template.txt @@ -916,7 +916,7 @@ OnSpawnGuardians: OnGuardianDied: end; -} +} // Kafra Template //============================================================ @@ -974,7 +974,7 @@ OnGuardianDied: end; } cutin "", 255; - close; + close; case 3: mes "[Kafra staff]"; mes "Please let me know your destination."; @@ -1028,7 +1028,7 @@ OnGuardianDied: case 2: break; } - } + } break; case 5: mes "[Kafra staff]"; diff --git a/npc/jobs/1-1/thief.txt b/npc/jobs/1-1/thief.txt index 31abb61b7..8d7e452f3 100644 --- a/npc/jobs/1-1/thief.txt +++ b/npc/jobs/1-1/thief.txt @@ -79,7 +79,7 @@ moc_prydb1,39,129,2 script Thief Guide#thief 69,{ mes "[Thief Guildsman]"; mes "Hey, brother."; mes "Why are you here? Go back to your place~ go back~~"; - close; + close; }else{ mes "[Thief Guildsman]"; mes "What the heck...?"; @@ -87,7 +87,7 @@ moc_prydb1,39,129,2 script Thief Guide#thief 69,{ mes "[Thief Guildsman]"; mes "Hey, lady."; mes "Why are you here? Go back to your place~ go back~~"; - close; + close; } } } @@ -146,7 +146,7 @@ moc_prydb1,39,129,2 script Thief Guide#thief 69,{ mes "I can see your strong will to become a Thief......"; mes "But only with your will, you cannot make it in a real fight, can you?"; mes "So go and reach at least Basic Skill Level 9."; - close; + close; } mes "[Thief Guildsman]"; mes "Hmm.... I found your interesting criminal records from the data of the detective agency. Well you seem to have what it takes to be a good thief."; diff --git a/npc/jobs/1-1e/gunslinger.txt b/npc/jobs/1-1e/gunslinger.txt index f715eed90..4b768a58a 100644 --- a/npc/jobs/1-1e/gunslinger.txt +++ b/npc/jobs/1-1e/gunslinger.txt @@ -358,7 +358,7 @@ payon,184,65,3 script Wise Bull Horn 866,{ mes "earth. Would you do this old"; mes "Gunslinger a favor a bring me"; mes "a cold glass of Milk, please?"; - close; + close; } delitem 519,1; // Milk set GUNS_Q,5; diff --git a/npc/jobs/2-1/hunter.txt b/npc/jobs/2-1/hunter.txt index ec8a828c2..76c12d26b 100644 --- a/npc/jobs/2-1/hunter.txt +++ b/npc/jobs/2-1/hunter.txt @@ -1510,7 +1510,7 @@ job_hunte,55,120,0 duplicate(HntTrap) 23-6 -1,0,0 job_hunte,66,120,0 duplicate(HntTrap) 24-1 -1,0,0 job_hunte,66,121,0 duplicate(HntTrap) 24-2 -1,0,0 job_hunte,67,120,0 duplicate(HntTrap) 24-3 -1,0,0 -job_hunte,67,121,0 duplicate(HntTrap) 24-4 -1,0,0 +job_hunte,67,121,0 duplicate(HntTrap) 24-4 -1,0,0 job_hunte,114,118,0 duplicate(HntTrap) 25-1 -1,0,0 job_hunte,114,119,0 duplicate(HntTrap) 25-2 -1,0,0 job_hunte,115,118,0 duplicate(HntTrap) 25-3 -1,0,0 diff --git a/npc/jobs/2-1e/StarGladiator.txt b/npc/jobs/2-1e/StarGladiator.txt index 348ebe793..e58dc4dde 100644 --- a/npc/jobs/2-1e/StarGladiator.txt +++ b/npc/jobs/2-1e/StarGladiator.txt @@ -106,7 +106,7 @@ payon,215,102,3 script Moohyun#job_star 828,3,3,{ set STGL_Q,1; setquest 7007; close; - } + } mes "[Moohyun]"; mes "That's fine. Changing your"; mes "job is an important decision,"; @@ -178,7 +178,7 @@ payon,215,102,3 script Moohyun#job_star 828,3,3,{ mes "when you really need it. There"; mes "is no shame in being unable to"; mes "accomplish something alone..."; - close; + close; } mes "[Moohyun]"; mes "Ah, that. Beeryu has"; diff --git a/npc/jobs/3-1/warlock.txt b/npc/jobs/3-1/warlock.txt index 4ab6e19ef..43845777a 100644 --- a/npc/jobs/3-1/warlock.txt +++ b/npc/jobs/3-1/warlock.txt @@ -1488,7 +1488,7 @@ spl_in02,80,108,5 script Guild Master#Warlock 465,{ } } mes "[Master Egnoloria]"; - //Custom Translation + //Custom Translation mes "Ah......?"; close; } @@ -1737,7 +1737,7 @@ OnTimer293000: end; OnTimer303000: - mapannounce "job3_war02","The magic stabilization has failed. The fragment has lost it's power.",bc_map; // custom translation. + mapannounce "job3_war02","The magic stabilization has failed. The fragment has lost it's power.",bc_map; // custom translation. donpcevent "The chamber of magic#W::OnReset"; donpcevent "The chamber of magic#W2::OnReset"; donpcevent "The chamber of magic#W3::OnReset"; diff --git a/npc/jobs/3-2/wanderer.txt b/npc/jobs/3-2/wanderer.txt index 087095f9c..a373fd302 100644 --- a/npc/jobs/3-2/wanderer.txt +++ b/npc/jobs/3-2/wanderer.txt @@ -218,7 +218,7 @@ xmas,132,143,5 script Performance Manager#w 713,{ switch(select("I'm not interested.:What happened?:If you're not saying, why would you tell me that?")) { case 1: mes "[Stage Staff]"; - mes "Oh! What a ruthless world!"; + mes "Oh! What a ruthless world!"; close; case 2: mes "[Stage Staff]"; @@ -231,7 +231,7 @@ xmas,132,143,5 script Performance Manager#w 713,{ case 3: emotion e_ag; mes "[Stage Staff]"; - mes "I am not saying it? I'm too depressed! Well, now you know!"; + mes "I am not saying it? I'm too depressed! Well, now you know!"; next; break; } @@ -247,7 +247,7 @@ L_wh1: next; emotion e_wah; mes "[Stage Staff]"; - mes "People will put a collar on me! Oh, terrible, so terrible!"; + mes "People will put a collar on me! Oh, terrible, so terrible!"; next; goto L_wh2; case 2: @@ -256,7 +256,7 @@ L_wh1: mes "It's !"; mes "Do you know?"; mes "They are the worst people in the world."; - next; + next; break; case 3: mes "[Stage Staff]"; @@ -386,7 +386,7 @@ L_wh3: mes "Thanks to you, the performance went successfully as planned."; mes "They are really talented!"; mes "As a reward, I will prepare a stage especially for you."; - close; + close; } } mes "[Stage Staff]"; @@ -556,7 +556,7 @@ comodo,140,86,5 script Cheerless Minstrel#w 479,{ else { mes "["+strcharinfo(0)+"]"; mes "It doesn't look like a good idea to me."; - close; + close; } case 3: set .@scream,getskilllv(329); @@ -624,7 +624,7 @@ comodo,140,86,5 script Cheerless Minstrel#w 479,{ emotion e_lv,1; next; break; - } + } } mes "[Guitar Song]"; mes "Ah, oh, well!"; @@ -692,7 +692,7 @@ comodo,140,86,5 script Cheerless Minstrel#w 479,{ else { mes "[inability of the court musicians]"; mes "Where is my companion ..."; - close; + close; } } @@ -753,7 +753,7 @@ hu_in01,305,251,5 script Vacant Looking Lady#w 879,{ emotion e_sob; mes "[Vacant Looking Lady]"; mes "Why didn't Guitar Song recognized me, ah? I still have no make-up on my face so he won't recognize me, ah? Ooo-ooo..."; - next; + next; menu "So you have to solve this problem?",-; emotion e_sob; mes "[Vacant Looking Lady]"; @@ -802,11 +802,11 @@ hu_in01,305,251,5 script Vacant Looking Lady#w 879,{ mes "[Dancer Kim]"; mes "I was once a beautiful dove, but now I became a hen."; mes "Dancer Kim's is no longer wanderer."; - next; + next; if (select("Don't give up.:You'll can handle it yourself.") == 2){ mes "[Dancer Kim]"; mes "My life has not came out from the abyss ..."; - close; + close; } mes "[Dancer Kim]"; mes "I already said that it's all over with Guitar Song."; @@ -828,8 +828,8 @@ hu_in01,305,251,5 script Vacant Looking Lady#w 879,{ if (select("Then there is nothing else to do.:Lets exercise.") == 1){ mes "[Dancer Kim]"; mes "There is no dream, no hope..."; - close; - } + close; + } mes "[Dancer Kim]"; mes "Do you want to exercise with me? Together?"; mes "Really?"; @@ -841,7 +841,7 @@ hu_in01,305,251,5 script Vacant Looking Lady#w 879,{ mes "My heart now feels better!"; mes "I feel like my body is igniting for some action."; mes "And now I'm motivated to take advantage of the time and overcome all difficulties as soon as possible!"; - next; + next; menu "What are we going to do?",-; mes "[Dancer Kim]"; mes "I have a good idea!"; @@ -856,7 +856,7 @@ hu_in01,305,251,5 script Vacant Looking Lady#w 879,{ else if (job_wan == 6 || job_wan == 7) { mes "[Dancer Kim]"; mes "I will wait for you in the Lake of Abyss."; - close; + close; } else if (job_wan == 8) { mes "[Dancer Kim]"; @@ -885,8 +885,8 @@ hu_fild05,342,130,5 script Dancer Kim#fild 879,{ if (select("No.:Yes.") == 1){ mes "[Dancer Kim]"; mes "Please prepare as fast as you can, before all of this will disappear from my interests!"; - close; - } + close; + } mes "[Dancer Kim]"; mes "Good! So, prepare!"; mes "Start!"; @@ -928,7 +928,7 @@ hu_fild05,342,130,5 script Dancer Kim#fild 879,{ mes "Ah, do me a favour, please."; mes "Can you bring Guitar Song to Lutie?"; mes "Say that his partner is waiting for him."; - next; + next; menu "No problem!",-; mes "[Dancer Kim]"; mes "You're a good person. I'm really happy that I met you."; @@ -950,7 +950,7 @@ hu_fild05,342,130,5 script Dancer Kim#fild 879,{ mes "- It looks like Dancer Kim cannot stand the pain and gives up. She sat down on the ground -"; set job_wan,6; changequest 2221,2220; - close; + close; } mes "[Dancer Kim]"; mes "Ah ...?"; @@ -960,7 +960,7 @@ hu_fild05,342,130,5 script Dancer Kim#fild 879,{ else if (job_wan == 8) { mes "[Dancer Kim]"; mes "Please tell Guitar Song that I'm waiting for him in Lutie."; - close; + close; } mes "[Dancer Kim]"; mes "Hunting Yellow Novus really is the best sport."; @@ -978,11 +978,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Yeah! Novuses are coming, my sister!",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -999,11 +999,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Yeah! Novuses are coming, my sister!",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1020,11 +1020,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Yeah! Novuses are coming, my sister!",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1041,11 +1041,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Yeah! Novuses are coming, my sister!",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1062,11 +1062,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Yeah! Novuses are coming, my sister!",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1083,11 +1083,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Ah, my nails are broken! It hurt... Forget about it...",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } @@ -1105,11 +1105,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Ah, my nails are broken! It hurt... Forget about it...",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1126,11 +1126,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Ah, my nails are broken! It hurt... Forget about it...",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1147,11 +1147,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Ah, my nails are broken! It hurt... Forget about it...",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1168,11 +1168,11 @@ OnTouch: } if (.@bc_rd == 2){ mapannounce "hu_fild05","Dancer Kim: Ah, my nails are broken! It hurt... Forget about it...",bc_map; - end; + end; } else { mapannounce "hu_fild05","Dancer Kim: Oh, you're tired so soon? It seems that I'll win this!",bc_map; - end; + end; } } end; @@ -1241,7 +1241,7 @@ if (job_wan == 9){ emotion e_lv,"Audience#xmas3"; emotion e_lv,"Audience#xmas4"; emotion e_lv,"Little Iraki#xm"; - emotion e_lv,"Mimi#xmas"; + emotion e_lv,"Mimi#xmas"; mes "[Audience]"; mes "Hello !!!!!"; next; diff --git a/npc/jobs/novice/novice.txt b/npc/jobs/novice/novice.txt index 807275e13..bc6bcae3b 100644 --- a/npc/jobs/novice/novice.txt +++ b/npc/jobs/novice/novice.txt @@ -622,7 +622,7 @@ new_1-2,32,172,4 script Chocolat#nv 96,{ mes "Why are you still here?"; close2; warp "prontera",156,90; - end; + end; } } @@ -1149,7 +1149,7 @@ new_5-3,96,30,4 duplicate(NvBrade) Brade#nv5 733 mes "I'll wait for you here."; mes "Wish you a good luck."; close; - } + } case 4: mes "[Swordman Guildsman]"; mes "If you have any questions about the Swordman class, please ask me."; @@ -1689,7 +1689,7 @@ new_5-3,109,41,4 duplicate(NvMer) Merchant Guide#nv5 97 next; mes "[Archer Guide]"; mes "Do you want to register to test skill experience?"; - mes "Would you like to test Archer skills?"; + mes "Would you like to test Archer skills?"; next; if(select("I want to test Archer skills.:I don't want to test it.") == 2) { mes "[Archer Guide]"; diff --git a/npc/merchants/buying_shops.txt b/npc/merchants/buying_shops.txt index 936dabac3..19bbbe28f 100644 --- a/npc/merchants/buying_shops.txt +++ b/npc/merchants/buying_shops.txt @@ -234,7 +234,7 @@ alberta_in,58,52,4 script Purchasing Team#Buying 59,{ mes "I've given you 5 Bulk Buyer Shop Licenses for your trial."; mes "Enjoy shopping!"; close; - } + } } }else{ mes "[Mr. Hugh]"; diff --git a/npc/merchants/cashheadgear_dye.txt b/npc/merchants/cashheadgear_dye.txt index a849dfad7..fa309738a 100644 --- a/npc/merchants/cashheadgear_dye.txt +++ b/npc/merchants/cashheadgear_dye.txt @@ -78,7 +78,7 @@ prt_in,253,168,4 script Alora 862,{ mes "Oh I'm so excited aren't you?"; mes "And just to be sure, what color is the "+ .@hgn$[.@t] +" you want me to use?"; next; - mes "[Alora]"; + mes "[Alora]"; mes "Please understand that I'm going to use the ^FF00001st "+ .@hgn$[.@t] +" of that color in your inventory!^000000"; next; mes "[Alora]"; diff --git a/npc/merchants/clothes_dyer.txt b/npc/merchants/clothes_dyer.txt index 6a79ebb4c..f619f8c0c 100644 --- a/npc/merchants/clothes_dyer.txt +++ b/npc/merchants/clothes_dyer.txt @@ -161,7 +161,7 @@ L_Super_Novice_M: //================================= // Clothing Dyeing for Females -//================================= +//================================= Female_dye: if(BaseJob==Job_Novice || BaseJob==Job_Novice_High || BaseJob==Job_Baby) goto L_Novice_F; if(BaseJob==Job_Swordman || BaseJob==Job_Swordman_High || BaseJob==Job_Baby_Swordman) goto L_Swordman_F; diff --git a/npc/merchants/icecream.txt b/npc/merchants/icecream.txt index 918b0be2d..d04dbe08e 100644 --- a/npc/merchants/icecream.txt +++ b/npc/merchants/icecream.txt @@ -54,7 +54,7 @@ mes "If you eat more than 5 Ice creams,"; mes "If you might haveto make a lot of trips"; mes "to the bathroom tonight."; - next; + next; } } if(Zeny<.@input*100) { diff --git a/npc/merchants/refine.txt b/npc/merchants/refine.txt index 9e6ebd034..f2556034e 100644 --- a/npc/merchants/refine.txt +++ b/npc/merchants/refine.txt @@ -479,7 +479,7 @@ ein_in01,38,29,0 script Paul Spanner 63,{ case 2: set .@item,1011; set .@item_price,1000; - break; + break; case 3: mes "[Paul Spanner]"; mes "If you need anything, just let me know."; @@ -896,7 +896,7 @@ function script refinemain { } mes "[" + getarg(0) + "]"; mes "All finished... Come again soon."; - close; + close; } diff --git a/npc/other/arena/arena_lvl50.txt b/npc/other/arena/arena_lvl50.txt index 6ed2ef96c..cb29ee807 100644 --- a/npc/other/arena/arena_lvl50.txt +++ b/npc/other/arena/arena_lvl50.txt @@ -59,7 +59,7 @@ OnTimer5000: OnTimer60000: set $@mapcount50, getmapusers ("force_1-1"); - if ($@mapcount50 == 0) { + if ($@mapcount50 == 0) { donpcevent "Heel and Toe#arena::Onfailclearstage"; } mapannounce "force_1-1","Remaining Time : 4 minutes ",0; @@ -67,7 +67,7 @@ OnTimer60000: OnTimer120000: set $@mapcount50, getmapusers ("force_1-1"); - if ($@mapcount50 == 0) { + if ($@mapcount50 == 0) { donpcevent "Heel and Toe#arena::Onfailclearstage"; } mapannounce "force_1-1","Remaining Time : 3 minutes ",0; @@ -75,14 +75,14 @@ OnTimer120000: OnTimer180000: set $@mapcount50, getmapusers ("force_1-1"); - if ($@mapcount50 == 0) { + if ($@mapcount50 == 0) { donpcevent "Heel and Toe#arena::Onfailclearstage"; } mapannounce "force_1-1","Remaining Time : 2 minutes ",0; end; OnTimer240000: set $@mapcount50, getmapusers ("force_1-1"); - if ($@mapcount50 == 0) { + if ($@mapcount50 == 0) { donpcevent "Heel and Toe#arena::Onfailclearstage"; } mapannounce "force_1-1","Remaining Time : 1 minute ",0; @@ -455,7 +455,7 @@ Onreset: OnMobDeath: set $force_01_50,$force_01_50 -1; - if ($force_01_50 < 1) { + if ($force_01_50 < 1) { donpcevent "Heel and Toe#arena::On01_end"; donpcevent "arena#50::Onreset_01"; } @@ -540,7 +540,7 @@ Onreset: OnMobDeath: set $force_03_50,$force_03_50 -1; donpcevent "force_03mob#50::Onsummonmob_03"; - if ($force_03_50 < 1) { + if ($force_03_50 < 1) { donpcevent "Heel and Toe#arena::On03_end"; donpcevent "arena#50::Onreset_03"; } @@ -598,7 +598,7 @@ Onreset: OnMobDeath: set $force_04_50,$force_04_50 -1; - if ($force_04_50 < 1) { + if ($force_04_50 < 1) { donpcevent "Heel and Toe#arena::On04_end"; donpcevent "arena#50::Onreset_04"; } @@ -653,7 +653,7 @@ Onreset: OnMobDeath: set $force_05_50,$force_05_50 -1; - if ($force_05_50 < 1) { + if ($force_05_50 < 1) { donpcevent "Heel and Toe#arena::On05_end"; donpcevent "arena#50::Onreset_05"; } @@ -711,7 +711,7 @@ Onreset: OnMobDeath: set $force_06_50,$force_06_50 -1; - if ($force_06_50 < 1) { + if ($force_06_50 < 1) { donpcevent "Heel and Toe#arena::On06_end"; donpcevent "arena#50::Onreset_06"; } @@ -774,7 +774,7 @@ Onreset: OnMobDeath: set $force_07_50,$force_07_50 -1; - if ($force_07_50 < 1) { + if ($force_07_50 < 1) { donpcevent "Heel and Toe#arena::On07_end"; donpcevent "arena#50::Onreset_07"; } @@ -844,7 +844,7 @@ Onreset: OnMobDeath: set $force_09_50,$force_09_50 -1; - if ($force_09_50 < 1) { + if ($force_09_50 < 1) { donpcevent "Heel and Toe#arena::On09_end"; donpcevent "arena#50::Onreset_09"; donpcevent "arena#50::Onreset_all"; @@ -860,7 +860,7 @@ prt_are_in,129,188,3 script Staff#50-1 67,{ mes "You did a good job."; mes "Even if you have failed to clear a time attack battle, I will reward you with a small amount of arena points."; next; - if (arena_point == 30000) { + if (arena_point == 30000) { mes "[Staff]"; mes "Uh huh!"; mes "You already have enough arena points."; @@ -924,7 +924,7 @@ prt_are_in,25,188,3 script Staff#50-2 67,{ mes "[Staff]"; mes "Although you failed to make a new record, I hope you will succeed next time."; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -971,7 +971,7 @@ prt_are_in,25,188,3 script Staff#50-2 67,{ set $arena_50topn$,strcharinfo(0); donpcevent "Vendigos::Onlinerec_50"; next; - if (arena_point > 29950) { + if (arena_point > 29950) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -1007,7 +1007,7 @@ prt_are_in,25,188,3 script Staff#50-2 67,{ donpcevent "alloff#50::Onon"; donpcevent "lvl 50s Waiting Room::Onstart"; end; - } + } } prt_are_in,14,195,3 script #arn_timer_50 139,{ @@ -1101,7 +1101,7 @@ Onon: enablenpc "arena#50"; end; -OnInit: +OnInit: if(!$top_50min && !$top_50sec) set $top_50min,5; end; diff --git a/npc/other/arena/arena_lvl60.txt b/npc/other/arena/arena_lvl60.txt index 440d9e451..fa396e88b 100644 --- a/npc/other/arena/arena_lvl60.txt +++ b/npc/other/arena/arena_lvl60.txt @@ -44,7 +44,7 @@ OnTouch: set Zeny,Zeny -1000; disablenpc "ArenaFee#60"; end; -} +} force_2-1,99,20,4 script Minilover#arena 124,{ @@ -72,7 +72,7 @@ OnTimer5000: OnTimer60000: set $@mapcount60, getmapusers ("force_2-1"); - if ($@mapcount60 == 0) { + if ($@mapcount60 == 0) { donpcevent "Minilover#arena::Onfailclearstage"; } mapannounce "force_2-1","Remaining Time : 5 minutes ",0; @@ -80,7 +80,7 @@ OnTimer60000: OnTimer120000: set $@mapcount60, getmapusers ("force_2-1"); - if ($@mapcount60 == 0) { + if ($@mapcount60 == 0) { donpcevent "Minilover#arena::Onfailclearstage"; } mapannounce "force_2-1","Remaining Time : 4 minutes ",0; @@ -88,7 +88,7 @@ OnTimer120000: OnTimer180000: set $@mapcount60, getmapusers ("force_2-1"); - if ($@mapcount60 == 0) { + if ($@mapcount60 == 0) { donpcevent "Minilover#arena::Onfailclearstage"; } mapannounce "force_2-1","Remaining Time : 3 minutes ",0; @@ -96,7 +96,7 @@ OnTimer180000: OnTimer240000: set $@mapcount60, getmapusers ("force_2-1"); - if ($@mapcount60 == 0) { + if ($@mapcount60 == 0) { donpcevent "Minilover#arena::Onfailclearstage"; } mapannounce "force_2-1","Remaining Time : 2 minutes ",0; @@ -104,7 +104,7 @@ OnTimer240000: OnTimer300000: set $@mapcount60, getmapusers ("force_2-1"); - if ($@mapcount60 == 0) { + if ($@mapcount60 == 0) { donpcevent "Minilover#arena::Onfailclearstage"; } mapannounce "force_2-1","Remaining Time : 1 minute ",0; @@ -450,7 +450,7 @@ Onon: OnMobDeath: set $force_01_60,$force_01_60 -1; - if ($force_01_60 < 1) { + if ($force_01_60 < 1) { donpcevent "Minilover#arena::On01_end"; donpcevent "arena#60::Onreset_01"; } @@ -553,7 +553,7 @@ Onreset: OnMobDeath: set $force_03_60,$force_03_60 -1; - if ($force_03_60 < 1) { + if ($force_03_60 < 1) { donpcevent "Minilover#arena::On03_end"; donpcevent "arena#60::Onreset_03"; } @@ -602,7 +602,7 @@ Onon: OnMobDeath: set $force_04_60,$force_04_60 -1; - if ($force_04_60 < 1) { + if ($force_04_60 < 1) { donpcevent "force_04ex#60::Onreset"; donpcevent "Minilover#arena::On04_end"; donpcevent "arena#60::Onreset_04"; @@ -660,7 +660,7 @@ Onon: OnMobDeath: set $force_05_60,$force_05_60 -1; - if ($force_05_60 < 1) { + if ($force_05_60 < 1) { donpcevent "Minilover#arena::On05_end"; donpcevent "arena#60::Onreset_05"; } @@ -741,7 +741,7 @@ Onon: OnMobDeath: set $force_06_60,$force_06_60 -1; - if ($force_06_60 < 1) { + if ($force_06_60 < 1) { set door, 1; donpcevent "Minilover#arena::On06_end"; donpcevent "arena#60::Onreset_06"; @@ -773,7 +773,7 @@ Onon: OnMobDeath: set $force_07_50,$force_07_50 -1; - if ($force_07_50 < 1) { + if ($force_07_50 < 1) { donpcevent "Minilover#arena::On07_end"; donpcevent "arena#60::Onreset_07"; } @@ -854,7 +854,7 @@ Onreset: OnMobDeath: set $force_09_60,$force_09_60 -1; - if ($force_09_60 < 1) { + if ($force_09_60 < 1) { donpcevent "Minilover#arena::On09_end"; donpcevent "arena#60::Onreset_09"; donpcevent "arena#60::Onreset_all"; @@ -870,7 +870,7 @@ prt_are_in,129,135,3 script Staff#60-1 67,{ mes "You did a good job."; mes "Even if you have failed to clear a time attack battle, I will reward you with a small amount of arena points."; next; - if (arena_point == 30000) { + if (arena_point == 30000) { mes "[Staff]"; mes "Uh huh!"; mes "You already have enough arena points."; @@ -934,7 +934,7 @@ prt_are_in,25,135,3 script Staff#60-2 67,{ mes "[Staff]"; mes "Although you failed to make a new record, I hope you will succeed next time."; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -981,7 +981,7 @@ prt_are_in,25,135,3 script Staff#60-2 67,{ set $arena_60topn$,strcharinfo(0); donpcevent "Vendigos::Onlinerec_60"; next; - if (arena_point > 29950) { + if (arena_point > 29950) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -1017,7 +1017,7 @@ prt_are_in,25,135,3 script Staff#60-2 67,{ donpcevent "alloff#60::Onon"; donpcevent "lvl 60s Waiting Room::Onstart"; end; - } + } } @@ -1115,7 +1115,7 @@ Onon: enablenpc "arena#60"; end; -OnInit: +OnInit: if(!$top_60min && !$top_60sec) set $top_60min,6; end; diff --git a/npc/other/arena/arena_lvl70.txt b/npc/other/arena/arena_lvl70.txt index 43e6e4fe0..87c89ce4a 100644 --- a/npc/other/arena/arena_lvl70.txt +++ b/npc/other/arena/arena_lvl70.txt @@ -59,7 +59,7 @@ OnTimer7000: OnTimer60000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 6 minutes ",0; @@ -67,7 +67,7 @@ OnTimer60000: OnTimer120000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 5 minutes ",0; @@ -75,14 +75,14 @@ OnTimer120000: OnTimer180000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 4 minutes ",0; end; OnTimer240000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 3 minutes ",0; @@ -90,7 +90,7 @@ OnTimer240000: OnTimer300000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 2 minutes ",0; @@ -98,7 +98,7 @@ OnTimer300000: OnTimer360000: set $@mapcount70, getmapusers ("force_3-1"); - if ($@mapcount70 == 0) { + if ($@mapcount70 == 0) { donpcevent "Cadillac#arena::Onfailclearstage"; } mapannounce "force_3-1","Remaining Time : 1 minute ",0; @@ -435,7 +435,7 @@ Onreset: OnMobDeath: set $force_01_70,$force_01_70 -1; - if ($force_01_70 < 1) { + if ($force_01_70 < 1) { donpcevent "Cadillac#arena::On01_end"; donpcevent "arena#70::Onreset_01"; } @@ -489,7 +489,7 @@ Onon: OnMobDeath: set $force_02_70,$force_02_70 -1; - if ($force_02_70 < 1) { + if ($force_02_70 < 1) { donpcevent "Cadillac#arena::On02_end"; donpcevent "arena#70::Onreset_02"; } @@ -535,7 +535,7 @@ Onreset: OnMobDeath: set $force_03_70,$force_03_70 -1; donpcevent "force_03ex#70::Onsummonmob_03"; - if ($force_03_70 < 1) { + if ($force_03_70 < 1) { donpcevent "Cadillac#arena::On03_end"; donpcevent "arena#70::Onreset_03"; } @@ -585,7 +585,7 @@ Onreset: OnMobDeath: set $force_04_70,$force_04_70 -1; - if ($force_04_70 < 1) { + if ($force_04_70 < 1) { donpcevent "Cadillac#arena::On04_end"; donpcevent "arena#70::Onreset_04"; } @@ -638,7 +638,7 @@ Onreset: OnMobDeath: set $force_05_70,$force_05_70 -1; - if ($force_05_70 < 1) { + if ($force_05_70 < 1) { donpcevent "Cadillac#arena::On05_end"; donpcevent "arena#70::Onreset_05"; } @@ -695,7 +695,7 @@ Onreset: OnMobDeath: set $force_06_70,$force_06_70 -1; - if ($force_06_70 < 1) { + if ($force_06_70 < 1) { donpcevent "Cadillac#arena::On06_end"; donpcevent "arena#70::Onreset_06"; } @@ -749,7 +749,7 @@ Onreset: OnMobDeath: set $force_07_70,$force_07_70 -1; - if ($force_07_70 < 1) { + if ($force_07_70 < 1) { donpcevent "Cadillac#arena::On07_end"; donpcevent "arena#70::Onreset_07"; } @@ -821,7 +821,7 @@ Onreset: OnMobDeath: set $force_09_70,$force_09_70 -1; - if ($force_09_70 < 1) { + if ($force_09_70 < 1) { donpcevent "Cadillac#arena::On09_end"; donpcevent "arena#70::Onreset_09"; donpcevent "arena#70::Onreset_all"; @@ -837,7 +837,7 @@ prt_are_in,129,83,3 script Staff#70-1 67,{ mes "You did a good job."; mes "Even if you have failed to clear a time attack battle, I will reward you with a small amount of arena points."; next; - if (arena_point == 30000) { + if (arena_point == 30000) { mes "[Staff]"; mes "Uh huh!"; mes "You already have enough arena points."; @@ -901,7 +901,7 @@ prt_are_in,25,84,3 script Staff#70-2 67,{ mes "[Staff]"; mes "Although you failed to make a new record, I hope you will succeed next time."; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -948,7 +948,7 @@ prt_are_in,25,84,3 script Staff#70-2 67,{ set $arena_70topn$,strcharinfo(0); donpcevent "Vendigos::Onlinerec_70"; next; - if (arena_point > 29970) { + if (arena_point > 29970) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -984,7 +984,7 @@ prt_are_in,25,84,3 script Staff#70-2 67,{ donpcevent "alloff#70::Onon"; donpcevent "lvl 70s Waiting Room::Onstart"; end; - } + } } prt_are_in,14,195,3 script #arn_timer_70 139,{ @@ -1080,7 +1080,7 @@ Onon: enablenpc "arena#70"; end; -OnInit: +OnInit: if(!$top_70min && !$top_70sec) set $top_70min,7; end; diff --git a/npc/other/arena/arena_lvl80.txt b/npc/other/arena/arena_lvl80.txt index c0db333e7..f91dc9eb9 100644 --- a/npc/other/arena/arena_lvl80.txt +++ b/npc/other/arena/arena_lvl80.txt @@ -59,7 +59,7 @@ OnTimer8000: OnTimer60000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 7 minutes ",0; @@ -67,7 +67,7 @@ OnTimer60000: OnTimer120000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 6 minutes ",0; @@ -75,14 +75,14 @@ OnTimer120000: OnTimer180000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 5 minutes ",0; end; OnTimer240000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 4 minutes ",0; @@ -90,7 +90,7 @@ OnTimer240000: OnTimer300000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 3 minutes ",0; @@ -98,7 +98,7 @@ OnTimer300000: OnTimer360000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 2 minutes ",0; @@ -106,7 +106,7 @@ OnTimer360000: OnTimer420000: set $@mapcount80, getmapusers ("force_4-1"); - if ($@mapcount80 == 0) { + if ($@mapcount80 == 0) { donpcevent "Octus#arena::Onfailclearstage"; } mapannounce "force_4-1","Remaining Time : 1 minute ",0; @@ -459,7 +459,7 @@ Onreset: OnMobDeath: set $force_01_80,$force_01_80 -1; - if ($force_01_80 < 1) { + if ($force_01_80 < 1) { donpcevent "Octus#arena::On01_end"; donpcevent "arena#80::Onreset_01"; } @@ -500,7 +500,7 @@ Onon: OnMobDeath: set $force_02_80,$force_02_80 -1; - if ($force_02_80 < 1) { + if ($force_02_80 < 1) { donpcevent "Octus#arena::On02_end"; donpcevent "arena#80::Onreset_02"; } @@ -551,7 +551,7 @@ Onreset: OnMobDeath: set $force_03_80,$force_03_80 -1; donpcevent "force_03ex#80::Onsummonmob_03"; - if ($force_03_80 < 1) { + if ($force_03_80 < 1) { donpcevent "Octus#arena::On03_end"; donpcevent "arena#80::Onreset_03"; } @@ -605,7 +605,7 @@ Onreset: OnMobDeath: set $force_04_80,$force_04_80 -1; - if ($force_04_80 < 1) { + if ($force_04_80 < 1) { donpcevent "Octus#arena::On04_end"; donpcevent "arena#80::Onreset_04"; } @@ -652,7 +652,7 @@ Onreset: OnMobDeath: set $force_05_80,$force_05_80 -1; - if ($force_05_80 < 1) { + if ($force_05_80 < 1) { donpcevent "Octus#arena::On05_end"; donpcevent "arena#80::Onreset_05"; } @@ -688,7 +688,7 @@ Onreset: OnMobDeath: set $force_06_80,$force_06_80 -1; - if ($force_06_80 < 1) { + if ($force_06_80 < 1) { donpcevent "Octus#arena::On06_end"; donpcevent "arena#80::Onreset_06"; } @@ -734,7 +734,7 @@ Onreset: OnMobDeath: set $force_07_80,$force_07_80 -1; - if ($force_07_80 < 1) { + if ($force_07_80 < 1) { donpcevent "Octus#arena::On07_end"; donpcevent "arena#80::Onreset_07"; } @@ -794,7 +794,7 @@ Onreset: OnMobDeath: set $force_09_80,$force_09_80 -1; - if ($force_09_80 < 1) { + if ($force_09_80 < 1) { donpcevent "Octus#arena::On09_end"; donpcevent "arena#80::Onreset_09"; donpcevent "arena#80::Onreset_all"; @@ -810,7 +810,7 @@ prt_are_in,181,188,3 script Staff#80-1 67,{ mes "You did a good job."; mes "Even if you have failed to clear a time attack battle, I will reward you with a small amount of arena points."; next; - if (arena_point == 30000) { + if (arena_point == 30000) { mes "[Staff]"; mes "Uh huh!"; mes "You already have enough arena points."; @@ -874,7 +874,7 @@ prt_are_in,77,187,3 script Staff#80-2 67,{ mes "[Staff]"; mes "Although you failed to make a new record, I hope you will succeed next time."; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -921,7 +921,7 @@ prt_are_in,77,187,3 script Staff#80-2 67,{ set $arena_80topn$,strcharinfo(0); donpcevent "Vendigos::Onlinerec_80"; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -957,7 +957,7 @@ prt_are_in,77,187,3 script Staff#80-2 67,{ donpcevent "alloff#80::Onon"; donpcevent "lvl 80s Waiting Room::Onstart"; end; - } + } } prt_are_in,14,195,3 script #arn_timer_80 139,{ @@ -1051,7 +1051,7 @@ Onon: enablenpc "arena#80"; end; -OnInit: +OnInit: if(!$top_80min && !$top_80sec) set $top_80min,8; end; diff --git a/npc/other/arena/arena_party.txt b/npc/other/arena/arena_party.txt index 03134b0cb..ec9d12f91 100644 --- a/npc/other/arena/arena_party.txt +++ b/npc/other/arena/arena_party.txt @@ -1140,7 +1140,7 @@ prt_are_in,181,135,3 script Staff#party-1 67,{ mes "You did a good job."; mes "Even if you have failed to clear a time attack battle, I will reward you with a small amount of arena points."; next; - if (arena_point == 30000) { + if (arena_point == 30000) { mes "[Staff]"; mes "Uh huh!"; mes "You already have enough arena points."; @@ -1205,7 +1205,7 @@ prt_are_in,77,135,3 script Staff#party-2 67,{ mes "[Staff]"; mes "Although you failed to make a new record, I hope you will succeed next time."; next; - if (arena_point > 29980) { + if (arena_point > 29980) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -1293,7 +1293,7 @@ prt_are_in,77,135,3 script Staff#party-2 67,{ } - if (arena_point > 29900) { + if (arena_point > 29900) { mes "[Staff]"; mes "Then let me reward you with some arena points....eh?"; mes "Your arena points have exceeded the maximum amount. I cannot give you more points until you spend some points."; @@ -1331,7 +1331,7 @@ prt_are_in,77,135,3 script Staff#party-2 67,{ specialeffect2 EF_HIT5; warp "arena_room",100,75; end; - } + } } @@ -1455,7 +1455,7 @@ Onon: enablenpc "arena_p"; end; -OnInit: +OnInit: if(!$top_ptmin && !$top_ptsec) set $top_ptmin,10; end; diff --git a/npc/other/bulletin_boards.txt b/npc/other/bulletin_boards.txt index fe95c7989..3bed8b7e6 100644 --- a/npc/other/bulletin_boards.txt +++ b/npc/other/bulletin_boards.txt @@ -78,7 +78,7 @@ gef_fild10,69,340,5 script Bulletin Board#3 837,{ mes "[Orc Dungeon]"; mes "If you don't have a Holy Weapon and you're teamed with a Priest, the Priest's Aspersio spell would be of tremendous help."; close; -} +} izlu2dun,104,92,5 script Bulletin Board#4 837,{ mes "[Byalan Island]"; diff --git a/npc/other/comodo_gambling.txt b/npc/other/comodo_gambling.txt index 679244b9f..2d18e01d3 100644 --- a/npc/other/comodo_gambling.txt +++ b/npc/other/comodo_gambling.txt @@ -84,7 +84,7 @@ comodo,219,158,6 script Kachua 91,{ if (countitem(732) == 0) { // anti-hack logmes "Hack: Tried to bypass item check."; - cutin "katsua01.bmp",255; + cutin "katsua01.bmp",255; close; } delitem 732,1; diff --git a/npc/other/hugel_bingo.txt b/npc/other/hugel_bingo.txt index fee3d3568..483ba7f52 100644 --- a/npc/other/hugel_bingo.txt +++ b/npc/other/hugel_bingo.txt @@ -110,7 +110,7 @@ L_Fill: mes "["+@bingo_e1$+"] ["+@bingo_e2$+"] ["+@bingo_e3$+"] ["+@bingo_e4$+"] ["+@bingo_e5$+"]"; close; - } + } goto L_Fill; } diff --git a/npc/other/mercenary_rent.txt b/npc/other/mercenary_rent.txt index 113d69225..bd2ffabaf 100644 --- a/npc/other/mercenary_rent.txt +++ b/npc/other/mercenary_rent.txt @@ -325,7 +325,7 @@ izlude,47,139,5 script Mercenary Manager#Sword 734,{ set Zeny, Zeny - (.@ZenyCost * 1000); getitem 12162 + .@Grade, 1; } - close; + close; case 2: mes "[Mercenary Manager]"; mes "Mercenaries are soldiers"; @@ -436,7 +436,7 @@ izlude,47,139,5 script Mercenary Manager#Sword 734,{ mercenary_set_faith SWORD_MERC_GUILD,-400; getitem 12172,1; } - close; + close; } } diff --git a/npc/quests/Dandelion_Request.txt b/npc/quests/Dandelion_Request.txt index a1ded141d..cb2add4f9 100644 --- a/npc/quests/Dandelion_Request.txt +++ b/npc/quests/Dandelion_Request.txt @@ -2735,7 +2735,7 @@ OnTouch: donpcevent "Valdes#2::OnEnter"; donpcevent "Kidd#2::OnEnter"; donpcevent "#mao_table::OnEnter"; - } + } else if(mao_request == 123) { donpcevent "Valdes#2::OnEnter"; @@ -2862,7 +2862,7 @@ OnTouch: donpcevent "Valdes#3::OnEnter"; donpcevent "Kidd#3::OnEnter"; donpcevent "#Rabsent::OnEnter"; - } + } else if(mao_request == 122) { donpcevent "#mao_empty::OnEnter"; diff --git a/npc/quests/Kiel_Hyre_Quest.txt b/npc/quests/Kiel_Hyre_Quest.txt index 5f577af9d..3248922f7 100644 --- a/npc/quests/Kiel_Hyre_Quest.txt +++ b/npc/quests/Kiel_Hyre_Quest.txt @@ -68,7 +68,7 @@ //= 3.3 Fixed the receiver log out bugs. [L0ne_W0lf] //= 3.4 Fixed bug when u can't get a Yellow Keycard if u got the Blue one at first [Lupus] //= Note: There are many condition checks that should be omitted in the future fixed item names in item_db.txt / txt resources according the quest -//= for items, should be used bitwise methods in a single variable. So let's fix the rest possible bugs (if they exist) and then optimize ^_- +//= for items, should be used bitwise methods in a single variable. So let's fix the rest possible bugs (if they exist) and then optimize ^_- //= 3.5 Changed the way the Black Keycard distibuting NPCs work slighty. [L0ne_W0lf] //= 3.6 Keil Hyre removes ALL outstanding quest items when he is talked [L0ne_W0lf] //= to after finishing the quest. @@ -1506,7 +1506,7 @@ kh_school,179,39,0 script Cute Student#kh 895,{ mes "homework before it's due!"; mes "Yeah, I've got to go see"; mes "Mrs. Lecollane now."; - next; + next; mes "[Elly]"; mes "Say, "+strcharinfo(0)+","; mes "if it's okay, would you"; @@ -7031,7 +7031,7 @@ kh_kiehl02,50,52,4 script Kiehl#Original 902,{ delitem 7504,1; //Toy_Motor set KielHyreQuest,104; hideonnpc "Kiehl#Copy"; - donpcevent "Kiehl_Room_Exit::OnEnable"; + donpcevent "Kiehl_Room_Exit::OnEnable"; enablenpc "Kiehl_Room_Exit"; initnpctimer; cutin "",255; diff --git a/npc/quests/Lvl4_weapon_quest.txt b/npc/quests/Lvl4_weapon_quest.txt index aba16eaa5..58945768a 100644 --- a/npc/quests/Lvl4_weapon_quest.txt +++ b/npc/quests/Lvl4_weapon_quest.txt @@ -1786,7 +1786,7 @@ niflheim,240,193,3 script Kayron#lv4 794,{ if (lv4_weapon == 29) { mes "this... Guillotine!"; getitem 1369,1; //Guillotine - } + } else { mes "this... Brionac!"; getitem 1470,1; //Brionac diff --git a/npc/quests/bunnyband.txt b/npc/quests/bunnyband.txt index 7d32f96a1..dbb231881 100644 --- a/npc/quests/bunnyband.txt +++ b/npc/quests/bunnyband.txt @@ -55,7 +55,7 @@ alberta,26,229,0 script Kafra Employee#bunny 83,{ mes "bring at least"; mes "1 Pearl."; close; - } + } if (countitem(2213) == 0) { mes "Ooh, I'm sorry"; mes "but you need to"; diff --git a/npc/quests/first_class/tu_archer.txt b/npc/quests/first_class/tu_archer.txt index a28fb9c13..98554b615 100644 --- a/npc/quests/first_class/tu_archer.txt +++ b/npc/quests/first_class/tu_archer.txt @@ -1290,7 +1290,7 @@ pay_arche,84,139,3 script Seisner 727,{ set tu_archer01, 3; if(JobLevel == 1){ getexp 0,5; - } else if((JobLevel > 1) && (JobLevel < 11)){ + } else if((JobLevel > 1) && (JobLevel < 11)){ getexp 0,10; } else if((JobLevel > 10) && (JobLevel < 21)){ getexp 0,25; @@ -1485,7 +1485,7 @@ pay_fild08,40,83,5 script Acolyte#tu 95,{ set .@kurae_agi, rand(1,2); if(.@kurae_agi == 1){ unitskilluseid getcharid(3),29,10; - } else if(.@kurae_agi == 2){ + } else if(.@kurae_agi == 2){ unitskilluseid getcharid(3),29,5; } diff --git a/npc/quests/first_class/tu_merchant.txt b/npc/quests/first_class/tu_merchant.txt index 2941ea030..44470c483 100644 --- a/npc/quests/first_class/tu_merchant.txt +++ b/npc/quests/first_class/tu_merchant.txt @@ -818,7 +818,7 @@ prontera,66,111,3 script Sagle 82,{ mes "Zeny, alright?"; close; } - if(MaxWeight - Weight < 71){ + if(MaxWeight - Weight < 71){ next; mes "[Sagle]"; mes "Whoa, hold on!"; @@ -1041,7 +1041,7 @@ prt_in,169,11,3 script Aigie 92,{ mes "^666666*Sniff Sniff*^000000"; close; break; - } + } } if(tu_merchant == 7){ mes "[Aigie]"; @@ -1088,7 +1088,7 @@ prt_in,169,11,3 script Aigie 92,{ mes "^666666*Sniff Sniff*^000000"; close; break; - } + } } if(tu_merchant == 6){ mes "[Aigie]"; diff --git a/npc/quests/first_class/tu_sword.txt b/npc/quests/first_class/tu_sword.txt index d7ada691a..2219810b4 100644 --- a/npc/quests/first_class/tu_sword.txt +++ b/npc/quests/first_class/tu_sword.txt @@ -2002,7 +2002,7 @@ geffen,154,143,3 script Dequ'ee 734,{ mes "out who he is."; close; } - if(tu_swordman == 6){ + if(tu_swordman == 6){ mes "[Dequ'ee]"; mes "Ah...!"; mes "Are you the Swordman"; @@ -2293,7 +2293,7 @@ morocc_in,51,101,3 script Geil 89,{ close; } -//=================================================Meutro==================================================== +//=================================================Meutro==================================================== morocc,82,292,5 script Muetro 84,{ mes "[Muetro]"; if(tu_swordman == 15){ diff --git a/npc/quests/gunslinger_quests.txt b/npc/quests/gunslinger_quests.txt index ecbda0eb7..84407e5d4 100644 --- a/npc/quests/gunslinger_quests.txt +++ b/npc/quests/gunslinger_quests.txt @@ -737,7 +737,7 @@ que_ng,185,180,3 script Vanessa 726,{ next; switch( select( "Maybe next time.","Okay.") ) { - case 1: + case 1: mes "[Vanessa]"; mes "Mm~ Is that so~"; mes "It will be an opportunity for you."; @@ -746,7 +746,7 @@ que_ng,185,180,3 script Vanessa 726,{ mes "Bye~Bye~"; close; - case 2: + case 2: mes "[Vanessa]"; mes "Mm, Okay."; mes "To make a Destroyer,"; diff --git a/npc/quests/newgears/2005_headgears.txt b/npc/quests/newgears/2005_headgears.txt index ff4fee6a7..d638d777c 100644 --- a/npc/quests/newgears/2005_headgears.txt +++ b/npc/quests/newgears/2005_headgears.txt @@ -89,7 +89,7 @@ yuno,222,116,3 script Kasis#LhzHat 851,{ next; switch( select( "You can have these if you want.", "Um, why are you staring?" ) ) { - case 1: + case 1: mes "[Kasis]"; mes "Really? Is it alright"; mes "with you for me to have"; @@ -655,7 +655,7 @@ lighthalzen,143,68,0 script Strange Guy#LhzHat 47,{ mes "^0000FF1 Slotted Bucket Hat^000000"; mes "and ^0000FF1,887 zeny^000000. Okay?"; close; - case 2: + case 2: mes "[Morris]"; mes "Great!"; mes "Now let me just"; @@ -1676,7 +1676,7 @@ gl_prison1,97,104,1 script Phendark#LhzHat 1202,{ else if(ZLMASKQ == 2 || ZLMASKQ == 3) { if(countitem(7315) > 368 && ZLMASKQ == 3) - { + { mes "[Phendark]"; mes "Y-you again!"; mes "Why do you hound me?!"; diff --git a/npc/quests/ninja_quests.txt b/npc/quests/ninja_quests.txt index 9a1342042..d4e119fac 100644 --- a/npc/quests/ninja_quests.txt +++ b/npc/quests/ninja_quests.txt @@ -257,7 +257,7 @@ que_ng,28,50,3 script Boshuu 709,{ } } } - else{ + else{ set ninbo,0; mes "[Boshuu]"; mes "Oh~ You~!"; @@ -356,7 +356,7 @@ que_ng,28,50,3 script Boshuu 709,{ set Zeny,Zeny-10000; set MISC_QUEST,MISC_QUEST | 2048; getitem 2118,1; - close; + close; } } } diff --git a/npc/quests/quests_comodo.txt b/npc/quests/quests_comodo.txt index 56d85b9dd..1fc23457b 100644 --- a/npc/quests/quests_comodo.txt +++ b/npc/quests/quests_comodo.txt @@ -1099,7 +1099,7 @@ cmd_in02,32,140,4 script Chief#cmd 49,{ mes "the tourist attraction~"; close; } - } + } } comodo,88,97,4 script Toruna#cmd 109,{ diff --git a/npc/quests/quests_ein.txt b/npc/quests/quests_ein.txt index 798b13bb9..a59857187 100644 --- a/npc/quests/quests_ein.txt +++ b/npc/quests/quests_ein.txt @@ -149,7 +149,7 @@ einbech,97,167,5 script Cavitar 847,{ mes "Come back"; mes "whenever you're ready."; close; - } + } } else { if (BaseLevel < 40){ @@ -423,7 +423,7 @@ einbech,97,167,5 script Cavitar 847,{ mes "But please understand"; mes "that I'm desperate..."; close; - } + } case 2: mes "[Cavitar]"; mes "You're..."; @@ -6022,7 +6022,7 @@ ein_in01,31,138,3 script Calla#ein 90,{ mes "Would you please tell"; mes "me your name again?"; close; - } + } } if (EIN_LOVERQ == 4) { mes "[Calla]"; diff --git a/npc/quests/quests_gonryun.txt b/npc/quests/quests_gonryun.txt index 398558399..ec7142c70 100644 --- a/npc/quests/quests_gonryun.txt +++ b/npc/quests/quests_gonryun.txt @@ -3700,7 +3700,7 @@ OnTouch: end; } end; -} +} // Lost Knife //============================================================ diff --git a/npc/quests/quests_hugel.txt b/npc/quests/quests_hugel.txt index e7b8b4f8c..ff0d7f5b4 100644 --- a/npc/quests/quests_hugel.txt +++ b/npc/quests/quests_hugel.txt @@ -3063,7 +3063,7 @@ hu_in01,256,40,3 script Herico 897,{ end; } else - { + { if(countitem(7342)) { mes "[Herico]"; @@ -3073,7 +3073,7 @@ hu_in01,256,40,3 script Herico 897,{ close2; cutin "",255; end; - } + } else { mes "[Herico]"; @@ -7205,7 +7205,7 @@ OnTouch: mes "game coordinators tend"; mes "to be pretty busy..."; close; - } + } } que_bingo,53,190,7 script Eukran 778,{ @@ -7325,7 +7325,7 @@ OnInit: disablenpc "Young Man#Hu_Quest"; end; -} +} odin_tem01,130,134,4 script Young Man#Hu_Quest 774,{ @@ -9989,7 +9989,7 @@ hu_in01,16,20,4 script Ashe 95,{ mes "Oh, dear, you don't"; mes "look very well. Did"; mes "something happen?"; - close; + close; case 16: mes "[Ashe]"; diff --git a/npc/quests/quests_juperos.txt b/npc/quests/quests_juperos.txt index 2edaee134..9a4675eef 100644 --- a/npc/quests/quests_juperos.txt +++ b/npc/quests/quests_juperos.txt @@ -285,10 +285,10 @@ yuno_in04,190,125,4 script Scholar 700,{ mes "My life is also fairly"; mes "uneventful, but somehow,"; mes "I'm don't think I'm content."; - close; + close; } - case 4: + case 4: mes "[Fayruz]"; mes "Oh hello, "+strcharinfo(0)+"."; mes "So what brings you to"; @@ -398,7 +398,7 @@ yuno_in04,190,125,4 script Scholar 700,{ next; switch( select( "Take a look at this.","Oh, I'm sorry...") ) { - case 1: + case 1: switch(jupe_hist) { case 1: @@ -1069,7 +1069,7 @@ yuno_in04,186,125,4 script Bundle of Files 111,{ mes "regarding the history"; mes "of Juperos have allowed"; mes "us to make a few conclusions.^000000"; - close; + close; case 2: if(yuno_hist < 9) @@ -1130,7 +1130,7 @@ yuno_in04,186,125,4 script Bundle of Files 111,{ mes "^8B6914..."; mes "......"; mes "..........^000000"; - next; + next; mes "["+strcharinfo(0)+"]"; mes "Huh. This writer keeps"; mes "talking about theories,"; @@ -1254,7 +1254,7 @@ yuno_in04,186,125,4 script Bundle of Files 111,{ } case 2: if(yuno_hist < 5) - { + { mes "["+strcharinfo(0)+"]"; mes "Nah..."; mes "I'm tired of reading."; diff --git a/npc/quests/quests_lighthalzen.txt b/npc/quests/quests_lighthalzen.txt index 05ad3b40b..24182d46f 100644 --- a/npc/quests/quests_lighthalzen.txt +++ b/npc/quests/quests_lighthalzen.txt @@ -547,9 +547,9 @@ lighthalzen,341,224,3 script Fishbone 868,{ mes "Lab. However, I do know of"; mes "this secret maze that should"; mes "get you there. Still, if you're"; - mes "willing and ready to go..."; + mes "willing and ready to go..."; } - else { + else { mes "Okay..."; mes "Are you ready now?"; mes "I'm gonna send you"; @@ -8622,7 +8622,7 @@ L_Mission: close2; cutin "",255; end; - } + } } yuno_pre,77,68,0 script Secretary#2 862,{ @@ -11122,7 +11122,7 @@ airplane_01,96,48,3 script Man#Lyozien 868,{ mes "Do you need to take a"; mes "break or something?"; close; - } + } else if(lhz_rekenber == 20) { mes "[Lyozien]"; @@ -11166,7 +11166,7 @@ airplane_01,96,48,3 script Man#Lyozien 868,{ mes "Then, we'll be done once you"; mes "contact Mr. Ahman in Izlude."; close; - } + } else if(lhz_rekenber == 18) { mes "[Lyozien]"; @@ -11370,7 +11370,7 @@ airplane_01,96,48,3 script Man#Lyozien 868,{ mes "I'll be waiting right here."; set lhz_rekenber,11; close; - } + } else if(lhz_rekenber == 9) { mes "[Lyozien]"; @@ -11381,7 +11381,7 @@ airplane_01,96,48,3 script Man#Lyozien 868,{ mes "Let him know his order has"; mes "already arrived, okay?"; close; - } + } else if(lhz_rekenber == 8) { mes "[Lyozien]"; diff --git a/npc/quests/quests_louyang.txt b/npc/quests/quests_louyang.txt index 1d0824732..53b1443ad 100644 --- a/npc/quests/quests_louyang.txt +++ b/npc/quests/quests_louyang.txt @@ -4805,7 +4805,7 @@ lou_in02,77,37,7 script Hermit 824,{ mes "[Sun Mao]"; switch(QL_REVOL) { - case 1: + case 1: mes "Please make sure that there is a total of two members in your party so that we can recruit your friend. I believe that will look natural."; close; diff --git a/npc/quests/quests_moscovia.txt b/npc/quests/quests_moscovia.txt index d19f10405..e3b442ffa 100644 --- a/npc/quests/quests_moscovia.txt +++ b/npc/quests/quests_moscovia.txt @@ -549,7 +549,7 @@ moscovia,135,49,5 script Mr. Ibanoff#npc 964,{ warp "mosk_ship",94,110; end; } - else if (gettime(3) >= 18 && gettime(3) < 21) { + else if (gettime(3) >= 18 && gettime(3) < 21) { mes "[Mr. Ibanoff]"; mes "Hmm. It's not a bad time."; mes "We should hurry up"; @@ -632,7 +632,7 @@ moscovia,135,49,5 script Mr. Ibanoff#npc 964,{ warp "mosk_ship",94,110; end; } - else if (gettime(3) >= 18 && gettime(3) < 21) { + else if (gettime(3) >= 18 && gettime(3) < 21) { mes "[Mr. Ibanoff]"; mes "Hmm. It's not a bad time."; mes "We should hurry up"; @@ -819,7 +819,7 @@ moscovia,135,49,5 script Mr. Ibanoff#npc 964,{ warp "mosk_ship",94,110; end; } - else if (gettime(3) >= 18 && gettime(3) < 21) { + else if (gettime(3) >= 18 && gettime(3) < 21) { mes "[Mr. Ibanoff]"; mes "Hmm. It's not a bad time."; mes "We should hurry up"; @@ -898,7 +898,7 @@ moscovia,135,49,5 script Mr. Ibanoff#npc 964,{ warp "mosk_ship",94,110; end; } - else if (gettime(3) >= 18 && gettime(3) < 21) { + else if (gettime(3) >= 18 && gettime(3) < 21) { mes "[Mr. Ibanoff]"; mes "Hmm. It's not a bad time."; mes "We should hurry up"; diff --git a/npc/quests/quests_nameless.txt b/npc/quests/quests_nameless.txt index 4aaac46e7..59d23c234 100644 --- a/npc/quests/quests_nameless.txt +++ b/npc/quests/quests_nameless.txt @@ -66,7 +66,7 @@ airplane_01,95,61,3 script QuestTrigger#Aru -1,3,3,{ end; -OnTouch: +OnTouch: if ((prt_curse == 36 || prt_curse == 45 || prt_curse == 56 || prt_curse == 61) && (aru_monas < 1)) { hideoffnpc "Agent#Aru"; mes "[????]"; @@ -474,7 +474,7 @@ ve_in,78,314,5 script Magistrate#Aru 945,{ mes "peace, and letting anyone"; mes "in here will cause trouble."; close; - } + } else if (aru_monas == 10) { mes "[Al Hamad]"; mes "I thought I told you"; diff --git a/npc/quests/quests_rachel.txt b/npc/quests/quests_rachel.txt index 5302c9008..1a86aa3df 100644 --- a/npc/quests/quests_rachel.txt +++ b/npc/quests/quests_rachel.txt @@ -402,7 +402,7 @@ ra_in01,384,246,3 script Vincent#ra_in01 47,{ mes "Jenny about Phobe?"; mes "Sure, sure, I'll do that."; close; - } + } else if (lost_boy == 11) { mes "["+strcharinfo(0)+"]"; diff --git a/npc/quests/quests_umbala.txt b/npc/quests/quests_umbala.txt index cb48eac42..e7b632cc2 100644 --- a/npc/quests/quests_umbala.txt +++ b/npc/quests/quests_umbala.txt @@ -375,9 +375,9 @@ um_in,44,71,2 script Utan Shaman 782,{ mes "using the Kafra Service"; mes "to store some of your items.^000000"; close; - } + } switch(event_umbala) { - default: + default: mes "[??????????]"; mes "Umbah umbah umbabah Utan umbah"; mes "Umbah mookala umbabah.."; @@ -387,7 +387,7 @@ um_in,44,71,2 script Utan Shaman 782,{ close2; warp "umbala",217,186; end; - case 3: + case 3: mes "[Puchuchartan]"; mes "I did not expect that even"; mes "more of you Rune-Midgardians"; diff --git a/npc/quests/quiz/quiz_qt.txt b/npc/quests/quiz/quiz_qt.txt index bf05fa87e..262905f40 100644 --- a/npc/quests/quiz/quiz_qt.txt +++ b/npc/quests/quiz/quiz_qt.txt @@ -966,7 +966,7 @@ if (checkweight(1201,3) == 0 ) goto L_OverWeight; next; mes "[Seeil]"; mes "So this is the last one. Show me some spirit!"; - mes "This is a present to encourage you! Take it!"; + mes "This is a present to encourage you! Take it!"; set quiz_rvl,14; getitem 503,10; //Yellow_Potion close; @@ -1631,7 +1631,7 @@ if(quiz_rvl == 18) { close; } M_MaxItem: - mes "^800000[Radeng]^000000"; + mes "^800000[Radeng]^000000"; mes "- Wait a minute !! -"; mes "- You currently have too many items that -"; mes "- you can't receive an item. -"; @@ -1872,7 +1872,7 @@ if(quiz_rvl == 20) { close; } M_MaxItem: - mes "[Kantryl]"; + mes "[Kantryl]"; mes "- Wait a minute !! -"; mes "- You currently have too many items that -"; mes "- you can't receive an item. -"; diff --git a/npc/quests/seals/brisingamen_seal.txt b/npc/quests/seals/brisingamen_seal.txt index 28e0b04d8..a4e87a815 100644 --- a/npc/quests/seals/brisingamen_seal.txt +++ b/npc/quests/seals/brisingamen_seal.txt @@ -900,7 +900,7 @@ yuno_in04,47,113,1 script Studying Scholar#1 749,{ if ($God3 == 50) { announce "The 3rd Seal of [Brisingamen] has appeared.",bc_all; } - else if ($God3 == 100) { + else if ($God3 == 100) { if ($God1 == 100 && $God2 == 100 && $God3 == 100 && $God4 == 100) { announce "Four seals have been released at the same time with the seal of [Brisingamen].",bc_all; } diff --git a/npc/quests/skills/crusader_skills.txt b/npc/quests/skills/crusader_skills.txt index 65659b6d5..5608acc18 100644 --- a/npc/quests/skills/crusader_skills.txt +++ b/npc/quests/skills/crusader_skills.txt @@ -52,7 +52,7 @@ geffen,110,117,3 script Ford#11 752,{ if (Upper == 1) mes "were dressed like a Paladin..."; else - mes "were dressed like a Crusader..."; + mes "were dressed like a Crusader..."; next; mes "["+ strcharinfo(0) +"]"; mes "I'm sorry..."; diff --git a/src/char/char.c b/src/char/char.c index 69c6a1e23..9f5be7d59 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -273,7 +273,7 @@ void set_char_online(int map_id, int char_id, int account_id) //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; @@ -4169,7 +4169,7 @@ int char_lan_config_read(const char *lancfgName) while(fgets(line, sizeof(line), fp)) { - line_num++; + line_num++; if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 2ce6d6141..df91e4de4 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -863,7 +863,7 @@ int guild_calcinfo(struct guild *g) // 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; } @@ -1672,7 +1672,7 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char flag |= GS_MEMBER; if( !inter_guild_tosql(g, flag) ) - return 0; + return 0; mapif_guild_info(-1,g); diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 102557df7..7a6f632e7 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -197,7 +197,7 @@ Escape sequences for Select Character Set int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { ///////////////////////////////////////////////////////////////// - /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] + /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] static COORD saveposition = {0,0}; */ @@ -369,7 +369,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { // number of chars from cursor to end origin = info.dwCursorPosition; cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X; - } + } FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp); FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp); } @@ -384,11 +384,11 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) SHORT cnt; DWORD tmp; if(num==1) - { + { cnt = info.dwCursorPosition.X + 1; } else if(num==2) - { + { cnt = info.dwSize.X; } else// 0 and default @@ -512,7 +512,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } int FPRINTF(HANDLE handle, const char *fmt, ...) -{ +{ int ret; va_list argptr; va_start(argptr, fmt); @@ -569,7 +569,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) while(1) { if( ISDIGIT(*q) ) - { + { ++q; // and next character continue; @@ -648,7 +648,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) return 0; } int FPRINTF(FILE *file, const char *fmt, ...) -{ +{ int ret; va_list argptr; va_start(argptr, fmt); diff --git a/src/common/utils.c b/src/common/utils.c index 1602afa52..8b9e33fa0 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -106,7 +106,7 @@ static char* checkpath(char *path, const char *srcpath) } void findfile(const char *p, const char *pat, void (func)(const char*)) -{ +{ WIN32_FIND_DATAA FindFileData; HANDLE hFind; char tmppath[MAX_PATH+1]; @@ -167,7 +167,7 @@ static char* checkpath(char *path, const char*srcpath) } void findfile(const char *p, const char *pat, void (func)(const char*)) -{ +{ DIR* dir; // pointer to the scanned directory. struct dirent* entry; // pointer to one directory entry. struct stat dir_stat; // used by stat(). diff --git a/src/login/account_sql.c b/src/login/account_sql.c index be1b36ebe..bc607c59e 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -159,7 +159,7 @@ static bool account_db_sql_init(AccountDB* self) Sql_ShowDebug(sql_handle); return true; -} +} /// disconnects from database static void account_db_sql_destroy(AccountDB* self) diff --git a/src/login/login.c b/src/login/login.c index e2c16eaed..78a9b9420 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -265,7 +265,7 @@ bool check_encrypted(const char* str1, const char* str2, const char* passwd) } bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass) -{ +{ if(passwdenc == 0) { return (0==strcmp(passwd, refpass)); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 3d60e06d0..c723d6d73 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4524,7 +4524,7 @@ ACMD_FUNC(mapinfo) strcat(atcmd_output, "Leaves | "); /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //if (map[m_id].flag.rain) // strcat(atcmd_output, "Rain | "); if (map[m_id].flag.nightenabled) @@ -6319,7 +6319,7 @@ ACMD_FUNC(autolootitem) } /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ /*========================================== * It is made to rain. *------------------------------------------*/ @@ -6477,7 +6477,7 @@ ACMD_FUNC(clearweather) nullpo_retr(-1, sd); /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //map[sd->bl.m].flag.rain=0; map[sd->bl.m].flag.snow=0; map[sd->bl.m].flag.sakura=0; @@ -9181,7 +9181,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message } while (*message == charcommand_symbol) - { + { //Checks to see if #command has a name or a name + parameters. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params); y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2); @@ -9195,7 +9195,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message clif_displaymessage(fd, output); } else { sprintf(output, "Charcommand failed. Usage: # ."); - clif_displaymessage(fd, output); + clif_displaymessage(fd, output); } return true; } diff --git a/src/map/battle.c b/src/map/battle.c index 419e40ebf..11e9fb81f 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1069,7 +1069,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo unsigned idef : 1; //Ignore defense unsigned idef2 : 1; //Ignore defense (left weapon) unsigned pdef : 2; //Pierces defense (Investigate/Ice Pick) - unsigned pdef2 : 2; //1: Use def+def2/100, 2: Use def+def2/50 + unsigned pdef2 : 2; //1: Use def+def2/100, 2: Use def+def2/50 unsigned infdef : 1; //Infinite defense (plants) unsigned arrow : 1; //Attack is arrow-based unsigned rh : 1; //Attack considers right hand (wd.damage) @@ -1326,7 +1326,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) - { + { unsigned char attacker_count; //256 max targets should be a sane max attacker_count = unit_counttargeted(target,battle_config.agi_penalty_count_lv); if(attacker_count >= battle_config.agi_penalty_count) @@ -2224,7 +2224,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo if(skill_num == AM_ACIDTERROR) def1 = 0; //Acid Terror ignores only armor defense. [Skotlex] if(def2 < 1) def2 = 1; } - //Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def + //Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def if (tsd) //Sd vit-eq { //[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1)) vit_def = def2*(def2-15)/150; @@ -2402,7 +2402,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo { // Melee attack if( !battle_config.left_cardfix_to_right ) { - cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100; + cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100; if (!(nk&NK_NO_ELEFIX)) { int ele_fix = sd->right_weapon.addele[tstatus->def_ele]; for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) { @@ -2423,9 +2423,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo if( flag.lh ) { - cardfix_=cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100; + cardfix_=cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100; if (!(nk&NK_NO_ELEFIX)) { - int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele]; + int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele]; for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) { if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue; if(!(sd->left_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK && @@ -3473,7 +3473,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) - { + { unsigned char attacker_count; //256 max targets should be a sane max attacker_count = unit_counttargeted(target,battle_config.agi_penalty_count_lv); if(attacker_count >= battle_config.agi_penalty_count) @@ -4121,7 +4121,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f case BL_HOM: break; //All else not specified is an invalid target. - default: + default: return 0; } diff --git a/src/map/battle.h b/src/map/battle.h index 2669af83d..de59f5717 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -123,7 +123,7 @@ extern struct Battle_Config int defnotenemy; int vs_traps_bctall; int traps_setting; - int summon_flora; //[Skotlex] + int summon_flora; //[Skotlex] int clear_unit_ondeath; //[Skotlex] int clear_unit_onwarp; //[Skotlex] int random_monster_checklv; diff --git a/src/map/chrif.c b/src/map/chrif.c index 03b4baeb0..10b7135b6 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1202,7 +1202,7 @@ int chrif_save_scdata(struct map_session_data *sd) //Retrieve and load sc_data for a player. [Skotlex] int chrif_load_scdata(int fd) -{ +{ #ifdef ENABLE_SC_SAVING struct map_session_data *sd; struct status_change_data *data; diff --git a/src/map/chrif.h b/src/map/chrif.h index 1d85ab7a2..dda80cec9 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -15,7 +15,7 @@ struct auth_node { struct map_session_data *sd; //Data from logged on char. struct mmo_charstatus *char_dat; //Data from char server. unsigned int node_created; //timestamp for node timeouts - enum sd_state state; //To track whether player was login in/out or changing maps. + enum sd_state state; //To track whether player was login in/out or changing maps. }; void chrif_setuserid(char* id); diff --git a/src/map/clif.c b/src/map/clif.c index 17cc24fd7..9df67ad70 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8750,13 +8750,13 @@ static bool clif_process_message(struct map_session_data* sd, int format, char** if( messagelen != strnlen(message, messagelen)+1 ) { // the declared length must match real length ShowWarning("clif_process_message: Received malformed packet from player '%s' (length is incorrect)!\n", sd->status.name); - return false; + return false; } // verify part of the packet if( message[messagelen-1] != '\0' ) { // message must be zero-terminated ShowWarning("clif_process_message: Player '%s' sent an unterminated message string!\n", sd->status.name); - return false; + return false; } if( messagelen > CHAT_SIZE_MAX-1 ) { // messages mustn't be too long @@ -9789,7 +9789,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) { char* str = target+4; //Skip the NPC: string part. struct npc_data* npc; - if ((npc = npc_name2id(str))) + if ((npc = npc_name2id(str))) { char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX]; char *split; @@ -11493,7 +11493,7 @@ void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag) /// Request to search for party booking advertisments (CZ_PARTY_BOOKING_REQ_SEARCH). /// 0804 .W .W .W .L .W void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) -{ +{ short level = RFIFOW(fd,2); short mapid = RFIFOW(fd,4); short job = RFIFOW(fd,6); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index d7f1c5f0c..d196ea566 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -469,7 +469,7 @@ int merc_hom_food(struct map_session_data *sd, struct homun_data *hd) clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger); clif_send_homdata(sd,SP_INTIMATE,hd->homunculus.intimacy / 100); clif_hom_food(sd,foodID,1); - + // Too much food :/ if(hd->homunculus.intimacy == 0) return merc_hom_delete(sd->hd, E_OMG); diff --git a/src/map/instance.c b/src/map/instance.c index d15b80a8a..52d0dfeef 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -140,7 +140,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename) map[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index - } + } // Reallocate cells num_cell = map[im].xs * map[im].ys; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 6ab88f872..6ea360e0c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -415,17 +415,17 @@ int itemdb_cansell_sub(struct item_data* item, int gmlv, int unused) } int itemdb_cancartstore_sub(struct item_data* item, int gmlv, int unused) -{ +{ return (item && (!(item->flag.trade_restriction&16) || gmlv >= item->gm_lv_trade_override)); } int itemdb_canstore_sub(struct item_data* item, int gmlv, int unused) -{ +{ return (item && (!(item->flag.trade_restriction&32) || gmlv >= item->gm_lv_trade_override)); } int itemdb_canguildstore_sub(struct item_data* item, int gmlv, int unused) -{ +{ return (item && (!(item->flag.trade_restriction&64) || gmlv >= item->gm_lv_trade_override)); } diff --git a/src/map/map.c b/src/map/map.c index ea6c58d2b..afe385e33 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1633,7 +1633,7 @@ int map_quit(struct map_session_data *sd) sd->bl.y = pt->y; sd->mapindex = pt->map; } - } + } party_booking_delete(sd); // Party Booking [Spiria] pc_makesavestatus(sd); @@ -1784,7 +1784,7 @@ struct mob_data * map_getmob_boss(int m) { if( md->bl.m == m ) { - found = true; + found = true; break; } } diff --git a/src/map/map.h b/src/map/map.h index 0829d93b3..06e955b6e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -501,7 +501,7 @@ struct map_data { unsigned leaves : 1; // [Valaris] /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //unsigned rain : 1; // [Valaris] unsigned nogo : 1; // [Valaris] unsigned nobaseexp : 1; // [Lorky] added by Lupus diff --git a/src/map/mob.c b/src/map/mob.c index 7da208827..cc3c8e6e6 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -931,7 +931,7 @@ static int mob_can_changetarget(struct mob_data* md, struct block_list* target, { // if the monster was provoked ignore the above rule [celest] if(md->state.provoke_flag) - { + { if (md->state.provoke_flag == target->id) return 1; else if (!(battle_config.mob_ai&0x4)) @@ -1112,7 +1112,7 @@ static int mob_warpchase_sub(struct block_list *bl,va_list ap) *target_nd = nd; *min_distance = cur_distance; return 1; - } + } return 0; } /*========================================== @@ -1161,7 +1161,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if(map_search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) && unit_walktoxy(&md->bl, x, y, 0)) return 1; - } + } } else if (bl->m != md->bl.m && map_flag_gvg(md->bl.m)) { //Delete the summoned mob if it's in a gvg ground and the master is elsewhere. [Skotlex] status_kill(&md->bl); @@ -2147,7 +2147,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) job_exp = 0; else job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * map[m].jexp/100., 1, UINT_MAX); - + if((temp = tmpsd[i]->status.party_id )>0 && !md->dmglog[i].flag == MDLF_HOMUN) //Homun-done damage (flag 1) is not given to party { int j; @@ -2954,7 +2954,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) //Pick a starting position and loop from that. i = battle_config.mob_ai&0x100?rnd()%md->db->maxskill:0; for (n = 0; n < md->db->maxskill; i++, n++) { - int c2, flag = 0; + int c2, flag = 0; if (i == md->db->maxskill) i = 0; @@ -3011,7 +3011,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) flag = ((fbl = mob_getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break; case MSC_FRIENDSTATUSON: // friend status[num] on case MSC_FRIENDSTATUSOFF: // friend status[num] off - flag = ((fmd = mob_getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break; + flag = ((fmd = mob_getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break; case MSC_SLAVELT: // slave < num flag = (mob_countslave(&md->bl) < c2 ); break; case MSC_ATTACKPCGT: // attack pc > num @@ -3049,7 +3049,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) clif_messagecolor(&md->bl, mc->color, temp); } - //Execute skill + //Execute skill if (skill_get_casttype(ms[i].skill_id) == CAST_GROUND) { //Ground skill. short x, y; @@ -3404,7 +3404,7 @@ static int mob_makedummymobdb(int class_) } return 0; } - //Initialize dummy data. + //Initialize dummy data. mob_dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob. sprintf(mob_dummy->sprite,"DUMMY"); sprintf(mob_dummy->name,"Dummy"); diff --git a/src/map/npc.c b/src/map/npc.c index 7802ac1f9..8a7a38b05 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -594,7 +594,7 @@ int npc_timerevent_start(struct npc_data* nd, int rid) else if( nd->u.scr.timerid != INVALID_TIMER ) return 0; - // Arrange for the next event + // Arrange for the next event ted = ers_alloc(timer_event_ers, struct timer_event_data); ted->next = j; // Set event index ted->time = nd->u.scr.timer_event[j].timer; @@ -696,8 +696,8 @@ void npc_timerevent_quit(struct map_session_data* sd) old_tick = nd->u.scr.timertick; old_timer = nd->u.scr.timer; - nd->u.scr.rid = sd->bl.id; - nd->u.scr.timertick = gettick(); + nd->u.scr.rid = sd->bl.id; + nd->u.scr.timertick = gettick(); nd->u.scr.timer = ted->time; //Execute label @@ -741,7 +741,7 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer) nullpo_ret(nd); - // TODO: Set player attached timer's tick. + // TODO: Set player attached timer's tick. old_rid = nd->u.scr.rid; nd->u.scr.rid = 0; @@ -1738,7 +1738,7 @@ int npc_unload(struct npc_data* nd) if( nd->subtype == SCRIPT ) { struct s_mapiterator* iter; - struct block_list* bl; + struct block_list* bl; ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related @@ -3186,7 +3186,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con map[m].flag.leaves=state; /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //else if (!strcmpi(w3,"rain")) // map[m].flag.rain=state; else if (!strcmpi(w3,"nightenabled")) diff --git a/src/map/pc.c b/src/map/pc.c index fc0769b57..abdaf6671 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1254,7 +1254,7 @@ int pc_calc_skilltree(struct map_session_data *sd) for( i = 0; i < MAX_SKILL; i++ ) { if( sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED ) - { // Restore original level of skills after deleting earned skills. + { // Restore original level of skills after deleting earned skills. sd->status.skill[i].lv = (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) ? 0 : sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0; sd->status.skill[i].flag = SKILL_FLAG_PERMANENT; } @@ -5211,7 +5211,7 @@ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsi if (battle_config.pk_mode && (int)(status_get_lv(src) - sd->status.base_level) >= 20) - bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris] + bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris] if (sd->sc.data[SC_EXPBOOST]) bonus += sd->sc.data[SC_EXPBOOST]->val1; @@ -6641,7 +6641,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) break; } //This will automatically adjust bard/dancer classes to the correct gender - //That is, if you try to jobchange into dancer, it will turn you to bard. + //That is, if you try to jobchange into dancer, it will turn you to bard. job = pc_mapid2jobid(b_class, sd->status.sex); if (job == -1) return 1; @@ -8527,7 +8527,7 @@ int pc_readdb(void) stat=0; if (i > MAX_LEVEL) break; - statp[i]=stat; + statp[i]=stat; i++; } fclose(fp); diff --git a/src/map/pc.h b/src/map/pc.h index 05cdc9e73..af26ce8d2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -487,7 +487,7 @@ enum weapon_type { W_2HMACE, //9 (unused) W_STAFF, //10 W_BOW, //11 - W_KNUCKLE, //12 + W_KNUCKLE, //12 W_MUSICAL, //13 W_WHIP, //14 W_BOOK, //15 diff --git a/src/map/pet.c b/src/map/pet.c index 248373edc..c3fa41219 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -173,7 +173,7 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) * Pet SC Check [Skotlex] *------------------------------------------*/ int pet_sc_check(struct map_session_data *sd, int type) -{ +{ struct pet_data *pd; nullpo_ret(sd); @@ -1203,7 +1203,7 @@ int read_petdb() FILE *fp; int nameid,i,j,k; - // Remove any previous scripts in case reloaddb was invoked. + // Remove any previous scripts in case reloaddb was invoked. for( j = 0; j < MAX_PET_DB; j++ ) { if( pet_db[j].pet_script ) @@ -1238,7 +1238,7 @@ int read_petdb() lines = entries = 0; while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB ) - { + { char *str[22], *p; lines++; diff --git a/src/map/quest.c b/src/map/quest.c index 6be181eac..c01557974 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -273,7 +273,7 @@ int quest_check(TBL_PC * sd, int quest_id, quest_check_type type) switch( type ) { - case HAVEQUEST: + case HAVEQUEST: return sd->quest_log[i].state; case PLAYTIME: return (sd->quest_log[i].time < (unsigned int)time(NULL) ? 2 : sd->quest_log[i].state == Q_COMPLETE ? 1 : 0); diff --git a/src/map/script.c b/src/map/script.c index 220583ff5..0e71a0c97 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -328,7 +328,7 @@ enum { MF_LEAVES, /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //MF_RAIN, //20 // 21 free MF_NOGO = 22, @@ -4591,7 +4591,7 @@ BUILDIN_FUNC(warpchar) else if(strcmp(str, "SavePoint") == 0) pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); - else + else pc_setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT); return 0; @@ -4883,7 +4883,7 @@ BUILDIN_FUNC(input) st->state = RERUNLINE; if( is_string_variable(name) ) clif_scriptinputstr(sd,st->oid); - else + else clif_scriptinput(sd,st->oid); } else @@ -7054,7 +7054,7 @@ BUILDIN_FUNC(bonus) case 1: pc_bonus(sd, type, val1); break; - case 2: + case 2: val2 = script_getnum(st,4); pc_bonus2(sd, type, val1, val2); break; @@ -9675,7 +9675,7 @@ BUILDIN_FUNC(getmapflag) case MF_LEAVES: script_pushint(st,map[m].flag.leaves); break; /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //case MF_RAIN: script_pushint(st,map[m].flag.rain); break; case MF_NOGO: script_pushint(st,map[m].flag.nogo); break; case MF_CLOUDS: script_pushint(st,map[m].flag.clouds); break; @@ -9750,7 +9750,7 @@ BUILDIN_FUNC(setmapflag) case MF_LEAVES: map[m].flag.leaves = 1; break; /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //case MF_RAIN: map[m].flag.rain = 1; break; case MF_NOGO: map[m].flag.nogo = 1; break; case MF_CLOUDS: map[m].flag.clouds = 1; break; @@ -9828,7 +9828,7 @@ BUILDIN_FUNC(removemapflag) case MF_LEAVES: map[m].flag.leaves = 0; break; /** * No longer available, keeping here just in case it's back someday. [Ind] - **/ + **/ //case MF_RAIN: map[m].flag.rain = 0; break; case MF_NOGO: map[m].flag.nogo = 0; break; case MF_CLOUDS: map[m].flag.clouds = 0; break; @@ -12313,7 +12313,7 @@ BUILDIN_FUNC(isequippedcnt) for(k=0; kinventory_data[index]->slot; k++) { if (sd->status.inventory[index].card[k] == id) ret++; //[Lupus] - } + } } } } @@ -12381,7 +12381,7 @@ BUILDIN_FUNC(isequipped) hash = 1<<((j<5?j:j-5)*4 + k); // check if card is already used by another set - if ((j<5?sd->setitem_hash:sd->setitem_hash2) & hash) + if ((j<5?sd->setitem_hash:sd->setitem_hash2) & hash) continue; // We have found a match @@ -12444,7 +12444,7 @@ BUILDIN_FUNC(cardscnt) for(k=0; kinventory_data[index]->slot; k++) { if (sd->status.inventory[index].card[k] == id) ret++; - } + } } } script_pushint(st,ret); @@ -15362,14 +15362,14 @@ BUILDIN_FUNC(instance_detachmap) else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id ) instance_id = p->instance_id; else return 0; - + if( (m = map_mapname2mapid(str)) < 0 || (m = instance_map2imap(m,instance_id)) < 0 ) - { + { ShowError("buildin_instance_detachmap: Trying to detach invalid map %s\n", str); - return 0; - } + return 0; + } - instance_del_map(m); + instance_del_map(m); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 74804ef84..cacb29e04 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1222,7 +1222,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int } if( rate ) skill_break_equip(src, EQP_WEAPON, rate, BCT_SELF); - } + } if( battle_config.equip_skill_break_rate && skillid != WS_CARTTERMINATION && skillid != ITM_TOMAHAWK ) { // Cart Termination/Tomahawk won't trigger breaking data. Why? No idea, go ask Gravity. // Target weapon breaking @@ -2377,7 +2377,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if( ssc && ssc->data[SC_POISONINGWEAPON] && rnd()%100 < 70 + 5*skilllv ) { sc_start(bl,ssc->data[SC_POISONINGWEAPON]->val2,100,ssc->data[SC_POISONINGWEAPON]->val1,skill_get_time2(GC_POISONINGWEAPON,ssc->data[SC_POISONINGWEAPON]->val1)); status_change_end(src,SC_POISONINGWEAPON,-1); - clif_skill_nodamage(src,bl,skillid,skilllv,1); + clif_skill_nodamage(src,bl,skillid,skilllv,1); } } } @@ -3953,7 +3953,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, int } else { - struct skill_unit *su = BL_CAST(BL_SKILL,bl); + struct skill_unit *su = BL_CAST(BL_SKILL,bl); struct skill_unit_group* sg; if( su && (sg=su->group) && skill_get_inf2(sg->skill_id)&INF2_TRAP && sg->src_id != src->id && @@ -4559,7 +4559,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in break; case PR_KYRIE: - case MER_KYRIE: + case MER_KYRIE: clif_skill_nodamage(bl,bl,skillid,skilllv, sc_start(bl,type,100,skilllv,skill_get_time(skillid,skilllv))); break; @@ -5138,7 +5138,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in map_freeblock_unlock(); return 0; } - clif_skill_nodamage(src,bl,skillid,-1,sc_start(bl,type,100,skilllv,skill_get_time(skillid,skilllv))); + clif_skill_nodamage(src,bl,skillid,-1,sc_start(bl,type,100,skilllv,skill_get_time(skillid,skilllv))); break; case TK_RUN: if (tsce) @@ -7096,7 +7096,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case WL_JACKFROST: clif_skill_nodamage(src,bl,skillid,skilllv,1); map_foreachinshootrange(skill_area_sub,bl,skill_get_splash(skillid,skilllv),BL_CHAR|BL_SKILL,src,skillid,skilllv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); - break; + break; case WL_MARSHOFABYSS: // Should marsh of abyss still apply half reduction to players after the 28/10 patch? [LimitLine] @@ -7321,7 +7321,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case NC_DISJOINT: { - if( bl->type != BL_MOB ) break; + if( bl->type != BL_MOB ) break; md = map_id2md(bl->id); if( md && md->class_ >= 2042 && md->class_ <= 2046 ) status_kill(bl); @@ -8407,7 +8407,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk i = skill_get_splash(skillid,skilllv); map_foreachinarea(skill_area_sub,src->m,x-i,y-i,x+i,y+i,BL_CHAR, src,skillid,skilllv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); - break; + break; /** * Guilotine Cross **/ @@ -9803,7 +9803,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_GRAVITATION: - case UNT_EARTHSTRAIN: + case UNT_EARTHSTRAIN: case UNT_FIREWALK: case UNT_ELECTRICWALK: case UNT_PSYCHIC_WAVE: @@ -10312,7 +10312,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, short skill, sh if (lv <= 0 || sd->chatID) return 0; if( battle_config.gm_skilluncond && pc_isGM(sd)>= battle_config.gm_skilluncond && sd->skillitem != skill ) - { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] + { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill_get_ammotype(skill)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. return 1; @@ -10972,7 +10972,7 @@ int skill_check_condition_castend(struct map_session_data* sd, short skill, shor return 0; if( battle_config.gm_skilluncond && pc_isGM(sd) >= battle_config.gm_skilluncond && sd->skillitem != skill ) - { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] + { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill_get_ammotype(skill)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. return 1; @@ -14435,14 +14435,14 @@ int skill_stasis_check(struct block_list *bl, int src_id, int skillid) { int inf = 0; if( !bl || skillid < 1 ) - return 0; // Can do it + return 0; // Can do it inf = skill_get_inf2(skillid); if( inf == INF2_SONG_DANCE || /*skill_get_inf2(skillid) == INF2_CHORUS_SKILL ||*/ inf == INF2_SPIRIT_SKILL ) return 1; // Can't do it. switch( skillid ) { - case NV_FIRSTAID: case TF_HIDING: case AS_CLOAKING: case WZ_SIGHTRASHER: + case NV_FIRSTAID: case TF_HIDING: case AS_CLOAKING: case WZ_SIGHTRASHER: case RG_STRIPWEAPON: case RG_STRIPSHIELD: case RG_STRIPARMOR: case WZ_METEOR: case RG_STRIPHELM: case SC_STRIPACCESSARY: case ST_FULLSTRIP: case WZ_SIGHTBLASTER: case ST_CHASEWALK: case SC_ENERVATION: case SC_GROOMY: case WZ_ICEWALL: diff --git a/src/map/status.c b/src/map/status.c index 275c6c8f2..2f36cd6f6 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1244,7 +1244,7 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe status_damage(src, target, 0, INT_MAX, 0, (!src||src==target?5:1)); else status_heal(target, 0, INT_MAX, 0); - } + } if (flag) return status_damage(src, target, hp, sp, 0, (!src||src==target?5:1)); return status_heal(target, hp, sp, 0); @@ -1442,7 +1442,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, int tsc = status_get_sc(target); if(tsc && tsc->count) - { + { if( tsc->data[SC_INVINCIBLE] ) return 0; if(!skill_num && tsc->data[SC_TRICKDEAD]) @@ -1926,7 +1926,7 @@ int status_calc_pet_(struct pet_data *pd, bool first) pd->rate_fix = pd->rate_fix*battle_config.pet_support_rate/100; return 1; -} +} /// Helper function for status_base_pc_maxhp(), used to pre-calculate the hp_sigma_val[] array static void status_calc_sigma(void) @@ -3420,7 +3420,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) else if( bl->type&BL_HOM ) { - amotion = (1000 -4*status->agi -status->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; + amotion = (1000 -4*status->agi -status->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; status->aspd_rate = status_calc_aspd_rate(bl, sc, b_status->aspd_rate); if(status->aspd_rate != 1000) @@ -4698,7 +4698,7 @@ static unsigned char status_calc_element_lv(struct block_list *bl, struct status if(!sc || !sc->count) return lv; - if(sc->data[SC_FREEZE]) + if(sc->data[SC_FREEZE]) return 1; if(sc->data[SC_STONE] && sc->opt1 == OPT1_STONE) return 1; @@ -5625,7 +5625,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC break; case SC_STRIPSHIELD: - if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off.. + if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off.. else if (sd && !(flag&4)) { int i; @@ -6379,7 +6379,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_DEFENDER: if (!(flag&1)) - { + { val2 = 5 + 15*val1; //Damage reduction val3 = 0; // unused, previously speed adjustment val4 = 250 - 50*val1; //Aspd adjustment @@ -6913,7 +6913,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_CLOAKINGEXCEED: val2 = ( val1 + 1 ) / 2; // Hits val3 = 90 + val1 * 10; // Walk speed - val_flag |= 1|2|4; + val_flag |= 1|2|4; if (bl->type == BL_PC) val4 |= battle_config.pc_cloak_check_type&7; else @@ -7066,7 +7066,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = 6 * val1; val2 += val3; //Adding 1% * Lesson Bonus val2 += (int)(val4*2/10); //Adding 0.2% per JobLevel - break; + break; case SC_MOONLITSERENADE: val2 = 10 * val1; break; @@ -7958,7 +7958,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const clif_updatestatus(sd,SP_MANNER); } break; - case SC_SPLASHER: + case SC_SPLASHER: { struct block_list *src=map_id2bl(sce->val3); if(src && tid != INVALID_TIMER) @@ -8116,7 +8116,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_ADORAMUS: status_change_end(bl, SC_BLIND, -1); - break; + break; /* case SC__SHADOWFORM: { @@ -8214,10 +8214,10 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_SIGHT: sc->option &= ~OPTION_SIGHT; break; - case SC_WEDDING: + case SC_WEDDING: sc->option &= ~OPTION_WEDDING; break; - case SC_XMAS: + case SC_XMAS: sc->option &= ~OPTION_XMAS; break; case SC_SUMMER: diff --git a/src/map/status.h b/src/map/status.h index e11252f1d..03310c3e3 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -741,13 +741,13 @@ enum si_type { // SI_FRIEND = 162, // SI_FRIENDUP = 163, // SI_SG_WARM = 164, - SI_WARM = 165, -// 166 | The three show the exact same display: ultra red character (165, 166, 167) + SI_WARM = 165, +// 166 | The three show the exact same display: ultra red character (165, 166, 167) // 167 | Their names would be SI_SG_SUN_WARM, SI_SG_MOON_WARM, SI_SG_STAR_WARM // SI_EMOTION = 168, SI_SUN_COMFORT = 169, - SI_MOON_COMFORT = 170, - SI_STAR_COMFORT = 171, + SI_MOON_COMFORT = 170, + SI_STAR_COMFORT = 171, // SI_EXPUP = 172, // SI_GDSKILL_BATTLEORDER = 173, // SI_GDSKILL_REGENERATION = 174, diff --git a/src/map/storage.c b/src/map/storage.c index f802dabe4..12d9a8107 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -339,7 +339,7 @@ struct guild_storage *guild2storage2(int guild_id) return (struct guild_storage*)idb_get(guild_storage_db,guild_id); } -int guild_storage_delete(int guild_id) +int guild_storage_delete(int guild_id) { idb_remove(guild_storage_db,guild_id); return 0; diff --git a/src/map/unit.c b/src/map/unit.c index c27bde544..9161c61d1 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -829,7 +829,7 @@ int unit_stop_walking(struct block_list *bl,int type) tick = gettick(); if( (type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell. || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell - ) { + ) { ud->walkpath.path_len = ud->walkpath.path_pos+1; unit_walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); } @@ -1176,7 +1176,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh switch(skill_num){ case ALL_RESURRECTION: - if(battle_check_undead(tstatus->race,tstatus->def_ele)) { + if(battle_check_undead(tstatus->race,tstatus->def_ele)) { temp = 1; } else if (!status_isdead(target)) return 0; //Can't cast on non-dead characters. @@ -1220,7 +1220,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh casttime *= 2; break; } - + // moved here to prevent Suffragium from ending if skill fails if (!(skill_get_castnodex(skill_num, skill_lv)&2)) casttime = skill_castfix_sc(src, casttime, skill_num, skill_lv); diff --git a/src/plugins/console.c b/src/plugins/console.c index 74c431d32..673a30e78 100644 --- a/src/plugins/console.c +++ b/src/plugins/console.c @@ -277,7 +277,7 @@ void input_setstate(char state) { if( state == INPUT_READY && input_getstate() == INPUT_READING ) {// send data from the worker to the main process - write(buf.data_pipe[PIPE_WRITE], &buf.len, sizeof(buf.len)); + write(buf.data_pipe[PIPE_WRITE], &buf.len, sizeof(buf.len)); write(buf.data_pipe[PIPE_WRITE], &buf.arr, buf.len); } else if( state == INPUT_WAITING ){ if( buf.close_unused_flag == 0 ) diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index ef9c08534..85556503b 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -538,7 +538,7 @@ Dhp__PrintTypeName( switch( symtag ) { case SymTagEnum: - { + { WCHAR* pwszTypeName; if( SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_SYMNAME, &pwszTypeName) ) -- 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 '3rdparty') 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: -#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 deleted file mode 100644 index 7d058d89d..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_alloc.h b/3rdparty/mysql/include/my_alloc.h deleted file mode 100644 index 1641b3acf..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_dbug.h b/3rdparty/mysql/include/my_dbug.h deleted file mode 100644 index b76a3fcc8..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_global.h b/3rdparty/mysql/include/my_global.h deleted file mode 100644 index 2417477e2..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_list.h b/3rdparty/mysql/include/my_list.h deleted file mode 100644 index 92598696f..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_pthread.h b/3rdparty/mysql/include/my_pthread.h deleted file mode 100644 index 202e047dc..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/my_sys.h b/3rdparty/mysql/include/my_sys.h deleted file mode 100644 index 44fe383bf..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/mysql.h b/3rdparty/mysql/include/mysql.h deleted file mode 100644 index 925a45253..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/mysql_com.h b/3rdparty/mysql/include/mysql_com.h deleted file mode 100644 index ec1c13379..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/mysql_time.h b/3rdparty/mysql/include/mysql_time.h deleted file mode 100644 index 5f4fc12c0..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/mysql_version.h b/3rdparty/mysql/include/mysql_version.h deleted file mode 100644 index 473a19987..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/raid.h b/3rdparty/mysql/include/raid.h deleted file mode 100644 index c840afcba..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/include/typelib.h b/3rdparty/mysql/include/typelib.h deleted file mode 100644 index 4d6a90ad5..000000000 --- a/3rdparty/mysql/include/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/3rdparty/mysql/lib/libmysql.lib b/3rdparty/mysql/lib/libmysql.lib deleted file mode 100644 index aa99dc3b8..000000000 Binary files a/3rdparty/mysql/lib/libmysql.lib and /dev/null differ diff --git a/3rdparty/mysql/mysql-5.0.20 b/3rdparty/mysql/mysql-5.0.20 deleted file mode 100644 index e69de29bb..000000000 diff --git a/3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz b/3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz new file mode 100644 index 000000000..a097f2086 Binary files /dev/null and b/3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz differ diff --git a/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz b/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz new file mode 100644 index 000000000..56a39a59a Binary files /dev/null and b/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz differ diff --git a/3rdparty/mysql/old/include/config-win.h b/3rdparty/mysql/old/include/config-win.h new file mode 100644 index 000000000..b2e1c9831 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/m_ctype.h b/3rdparty/mysql/old/include/m_ctype.h new file mode 100644 index 000000000..54ae41bf2 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_alloc.h b/3rdparty/mysql/old/include/my_alloc.h new file mode 100644 index 000000000..1641b3acf --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_dbug.h b/3rdparty/mysql/old/include/my_dbug.h new file mode 100644 index 000000000..b76a3fcc8 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_global.h b/3rdparty/mysql/old/include/my_global.h new file mode 100644 index 000000000..2417477e2 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_list.h b/3rdparty/mysql/old/include/my_list.h new file mode 100644 index 000000000..92598696f --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_pthread.h b/3rdparty/mysql/old/include/my_pthread.h new file mode 100644 index 000000000..202e047dc --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/my_sys.h b/3rdparty/mysql/old/include/my_sys.h new file mode 100644 index 000000000..44fe383bf --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/mysql.h b/3rdparty/mysql/old/include/mysql.h new file mode 100644 index 000000000..925a45253 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/mysql_com.h b/3rdparty/mysql/old/include/mysql_com.h new file mode 100644 index 000000000..ec1c13379 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/mysql_time.h b/3rdparty/mysql/old/include/mysql_time.h new file mode 100644 index 000000000..5f4fc12c0 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/mysql_version.h b/3rdparty/mysql/old/include/mysql_version.h new file mode 100644 index 000000000..473a19987 --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/raid.h b/3rdparty/mysql/old/include/raid.h new file mode 100644 index 000000000..c840afcba --- /dev/null +++ b/3rdparty/mysql/old/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/old/include/typelib.h b/3rdparty/mysql/old/include/typelib.h new file mode 100644 index 000000000..4d6a90ad5 --- /dev/null +++ b/3rdparty/mysql/old/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/old/lib/libmysql.lib b/3rdparty/mysql/old/lib/libmysql.lib new file mode 100644 index 000000000..aa99dc3b8 Binary files /dev/null and b/3rdparty/mysql/old/lib/libmysql.lib differ diff --git a/3rdparty/mysql/old/mysql-5.0.20 b/3rdparty/mysql/old/mysql-5.0.20 new file mode 100644 index 000000000..e69de29bb diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d0771254..6c08297b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,7 +465,6 @@ set( RUNTIME_FILES "${CMAKE_CURRENT_SOURCE_DIR}/char-server.sh" "${CMAKE_CURRENT_SOURCE_DIR}/charserv-sql.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" diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index a7b57e7aa..436c294ad 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -73,7 +73,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -94,7 +94,7 @@ true true true - ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LIBCONFIG_STATIC;YY_USE_CONST;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded @@ -111,7 +111,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index d747c3e1e..4b152c0ab 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -73,7 +73,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -94,7 +94,7 @@ true true true - ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) true MultiThreaded @@ -115,7 +115,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-10/map-server_sql.vcxproj b/vcproj-10/map-server_sql.vcxproj index 2326f5a6e..8a834b505 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;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -72,7 +72,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -93,7 +93,7 @@ true true true - ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) true MultiThreaded @@ -110,7 +110,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 3e6e85558..0ea3e9c27 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -71,7 +71,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -137,7 +137,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" @@ -162,7 +162,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" diff --git a/vcproj-9/login-server_sql.vcproj b/vcproj-9/login-server_sql.vcproj index 2cf3c6e6c..3799fda05 100644 --- a/vcproj-9/login-server_sql.vcproj +++ b/vcproj-9/login-server_sql.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;WITH_SQL" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -71,7 +71,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -137,7 +137,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;WITH_SQL" StringPooling="true" RuntimeLibrary="0" @@ -164,7 +164,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index a9f2b4fba..3cf1c0ff5 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -70,7 +70,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -136,7 +136,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" @@ -161,7 +161,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" -- cgit v1.2.3-70-g09d2 From 93dd8ad5d0d9e1888ff4b32afa1fb09dbdd80be9 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Sun, 13 May 2012 17:14:43 +0000 Subject: - Full revert of r16105 and r16106. * Merged changes up to eAthena 15094. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16110 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 33 +- 3rdparty/mysql/CMakeLists.txt | 85 +- 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/mysql/mysql-5.5.24-win32-libmysql.tar.gz | Bin 2094955 -> 0 bytes 3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz | Bin 2076879 -> 0 bytes 3rdparty/mysql/old/include/config-win.h | 470 ------- 3rdparty/mysql/old/include/m_ctype.h | 493 -------- 3rdparty/mysql/old/include/my_alloc.h | 52 - 3rdparty/mysql/old/include/my_dbug.h | 101 -- 3rdparty/mysql/old/include/my_global.h | 1306 -------------------- 3rdparty/mysql/old/include/my_list.h | 46 - 3rdparty/mysql/old/include/my_pthread.h | 717 ----------- 3rdparty/mysql/old/include/my_sys.h | 904 -------------- 3rdparty/mysql/old/include/mysql.h | 847 ------------- 3rdparty/mysql/old/include/mysql_com.h | 452 ------- 3rdparty/mysql/old/include/mysql_time.h | 56 - 3rdparty/mysql/old/include/mysql_version.h | 29 - 3rdparty/mysql/old/include/raid.h | 159 --- 3rdparty/mysql/old/include/typelib.h | 34 - 3rdparty/mysql/old/lib/libmysql.lib | Bin 34900 -> 0 bytes 3rdparty/mysql/old/mysql-5.0.20 | 0 CMakeLists.txt | 5 +- src/char/CMakeLists.txt | 8 +- src/common/CMakeLists.txt | 18 +- src/login/sql/CMakeLists.txt | 8 +- src/map/sql/CMakeLists.txt | 11 +- src/plugins/CMakeLists.txt | 4 +- src/tool/CMakeLists.txt | 8 +- vcproj-10/char-server_sql.vcxproj | 8 +- vcproj-10/login-server_sql.vcxproj | 8 +- vcproj-10/map-server_sql.vcxproj | 8 +- vcproj-9/char-server_sql.vcproj | 8 +- vcproj-9/login-server_sql.vcproj | 8 +- vcproj-9/map-server_sql.vcproj | 8 +- 49 files changed, 5752 insertions(+), 5808 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 delete mode 100644 3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz delete mode 100644 3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz delete mode 100644 3rdparty/mysql/old/include/config-win.h delete mode 100644 3rdparty/mysql/old/include/m_ctype.h delete mode 100644 3rdparty/mysql/old/include/my_alloc.h delete mode 100644 3rdparty/mysql/old/include/my_dbug.h delete mode 100644 3rdparty/mysql/old/include/my_global.h delete mode 100644 3rdparty/mysql/old/include/my_list.h delete mode 100644 3rdparty/mysql/old/include/my_pthread.h delete mode 100644 3rdparty/mysql/old/include/my_sys.h delete mode 100644 3rdparty/mysql/old/include/mysql.h delete mode 100644 3rdparty/mysql/old/include/mysql_com.h delete mode 100644 3rdparty/mysql/old/include/mysql_time.h delete mode 100644 3rdparty/mysql/old/include/mysql_version.h delete mode 100644 3rdparty/mysql/old/include/raid.h delete mode 100644 3rdparty/mysql/old/include/typelib.h delete mode 100644 3rdparty/mysql/old/lib/libmysql.lib delete mode 100644 3rdparty/mysql/old/mysql-5.0.20 (limited to '3rdparty') diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 41916ec48..3b60b68dc 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -2,23 +2,19 @@ # macro to configure the use of local or system version of a package # Uses: # HAVE_LOCAL_${name} - is local version available? -# ${name}_LOCAL_DEPENDENCIES - dependencies of the local version # ${name}_LOCAL_LIBRARIES - libraries of the local version # ${name}_LOCAL_INCLUDE_DIRS - include directories of the local version -# ${name}_LOCAL_DEFINITIONS - definitions of the local version # HAVE_SYSTEM_${name} - is system version available? -# ${name}_SYSTEM_DEPENDENCIES - dependencies of the system version # ${name}_SYSTEM_LIBRARIES - libraries of the system version # ${name}_SYSTEM_INCLUDE_DIRS - include directories of the system version -# ${name}_SYSTEM_DEFINITIONS - definitions of the system version # Generates: # WITH_LOCAL_${name} - use the local version of the package (only when local is available) # WITH_${name} - use this package -# ${name}_DEPENDENCIES - dependencies # ${name}_LIBRARIES - libraries # ${name}_INCLUDE_DIRS - include directories -# ${name}_DEFINITIONS - definitions macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) + unset( ${name}_LIBRARIES CACHE ) + unset( ${name}_INCLUDE_DIRS CACHE ) if( HAVE_LOCAL_${name} ) set( WITH_LOCAL_${name} ON CACHE BOOL "use local version of ${name}" ) @@ -26,9 +22,14 @@ macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) unset( WITH_LOCAL_${name} CACHE ) endif() if( WITH_LOCAL_${name} ) - set( _type "LOCAL" ) + message( STATUS "Configuring for local ${name}" ) + set( ${name}_LIBRARIES ${${name}_LOCAL_LIBRARIES} ) + set( ${name}_INCLUDE_DIRS ${${name}_LOCAL_INCLUDE_DIRS} ) + message( STATUS "Configuring for local ${name} - done" ) elseif( HAVE_SYSTEM_${name} ) - set( _type "SYSTEM" ) + message( STATUS "Configuring for system ${name}" ) + set( ${name}_LIBRARIES ${${name}_SYSTEM_LIBRARIES} ) + set( ${name}_INCLUDE_DIRS ${${name}_SYSTEM_INCLUDE_DIRS} ) message( STATUS "Configuring for system ${name} - done" ) endif() if( WITH_LOCAL_${name} OR HAVE_SYSTEM_${name} ) @@ -37,24 +38,12 @@ macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) else() unset( WITH_${name} CACHE ) endif() - message( STATUS "Configuring for ${_type} ${name}" ) - unset( ${name}_DEPENDENCIES CACHE ) - unset( ${name}_LIBRARIES CACHE ) - unset( ${name}_INCLUDE_DIRS CACHE ) - unset( ${name}_DEFINITIONS CACHE ) - set( ${name}_DEPENDENCIES ${${name}_${_type}_DEPENDENCIES} - CACHE PATH "${name} dependencies" ) - set( ${name}_LIBRARIES ${${name}_${_type}_LIBRARIES} + set( ${name}_LIBRARIES ${${name}_LIBRARIES} CACHE PATH "${name} libraries" ) - set( ${name}_INCLUDE_DIRS ${${name}_${_type}_INCLUDE_DIRS} + set( ${name}_INCLUDE_DIRS ${${name}_INCLUDE_DIRS} CACHE PATH "${name} include directories" ) - set( ${name}_DEFINITIONS ${${name}_${_type}_DEFINITIONS} - CACHE PATH "${name} definitions" ) - mark_as_advanced( ${name}_DEPENDENCIES ) mark_as_advanced( ${name}_LIBRARIES ) mark_as_advanced( ${name}_INCLUDE_DIRS ) - mark_as_advanced( ${name}_DEFINITIONS ) - message( STATUS "Configuring for ${_type} ${name} - done" ) endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index 7bffa06af..e85fd626d 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -4,62 +4,37 @@ # if( WIN32 ) message( STATUS "Detecting local MYSQL" ) +find_path( MYSQL_LOCAL_INCLUDE_DIRS "mysql.h" + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" + NO_DEFAULT_PATH ) +find_library( MYSQL_LOCAL_LIBRARIES + NAMES libmysql + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/lib" + NO_DEFAULT_PATH ) +mark_as_advanced( MYSQL_LOCAL_LIBRARIES ) +mark_as_advanced( MYSQL_LOCAL_INCLUDE_DIRS ) -# external_mysql -message( STATUS "Creating target external_mysql" ) -if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - set( _URL "${CMAKE_CURRENT_SOURCE_DIR}/mysql-5.5.24-winx64-libmysql.tar.gz" ) - set( _URL_MD5 "36ae333e56ff6ae99de13edf893a1792" ) -elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 ) - set( _URL "${CMAKE_CURRENT_SOURCE_DIR}/mysql-5.5.24-win32-libmysql.tar.gz" ) - set( _URL_MD5 "e9abe2055bba07995c89e66c7c6d1e2c" ) +if( MYSQL_LOCAL_LIBRARIES AND MYSQL_LOCAL_INCLUDE_DIRS ) + if( EXISTS "${MYSQL_LOCAL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${MYSQL_LOCAL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_SERVER_VERSION "${MYSQL_VERSION_H}" ) + message( STATUS "Found MYSQL: ${MYSQL_LOCAL_LIBRARIES} (found version ${MYSQL_SERVER_VERSION})" ) + else() + message( STATUS "Found MYSQL: ${MYSQL_LOCAL_LIBRARIES}" ) + endif() + set( HAVE_LOCAL_MYSQL ON + CACHE BOOL "mysql client is available as a local copy") + mark_as_advanced( HAVE_LOCAL_MYSQL ) else() - message( FATAL_ERROR "Not supported: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) + foreach( _VAR MYSQL_LOCAL_LIBRARIES MYSQL_LOCAL_INCLUDE_DIRS ) + if( NOT "${_VAR}" ) + set( MISSING_VARS ${MISSING_VARS} ${_VAR} ) + endif() + endforeach() + message( STATUS "Could NOT find MYSQL (missing: ${MISSING_VARS})" ) + unset( HAVE_LOCAL_MYSQL CACHE ) endif() -set( _INSTALL_DIR "${CMAKE_BINARY_DIR}/external/mysql" ) - - -message( STATUS "Using URL=${_URL}" ) -message( STATUS "Using URL_MD5=${_URL_MD5}" ) -message( STATUS "Using INSTALL_DIR=${_INSTALL_DIR}" ) -include(ExternalProject) -ExternalProject_Add( external_mysql - URL "${_URL}" - URL_MD5 "${_URL_MD5}" - SOURCE_DIR "${_INSTALL_DIR}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) -set( TARGET_LIST ${TARGET_LIST} external_mysql CACHE INTERNAL "" ) -message( STATUS "Creating target external_mysql - done" ) - -# libmysql -message( STATUS "Creating import shared library libmysql" ) -add_library( libmysql SHARED IMPORTED GLOBAL ) -set_target_properties( libmysql PROPERTIES - IMPORTED_LOCATION "${_INSTALL_DIR}/lib/libmysql.dll" - IMPORTED_IMPLIB "${_INSTALL_DIR}/lib/libmysql.lib" ) -message( STATUS "Creating import shared library libmysql - done" ) - -set( HAVE_LOCAL_MYSQL ON - CACHE BOOL "mysql client is available as a local copy" ) -set( MYSQL_LOCAL_DEPENDENCIES external_mysql - CACHE STRING "local mysql dependencies" ) -set( MYSQL_LOCAL_LIBRARIES libmysql - CACHE PATH "local mysql libraries" ) -set( MYSQL_LOCAL_INCLUDE_DIRS "${_INSTALL_DIR}/include" - CACHE PATH "local mysql include directories" ) -set( MYSQL_LOCAL_DEFINITIONS - CACHE STRING "local mysql definitions" ) -mark_as_advanced( HAVE_LOCAL_MYSQL ) -mark_as_advanced( MYSQL_LOCAL_DEPENDENCIES ) -mark_as_advanced( MYSQL_LOCAL_LIBRARIES ) -mark_as_advanced( MYSQL_LOCAL_INCLUDE_DIRS ) -mark_as_advanced( MYSQL_LOCAL_DEFINITIONS ) message( STATUS "Detecting local MYSQL - done" ) -else( WIN32 ) -message( STATUS "Skipping local MYSQL (requires WIN32)" ) endif( WIN32 ) @@ -91,9 +66,3 @@ message( STATUS "Detecting system MYSQL - done" ) # configure # CONFIGURE_WITH_LOCAL_OR_SYSTEM( MYSQL ) -if( WITH_LOCAL_MYSQL AND INSTALL_COMPONENT_RUNTIME ) - install( FILES "${_INSTALL_DIR}/lib/libmysql.dll" - DESTINATION "." - COMPONENT Runtime_base ) -endif( WITH_LOCAL_MYSQL AND INSTALL_COMPONENT_RUNTIME ) - 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..7d058d89d --- /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/mysql/mysql-5.5.24-win32-libmysql.tar.gz b/3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz deleted file mode 100644 index a097f2086..000000000 Binary files a/3rdparty/mysql/mysql-5.5.24-win32-libmysql.tar.gz and /dev/null differ diff --git a/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz b/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz deleted file mode 100644 index 56a39a59a..000000000 Binary files a/3rdparty/mysql/mysql-5.5.24-winx64-libmysql.tar.gz and /dev/null differ diff --git a/3rdparty/mysql/old/include/config-win.h b/3rdparty/mysql/old/include/config-win.h deleted file mode 100644 index b2e1c9831..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/m_ctype.h b/3rdparty/mysql/old/include/m_ctype.h deleted file mode 100644 index 54ae41bf2..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_alloc.h b/3rdparty/mysql/old/include/my_alloc.h deleted file mode 100644 index 1641b3acf..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_dbug.h b/3rdparty/mysql/old/include/my_dbug.h deleted file mode 100644 index b76a3fcc8..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_global.h b/3rdparty/mysql/old/include/my_global.h deleted file mode 100644 index 2417477e2..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_list.h b/3rdparty/mysql/old/include/my_list.h deleted file mode 100644 index 92598696f..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_pthread.h b/3rdparty/mysql/old/include/my_pthread.h deleted file mode 100644 index 202e047dc..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/my_sys.h b/3rdparty/mysql/old/include/my_sys.h deleted file mode 100644 index 44fe383bf..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/mysql.h b/3rdparty/mysql/old/include/mysql.h deleted file mode 100644 index 925a45253..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/mysql_com.h b/3rdparty/mysql/old/include/mysql_com.h deleted file mode 100644 index ec1c13379..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/mysql_time.h b/3rdparty/mysql/old/include/mysql_time.h deleted file mode 100644 index 5f4fc12c0..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/mysql_version.h b/3rdparty/mysql/old/include/mysql_version.h deleted file mode 100644 index 473a19987..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/raid.h b/3rdparty/mysql/old/include/raid.h deleted file mode 100644 index c840afcba..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/include/typelib.h b/3rdparty/mysql/old/include/typelib.h deleted file mode 100644 index 4d6a90ad5..000000000 --- a/3rdparty/mysql/old/include/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/3rdparty/mysql/old/lib/libmysql.lib b/3rdparty/mysql/old/lib/libmysql.lib deleted file mode 100644 index aa99dc3b8..000000000 Binary files a/3rdparty/mysql/old/lib/libmysql.lib and /dev/null differ diff --git a/3rdparty/mysql/old/mysql-5.0.20 b/3rdparty/mysql/old/mysql-5.0.20 deleted file mode 100644 index e69de29bb..000000000 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c08297b7..83e021fc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,6 +465,7 @@ set( RUNTIME_FILES "${CMAKE_CURRENT_SOURCE_DIR}/char-server.sh" "${CMAKE_CURRENT_SOURCE_DIR}/charserv-sql.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" @@ -571,7 +572,9 @@ add_subdirectory( src ) ##################################################################### # final checks and warnings # -if( NOT (CMAKE_SIZEOF_VOID_P EQUAL 4) AND NOT (CMAKE_SIZEOF_VOID_P EQUAL 8) ) +if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + message( WARNING "64bit should work, but is not recommended." ) +elseif( NOT CMAKE_SIZEOF_VOID_P EQUAL 4 ) message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" ) endif() list( LENGTH TARGET_LIST _LEN ) diff --git a/src/char/CMakeLists.txt b/src/char/CMakeLists.txt index df32e758d..22b793bef 100644 --- a/src/char/CMakeLists.txt +++ b/src/char/CMakeLists.txt @@ -39,7 +39,7 @@ set( SQL_CHAR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/inter.c" ) set( DEPENDENCIES common_sql ) -set( LIBRARIES ${GLOBAL_LIBRARIES} common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ) set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} ) @@ -47,10 +47,8 @@ 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} ) -if( DEPENDENCIES ) - add_dependencies( char-server_sql ${DEPENDENCIES} ) -endif() -target_link_libraries( char-server_sql ${LIBRARIES} ) +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 ) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index f37819188..effd0b2ab 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -101,7 +101,6 @@ set( COMMON_BASE_SOURCES "${COMMON_SOURCE_DIR}/utils.c" ${LIBCONFIG_SOURCES} # needed by conf.c/showmsg.c CACHE INTERNAL "common_base sources" ) -set( DEPENDENCIES ${ZLIB_DEPENDENCIES} ) set( COMMON_BASE_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS} CACHE INTERNAL "common_base include dirs" ) @@ -110,14 +109,11 @@ set( COMMON_BASE_DEFINITIONS CACHE INTERNAL "common_base definitions" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS} ${ZLIB_DEFINITIONS}" ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) set( SOURCE_FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) source_group( mt19937ar FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) add_library( common_base ${SOURCE_FILES} ) -if( DEPENDENCIES ) - add_dependencies( common_base ${DEPENDENCIES} ) -endif() target_link_libraries( common_base ${LIBRARIES} ) set_target_properties( common_base PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) include_directories( ${INCLUDE_DIRS} ) @@ -142,17 +138,15 @@ set( COMMON_SQL_HEADERS set( COMMON_SQL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/sql.c" CACHE INTERNAL "common_sql sources" ) -set( DEPENDENCIES common_base ${MYSQL_DEPENDENCIES} ) -set( LIBRARIES ${GLOBAL_LIBRARIES} common_base ${MYSQL_LIBRARIES} ) +set( DEPENDENCIES common_base ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${MYSQL_DEFINITIONS}" ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS}" ) set( SOURCE_FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) source_group( common FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} ) add_library( common_sql ${SOURCE_FILES} ) -if( DEPENDENCIES ) - add_dependencies( common_sql ${DEPENDENCIES} ) -endif() -target_link_libraries( common_sql ${LIBRARIES} ) +add_dependencies( common_sql ${DEPENDENCIES} ) +target_link_libraries( common_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( common_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) include_directories( ${INCLUDE_DIRS} ) set( HAVE_common_sql ON CACHE INTERNAL "" ) diff --git a/src/login/sql/CMakeLists.txt b/src/login/sql/CMakeLists.txt index 16d48df64..1355f17ee 100644 --- a/src/login/sql/CMakeLists.txt +++ b/src/login/sql/CMakeLists.txt @@ -17,7 +17,7 @@ set( SQL_LOGIN_SOURCES "${SQL_LOGIN_SOURCE_DIR}/loginlog_sql.c" ) set( DEPENDENCIES common_sql ) -set( LIBRARIES ${GLOBAL_LIBRARIES} common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ) set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS} -DWITH_SQL" ) set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) @@ -25,10 +25,8 @@ source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) source_group( login FILES ${SQL_LOGIN_HEADERS} ${SQL_LOGIN_SOURCES} ) include_directories( ${INCLUDE_DIRS} ) add_executable( login-server_sql ${SOURCE_FILES} ) -if( DEPENDENCIES ) - add_dependencies( login-server_sql ${DEPENDENCIES} ) -endif() -target_link_libraries( login-server_sql ${LIBRARIES} ) +add_dependencies( login-server_sql ${DEPENDENCIES} ) +target_link_libraries( login-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( login-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( INSTALL_COMPONENT_RUNTIME ) cpack_add_component( Runtime_loginserver_sql DESCRIPTION "login-server (sql version)" DISPLAY_NAME "login-server_sql" GROUP Runtime ) diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index bf2d7cefa..47c8e495c 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -82,15 +82,14 @@ set( SQL_MAP_SOURCES "${SQL_MAP_SOURCE_DIR}/vending.c" ) set( DEPENDENCIES common_sql ) -set( LIBRARIES ${GLOBAL_LIBRARIES} common_sql ) +set( LIBRARIES ${GLOBAL_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ) set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) if( WITH_PCRE ) message( STATUS "Enabled PCRE code" ) - set( DEPENDENCIES ${DEPENDENCIES} ${PCRE_DEPENDENCIES} ) set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} ) set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} ) - set( DEFINITIONS "${DEFINITIONS} ${PCRE_DEFINITIONS} -DPCRE_SUPPORT" ) + set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" ) else() message( STATUS "Disabled PCRE code" ) endif() @@ -99,10 +98,8 @@ source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ) source_group( map FILES ${SQL_MAP_HEADERS} ${SQL_MAP_SOURCES} ) include_directories( ${INCLUDE_DIRS} ) add_executable( map-server_sql ${SOURCE_FILES} ) -if( DEPENDENCIES ) - add_dependencies( map-server_sql ${DEPENDENCIES} ) -endif() -target_link_libraries( map-server_sql ${LIBRARIES} ) +add_dependencies( map-server_sql ${DEPENDENCIES} ) +target_link_libraries( map-server_sql ${LIBRARIES} ${DEPENDENCIES} ) set_target_properties( map-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) if( INSTALL_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapserver_sql DESCRIPTION "map-server (sql version)" DISPLAY_NAME "map-server_sql" GROUP Runtime ) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 2bc7151a9..21ffc3994 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -41,7 +41,7 @@ endif( BUILD_PLUGIN_console ) # # dbghelpplug # -if( WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4 ) +if( WIN32 ) find_path( HAVE_DBGHELP_H dbghelp.h ) mark_as_advanced( HAVE_DBGHELP_H ) if( HAVE_DBGHELP_H ) @@ -49,7 +49,7 @@ if( WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4 ) endif() endif() if( NOT DEFINED BUILD_PLUGIN_dbghelpplug ) - message( STATUS "Disabled dbghelpplug plugin target (requires WIN32 and CMAKE_SIZEOF_VOID_P=4 and HAVE_DBGHELP_H)" ) + message( STATUS "Disabled dbghelpplug plugin target (requires WIN32 and HAVE_DBGHELP_H)" ) endif() if( BUILD_PLUGIN_dbghelpplug ) message( STATUS "Creating target dbghelpplug" ) diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index 434cbbfe6..a54ffa0e2 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -24,20 +24,16 @@ set( COMMON_SOURCES set( MAPCACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c" ) -set( DEPENDENCIES ${ZLIB_DEPENDENCIES} ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_MINI_INCLUDE_DIRS} ) -set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} ${ZLIB_DEFINITIONS}" ) +set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS}" ) set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${MAPCACHE_SOURCES} ) source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ) source_group( mapcache FILES ${MAPCACHE_SOURCES} ) add_executable( mapcache ${SOURCE_FILES} ) -if( DEPENDENCIES ) - add_dependencies( mapcache ${DEPENDENCIES} ) -endif() +include_directories( ${INCLUDE_DIRS} ) target_link_libraries( mapcache ${LIBRARIES} ) set_target_properties( mapcache PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) -include_directories( ${INCLUDE_DIRS} ) if( INSTALL_COMPONENT_RUNTIME ) cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime ) install( TARGETS mapcache diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index 436c294ad..a7b57e7aa 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -73,7 +73,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -94,7 +94,7 @@ true true true - ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LIBCONFIG_STATIC;YY_USE_CONST;FD_SETSIZE=4096;%(PreprocessorDefinitions) true MultiThreaded @@ -111,7 +111,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index 4b152c0ab..d747c3e1e 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -51,7 +51,7 @@ Disabled - ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -73,7 +73,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -94,7 +94,7 @@ true true true - ..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) + ..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) true MultiThreaded @@ -115,7 +115,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-10/map-server_sql.vcxproj b/vcproj-10/map-server_sql.vcxproj index 8a834b505..2326f5a6e 100644 --- a/vcproj-10/map-server_sql.vcxproj +++ b/vcproj-10/map-server_sql.vcxproj @@ -50,7 +50,7 @@ Disabled - ..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) false false @@ -72,7 +72,7 @@ libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true @@ -93,7 +93,7 @@ true true true - ..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) + ..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;..\3rdparty\libconfig;%(AdditionalIncludeDirectories) WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions) true MultiThreaded @@ -110,7 +110,7 @@ libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe - ..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) + ..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories) true %(IgnoreSpecificDefaultLibraries) true diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 0ea3e9c27..3e6e85558 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -71,7 +71,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -137,7 +137,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" @@ -162,7 +162,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" diff --git a/vcproj-9/login-server_sql.vcproj b/vcproj-9/login-server_sql.vcproj index 3799fda05..2cf3c6e6c 100644 --- a/vcproj-9/login-server_sql.vcproj +++ b/vcproj-9/login-server_sql.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;WITH_SQL" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -71,7 +71,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -137,7 +137,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;WITH_SQL" StringPooling="true" RuntimeLibrary="0" @@ -164,7 +164,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index 3cf1c0ff5..a9f2b4fba 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" @@ -70,7 +70,7 @@ AdditionalDependencies="libcmtd.lib oldnames.lib ws2_32.lib libmysql.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="2" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" @@ -136,7 +136,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\old\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" @@ -161,7 +161,7 @@ AdditionalDependencies="libcmt.lib oldnames.lib ws2_32.lib libmysql.lib zdll.lib pcre.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="..\3rdparty\mysql\old\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" + AdditionalLibraryDirectories="..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" -- cgit v1.2.3-70-g09d2 From 49db06bbc7fea1bd68b578275d3a209b1cac28f6 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 04:24:46 +0000 Subject: * Merged changes ONLY eAthena 15100. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16168 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/zlib/include/zconf.h | 196 +++++++++++++++++++-------- 3rdparty/zlib/include/zlib.h | 309 ++++++++++++++++++++++++++++++------------ 3rdparty/zlib/lib/zdll.lib | Bin 13438 -> 15484 bytes 3rdparty/zlib/zlib-1.2.5 | 0 3rdparty/zlib/zlib-1.2.7 | 0 zlib1.dll | Bin 77824 -> 81920 bytes 6 files changed, 357 insertions(+), 148 deletions(-) delete mode 100644 3rdparty/zlib/zlib-1.2.5 create mode 100644 3rdparty/zlib/zlib-1.2.7 (limited to '3rdparty') diff --git a/3rdparty/zlib/include/zconf.h b/3rdparty/zlib/include/zconf.h index 02ce56c43..8a46a58b3 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-2010 Jean-loup Gailly. + * Copyright (C) 1995-2012 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,6 +15,7 @@ * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET /* all linked symbols */ # define _dist_code z__dist_code @@ -27,9 +28,11 @@ # 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 +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 @@ -40,44 +43,52 @@ # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams +# define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep # 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 +# ifndef Z_SOLO +# 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 gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# 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 +# endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd @@ -95,13 +106,18 @@ # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table -# define uncompress z_uncompress +# ifndef Z_SOLO +# define uncompress z_uncompress +# endif # define zError z_zError -# define zcalloc z_zcalloc -# define zcfree z_zcfree +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif # define zlibCompileFlags z_zlibCompileFlags # define zlibVersion z_zlibVersion @@ -111,7 +127,9 @@ # define alloc_func z_alloc_func # define charf z_charf # define free_func z_free_func -# define gzFile z_gzFile +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif # define gz_header z_gz_header # define gz_headerp z_gz_headerp # define in_func z_in_func @@ -197,6 +215,12 @@ # endif #endif +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) # define NO_DUMMY_DECL @@ -243,6 +267,14 @@ # endif #endif +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(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 @@ -356,12 +388,45 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif +/* ./configure may #define Z_U4 here */ + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# else +# if (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# else +# if (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +# endif +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + #ifdef STDC -# include /* for off_t */ +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#ifdef _WIN32 +# include /* for wchar_t */ #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and @@ -370,21 +435,38 @@ typedef uLong FAR uLongf; * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ -#if -_LARGEFILE64_SOURCE - -1 == 1 +#if defined(LARGEFILE64_SOURCE) && -_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 */ -# endif -# ifndef z_off_t -# define z_off_t off_t +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif # endif #endif -#ifndef SEEK_SET +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) # 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" */ @@ -394,18 +476,14 @@ typedef uLong FAR uLongf; # define z_off_t long #endif -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +#if !defined(_WIN32) && defined(Z_LARGE64) # 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 +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif #endif /* MVS linker does not support external names larger than 8 bytes */ diff --git a/3rdparty/zlib/include/zlib.h b/3rdparty/zlib/include/zlib.h index bfbba83e8..3edf3acdb 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.5, April 19th, 2010 + version 1.2.7, May 2nd, 2012 - Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2012 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 @@ -24,8 +24,8 @@ 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). + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). */ #ifndef ZLIB_H @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.5" -#define ZLIB_VERNUM 0x1250 +#define ZLIB_VERSION "1.2.7" +#define ZLIB_VERNUM 0x1270 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_REVISION 7 #define ZLIB_VER_SUBREVISION 0 /* @@ -83,15 +83,15 @@ typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ + z_const 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 */ + uLong total_in; /* total number 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 */ + uLong total_out; /* total number of bytes output so far */ - char *msg; /* last error message, NULL if no error */ + z_const 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 */ @@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); 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. + value returned by deflateBound (see below). Then deflate is guaranteed to + return Z_STREAM_END. If not enough output space is provided, deflate will + not return Z_STREAM_END, and 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). @@ -451,23 +452,29 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); 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. + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. 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 or Z_TREES is used. + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH 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 + below), inflate sets strm->adler to the Adler-32 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, + strm->adler to the Adler-32 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 @@ -478,7 +485,9 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); 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. + perform their own processing of the gzip header and trailer. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + producted so far. The CRC-32 is checked against the gzip 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 @@ -580,10 +589,15 @@ 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 - dictionary (see inflateSetDictionary). + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. 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 @@ -610,8 +624,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a 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 - perform any compression: this will be done by deflate(). + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, @@ -688,8 +702,28 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, 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(). -*/ + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, + unsigned *pending, + int *bits)); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, @@ -703,8 +737,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, 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. + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, @@ -790,10 +825,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, 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. + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. 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 (e.g. dictionary being Z_NULL) or the stream state is @@ -805,17 +841,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, 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 + Skips invalid compressed data until a possible full flush point (see above + for 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. + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible 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, @@ -962,7 +1002,7 @@ 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 + the parameters 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. */ @@ -1088,6 +1128,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 27-31: 0 (reserved) */ +#ifndef Z_SOLO /* utility functions */ @@ -1149,10 +1190,11 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, 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. + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. */ - /* gzip file access functions */ /* @@ -1162,7 +1204,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, wrapper, documented in RFC 1952, wrapped around a deflate stream. */ -typedef voidp gzFile; /* opaque gzip file descriptor */ +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); @@ -1172,13 +1214,28 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); 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. + deflateInit2 for more information about the strategy parameter.) 'T' will + request transparent writing or appending with no compression and not using + the gzip format. + + "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. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. 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. + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. 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 @@ -1197,7 +1254,11 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); 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 does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. 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 @@ -1235,14 +1296,26 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); 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. + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. 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. + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. gzread returns the number of uncompressed bytes actually read, less than len for end of file, or -1 for error. @@ -1256,7 +1329,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, error. */ -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of @@ -1301,7 +1374,10 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); 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. + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. */ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); @@ -1397,9 +1473,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); /* 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. + (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input does not contain a gzip stream. @@ -1408,6 +1482,13 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); 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(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); @@ -1419,7 +1500,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); 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. + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. */ ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); @@ -1457,6 +1539,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); file that is being written concurrently. */ +#endif /* !Z_SOLO */ /* checksum functions */ @@ -1492,16 +1575,17 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, 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. + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. */ 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 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. + initial value 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: @@ -1544,17 +1628,42 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); #define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) #define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) + ZLIB_VERSION, (int)sizeof(z_stream)) + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#endif /* 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 @@ -1562,7 +1671,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, * 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 +#ifdef Z_LARGE64 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)); @@ -1571,14 +1680,23 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, 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 +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# endif +# ifndef Z_LARGE64 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)); @@ -1595,6 +1713,13 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); #endif +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + +#endif /* !Z_SOLO */ + /* hack for buggy compilers */ #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; @@ -1603,8 +1728,14 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, /* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); +ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); +#endif #ifdef __cplusplus } diff --git a/3rdparty/zlib/lib/zdll.lib b/3rdparty/zlib/lib/zdll.lib index d6ba151a0..e27d95c8f 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.5 b/3rdparty/zlib/zlib-1.2.5 deleted file mode 100644 index e69de29bb..000000000 diff --git a/3rdparty/zlib/zlib-1.2.7 b/3rdparty/zlib/zlib-1.2.7 new file mode 100644 index 000000000..e69de29bb diff --git a/zlib1.dll b/zlib1.dll index 4296800a1..a05e41e1c 100644 Binary files a/zlib1.dll and b/zlib1.dll differ -- cgit v1.2.3-70-g09d2 From 26b56a689646b6153447e85b877c0dd10f89e698 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 04:27:27 +0000 Subject: * Merged changes ONLY eAthena 15101. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16169 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/pcre/include/pcre.h | 219 ++++++++++++++++++++++++++++++++-------- 3rdparty/pcre/lib/libpcre.dll.a | Bin 19288 -> 19400 bytes 3rdparty/pcre/lib/pcre.lib | Bin 8298 -> 8408 bytes 3rdparty/pcre/pcre-8.20 | 0 3rdparty/pcre/pcre-8.30 | 0 pcre3.dll | Bin 159744 -> 159744 bytes 6 files changed, 176 insertions(+), 43 deletions(-) delete mode 100644 3rdparty/pcre/pcre-8.20 create mode 100644 3rdparty/pcre/pcre-8.30 (limited to '3rdparty') diff --git a/3rdparty/pcre/include/pcre.h b/3rdparty/pcre/include/pcre.h index 42a109a65..712bd3d71 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-2011 University of Cambridge + Copyright (c) 1997-2012 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. /* The current PCRE version information. */ #define PCRE_MAJOR 8 -#define PCRE_MINOR 20 +#define PCRE_MINOR 30 #define PCRE_PRERELEASE -#define PCRE_DATE 2011-10-21 +#define PCRE_DATE 2012-02-04 /* 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 @@ -98,28 +98,37 @@ extern "C" { /* 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. */ +compile-time only bits for runtime options, or vice versa. In the comments +below, "compile", "exec", and "DFA exec" mean that the option is permitted to +be set for those functions; "used in" means that an option may be set only for +compile, but is subsequently referenced in exec and/or DFA exec. Any of the +compile-time options may be inspected during studying (and therefore JIT +compiling). */ #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_DOLLAR_ENDONLY 0x00000020 /* Compile, used in exec, DFA exec */ #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 */ +/* The next two are also used in exec and DFA exec */ +#define PCRE_UTF8 0x00000800 /* Compile (same as PCRE_UTF16) */ +#define PCRE_UTF16 0x00000800 /* Compile (same as PCRE_UTF8) */ #define PCRE_NO_AUTO_CAPTURE 0x00001000 /* Compile */ -#define PCRE_NO_UTF8_CHECK 0x00002000 /* Compile, exec, DFA exec */ +/* The next two are also used in exec and DFA exec */ +#define PCRE_NO_UTF8_CHECK 0x00002000 /* Compile (same as PCRE_NO_UTF16_CHECK) */ +#define PCRE_NO_UTF16_CHECK 0x00002000 /* Compile (same as PCRE_NO_UTF8_CHECK) */ #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_FIRSTLINE 0x00040000 /* Compile, used in exec, DFA exec */ #define PCRE_DUPNAMES 0x00080000 /* Compile */ #define PCRE_NEWLINE_CR 0x00100000 /* Compile, exec, DFA exec */ #define PCRE_NEWLINE_LF 0x00200000 /* Compile, exec, DFA exec */ @@ -128,43 +137,48 @@ compile-time only bits for runtime options, or vice versa. */ #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_JAVASCRIPT_COMPAT 0x02000000 /* Compile, used in exec */ #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 */ +#define PCRE_UCP 0x20000000 /* Compile, used in exec, DFA exec */ /* 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) /* 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) +#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) /* Same for 8/16 */ +#define PCRE_ERROR_BADUTF16 (-10) /* Same for 8/16 */ +#define PCRE_ERROR_BADUTF8_OFFSET (-11) /* Same for 8/16 */ +#define PCRE_ERROR_BADUTF16_OFFSET (-11) /* Same for 8/16 */ +#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) /* No longer actually used */ +#define PCRE_ERROR_BADNEWLINE (-23) +#define PCRE_ERROR_BADOFFSET (-24) +#define PCRE_ERROR_SHORTUTF8 (-25) +#define PCRE_ERROR_SHORTUTF16 (-25) /* Same for 8/16 */ +#define PCRE_ERROR_RECURSELOOP (-26) +#define PCRE_ERROR_JIT_STACKLIMIT (-27) +#define PCRE_ERROR_BADMODE (-28) +#define PCRE_ERROR_BADENDIANNESS (-29) /* Specific error codes for UTF-8 validity checks */ @@ -191,6 +205,14 @@ compile-time only bits for runtime options, or vice versa. */ #define PCRE_UTF8_ERR20 20 #define PCRE_UTF8_ERR21 21 +/* Specific error codes for UTF-16 validity checks */ + +#define PCRE_UTF16_ERR0 0 +#define PCRE_UTF16_ERR1 1 +#define PCRE_UTF16_ERR2 2 +#define PCRE_UTF16_ERR3 3 +#define PCRE_UTF16_ERR4 4 + /* Request types for pcre_fullinfo() */ #define PCRE_INFO_OPTIONS 0 @@ -211,6 +233,7 @@ compile-time only bits for runtime options, or vice versa. */ #define PCRE_INFO_HASCRORLF 14 #define PCRE_INFO_MINLENGTH 15 #define PCRE_INFO_JIT 16 +#define PCRE_INFO_JITSIZE 17 /* Request types for pcre_config(). Do not re-arrange, in order to remain compatible. */ @@ -225,13 +248,15 @@ compatible. */ #define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 #define PCRE_CONFIG_BSR 8 #define PCRE_CONFIG_JIT 9 +#define PCRE_CONFIG_UTF16 10 +#define PCRE_CONFIG_JITTARGET 11 /* 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 +/* Bit flags for the pcre[16]_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 @@ -247,9 +272,26 @@ these bits, just add new ones on the end, in order to remain compatible. */ struct real_pcre; /* declaration; the definition is private */ typedef struct real_pcre pcre; +struct real_pcre16; /* declaration; the definition is private */ +typedef struct real_pcre16 pcre16; + struct real_pcre_jit_stack; /* declaration; the definition is private */ typedef struct real_pcre_jit_stack pcre_jit_stack; +struct real_pcre16_jit_stack; /* declaration; the definition is private */ +typedef struct real_pcre16_jit_stack pcre16_jit_stack; + +/* If PCRE is compiled with 16 bit character support, PCRE_UCHAR16 must contain +a 16 bit wide signed data type. Otherwise it can be a dummy data type since +pcre16 functions are not implemented. There is a check for this in pcre_internal.h. */ +#ifndef PCRE_UCHAR16 +#define PCRE_UCHAR16 unsigned short +#endif + +#ifndef PCRE_SPTR16 +#define PCRE_SPTR16 const PCRE_UCHAR16 * +#endif + /* 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 *. */ @@ -273,6 +315,19 @@ typedef struct pcre_extra { void *executable_jit; /* Contains a pointer to a compiled jit code */ } pcre_extra; +/* Same structure as above, but with 16 bit char pointers. */ + +typedef struct pcre16_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_UCHAR16 **mark; /* For passing back a mark pointer */ + void *executable_jit; /* Contains a pointer to a compiled jit code */ +} pcre16_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 @@ -298,6 +353,28 @@ typedef struct pcre_callout_block { /* ------------------------------------------------------------------ */ } pcre_callout_block; +/* Same structure as above, but with 16 bit char pointers. */ + +typedef struct pcre16_callout_block { + int version; /* Identifies version of block */ + /* ------------------------ Version 0 ------------------------------- */ + int callout_number; /* Number compiled into pattern */ + int *offset_vector; /* The offset vector */ + PCRE_SPTR16 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 */ + /* ------------------- Added for Version 2 -------------------------- */ + const PCRE_UCHAR16 *mark; /* Pointer to current mark or NULL */ + /* ------------------------------------------------------------------ */ +} pcre16_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 @@ -310,58 +387,114 @@ 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 *); + +PCRE_EXP_DECL void *(*pcre16_malloc)(size_t); +PCRE_EXP_DECL void (*pcre16_free)(void *); +PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t); +PCRE_EXP_DECL void (*pcre16_stack_free)(void *); +PCRE_EXP_DECL int (*pcre16_callout)(pcre16_callout_block *); #else /* VPCOMPAT */ 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 *); + +PCRE_EXP_DECL void *pcre16_malloc(size_t); +PCRE_EXP_DECL void pcre16_free(void *); +PCRE_EXP_DECL void *pcre16_stack_malloc(size_t); +PCRE_EXP_DECL void pcre16_stack_free(void *); +PCRE_EXP_DECL int pcre16_callout(pcre16_callout_block *); #endif /* VPCOMPAT */ /* User defined callback which provides a stack just before the match starts. */ typedef pcre_jit_stack *(*pcre_jit_callback)(void *); +typedef pcre16_jit_stack *(*pcre16_jit_callback)(void *); /* Exported PCRE functions */ PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *, const unsigned char *); +PCRE_EXP_DECL pcre16 *pcre16_compile(PCRE_SPTR16, int, const char **, int *, + const unsigned char *); PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **, int *, const unsigned char *); +PCRE_EXP_DECL pcre16 *pcre16_compile2(PCRE_SPTR16, int, int *, const char **, + int *, const unsigned char *); PCRE_EXP_DECL int pcre_config(int, void *); +PCRE_EXP_DECL int pcre16_config(int, void *); PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *, int *, int, const char *, char *, int); -PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, char *, - int); +PCRE_EXP_DECL int pcre16_copy_named_substring(const pcre16 *, PCRE_SPTR16, + int *, int, PCRE_SPTR16, PCRE_UCHAR16 *, int); +PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, + char *, int); +PCRE_EXP_DECL int pcre16_copy_substring(PCRE_SPTR16, int *, int, int, + PCRE_UCHAR16 *, int); PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *, const char *, int, int, int, int *, int , int *, int); +PCRE_EXP_DECL int pcre16_dfa_exec(const pcre16 *, const pcre16_extra *, + PCRE_SPTR16, int, int, int, int *, int , int *, int); PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, int, int, int, int *, int); +PCRE_EXP_DECL int pcre16_exec(const pcre16 *, const pcre16_extra *, + PCRE_SPTR16, int, int, int, int *, int); PCRE_EXP_DECL void pcre_free_substring(const char *); +PCRE_EXP_DECL void pcre16_free_substring(PCRE_SPTR16); PCRE_EXP_DECL void pcre_free_substring_list(const char **); +PCRE_EXP_DECL void pcre16_free_substring_list(PCRE_SPTR16 *); PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *); +PCRE_EXP_DECL int pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int, + void *); PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *, int *, int, const char *, const char **); +PCRE_EXP_DECL int pcre16_get_named_substring(const pcre16 *, PCRE_SPTR16, + int *, int, PCRE_SPTR16, PCRE_SPTR16 *); PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *); +PCRE_EXP_DECL int pcre16_get_stringnumber(const pcre16 *, PCRE_SPTR16); PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *, char **, char **); +PCRE_EXP_DECL int pcre16_get_stringtable_entries(const pcre16 *, PCRE_SPTR16, + PCRE_UCHAR16 **, PCRE_UCHAR16 **); PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int, const char **); +PCRE_EXP_DECL int pcre16_get_substring(PCRE_SPTR16, int *, int, int, + PCRE_SPTR16 *); PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int, const char ***); -PCRE_EXP_DECL int pcre_info(const pcre *, int *, int *); +PCRE_EXP_DECL int pcre16_get_substring_list(PCRE_SPTR16, int *, int, + PCRE_SPTR16 **); PCRE_EXP_DECL const unsigned char *pcre_maketables(void); +PCRE_EXP_DECL const unsigned char *pcre16_maketables(void); PCRE_EXP_DECL int pcre_refcount(pcre *, int); +PCRE_EXP_DECL int pcre16_refcount(pcre16 *, int); PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **); +PCRE_EXP_DECL pcre16_extra *pcre16_study(const pcre16 *, int, const char **); PCRE_EXP_DECL void pcre_free_study(pcre_extra *); +PCRE_EXP_DECL void pcre16_free_study(pcre16_extra *); PCRE_EXP_DECL const char *pcre_version(void); +PCRE_EXP_DECL const char *pcre16_version(void); + +/* Utility functions for byte order swaps. */ +PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *, pcre_extra *, + const unsigned char *); +PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *, pcre16_extra *, + const unsigned char *); +PCRE_EXP_DECL int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *, + PCRE_SPTR16, int, int *, int); /* JIT compiler related functions. */ PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int); +PCRE_EXP_DECL pcre16_jit_stack *pcre16_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 *); +PCRE_EXP_DECL void pcre16_jit_stack_free(pcre16_jit_stack *); +PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *, + pcre_jit_callback, void *); +PCRE_EXP_DECL void pcre16_assign_jit_stack(pcre16_extra *, + pcre16_jit_callback, void *); #ifdef __cplusplus } /* extern "C" */ diff --git a/3rdparty/pcre/lib/libpcre.dll.a b/3rdparty/pcre/lib/libpcre.dll.a index d82c1f28b..af121d08d 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 1024ec4a5..e9ed140bd 100644 Binary files a/3rdparty/pcre/lib/pcre.lib and b/3rdparty/pcre/lib/pcre.lib differ diff --git a/3rdparty/pcre/pcre-8.20 b/3rdparty/pcre/pcre-8.20 deleted file mode 100644 index e69de29bb..000000000 diff --git a/3rdparty/pcre/pcre-8.30 b/3rdparty/pcre/pcre-8.30 new file mode 100644 index 000000000..e69de29bb diff --git a/pcre3.dll b/pcre3.dll index a1adc37f2..f4fa1ea2e 100644 Binary files a/pcre3.dll and b/pcre3.dll differ -- cgit v1.2.3-70-g09d2 From e7b059e2ddbd6f4b12ae78d6e1053a896f09c283 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 04:32:31 +0000 Subject: * Merged changes ONLY eAthena 15104. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16170 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/README.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 3rdparty/README.txt (limited to '3rdparty') diff --git a/3rdparty/README.txt b/3rdparty/README.txt new file mode 100644 index 000000000..a39a0dc97 --- /dev/null +++ b/3rdparty/README.txt @@ -0,0 +1,9 @@ +This folder contains everything related to 3rdparty code or tools. + +cmake - scripts for the cmake build system (http://www.cmake.org) +libconfig - library for processing structured configuration files (http://www.hyperrealm.com/libconfig/) +msinttypes - standard headers missing from Microsoft Visual Studio (http://code.google.com/p/msinttypes) +mt19937ar - code for Mersenne Twister pseudorandom number generator +mysql - library for MySQL Community Server (http://www.mysql.com) +pcre - library for Perl Compatible Regular Expressions (http://www.pcre.org) +zlib - library for DEFLATE lossless compression algorithm (http://www.zlib.net) -- cgit v1.2.3-70-g09d2 From 1566ff9160d32539b521645c78e25d2211f0fa92 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 05:02:00 +0000 Subject: * Merged changes up to eAthena 15105. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16171 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c | 8 ++++++++ CMakeLists.txt | 12 ++---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c (limited to '3rdparty') diff --git a/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c b/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c new file mode 100644 index 000000000..ad460a1af --- /dev/null +++ b/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c @@ -0,0 +1,8 @@ +#include +#include +#include +int main(int argc, char** argv) +{ + struct timespec tval; + return clock_gettime(CLOCK_MONOTONIC, &tval); +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 83e021fc3..4a1a06b2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,19 +209,11 @@ endif() # (ref. bugreport:1003). # message( STATUS "Check for monotonic clock" ) -set( SOURCECODE - "#include \n" - "#include \n" - "#include \n" - "int main(int argc, char** argv){\n" - " struct timespec tval;\n" - " return clock_gettime(CLOCK_MONOTONIC, &tval);\n" - "}\n" - ) find_library( RT_LIBRARY rt )# (optional, rt on Debian) mark_as_advanced( RT_LIBRARY ) set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY} ) -CHECK_C_SOURCE_RUNS( "${SOURCECODE}" HAVE_MONOTONIC_CLOCK ) +file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE ) +CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_MONOTONIC_CLOCK ) if( HAVE_MONOTONIC_CLOCK ) message( STATUS "Check for monotonic clock - yes" ) set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${RT_LIBRARY} ) -- cgit v1.2.3-70-g09d2 From d8f220b594a71e90b663b348fe58b9382b7ca36b Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 05:06:05 +0000 Subject: * Merged changes ONLY eAthena 15107. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16172 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/cmake/FindMYSQL.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/cmake/FindMYSQL.cmake b/3rdparty/cmake/FindMYSQL.cmake index c18e8d637..9da72073a 100644 --- a/3rdparty/cmake/FindMYSQL.cmake +++ b/3rdparty/cmake/FindMYSQL.cmake @@ -1,4 +1,4 @@ -# - Find mysqlclient +# - Find libmysql/mysqlclient # Find the native MySQL includes and library # # MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. @@ -15,7 +15,7 @@ find_path( MYSQL_INCLUDE_DIRS "mysql.h" "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) find_library( MYSQL_LIBRARIES - NAMES "mysqlclient" "mysqlclient_r" + NAMES "libmysql" "mysqlclient" "mysqlclient_r" PATHS "/usr/lib/mysql" "/usr/local/lib/mysql" -- cgit v1.2.3-70-g09d2 From 81e4918a779ef631106fd2ecaae6bd6433fb2b07 Mon Sep 17 00:00:00 2001 From: blacksirius Date: Fri, 1 Jun 2012 10:46:02 +0000 Subject: feature merge bs-coreoptimize->trunk: Build Output Cleanup, Makefile Common Dependency Handling - "Optimized" the build Output using Makefiles - to Kernel style build output. - Changed dependency handling to common (core), by generating one lib file (ar) and link against that instead of assigning all deps individually in every subproject - Changed header dependency handling in Subproject makefiles - requiring all common/ headers. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16198 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/Makefile.in | 6 ++++-- 3rdparty/mt19937ar/Makefile.in | 8 +++++--- configure | 43 +++++++++++++++++++++++++++++++++++++++++- configure.in | 1 + src/char/Makefile.in | 29 ++++++++++++---------------- src/common/Makefile.in | 37 +++++++++++++++++++++++------------- src/login/Makefile.in | 34 +++++++++++++-------------------- src/map/Makefile.in | 43 +++++++++++++++++------------------------- src/plugins/Makefile.in | 9 ++++++--- src/tool/Makefile.in | 9 ++++++--- 10 files changed, 130 insertions(+), 89 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index 12ff7572b..ab03d4154 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -10,7 +10,8 @@ LIBCONFIG_H = libconfig.h grammar.h parsectx.h scanctx.h scanner.h strbuf.h winc all: $(LIBCONFIG_OBJ) clean: - rm -rf *.o + @echo " CLEAN libconfig" + @rm -rf *.o help: @echo "possible targets are 'all' 'clean' 'help'" @@ -21,4 +22,5 @@ help: ##################################################################### %.o: %.c $(LIBCONFIG_H) - @CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in index 7cae3140b..63f75fdad 100644 --- a/3rdparty/mt19937ar/Makefile.in +++ b/3rdparty/mt19937ar/Makefile.in @@ -9,8 +9,9 @@ MT19937AR_H = mt19937ar.h all: $(MT19937AR_OBJ) -clean: - rm -rf *.o +clean: + @echo " CLEAN mt19937ar" + @rm -rf *.o help: @echo "possible targets are 'all' 'clean' 'help'" @@ -21,4 +22,5 @@ help: ##################################################################### %.o: %.c $(MT19937AR_H) - @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/configure b/configure index d8fb1068e..23c222c68 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 16196 . +# From configure.in Revision: 16197 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.67. # @@ -605,6 +605,7 @@ MYSQL_VERSION HAVE_MYSQL MYSQL_CONFIG_HOME WITH_PLUGINS +AR SET_MAKE EGREP GREP @@ -4342,6 +4343,46 @@ 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 +# Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $AR in + [\\/]* | ?:[\\/]*) + ac_cv_path_AR="$AR" # 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_AR="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +AR=$ac_cv_path_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/configure.in b/configure.in index e5dae76b6..75c20dd48 100644 --- a/configure.in +++ b/configure.in @@ -298,6 +298,7 @@ AC_ARG_WITH( AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_CPP +AC_PATH_PROG(AR, ar) AC_LANG([C]) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 1c93cfa6d..bfe9d1585 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,14 +1,5 @@ -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/obj_all/conf.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.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 ../common/obj_all/conf.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -30,7 +21,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) $(MT19937AR_OBJ) + CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) else CHAR_SERVER_SQL_DEPENDS=needs_mysql endif @@ -43,10 +34,12 @@ 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) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ + @echo " CLEAN char" + @rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ help: @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" @@ -62,16 +55,18 @@ needs_mysql: @exit 1 obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql -../common/obj_sql/%.o: +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql MT19937AR_OBJ: diff --git a/src/common/Makefile.in b/src/common/Makefile.in index de591a59f..5e3b00a88 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -4,11 +4,8 @@ COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_al 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/random.o obj_all/des.o \ obj_all/conf.o -COMMON_H = mmo.h plugin.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 random.h des.h \ - conf.h + +COMMON_H = $(shell ls ../common/*.h) COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h @@ -46,7 +43,8 @@ txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj_all obj_sql + @echo " CLEAN common" + @rm -rf *.o obj_all obj_sql help: @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" @@ -63,24 +61,37 @@ needs_mysql: @exit 1 obj_all: - -mkdir obj_all + @echo " MKDIR obj_all" + @-mkdir obj_all obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql + +obj_all/common.a: $(COMMON_OBJ) + @echo " AR $@" + @@AR@ rcs obj_all/common.a $(COMMON_OBJ) -common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) +obj_sql/common_sql.a: $(COMMON_SQL_OBJ) + @echo " AR $@" + @@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ) + -common_sql: obj_sql $(COMMON_SQL_OBJ) +common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a +common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 348943403..d0fc34756 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,18 +1,5 @@ -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/md5calc.o ../common/obj_all/random.o \ - ../common/obj_all/conf.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.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/md5calc.h ../common/random.h ../common/conf.h - -COMMON_SQL_OBJ = ../common/obj_sql/sql.o -COMMON_SQL_H = ../common/sql.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -32,7 +19,7 @@ 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) $(MT19937AR_OBJ) + LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif @@ -47,7 +34,8 @@ all: sql sql: obj_sql login-server_sql clean: - rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ + @echo " CLEAN login" + @rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ help: @echo "possible targets are 'sql' 'all' 'clean' 'help'" @@ -65,23 +53,27 @@ needs_mysql: # object directories obj_sql: - test -d obj_sql || mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql #executables login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ + # login object files obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql -../common/obj_sql/%.o: +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql MT19937AR_OBJ: diff --git a/src/map/Makefile.in b/src/map/Makefile.in index beeab32dd..06925bcec 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,19 +1,5 @@ -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/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/random.o ../common/obj_all/des.o ../common/obj_all/conf.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/random.h ../common/des.h ../common/conf.h - -COMMON_SQL_OBJ = ../common/obj_sql/sql.o -COMMON_SQL_H = ../common/sql.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -72,7 +58,8 @@ txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ + @echo " CLEAN map" + @rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ help: ifeq ($(HAVE_MYSQL),yes) @@ -94,28 +81,32 @@ needs_mysql: # object directories obj_txt: - -mkdir obj_txt + @echo " MKDIR obj_txt" + @-mkdir obj_txt obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql # executables -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) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ +map-server_sql: obj_sql $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files -obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql - -../common/obj_sql/%.o: + +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql - + MT19937AR_OBJ: @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index fa74ff90d..1b92ea3fa 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -23,7 +23,8 @@ pid: pid@DLLEXT@ console: console@DLLEXT@ clean: - rm -rf *.o + @echo " CLEAN plugins" + @rm -rf *.o help: @echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'" @@ -38,10 +39,12 @@ help: ##################################################################### %@DLLEXT@: %.c - @CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< + @echo " CC $<" + @@CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< sig@DLLEXT@: sig.c $(COMMON_OBJ) - @CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< $(COMMON_OBJ) + @echo " CC $<" + @@CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< $(COMMON_OBJ) # missing common object files ../common/obj_all/%.o: ../common/%.c $(COMMON_H) diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 2ad022936..59ef89958 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -23,10 +23,12 @@ MAPCACHE_OBJ = obj_all/mapcache.o all: mapcache mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) - @CC@ @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ clean: - rm -rf obj_all/*.o ../../mapcache@EXEEXT@ + @echo " CLEAN tool" + @rm -rf obj_all/*.o ../../mapcache@EXEEXT@ help: @echo "possible targets are 'mapcache' 'all' 'clean' 'help'" @@ -41,7 +43,8 @@ obj_all: -mkdir obj_all obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: -- cgit v1.2.3-70-g09d2 From 0598cc569db02ee93d7fc0470defecb64e995f5c Mon Sep 17 00:00:00 2001 From: blacksirius Date: Mon, 11 Jun 2012 23:31:19 +0000 Subject: Fixed bugreport:5990 OSX compiling error / warnings Bug in Detail: - Misplaced LDFLAGS uage in some Makefile templates (by passing them to the compiler not to the linker.) - Wrong usage of volatile (a functions return value couldnt be declared to return volatile :D ) - Unsupported Inline ASM using lock xchg operation on llvm-gcc .. (apple loves this ..) Fixed by: - Removed unnecessary LDFLAGS - Removed unnecessary volatile declarator - Replaced InterlockedExchange and InterlockedExchange64 with gcc intrinsics. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16270 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/Makefile.in | 2 +- 3rdparty/mt19937ar/Makefile.in | 2 +- src/common/Makefile.in | 4 ++-- src/common/atomic.h | 44 +++++++++++++----------------------------- src/tool/Makefile.in | 2 +- 5 files changed, 18 insertions(+), 36 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index ab03d4154..b0fa9a314 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -23,4 +23,4 @@ help: %.o: %.c $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in index 63f75fdad..8a7b64669 100644 --- a/3rdparty/mt19937ar/Makefile.in +++ b/3rdparty/mt19937ar/Makefile.in @@ -23,4 +23,4 @@ help: %.o: %.c $(MT19937AR_H) @echo " CC $<" - @@CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/common/Makefile.in b/src/common/Makefile.in index b6713b6a1..379f80231 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -83,11 +83,11 @@ common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H) @echo " CC $<" diff --git a/src/common/atomic.h b/src/common/atomic.h index c09d8d386..b1a4bda92 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -86,71 +86,53 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v #error Your Target Platfrom is not supported #endif -static forceinline volatile int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ +static forceinline int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ return __sync_fetch_and_add(addend, increment); }//end: InterlockedExchangeAdd64() -static forceinline volatile int32 InterlockedExchangeAdd(volatile int32 *addend, int32 increment){ +static forceinline int32 InterlockedExchangeAdd(volatile int32 *addend, int32 increment){ return __sync_fetch_and_add(addend, increment); }//end: InterlockedExchangeAdd() -static forceinline volatile int64 InterlockedIncrement64(volatile int64 *addend){ +static forceinline int64 InterlockedIncrement64(volatile int64 *addend){ return __sync_add_and_fetch(addend, 1); }//end: InterlockedIncrement64() -static forceinline volatile int32 InterlockedIncrement(volatile int32 *addend){ +static forceinline int32 InterlockedIncrement(volatile int32 *addend){ return __sync_add_and_fetch(addend, 1); }//end: InterlockedIncrement() -static forceinline volatile int64 InterlockedDecrement64(volatile int64 *addend){ +static forceinline int64 InterlockedDecrement64(volatile int64 *addend){ return __sync_sub_and_fetch(addend, 1); }//end: InterlockedDecrement64() -static forceinline volatile int32 InterlockedDecrement(volatile int32 *addend){ +static forceinline int32 InterlockedDecrement(volatile int32 *addend){ return __sync_sub_and_fetch(addend, 1); }//end: InterlockedDecrement() -static forceinline volatile int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 cmp){ +static forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 cmp){ return __sync_val_compare_and_swap(dest, cmp, exch); }//end: InterlockedCompareExchange64() -static forceinline volatile int32 InterlockedCompareExchange(volatile int32 *dest, int32 exch, int32 cmp){ - return __sync_val_compare_and_swap(dest, cmp, exch); +static forceinline int32 InterlockedCompareExchange(volatile int32 *dest, int32 exch, int32 cmp){ + return __sync_val_compare_and_swap(dest, cmp, exch); }//end: InterlockedCompareExchnage() -static forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 val){ - int ret; - - __asm__ __volatile__( - "lock xchg %2, (%1)" - :"=r" (ret) - :"r" (target), "0" (val) - :"memory" - ); - - return ret; +static forceinline int64 InterlockedExchange64(volatile int64 *target, int64 val){ + return __sync_lock_test_and_set(target, val); }//end: InterlockedExchange64() -static forceinline volatile int32 InterlockedExchange(volatile int32 *target, int32 val){ - int ret; - - __asm__ __volatile__( - "lock xchgl %2, (%1)" - :"=r" (ret) - :"r" (target), "0" (val) - :"memory" - ); - - return ret; +static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ + return __sync_lock_test_and_set(target, val); }//end: InterlockedExchange() diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 59ef89958..9d9a8668f 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -44,7 +44,7 @@ obj_all: obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: -- cgit v1.2.3-70-g09d2 From 22ea2706f0a9767d9910522868cc90f121cfc6fa Mon Sep 17 00:00:00 2001 From: brianluau Date: Tue, 12 Jun 2012 15:33:46 +0000 Subject: - Added svn:eol-style=native property on some recently added text files. - Fixed a typo in script_commands.txt (bugreport:5998) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16278 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/Makefile.in | 52 +++++++++++++++++++++--------------------- doc/script_commands.txt | 4 ++-- src/common/evdp_epoll.c | 1 - src/common/network.c | 3 +-- 4 files changed, 29 insertions(+), 31 deletions(-) (limited to '3rdparty') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index b0fa9a314..ee17298b4 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -1,26 +1,26 @@ - -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: - @echo " CLEAN libconfig" - @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) - @echo " CC $<" - @@CC@ @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +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: + @echo " CLEAN libconfig" + @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) + @echo " CC $<" + @@CC@ @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/doc/script_commands.txt b/doc/script_commands.txt index adae3726f..6e6c9127f 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -6706,12 +6706,12 @@ The first letter is position 0. Returns the original string with the specified char inserted at the specified index. If index is out of range, the char - will be inserted on the end of the string that it is closest. + will be inserted on the end of the string that it is closest. Only the 1st char in the parameter will be used. Example: - setchar("laughter", "s", 0); //returns "slaughter" + insertchar("laughter", "s", 0); //returns "slaughter" --------------------------------------- diff --git a/src/common/evdp_epoll.c b/src/common/evdp_epoll.c index d71c8d4d7..0357dfc66 100644 --- a/src/common/evdp_epoll.c +++ b/src/common/evdp_epoll.c @@ -230,4 +230,3 @@ void evdp_writable_remove(int32 fd, EVDP_DATA *ep){ return; }//end: evdp_writable_remove() - diff --git a/src/common/network.c b/src/common/network.c index 2574f3cc1..1f1621363 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -1,4 +1,4 @@ - // +// // Network Subsystem (previously known as socket system) // // Author: Florian Wilkemeyer @@ -1059,4 +1059,3 @@ void network_parser_set_ro(int32 fd, // }//end: network_parser_set_ro() - -- cgit v1.2.3-70-g09d2