mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
LIBRARY LIBMYSQL
|
||||
DESCRIPTION 'MySQL 3.23 Client Library'
|
||||
VERSION 2.5
|
||||
EXPORTS
|
||||
mysql_affected_rows
|
||||
mysql_close
|
||||
mysql_connect
|
||||
mysql_create_db
|
||||
mysql_data_seek
|
||||
mysql_debug
|
||||
mysql_drop_db
|
||||
mysql_dump_debug_info
|
||||
mysql_eof
|
||||
mysql_errno
|
||||
mysql_error
|
||||
mysql_escape_string
|
||||
mysql_fetch_field
|
||||
mysql_fetch_field_direct
|
||||
mysql_fetch_fields
|
||||
mysql_fetch_lengths
|
||||
mysql_fetch_row
|
||||
mysql_field_count
|
||||
mysql_field_seek
|
||||
mysql_field_tell
|
||||
mysql_free_result
|
||||
mysql_get_client_info
|
||||
mysql_get_host_info
|
||||
mysql_get_proto_info
|
||||
mysql_get_server_info
|
||||
mysql_info
|
||||
mysql_init
|
||||
mysql_insert_id
|
||||
mysql_kill
|
||||
mysql_list_dbs
|
||||
mysql_list_fields
|
||||
mysql_list_processes
|
||||
mysql_list_tables
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_odbc_escape_string
|
||||
mysql_options
|
||||
mysql_ping
|
||||
mysql_query
|
||||
mysql_real_connect
|
||||
mysql_real_query
|
||||
mysql_refresh
|
||||
mysql_row_seek
|
||||
mysql_row_tell
|
||||
mysql_select_db
|
||||
mysql_shutdown
|
||||
mysql_stat
|
||||
mysql_store_result
|
||||
mysql_thread_id
|
||||
mysql_use_result
|
||||
bmove_upp
|
||||
delete_dynamic
|
||||
_dig_vec
|
||||
init_dynamic_array
|
||||
insert_dynamic
|
||||
int2str
|
||||
is_prefix
|
||||
list_add
|
||||
list_delete
|
||||
max_allowed_packet
|
||||
my_casecmp
|
||||
my_init
|
||||
my_end
|
||||
my_strdup
|
||||
my_malloc
|
||||
my_memdup
|
||||
my_no_flags_free
|
||||
my_realloc
|
||||
my_thread_end
|
||||
my_thread_init
|
||||
net_buffer_length
|
||||
set_dynamic
|
||||
strcend
|
||||
strdup_root
|
||||
strfill
|
||||
strinstr
|
||||
strmake
|
||||
strmov
|
||||
strxmov
|
||||
myodbc_remove_escape
|
||||
mysql_thread_safe
|
||||
mysql_character_set_name
|
||||
mysql_change_user
|
||||
mysql_send_query
|
||||
mysql_read_query_result
|
||||
mysql_real_escape_string
|
||||
@@ -0,0 +1,306 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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 */
|
||||
|
||||
#include <sys/locking.h>
|
||||
#include <windows.h>
|
||||
#include <math.h> /* Because of rint() */
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#if defined(__NT__)
|
||||
#define SYSTEM_TYPE "NT"
|
||||
#elif defined(__WIN2000__)
|
||||
#define SYSTEM_TYPE "WIN2000"
|
||||
#else
|
||||
#define SYSTEM_TYPE "Win95/Win98"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define MACHINE_TYPE "ia64" /* Define to machine type name */
|
||||
#else
|
||||
#define MACHINE_TYPE "i32" /* Define to machine type name */
|
||||
#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
|
||||
|
||||
/* 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 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 */
|
||||
|
||||
#define LONGLONG_MIN ((__int64) 0x8000000000000000)
|
||||
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
|
||||
#define LL(A) ((__int64) A)
|
||||
|
||||
/* Type information */
|
||||
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
|
||||
typedef __int64 longlong;
|
||||
typedef int sigset_t;
|
||||
#define longlong_defined
|
||||
/* off_t should not be __int64 because of conflicts in header files;
|
||||
Use my_off_t or os_off_t instead */
|
||||
typedef long off_t;
|
||||
typedef __int64 os_off_t;
|
||||
#ifdef _WIN64
|
||||
typedef UINT_PTR rf_SetTimer;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
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 */
|
||||
|
||||
#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
|
||||
#define HAVE_BROKEN_NETINET_INCLUDES
|
||||
#ifdef __NT__
|
||||
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
|
||||
#endif
|
||||
|
||||
/* Use all character sets in MySQL */
|
||||
#define USE_MB 1
|
||||
#define USE_MB_IDENT 1
|
||||
#define USE_STRCOLL 1
|
||||
|
||||
/* Convert some simple functions to Posix */
|
||||
|
||||
#define sigset(A,B) signal((A),(B))
|
||||
#define finite(A) _finite(A)
|
||||
#define sleep(A) Sleep((A)*1000)
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
#define access(A,B) _access(A,B)
|
||||
#endif
|
||||
|
||||
#if defined(__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) (A))
|
||||
#define my_off_t2double(A) ((double) (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 */
|
||||
#else
|
||||
#define inline __inline
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if SIZEOF_OFF_T > 4
|
||||
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
|
||||
#define tell(A) _telli64(A)
|
||||
#endif
|
||||
|
||||
#define STACK_DIRECTION -1
|
||||
|
||||
/* Optimized store functions for Intel x86 */
|
||||
|
||||
#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)))
|
||||
#define uint3korr(A) (long) (*((unsigned long *) (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) { *((long *) &V) = *((long*) M); \
|
||||
*(((long *) &V)+1) = *(((long*) M)+1); }
|
||||
#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
|
||||
*(((long *) T)+1) = *(((long*) &V)+1); }
|
||||
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
|
||||
#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))
|
||||
|
||||
|
||||
#define HAVE_PERROR
|
||||
#define HAVE_VFPRINT
|
||||
#define HAVE_CHSIZE /* System has chsize() function */
|
||||
#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
|
||||
|
||||
#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 <A>
|
||||
#define my_const_cast(A) const_cast<A>
|
||||
|
||||
/* MYSQL OPTIONS */
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define DEFAULT_MYSQL_HOME "c:\\mysql"
|
||||
#define PACKAGE "mysql"
|
||||
#define DEFAULT_BASEDIR "C:\\"
|
||||
#define SHAREDIR "share"
|
||||
#define DEFAULT_CHARSET_HOME "C:/mysql/"
|
||||
#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 MY_NFILE 1024
|
||||
|
||||
#define DO_NOT_REMOVE_THREAD_WRAPPERS
|
||||
#define thread_safe_increment(V,L) InterlockedIncrement((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))
|
||||
@@ -0,0 +1,94 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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 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_lock_file();
|
||||
extern void _db_unlock_file();
|
||||
|
||||
#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_ASSERT(A) assert(A)
|
||||
#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_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_ASSERT(A) {}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
/* Error messages for mysql clients */
|
||||
/* error messages for the demon is in share/language/errmsg.sys */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void init_client_errs(void);
|
||||
extern const char *client_errors[]; /* Error messages */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CR_MIN_ERROR 2000 /* For easier client code */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#if defined(OS2) && defined( MYSQL_SERVER)
|
||||
#define CER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#else
|
||||
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#endif
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
|
||||
#define CR_UNKNOWN_ERROR 2000
|
||||
#define CR_SOCKET_CREATE_ERROR 2001
|
||||
#define CR_CONNECTION_ERROR 2002
|
||||
#define CR_CONN_HOST_ERROR 2003
|
||||
#define CR_IPSOCK_ERROR 2004
|
||||
#define CR_UNKNOWN_HOST 2005
|
||||
#define CR_SERVER_GONE_ERROR 2006
|
||||
#define CR_VERSION_ERROR 2007
|
||||
#define CR_OUT_OF_MEMORY 2008
|
||||
#define CR_WRONG_HOST_INFO 2009
|
||||
#define CR_LOCALHOST_CONNECTION 2010
|
||||
#define CR_TCP_CONNECTION 2011
|
||||
#define CR_SERVER_HANDSHAKE_ERR 2012
|
||||
#define CR_SERVER_LOST 2013
|
||||
#define CR_COMMANDS_OUT_OF_SYNC 2014
|
||||
#define CR_NAMEDPIPE_CONNECTION 2015
|
||||
#define CR_NAMEDPIPEWAIT_ERROR 2016
|
||||
#define CR_NAMEDPIPEOPEN_ERROR 2017
|
||||
#define CR_NAMEDPIPESETSTATE_ERROR 2018
|
||||
#define CR_CANT_READ_CHARSET 2019
|
||||
#define CR_NET_PACKET_TOO_LARGE 2020
|
||||
@@ -0,0 +1,158 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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: global.h should be included before ctype.h
|
||||
*/
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#define _m_ctype_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CHARSET_DIR "charsets/"
|
||||
|
||||
typedef struct charset_info_st
|
||||
{
|
||||
uint number;
|
||||
const char *name;
|
||||
uchar *ctype;
|
||||
uchar *to_lower;
|
||||
uchar *to_upper;
|
||||
uchar *sort_order;
|
||||
|
||||
uint strxfrm_multiply;
|
||||
int (*strcoll)(const uchar *, const uchar *);
|
||||
int (*strxfrm)(uchar *, const uchar *, int);
|
||||
int (*strnncoll)(const uchar *, int, const uchar *, int);
|
||||
int (*strnxfrm)(uchar *, const uchar *, int, int);
|
||||
my_bool (*like_range)(const char *, uint, pchar, uint,
|
||||
char *, char *, uint *, uint *);
|
||||
|
||||
uint mbmaxlen;
|
||||
int (*ismbchar)(const char *, const char *);
|
||||
my_bool (*ismbhead)(uint);
|
||||
int (*mbcharlen)(uint);
|
||||
} CHARSET_INFO;
|
||||
|
||||
/* strings/ctype.c */
|
||||
extern CHARSET_INFO *default_charset_info;
|
||||
extern CHARSET_INFO *find_compiled_charset(uint cs_number);
|
||||
extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
|
||||
extern CHARSET_INFO compiled_charsets[];
|
||||
|
||||
#define MY_CHARSET_UNDEFINED 0
|
||||
#define MY_CHARSET_CURRENT (default_charset_info->number)
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
/* Don't include std ctype.h when this is included */
|
||||
#define _CTYPE_H
|
||||
#define _CTYPE_H_
|
||||
#define _CTYPE_INCLUDED
|
||||
#define __CTYPE_INCLUDED
|
||||
#define _CTYPE_USING /* Don't put names in global namespace. */
|
||||
|
||||
#define _U 01 /* Upper case */
|
||||
#define _L 02 /* Lower case */
|
||||
#define _N 04 /* Numeral (digit) */
|
||||
#define _S 010 /* Spacing character */
|
||||
#define _P 020 /* Punctuation */
|
||||
#define _C 040 /* Control character */
|
||||
#define _B 0100 /* Blank */
|
||||
#define _X 0200 /* heXadecimal digit */
|
||||
|
||||
#define my_ctype (default_charset_info->ctype)
|
||||
#define my_to_upper (default_charset_info->to_upper)
|
||||
#define my_to_lower (default_charset_info->to_lower)
|
||||
#define my_sort_order (default_charset_info->sort_order)
|
||||
|
||||
#ifndef __WIN__
|
||||
#define _toupper(c) (char) my_to_upper[(uchar) (c)]
|
||||
#define _tolower(c) (char) my_to_lower[(uchar) (c)]
|
||||
#define toupper(c) (char) my_to_upper[(uchar) (c)]
|
||||
#define tolower(c) (char) my_to_lower[(uchar) (c)]
|
||||
|
||||
#define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
|
||||
#define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
|
||||
#define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
|
||||
#define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
|
||||
#define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
|
||||
#define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
|
||||
#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
|
||||
#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
|
||||
#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
|
||||
#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
|
||||
#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
|
||||
#define isascii(c) (!((c) & ~0177))
|
||||
#define toascii(c) ((c) & 0177)
|
||||
|
||||
#ifdef ctype
|
||||
#undef ctype
|
||||
#endif /* ctype */
|
||||
|
||||
#endif /* __WIN__ */
|
||||
|
||||
#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L))
|
||||
#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _U)
|
||||
#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _L)
|
||||
#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _N)
|
||||
#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _X)
|
||||
#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L | _N))
|
||||
#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _S)
|
||||
#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _P)
|
||||
#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
|
||||
#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
|
||||
#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _C)
|
||||
|
||||
#define use_strcoll(s) ((s)->strcoll != NULL)
|
||||
#define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply)
|
||||
#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c), (d)))
|
||||
#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((a), (b), (c), (d)))
|
||||
#define my_strxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c)))
|
||||
#define my_strcoll(s, a, b) ((s)->strcoll((a), (b)))
|
||||
#define my_like_range(s, a, b, c, d, e, f, g, h) \
|
||||
((s)->like_range((a), (b), (c), (d), (e), (f), (g), (h)))
|
||||
|
||||
#define use_mb(s) ((s)->ismbchar != NULL)
|
||||
#define MBMAXLEN (default_charset_info->mbmaxlen)
|
||||
#define my_ismbchar(s, a, b) ((s)->ismbchar((a), (b)))
|
||||
#define my_ismbhead(s, a) ((s)->ismbhead((a)))
|
||||
#define my_mbcharlen(s, a) ((s)->mbcharlen((a)))
|
||||
|
||||
/* Some macros that should be cleaned up a little */
|
||||
#define isvar(c) (isalnum(c) || (c) == '_')
|
||||
#define isvar_start(c) (isalpha(c) || (c) == '_')
|
||||
#define tocntrl(c) ((c) & 31)
|
||||
#define toprint(c) ((c) | 64)
|
||||
|
||||
/* 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 */
|
||||
@@ -0,0 +1,244 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
/* There may be prolems include all of theese. Try to test in
|
||||
configure with ones are needed? */
|
||||
|
||||
/* This is needed for the definitions of strchr... on solaris */
|
||||
|
||||
#ifndef _m_string_h
|
||||
#define _m_string_h
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU /* We want to use stpcpy */
|
||||
#endif
|
||||
#if defined(HAVE_STRINGS_H)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#if defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/* Correct some things for UNIXWARE7 */
|
||||
#ifdef HAVE_UNIXWARE7_THREADS
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_MEMORY_H
|
||||
#define HAVE_MEMCPY
|
||||
#ifndef HAVE_MEMMOVE
|
||||
#define HAVE_MEMMOVE
|
||||
#endif
|
||||
#undef HAVE_BCMP
|
||||
#undef bcopy
|
||||
#undef bcmp
|
||||
#undef bzero
|
||||
#endif /* HAVE_UNIXWARE7_THREADS */
|
||||
#ifdef _AIX
|
||||
#undef HAVE_BCMP
|
||||
#endif
|
||||
|
||||
/* This is needed for the definitions of bzero... on solaris */
|
||||
#if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/* This is needed for the definitions of memcpy... on solaris */
|
||||
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# define memset(A,C,B) bfill((A),(B),(C))
|
||||
# define memmove(d, s, n) bmove ((d), (s), (n))
|
||||
#elif defined(HAVE_MEMMOVE)
|
||||
# define bmove(d, s, n) memmove((d), (s), (n))
|
||||
#else
|
||||
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
|
||||
#endif
|
||||
|
||||
/* Unixware 7 */
|
||||
#if !defined(HAVE_BFILL)
|
||||
# define bfill(A,B,C) memset((A),(C),(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BCMP)
|
||||
# define bcopy(s, d, n) memcpy((d), (s), (n))
|
||||
# define bcmp(A,B,C) memcmp((A),(B),(C))
|
||||
# define bzero(A,B) memset((A),0,(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(OS2)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
|
||||
#define strmov(A,B) stpcpy((A),(B))
|
||||
#ifndef stpcpy
|
||||
extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern char NEAR _dig_vec[]; /* Declared in int2str() */
|
||||
|
||||
#ifdef BAD_STRING_COMPILER
|
||||
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
|
||||
#else
|
||||
#define strmov_overlapp(A,B) strmov(A,B)
|
||||
#define strmake_overlapp(A,B,C) strmake(A,B,C)
|
||||
#endif
|
||||
|
||||
#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
|
||||
#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
|
||||
#else
|
||||
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#ifdef MSDOS
|
||||
#undef bmove_allign
|
||||
#define bmove512(A,B,C) bmove_allign(A,B,C)
|
||||
#define my_itoa(A,B,C) itoa(A,B,C)
|
||||
#define my_ltoa(A,B,C) ltoa(A,B,C)
|
||||
extern void bmove_allign(gptr dst,const gptr src,uint len);
|
||||
#endif
|
||||
|
||||
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
|
||||
#define bmove512(A,B,C) memcpy(A,B,C)
|
||||
#endif
|
||||
|
||||
/* Prototypes for string functions */
|
||||
|
||||
#if !defined(bfill) && !defined(HAVE_BFILL)
|
||||
extern void bfill(gptr dst,uint len,pchar fill);
|
||||
#endif
|
||||
|
||||
#if !defined(bzero) && !defined(HAVE_BZERO)
|
||||
extern void bzero(gptr dst,uint len);
|
||||
#endif
|
||||
|
||||
#if !defined(bcmp) && !defined(HAVE_BCMP)
|
||||
extern int bcmp(const char *s1,const char *s2,uint len);
|
||||
#ifdef HAVE_purify
|
||||
extern int my_bcmp(const char *s1,const char *s2,uint len);
|
||||
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef bmove512
|
||||
extern void bmove512(gptr dst,const gptr src,uint len);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BMOVE) && !defined(bmove)
|
||||
extern void bmove(char *dst, const char *src,uint len);
|
||||
#endif
|
||||
|
||||
extern void bmove_upp(char *dst,const char *src,uint len);
|
||||
extern void bchange(char *dst,uint old_len,const char *src,
|
||||
uint new_len,uint tot_len);
|
||||
extern void strappend(char *s,uint len,pchar fill);
|
||||
extern char *strend(const char *s);
|
||||
extern char *strcend(const char *, pchar);
|
||||
extern char *strfield(char *src,int fields,int chars,int blanks,
|
||||
int tabch);
|
||||
extern char *strfill(my_string s,uint len,pchar fill);
|
||||
extern uint strinstr(const char *str,const char *search);
|
||||
extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
|
||||
extern char *strkey(char *dst,char *head,char *tail,char *flags);
|
||||
extern char *strmake(char *dst,const char *src,uint length);
|
||||
#ifndef strmake_overlapp
|
||||
extern char *strmake_overlapp(char *dst,const char *src, uint length);
|
||||
#endif
|
||||
|
||||
#ifndef strmov
|
||||
extern char *strmov(char *dst,const char *src);
|
||||
#endif
|
||||
extern char *strnmov(char *dst,const char *src,uint n);
|
||||
extern char *strsuff(const char *src,const char *suffix);
|
||||
extern char *strcont(const char *src,const char *set);
|
||||
extern char *strxcat _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxmov _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
|
||||
extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
|
||||
extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
|
||||
|
||||
/* Prototypes of normal stringfunctions (with may ours) */
|
||||
|
||||
#ifdef WANT_STRING_PROTOTYPES
|
||||
extern char *strcat(char *, const char *);
|
||||
extern char *strchr(const char *, pchar);
|
||||
extern char *strrchr(const char *, pchar);
|
||||
extern char *strcpy(char *, const char *);
|
||||
extern int strcmp(const char *, const char *);
|
||||
#ifndef __GNUC__
|
||||
extern size_t strlen(const char *);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef HAVE_STRNLEN
|
||||
extern uint strnlen(const char *s, uint n);
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#ifndef HAVE_STRPBRK
|
||||
extern char *strpbrk(const char *, const char *);
|
||||
#endif
|
||||
#ifndef HAVE_STRSTR
|
||||
extern char *strstr(const char *, const char *);
|
||||
#endif
|
||||
#endif
|
||||
extern int is_prefix(const char *, const char *);
|
||||
|
||||
/* Conversion rutins */
|
||||
|
||||
#ifdef USE_MY_ITOA
|
||||
extern char *my_itoa(int val,char *dst,int radix);
|
||||
extern char *my_ltoa(long val,char *dst,int radix);
|
||||
#endif
|
||||
|
||||
extern char *llstr(longlong value,char *buff);
|
||||
#ifndef HAVE_STRTOUL
|
||||
extern long strtol(const char *str, char **ptr, int base);
|
||||
extern ulong strtoul(const char *str, char **ptr, int base);
|
||||
#endif
|
||||
|
||||
extern char *int2str(long val,char *dst,int radix);
|
||||
extern char *int10_to_str(long val,char *dst,int radix);
|
||||
extern char *str2int(const char *src,int radix,long lower,long upper,
|
||||
long *val);
|
||||
#if SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
#define longlong2str(A,B,C) int2str((A),(B),(C))
|
||||
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
|
||||
#define strtoll(A,B,C) strtol((A),(B),(C))
|
||||
#define strtoull(A,B,C) strtoul((A),(B),(C))
|
||||
#ifndef HAVE_STRTOULL
|
||||
#define HAVE_STRTOULL
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_LONG_LONG
|
||||
extern char *longlong2str(longlong val,char *dst,int radix);
|
||||
extern char *longlong10_to_str(longlong val,char *dst,int radix);
|
||||
#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
|
||||
extern longlong strtoll(const char *str, char **ptr, int base);
|
||||
extern ulonglong strtoull(const char *str, char **ptr, int base);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(OS2)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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,pbool free_data);
|
||||
extern uint list_length(LIST *list);
|
||||
extern int list_walk(LIST *list,list_walk_action action,gptr argument);
|
||||
|
||||
#define 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
|
||||
@@ -0,0 +1,635 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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 <errno.h>
|
||||
#ifndef ETIME
|
||||
#define ETIME ETIMEDOUT /* For FreeBSD */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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_decl(A,B) void * _Optlink A(void *B)
|
||||
typedef void * (_Optlink *pthread_handler)(void *);
|
||||
#else
|
||||
#define pthread_handler_decl(A,B) void * __cdecl A(void *B)
|
||||
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);
|
||||
|
||||
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_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_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)
|
||||
#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 <thread.h>
|
||||
#include <synch.h>
|
||||
|
||||
#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_handler_decl(A,B) void *A(void *B)
|
||||
#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 <signal.h>
|
||||
#undef sigwait
|
||||
#endif
|
||||
#undef _REENTRANT /* Fix if _REENTRANT is in pthread.h */
|
||||
#include <pthread.h>
|
||||
#ifndef _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
#ifdef HAVE_THR_SETCONCURRENCY
|
||||
#include <thread.h> /* Probably solaris */
|
||||
#endif
|
||||
#ifdef HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYNCH_H
|
||||
#include <synch.h>
|
||||
#endif
|
||||
#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
|
||||
#error Requires at least rev 2 of EMX pthreads library.
|
||||
#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_decl(A,B) void *A(void *B)
|
||||
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_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 sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
|
||||
#define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
|
||||
#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
|
||||
|
||||
#if defined(HAVE_UNIXWARE7_POSIX)
|
||||
#undef HAVE_NONPOSIX_SIGWAIT
|
||||
#define HAVE_NONPOSIX_SIGWAIT /* sigwait takes only 1 argument */
|
||||
#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
|
||||
#if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
|
||||
#define 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)
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#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_DARWIN_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)
|
||||
#define pthread_signal(A,B) pthread_dummy(0)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
|
||||
#undef sigset
|
||||
#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
|
||||
#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); }
|
||||
#else /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
|
||||
#define HAVE_PTHREAD_KILL
|
||||
#endif
|
||||
|
||||
#endif /* defined(__WIN__) */
|
||||
|
||||
#if defined(HPUX) && !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(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 */
|
||||
|
||||
typedef struct st_safe_mutex_t
|
||||
{
|
||||
pthread_mutex_t global,mutex;
|
||||
char *file;
|
||||
uint line,count;
|
||||
pthread_t thread;
|
||||
} safe_mutex_t;
|
||||
|
||||
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
|
||||
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);
|
||||
|
||||
/* 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))
|
||||
#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))
|
||||
#else
|
||||
#define safe_mutex_assert_owner(mp)
|
||||
#endif /* SAFE_MUTEX */
|
||||
|
||||
/* READ-WRITE thread locking */
|
||||
|
||||
#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 */
|
||||
#define MY_MUTEX_INIT_SLOW NULL
|
||||
#define MY_MUTEX_INIT_FAST NULL
|
||||
#define MY_MUTEX_INIT_ERRCHK NULL
|
||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||
extern pthread_mutexattr_t my_fast_mutexattr;
|
||||
#undef MY_MUTEX_INIT_FAST
|
||||
#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
|
||||
#endif
|
||||
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
extern pthread_mutexattr_t my_errchk_mutexattr;
|
||||
#undef MY_INIT_MUTEX_ERRCHK
|
||||
#define MY_INIT_MUTEX_ERRCHK &my_errchk_mutexattr
|
||||
#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
|
||||
#if defined(__ia64__)
|
||||
#define DEFAULT_THREAD_STACK (128*1024)
|
||||
#else
|
||||
#define DEFAULT_THREAD_STACK (64*1024)
|
||||
#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;
|
||||
#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
|
||||
|
||||
/* statistics_xxx functions are for not essential statistic */
|
||||
|
||||
#ifndef thread_safe_increment
|
||||
#ifdef HAVE_ATOMIC_ADD
|
||||
#define thread_safe_increment(V,L) atomic_add(1,(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);
|
||||
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
||||
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
||||
#else
|
||||
#define thread_safe_increment(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));
|
||||
#ifdef SAFE_STATISTICS
|
||||
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
||||
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
||||
#else
|
||||
#define statistic_increment(V,L) (V)++
|
||||
#define statistic_add(V,C,L) (V)+=(C)
|
||||
#endif /* SAFE_STATISTICS */
|
||||
#endif /* HAVE_ATOMIC_ADD */
|
||||
#endif /* thread_safe_increment */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _my_ptread_h */
|
||||
@@ -0,0 +1,624 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AIOWAIT
|
||||
#include <sys/asynch.h> /* 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 <my_pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#include <m_ctype.h> /* for CHARSET_INFO */
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#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 MAXMAPS (4) /* Number of error message maps */
|
||||
#define ERRMOD (1000) /* Max number of errors in a map */
|
||||
#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_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
|
||||
#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_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))
|
||||
|
||||
/* My seek flags */
|
||||
#define MY_SEEK_SET 0
|
||||
#define MY_SEEK_CUR 1
|
||||
#define MY_SEEK_END 2
|
||||
|
||||
/* My charsets_list flags */
|
||||
#define MY_NO_SETS 0
|
||||
#define MY_COMPILED_SETS 1 /* show compiled-in sets */
|
||||
#define MY_CONFIG_SETS 2 /* sets that have a *.conf file */
|
||||
#define MY_INDEX_SETS 4 /* all sets listed in the Index file */
|
||||
#define MY_LOADED_SETS 8 /* the sets that are currently loaded */
|
||||
|
||||
/* 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 KEYCACHE_BLOCK_SIZE 1024
|
||||
|
||||
/* root_alloc flags */
|
||||
#define MY_KEEP_PREALLOC 1
|
||||
|
||||
/* 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 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 safemalloc_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() (0)
|
||||
#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 my_string my_strdup(const char *from,myf MyFlags);
|
||||
#define my_free(PTR,FG) my_no_flags_free(PTR)
|
||||
#define CALLER_INFO_PROTO /* nothing */
|
||||
#define CALLER_INFO /* nothing */
|
||||
#define ORIG_CALLER_INFO /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ALLOCA
|
||||
#if defined(_AIX) && !defined(__GNUC__)
|
||||
#pragma alloca
|
||||
#endif /* _AIX */
|
||||
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
|
||||
#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 */
|
||||
|
||||
#ifdef HAVE_ERRNO_AS_DEFINE
|
||||
#include <errno.h> /* errno is a define */
|
||||
#else
|
||||
extern int errno; /* declare errno */
|
||||
#endif
|
||||
extern const char ** NEAR my_errmsg[];
|
||||
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
|
||||
extern char *home_dir; /* Home directory for user */
|
||||
extern 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);
|
||||
|
||||
/* charsets */
|
||||
extern uint get_charset_number(const char *cs_name);
|
||||
extern const char *get_charset_name(uint cs_number);
|
||||
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
|
||||
extern my_bool set_default_charset(uint cs, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
|
||||
extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
|
||||
extern void free_charsets(void);
|
||||
extern char *list_charsets(myf want_flags); /* my_free() this string... */
|
||||
extern char *get_charsets_dir(char *buf);
|
||||
|
||||
|
||||
/* statistics */
|
||||
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
|
||||
_my_cache_read;
|
||||
extern ulong _my_blocks_used,_my_blocks_changed;
|
||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||
extern my_bool key_cache_inited;
|
||||
|
||||
/* 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 long lCurMemory,lMaxMemory; /* from safemalloc */
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
typedef struct st_typelib { /* Different types saved here */
|
||||
uint count; /* How many types */
|
||||
const char *name; /* Name of typelib */
|
||||
const char **type_names;
|
||||
} TYPELIB;
|
||||
|
||||
enum cache_type {READ_CACHE,WRITE_CACHE,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 };
|
||||
|
||||
extern struct my_file_info
|
||||
{
|
||||
my_string name;
|
||||
enum file_type type;
|
||||
#if defined(THREAD) && !defined(HAVE_PREAD)
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
} my_file_info[MY_NFILE];
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
typedef struct st_io_cache /* Used when cacheing files */
|
||||
{
|
||||
my_off_t pos_in_file,end_of_file;
|
||||
byte *rc_pos,*rc_end,*buffer,*rc_request_pos;
|
||||
int (*read_function)(struct st_io_cache *,byte *,uint);
|
||||
char *file_name; /* if used with 'open_cached_file' */
|
||||
char *dir,*prefix;
|
||||
File file;
|
||||
int seek_not_done,error;
|
||||
uint buffer_length,read_length;
|
||||
myf myflags; /* Flags used to my_read/my_write */
|
||||
enum cache_type type;
|
||||
#ifdef HAVE_AIOWAIT
|
||||
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)->rc_pos + (Count) <= (info)->rc_end ?\
|
||||
(memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \
|
||||
((info)->rc_pos+=(Count)),0) :\
|
||||
(*(info)->read_function)((info),Buffer,Count))
|
||||
|
||||
#define my_b_get(info) \
|
||||
((info)->rc_pos != (info)->rc_end ?\
|
||||
((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
|
||||
_my_b_get(info))
|
||||
|
||||
#define my_b_write(info,Buffer,Count) \
|
||||
((info)->rc_pos + (Count) <= (info)->rc_end ?\
|
||||
(memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
|
||||
((info)->rc_pos+=(Count)),0) :\
|
||||
_my_b_write(info,Buffer,Count))
|
||||
|
||||
/* my_b_write_byte dosn't have any err-check */
|
||||
#define my_b_write_byte(info,chr) \
|
||||
(((info)->rc_pos < (info)->rc_end) ?\
|
||||
((*(info)->rc_pos++)=(chr)) :\
|
||||
(_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr))))
|
||||
|
||||
#define my_b_fill_cache(info) \
|
||||
(((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0))
|
||||
|
||||
#define my_b_tell(info) ((info)->pos_in_file + \
|
||||
((info)->rc_pos - (info)->rc_request_pos))
|
||||
|
||||
#define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos))
|
||||
|
||||
typedef struct st_changeable_var {
|
||||
const char *name; /* Name of variable */
|
||||
long *varptr; /* Pointer to variable */
|
||||
long def_value, /* Default value */
|
||||
min_value, /* Min allowed value */
|
||||
max_value, /* Max allowed value */
|
||||
sub_size, /* Subtract this from given value */
|
||||
block_size; /* Value should be a mult. of this */
|
||||
} CHANGEABLE_VAR;
|
||||
|
||||
|
||||
/* structs for alloc_root */
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
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;
|
||||
USED_MEM *used;
|
||||
USED_MEM *pre_alloc;
|
||||
unsigned int min_malloc;
|
||||
unsigned int block_size;
|
||||
|
||||
void (*error_handler)(void);
|
||||
} MEM_ROOT;
|
||||
#endif
|
||||
|
||||
/* 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 my_string my_tempnam(const char *dir,const char *pfx,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 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);
|
||||
#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,myf MyFlags);
|
||||
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_vsnprintf( char *str, size_t n,
|
||||
const char *format, va_list ap );
|
||||
extern int my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
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 void 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 void my_remember_signal(int signal_number,sig_handler (*func)(int));
|
||||
extern void caseup(my_string str,uint length);
|
||||
extern void casedn(my_string str,uint length);
|
||||
extern void caseup_str(my_string str);
|
||||
extern void casedn_str(my_string str);
|
||||
extern void case_sort(my_string str,uint length);
|
||||
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 char *convert_dirname(my_string name);
|
||||
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 *dsk,
|
||||
const char *form,int 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 my_string 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);
|
||||
extern my_string my_strcasestr(const char *src,const char *suffix);
|
||||
extern int my_strcasecmp(const char *s,const char *t);
|
||||
extern int my_strsortcmp(const char *s,const char *t);
|
||||
extern int my_casecmp(const char *s,const char *t,uint length);
|
||||
extern int my_sortcmp(const char *s,const char *t,uint length);
|
||||
extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
|
||||
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(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 int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
|
||||
extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length,
|
||||
uint block_length,int return_buffer);
|
||||
extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length,
|
||||
uint block_length,int force_write);
|
||||
extern int flush_key_blocks(int file, enum flush_type type);
|
||||
extern void end_key_cache(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);
|
||||
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 int _my_b_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_block_write(IO_CACHE *info, const byte *Buffer,
|
||||
uint Count, my_off_t pos);
|
||||
extern int flush_io_cache(IO_CACHE *info);
|
||||
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 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)
|
||||
|
||||
extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
|
||||
extern void make_type(my_string to,uint nr,TYPELIB *typelib);
|
||||
extern const char *get_type(TYPELIB *typelib,uint nr);
|
||||
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);
|
||||
void set_all_changeable_vars(CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_varval(const char *var, ulong val,
|
||||
CHANGEABLE_VAR *vars);
|
||||
#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)
|
||||
void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size);
|
||||
gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
|
||||
void free_root(MEM_ROOT *root, myf MyFLAGS);
|
||||
char *strdup_root(MEM_ROOT *root,const char *str);
|
||||
char *memdup_root(MEM_ROOT *root,const char *str,uint len);
|
||||
void load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv);
|
||||
void free_defaults(char **argv);
|
||||
void print_defaults(const char *conf_file, const char **groups);
|
||||
my_bool my_compress(byte *, ulong *, ulong *);
|
||||
my_bool my_uncompress(byte *, ulong *, ulong *);
|
||||
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
|
||||
ulong checksum(const byte *mem, uint count);
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__WIN__)
|
||||
extern void sleep(int sec);
|
||||
#endif
|
||||
#ifdef __WIN__
|
||||
extern my_bool have_tcpip; /* Is set if tcpip is used */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "raid.h"
|
||||
#endif /* _my_sys_h */
|
||||
@@ -0,0 +1,312 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
/* defines for the libmysql library */
|
||||
|
||||
#ifndef _mysql_h
|
||||
#define _mysql_h
|
||||
|
||||
#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */
|
||||
#undef WIN
|
||||
#undef _WIN
|
||||
#undef _WIN32
|
||||
#undef _WIN64
|
||||
#undef __WIN__
|
||||
#endif
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _global_h /* If not standard header */
|
||||
#include <sys/types.h>
|
||||
#ifdef __LCC__
|
||||
#include <winsock.h> /* 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 ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
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;
|
||||
USED_MEM *used;
|
||||
USED_MEM *pre_alloc;
|
||||
unsigned int min_malloc;
|
||||
unsigned int block_size;
|
||||
|
||||
void (*error_handler)(void);
|
||||
} MEM_ROOT;
|
||||
#endif
|
||||
|
||||
#ifndef my_socket_defined
|
||||
#ifdef __WIN__
|
||||
#define my_socket SOCKET
|
||||
#else
|
||||
typedef int my_socket;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#include "mysql_com.h"
|
||||
#include "mysql_version.h"
|
||||
|
||||
extern unsigned int mysql_port;
|
||||
extern char *mysql_unix_port;
|
||||
|
||||
#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)
|
||||
#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 *table; /* Table of column if column was a field */
|
||||
char *def; /* Default value (set by mysql_list_fields) */
|
||||
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
|
||||
unsigned int length; /* Width of column */
|
||||
unsigned int max_length; /* Max width of selected set */
|
||||
unsigned int flags; /* Div flags */
|
||||
unsigned int decimals; /* Number of decimals in field */
|
||||
} MYSQL_FIELD;
|
||||
|
||||
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
|
||||
|
||||
#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
|
||||
|
||||
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
|
||||
|
||||
typedef struct st_mysql_rows {
|
||||
struct st_mysql_rows *next; /* list of rows */
|
||||
MYSQL_ROW data;
|
||||
} MYSQL_ROWS;
|
||||
|
||||
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||
|
||||
typedef struct st_mysql_data {
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
MYSQL_ROWS *data;
|
||||
MEM_ROOT alloc;
|
||||
} MYSQL_DATA;
|
||||
|
||||
struct st_mysql_options {
|
||||
unsigned int connect_timeout,client_flag;
|
||||
my_bool compress,named_pipe;
|
||||
unsigned int port;
|
||||
char *host,*init_command,*user,*password,*unix_socket,*db;
|
||||
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
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? */
|
||||
};
|
||||
|
||||
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};
|
||||
|
||||
enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
|
||||
MYSQL_STATUS_USE_RESULT};
|
||||
|
||||
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,*db;
|
||||
unsigned int port,client_flag,server_capabilities;
|
||||
unsigned int protocol_version;
|
||||
unsigned int field_count;
|
||||
unsigned int server_status;
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Used by mysqlshow */
|
||||
unsigned long packet_length;
|
||||
enum mysql_status status;
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_bool free_me; /* If free in mysql_close */
|
||||
my_bool reconnect; /* set to 1 if automatic reconnect */
|
||||
struct st_mysql_options options;
|
||||
char scramble_buff[9];
|
||||
struct charset_info_st *charset;
|
||||
unsigned int server_language;
|
||||
} MYSQL;
|
||||
|
||||
|
||||
typedef struct st_mysql_res {
|
||||
my_ulonglong row_count;
|
||||
unsigned int field_count, current_field;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_DATA *data;
|
||||
MYSQL_ROWS *data_cursor;
|
||||
MEM_ROOT field_alloc;
|
||||
MYSQL_ROW row; /* If unbuffered read */
|
||||
MYSQL_ROW current_row; /* buffer to current row */
|
||||
unsigned long *lengths; /* column lengths of current row */
|
||||
MYSQL *handle; /* for unbuffered reads */
|
||||
my_bool eof; /* Used my mysql_fetch_row */
|
||||
} MYSQL_RES;
|
||||
|
||||
/* 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_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res);
|
||||
unsigned int 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);
|
||||
char * STDCALL mysql_error(MYSQL *mysql);
|
||||
char * STDCALL mysql_info(MYSQL *mysql);
|
||||
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
|
||||
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
|
||||
|
||||
MYSQL * STDCALL mysql_init(MYSQL *mysql);
|
||||
#ifdef HAVE_OPENSSL
|
||||
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
|
||||
const char *cert, const char *ca,
|
||||
const char *capath);
|
||||
char * STDCALL mysql_ssl_cipher(MYSQL *mysql);
|
||||
int STDCALL mysql_ssl_clear(MYSQL *mysql);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
|
||||
const char *user, const char *passwd);
|
||||
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
||||
const char *passwd, const char *db);
|
||||
#if MYSQL_VERSION_ID >= 32200
|
||||
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 int clientflag);
|
||||
#else
|
||||
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
unsigned int port,
|
||||
const char *unix_socket,
|
||||
unsigned int clientflag);
|
||||
#endif
|
||||
void STDCALL mysql_close(MYSQL *sock);
|
||||
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 int length);
|
||||
int STDCALL mysql_read_query_result(MYSQL *mysql);
|
||||
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
|
||||
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
|
||||
int STDCALL mysql_shutdown(MYSQL *mysql);
|
||||
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_ping(MYSQL *mysql);
|
||||
char * STDCALL mysql_stat(MYSQL *mysql);
|
||||
char * STDCALL mysql_get_server_info(MYSQL *mysql);
|
||||
char * STDCALL mysql_get_client_info(void);
|
||||
char * STDCALL mysql_get_host_info(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_fields(MYSQL *mysql, const char *table,
|
||||
const char *wild);
|
||||
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
|
||||
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
|
||||
MYSQL_RES * STDCALL mysql_use_result(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);
|
||||
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);
|
||||
unsigned long STDCALL mysql_escape_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);
|
||||
|
||||
|
||||
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
||||
|
||||
/* new api functions */
|
||||
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,239 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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 LOCAL_HOST "localhost"
|
||||
#define LOCAL_HOST_NAMEDPIPE "."
|
||||
|
||||
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
|
||||
#define MYSQL_NAMEDPIPE "MySQL"
|
||||
#define MYSQL_SERVICENAME "MySql"
|
||||
#endif /* __WIN__ */
|
||||
|
||||
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};
|
||||
|
||||
#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
|
||||
/* 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 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 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 */
|
||||
|
||||
#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_CHANGE_USER 512 /* Support the mysql_change_user() */
|
||||
#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 SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
|
||||
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
|
||||
|
||||
#define MYSQL_ERRMSG_SIZE 200
|
||||
#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 */
|
||||
|
||||
#ifndef Vio_defined
|
||||
#define Vio_defined
|
||||
#ifdef HAVE_VIO
|
||||
class Vio; /* Fill Vio class in C++ */
|
||||
#else
|
||||
struct st_vio; /* Only C */
|
||||
typedef struct st_vio Vio;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
|
||||
#define MAX_BLOB_WIDTH 8192 /* Default width for blob */
|
||||
|
||||
typedef struct st_net {
|
||||
Vio* vio;
|
||||
my_socket fd; /* For Perl DBI/dbd */
|
||||
int fcntl;
|
||||
unsigned char *buff,*buff_end,*write_pos,*read_pos;
|
||||
char last_error[MYSQL_ERRMSG_SIZE];
|
||||
unsigned int last_errno,max_packet,timeout,pkt_nr;
|
||||
unsigned char error;
|
||||
my_bool return_errno,compress;
|
||||
my_bool no_send_ok; /* needed 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;
|
||||
} NET;
|
||||
|
||||
#define packet_error ((unsigned int) -1)
|
||||
|
||||
enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
|
||||
FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
|
||||
FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
|
||||
FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
|
||||
FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
|
||||
FIELD_TYPE_DATE, FIELD_TYPE_TIME,
|
||||
FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
|
||||
FIELD_TYPE_NEWDATE,
|
||||
FIELD_TYPE_ENUM=247,
|
||||
FIELD_TYPE_SET=248,
|
||||
FIELD_TYPE_TINY_BLOB=249,
|
||||
FIELD_TYPE_MEDIUM_BLOB=250,
|
||||
FIELD_TYPE_LONG_BLOB=251,
|
||||
FIELD_TYPE_BLOB=252,
|
||||
FIELD_TYPE_VAR_STRING=253,
|
||||
FIELD_TYPE_STRING=254
|
||||
};
|
||||
|
||||
#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
|
||||
#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
|
||||
|
||||
extern unsigned long max_allowed_packet;
|
||||
extern unsigned long net_buffer_length;
|
||||
|
||||
#define net_new_transaction(net) ((net)->pkt_nr=0)
|
||||
|
||||
int my_net_init(NET *net, Vio* vio);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net);
|
||||
int net_flush(NET *net);
|
||||
int my_net_write(NET *net,const char *packet,unsigned long len);
|
||||
int net_write_command(NET *net,unsigned char command,const char *packet,
|
||||
unsigned long len);
|
||||
int net_real_write(NET *net,const char *packet,unsigned long len);
|
||||
unsigned int my_net_read(NET *net);
|
||||
|
||||
struct rand_struct {
|
||||
unsigned long seed1,seed2,max_value;
|
||||
double max_value_dbl;
|
||||
};
|
||||
|
||||
/* The following is for user defined functions */
|
||||
|
||||
enum Item_result {STRING_RESULT,REAL_RESULT,INT_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 */
|
||||
} 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 int 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
|
||||
|
||||
void randominit(struct rand_struct *,unsigned long seed1,
|
||||
unsigned long seed2);
|
||||
double rnd(struct rand_struct *);
|
||||
void make_scrambled_password(char *to,const char *password);
|
||||
void get_salt_from_password(unsigned long *res,const char *password);
|
||||
void make_password_from_salt(char *to, unsigned long *hash_res);
|
||||
char *scramble(char *to,const char *message,const char *password,
|
||||
my_bool old_ver);
|
||||
my_bool check_scramble(const char *, const char *message,
|
||||
unsigned long *salt,my_bool old_ver);
|
||||
char *get_tty_password(char *opt_message);
|
||||
void hash_password(unsigned long *result, const char *password);
|
||||
|
||||
/* Some other useful functions */
|
||||
|
||||
void my_init(void);
|
||||
void 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 __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 */
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define PROTOCOL_VERSION 10
|
||||
#define MYSQL_SERVER_VERSION "3.23.54"
|
||||
#define MYSQL_SERVER_SUFFIX ""
|
||||
#define FRM_VER 6
|
||||
#define MYSQL_VERSION_ID 32354
|
||||
#define MYSQL_PORT 3306
|
||||
#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
|
||||
#define MYSQL_CONFIG_NAME "my"
|
||||
|
||||
/* mysqld compile time options */
|
||||
#ifndef MYSQL_CHARSET
|
||||
#define MYSQL_CHARSET "latin1"
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,237 @@
|
||||
/* 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 */
|
||||
|
||||
/* Definefile for error messagenumbers */
|
||||
|
||||
#define ER_HASHCHK 1000
|
||||
#define ER_NISAMCHK 1001
|
||||
#define ER_NO 1002
|
||||
#define ER_YES 1003
|
||||
#define ER_CANT_CREATE_FILE 1004
|
||||
#define ER_CANT_CREATE_TABLE 1005
|
||||
#define ER_CANT_CREATE_DB 1006
|
||||
#define ER_DB_CREATE_EXISTS 1007
|
||||
#define ER_DB_DROP_EXISTS 1008
|
||||
#define ER_DB_DROP_DELETE 1009
|
||||
#define ER_DB_DROP_RMDIR 1010
|
||||
#define ER_CANT_DELETE_FILE 1011
|
||||
#define ER_CANT_FIND_SYSTEM_REC 1012
|
||||
#define ER_CANT_GET_STAT 1013
|
||||
#define ER_CANT_GET_WD 1014
|
||||
#define ER_CANT_LOCK 1015
|
||||
#define ER_CANT_OPEN_FILE 1016
|
||||
#define ER_FILE_NOT_FOUND 1017
|
||||
#define ER_CANT_READ_DIR 1018
|
||||
#define ER_CANT_SET_WD 1019
|
||||
#define ER_CHECKREAD 1020
|
||||
#define ER_DISK_FULL 1021
|
||||
#define ER_DUP_KEY 1022
|
||||
#define ER_ERROR_ON_CLOSE 1023
|
||||
#define ER_ERROR_ON_READ 1024
|
||||
#define ER_ERROR_ON_RENAME 1025
|
||||
#define ER_ERROR_ON_WRITE 1026
|
||||
#define ER_FILE_USED 1027
|
||||
#define ER_FILSORT_ABORT 1028
|
||||
#define ER_FORM_NOT_FOUND 1029
|
||||
#define ER_GET_ERRNO 1030
|
||||
#define ER_ILLEGAL_HA 1031
|
||||
#define ER_KEY_NOT_FOUND 1032
|
||||
#define ER_NOT_FORM_FILE 1033
|
||||
#define ER_NOT_KEYFILE 1034
|
||||
#define ER_OLD_KEYFILE 1035
|
||||
#define ER_OPEN_AS_READONLY 1036
|
||||
#define ER_OUTOFMEMORY 1037
|
||||
#define ER_OUT_OF_SORTMEMORY 1038
|
||||
#define ER_UNEXPECTED_EOF 1039
|
||||
#define ER_CON_COUNT_ERROR 1040
|
||||
#define ER_OUT_OF_RESOURCES 1041
|
||||
#define ER_BAD_HOST_ERROR 1042
|
||||
#define ER_HANDSHAKE_ERROR 1043
|
||||
#define ER_DBACCESS_DENIED_ERROR 1044
|
||||
#define ER_ACCESS_DENIED_ERROR 1045
|
||||
#define ER_NO_DB_ERROR 1046
|
||||
#define ER_UNKNOWN_COM_ERROR 1047
|
||||
#define ER_BAD_NULL_ERROR 1048
|
||||
#define ER_BAD_DB_ERROR 1049
|
||||
#define ER_TABLE_EXISTS_ERROR 1050
|
||||
#define ER_BAD_TABLE_ERROR 1051
|
||||
#define ER_NON_UNIQ_ERROR 1052
|
||||
#define ER_SERVER_SHUTDOWN 1053
|
||||
#define ER_BAD_FIELD_ERROR 1054
|
||||
#define ER_WRONG_FIELD_WITH_GROUP 1055
|
||||
#define ER_WRONG_GROUP_FIELD 1056
|
||||
#define ER_WRONG_SUM_SELECT 1057
|
||||
#define ER_WRONG_VALUE_COUNT 1058
|
||||
#define ER_TOO_LONG_IDENT 1059
|
||||
#define ER_DUP_FIELDNAME 1060
|
||||
#define ER_DUP_KEYNAME 1061
|
||||
#define ER_DUP_ENTRY 1062
|
||||
#define ER_WRONG_FIELD_SPEC 1063
|
||||
#define ER_PARSE_ERROR 1064
|
||||
#define ER_EMPTY_QUERY 1065
|
||||
#define ER_NONUNIQ_TABLE 1066
|
||||
#define ER_INVALID_DEFAULT 1067
|
||||
#define ER_MULTIPLE_PRI_KEY 1068
|
||||
#define ER_TOO_MANY_KEYS 1069
|
||||
#define ER_TOO_MANY_KEY_PARTS 1070
|
||||
#define ER_TOO_LONG_KEY 1071
|
||||
#define ER_KEY_COLUMN_DOES_NOT_EXITS 1072
|
||||
#define ER_BLOB_USED_AS_KEY 1073
|
||||
#define ER_TOO_BIG_FIELDLENGTH 1074
|
||||
#define ER_WRONG_AUTO_KEY 1075
|
||||
#define ER_READY 1076
|
||||
#define ER_NORMAL_SHUTDOWN 1077
|
||||
#define ER_GOT_SIGNAL 1078
|
||||
#define ER_SHUTDOWN_COMPLETE 1079
|
||||
#define ER_FORCING_CLOSE 1080
|
||||
#define ER_IPSOCK_ERROR 1081
|
||||
#define ER_NO_SUCH_INDEX 1082
|
||||
#define ER_WRONG_FIELD_TERMINATORS 1083
|
||||
#define ER_BLOBS_AND_NO_TERMINATED 1084
|
||||
#define ER_TEXTFILE_NOT_READABLE 1085
|
||||
#define ER_FILE_EXISTS_ERROR 1086
|
||||
#define ER_LOAD_INFO 1087
|
||||
#define ER_ALTER_INFO 1088
|
||||
#define ER_WRONG_SUB_KEY 1089
|
||||
#define ER_CANT_REMOVE_ALL_FIELDS 1090
|
||||
#define ER_CANT_DROP_FIELD_OR_KEY 1091
|
||||
#define ER_INSERT_INFO 1092
|
||||
#define ER_INSERT_TABLE_USED 1093
|
||||
#define ER_NO_SUCH_THREAD 1094
|
||||
#define ER_KILL_DENIED_ERROR 1095
|
||||
#define ER_NO_TABLES_USED 1096
|
||||
#define ER_TOO_BIG_SET 1097
|
||||
#define ER_NO_UNIQUE_LOGFILE 1098
|
||||
#define ER_TABLE_NOT_LOCKED_FOR_WRITE 1099
|
||||
#define ER_TABLE_NOT_LOCKED 1100
|
||||
#define ER_BLOB_CANT_HAVE_DEFAULT 1101
|
||||
#define ER_WRONG_DB_NAME 1102
|
||||
#define ER_WRONG_TABLE_NAME 1103
|
||||
#define ER_TOO_BIG_SELECT 1104
|
||||
#define ER_UNKNOWN_ERROR 1105
|
||||
#define ER_UNKNOWN_PROCEDURE 1106
|
||||
#define ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107
|
||||
#define ER_WRONG_PARAMETERS_TO_PROCEDURE 1108
|
||||
#define ER_UNKNOWN_TABLE 1109
|
||||
#define ER_FIELD_SPECIFIED_TWICE 1110
|
||||
#define ER_INVALID_GROUP_FUNC_USE 1111
|
||||
#define ER_UNSUPPORTED_EXTENSION 1112
|
||||
#define ER_TABLE_MUST_HAVE_COLUMNS 1113
|
||||
#define ER_RECORD_FILE_FULL 1114
|
||||
#define ER_UNKNOWN_CHARACTER_SET 1115
|
||||
#define ER_TOO_MANY_TABLES 1116
|
||||
#define ER_TOO_MANY_FIELDS 1117
|
||||
#define ER_TOO_BIG_ROWSIZE 1118
|
||||
#define ER_STACK_OVERRUN 1119
|
||||
#define ER_WRONG_OUTER_JOIN 1120
|
||||
#define ER_NULL_COLUMN_IN_INDEX 1121
|
||||
#define ER_CANT_FIND_UDF 1122
|
||||
#define ER_CANT_INITIALIZE_UDF 1123
|
||||
#define ER_UDF_NO_PATHS 1124
|
||||
#define ER_UDF_EXISTS 1125
|
||||
#define ER_CANT_OPEN_LIBRARY 1126
|
||||
#define ER_CANT_FIND_DL_ENTRY 1127
|
||||
#define ER_FUNCTION_NOT_DEFINED 1128
|
||||
#define ER_HOST_IS_BLOCKED 1129
|
||||
#define ER_HOST_NOT_PRIVILEGED 1130
|
||||
#define ER_PASSWORD_ANONYMOUS_USER 1131
|
||||
#define ER_PASSWORD_NOT_ALLOWED 1132
|
||||
#define ER_PASSWORD_NO_MATCH 1133
|
||||
#define ER_UPDATE_INFO 1134
|
||||
#define ER_CANT_CREATE_THREAD 1135
|
||||
#define ER_WRONG_VALUE_COUNT_ON_ROW 1136
|
||||
#define ER_CANT_REOPEN_TABLE 1137
|
||||
#define ER_INVALID_USE_OF_NULL 1138
|
||||
#define ER_REGEXP_ERROR 1139
|
||||
#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
|
||||
#define ER_NONEXISTING_GRANT 1141
|
||||
#define ER_TABLEACCESS_DENIED_ERROR 1142
|
||||
#define ER_COLUMNACCESS_DENIED_ERROR 1143
|
||||
#define ER_ILLEGAL_GRANT_FOR_TABLE 1144
|
||||
#define ER_GRANT_WRONG_HOST_OR_USER 1145
|
||||
#define ER_NO_SUCH_TABLE 1146
|
||||
#define ER_NONEXISTING_TABLE_GRANT 1147
|
||||
#define ER_NOT_ALLOWED_COMMAND 1148
|
||||
#define ER_SYNTAX_ERROR 1149
|
||||
#define ER_DELAYED_CANT_CHANGE_LOCK 1150
|
||||
#define ER_TOO_MANY_DELAYED_THREADS 1151
|
||||
#define ER_ABORTING_CONNECTION 1152
|
||||
#define ER_NET_PACKET_TOO_LARGE 1153
|
||||
#define ER_NET_READ_ERROR_FROM_PIPE 1154
|
||||
#define ER_NET_FCNTL_ERROR 1155
|
||||
#define ER_NET_PACKETS_OUT_OF_ORDER 1156
|
||||
#define ER_NET_UNCOMPRESS_ERROR 1157
|
||||
#define ER_NET_READ_ERROR 1158
|
||||
#define ER_NET_READ_INTERRUPTED 1159
|
||||
#define ER_NET_ERROR_ON_WRITE 1160
|
||||
#define ER_NET_WRITE_INTERRUPTED 1161
|
||||
#define ER_TOO_LONG_STRING 1162
|
||||
#define ER_TABLE_CANT_HANDLE_BLOB 1163
|
||||
#define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
|
||||
#define ER_DELAYED_INSERT_TABLE_LOCKED 1165
|
||||
#define ER_WRONG_COLUMN_NAME 1166
|
||||
#define ER_WRONG_KEY_COLUMN 1167
|
||||
#define ER_WRONG_MRG_TABLE 1168
|
||||
#define ER_DUP_UNIQUE 1169
|
||||
#define ER_BLOB_KEY_WITHOUT_LENGTH 1170
|
||||
#define ER_PRIMARY_CANT_HAVE_NULL 1171
|
||||
#define ER_TOO_MANY_ROWS 1172
|
||||
#define ER_REQUIRES_PRIMARY_KEY 1173
|
||||
#define ER_NO_RAID_COMPILED 1174
|
||||
#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
|
||||
#define ER_KEY_DOES_NOT_EXITS 1176
|
||||
#define ER_CHECK_NO_SUCH_TABLE 1177
|
||||
#define ER_CHECK_NOT_IMPLEMENTED 1178
|
||||
#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
|
||||
#define ER_ERROR_DURING_COMMIT 1180
|
||||
#define ER_ERROR_DURING_ROLLBACK 1181
|
||||
#define ER_ERROR_DURING_FLUSH_LOGS 1182
|
||||
#define ER_ERROR_DURING_CHECKPOINT 1183
|
||||
#define ER_NEW_ABORTING_CONNECTION 1184
|
||||
#define ER_DUMP_NOT_IMPLEMENTED 1185
|
||||
#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186
|
||||
#define ER_INDEX_REBUILD 1187
|
||||
#define ER_MASTER 1188
|
||||
#define ER_MASTER_NET_READ 1189
|
||||
#define ER_MASTER_NET_WRITE 1190
|
||||
#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
|
||||
#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192
|
||||
#define ER_UNKNOWN_SYSTEM_VARIABLE 1193
|
||||
#define ER_CRASHED_ON_USAGE 1194
|
||||
#define ER_CRASHED_ON_REPAIR 1195
|
||||
#define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
|
||||
#define ER_TRANS_CACHE_FULL 1197
|
||||
#define ER_SLAVE_MUST_STOP 1198
|
||||
#define ER_SLAVE_NOT_RUNNING 1199
|
||||
#define ER_BAD_SLAVE 1200
|
||||
#define ER_MASTER_INFO 1201
|
||||
#define ER_SLAVE_THREAD 1202
|
||||
#define ER_TOO_MANY_USER_CONNECTIONS 1203
|
||||
#define ER_SET_CONSTANTS_ONLY 1204
|
||||
#define ER_LOCK_WAIT_TIMEOUT 1205
|
||||
#define ER_LOCK_TABLE_FULL 1206
|
||||
#define ER_READ_ONLY_TRANSACTION 1207
|
||||
#define ER_DROP_DB_WITH_READ_LOCK 1208
|
||||
#define ER_CREATE_DB_WITH_READ_LOCK 1209
|
||||
#define ER_WRONG_ARGUMENTS 1210
|
||||
#define ER_NO_PERMISSION_TO_CREATE_USER 1211
|
||||
#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
|
||||
#define ER_LOCK_DEADLOCK 1213
|
||||
#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214
|
||||
#define ER_CANNOT_ADD_FOREIGN 1215
|
||||
#define ER_NO_REFERENCED_ROW 1216
|
||||
#define ER_ROW_IS_REFERENCED 1217
|
||||
#define ER_ERROR_MESSAGES 218
|
||||
@@ -0,0 +1,161 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library 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, 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 */
|
||||
|
||||
extern const char *raid_type_string[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
const char *my_raid_type(int raid_type);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_RAID) && !defined(DONT_USE_RAID)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
#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) my_raid_chsize(A,B,C)
|
||||
#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, myf MyFlags);
|
||||
int my_raid_close(File, myf MyFlags);
|
||||
int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
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, 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 */
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// mysql_wrapper.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,31 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__1FC781E6_1CD6_4383_AF43_17CB309431F9__INCLUDED_)
|
||||
#define AFX_STDAFX_H__1FC781E6_1CD6_4383_AF43_17CB309431F9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
// Insert your headers here
|
||||
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__1FC781E6_1CD6_4383_AF43_17CB309431F9__INCLUDED_)
|
||||
@@ -0,0 +1,398 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
// mysql_wrapper.cpp : Defines the entry point for the DLL application.
|
||||
//
|
||||
#include "stdafx.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "mysql.h"
|
||||
};
|
||||
|
||||
#include "imysqlwrapper.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static char* CopyString( const char *pStr )
|
||||
{
|
||||
if ( !pStr )
|
||||
{
|
||||
pStr = "";
|
||||
}
|
||||
|
||||
char *pRet = new char[ strlen( pStr ) + 1 ];
|
||||
strcpy( pRet, pStr );
|
||||
return pRet;
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
class CCopiedRow
|
||||
{
|
||||
public:
|
||||
~CCopiedRow()
|
||||
{
|
||||
m_Columns.PurgeAndDeleteElements();
|
||||
}
|
||||
|
||||
CUtlVector<char*> m_Columns;
|
||||
};
|
||||
|
||||
|
||||
class CMySQLCopiedRowSet : public IMySQLRowSet
|
||||
{
|
||||
public:
|
||||
~CMySQLCopiedRowSet()
|
||||
{
|
||||
m_Rows.PurgeAndDeleteElements();
|
||||
m_ColumnNames.PurgeAndDeleteElements();
|
||||
}
|
||||
|
||||
virtual void Release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual int NumFields()
|
||||
{
|
||||
return m_ColumnNames.Count();
|
||||
}
|
||||
|
||||
virtual const char* GetFieldName( int iColumn )
|
||||
{
|
||||
return m_ColumnNames[iColumn];
|
||||
}
|
||||
|
||||
virtual bool NextRow()
|
||||
{
|
||||
++m_iCurRow;
|
||||
return m_iCurRow < m_Rows.Count();
|
||||
}
|
||||
|
||||
virtual bool SeekToFirstRow()
|
||||
{
|
||||
m_iCurRow = 0;
|
||||
return m_iCurRow < m_Rows.Count();
|
||||
}
|
||||
|
||||
virtual CColumnValue GetColumnValue( int iColumn )
|
||||
{
|
||||
return CColumnValue( this, iColumn );
|
||||
}
|
||||
|
||||
virtual CColumnValue GetColumnValue( const char *pColumnName )
|
||||
{
|
||||
return CColumnValue( this, GetColumnIndex( pColumnName ) );
|
||||
}
|
||||
|
||||
virtual const char* GetColumnValue_String( int iColumn )
|
||||
{
|
||||
if ( iColumn < 0 || iColumn >= m_ColumnNames.Count() )
|
||||
return "<invalid column specified>";
|
||||
else if ( m_iCurRow < 0 || m_iCurRow >= m_Rows.Count() )
|
||||
return "<invalid row specified>";
|
||||
else
|
||||
return m_Rows[m_iCurRow]->m_Columns[iColumn];
|
||||
}
|
||||
|
||||
virtual long GetColumnValue_Int( int iColumn )
|
||||
{
|
||||
return atoi( GetColumnValue_String( iColumn ) );
|
||||
}
|
||||
|
||||
virtual int GetColumnIndex( const char *pColumnName )
|
||||
{
|
||||
for ( int i=0; i < m_ColumnNames.Count(); i++ )
|
||||
{
|
||||
if ( stricmp( m_ColumnNames[i], pColumnName ) == 0 )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
int m_iCurRow;
|
||||
CUtlVector<CCopiedRow*> m_Rows;
|
||||
CUtlVector<char*> m_ColumnNames;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------- //
|
||||
// CMySQL class.
|
||||
// -------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
class CMySQL : public IMySQL
|
||||
{
|
||||
public:
|
||||
CMySQL();
|
||||
virtual ~CMySQL();
|
||||
|
||||
virtual bool InitMySQL( const char *pDBName, const char *pHostName, const char *pUserName, const char *pPassword );
|
||||
virtual void Release();
|
||||
virtual int Execute( const char *pString );
|
||||
virtual IMySQLRowSet* DuplicateRowSet();
|
||||
virtual unsigned long InsertID();
|
||||
virtual int NumFields();
|
||||
virtual const char* GetFieldName( int iColumn );
|
||||
virtual bool NextRow();
|
||||
virtual bool SeekToFirstRow();
|
||||
virtual CColumnValue GetColumnValue( int iColumn );
|
||||
virtual CColumnValue GetColumnValue( const char *pColumnName );
|
||||
virtual const char* GetColumnValue_String( int iColumn );
|
||||
virtual long GetColumnValue_Int( int iColumn );
|
||||
virtual int GetColumnIndex( const char *pColumnName );
|
||||
|
||||
// Cancels the storage of the rows from the latest query.
|
||||
void CancelIteration();
|
||||
|
||||
virtual const char * GetLastError( void );
|
||||
|
||||
|
||||
public:
|
||||
|
||||
MYSQL *m_pSQL;
|
||||
MYSQL_RES *m_pResult;
|
||||
MYSQL_ROW m_Row;
|
||||
CUtlVector<MYSQL_FIELD> m_Fields;
|
||||
|
||||
char m_szLastError[128];
|
||||
};
|
||||
|
||||
|
||||
EXPOSE_INTERFACE( CMySQL, IMySQL, MYSQL_WRAPPER_VERSION_NAME );
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------- //
|
||||
// CMySQL implementation.
|
||||
// -------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
CMySQL::CMySQL()
|
||||
{
|
||||
m_pSQL = NULL;
|
||||
m_pResult = NULL;
|
||||
m_Row = NULL;
|
||||
}
|
||||
|
||||
|
||||
CMySQL::~CMySQL()
|
||||
{
|
||||
CancelIteration();
|
||||
|
||||
if ( m_pSQL )
|
||||
{
|
||||
mysql_close( m_pSQL );
|
||||
m_pSQL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CMySQL::InitMySQL( const char *pDBName, const char *pHostName, const char *pUserName, const char *pPassword )
|
||||
{
|
||||
MYSQL *pSQL = mysql_init( NULL );
|
||||
if ( !pSQL )
|
||||
return NULL;
|
||||
|
||||
if ( !mysql_real_connect( pSQL, pHostName, pUserName, pPassword, pDBName, 0, NULL, 0 ) )
|
||||
{
|
||||
Q_strncpy( m_szLastError, mysql_error( pSQL ), sizeof(m_szLastError) );
|
||||
|
||||
mysql_close( pSQL );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pSQL = pSQL;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CMySQL::Release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
int CMySQL::Execute( const char *pString )
|
||||
{
|
||||
CancelIteration();
|
||||
|
||||
int result = mysql_query( m_pSQL, pString );
|
||||
if ( result == 0 )
|
||||
{
|
||||
// Is this a query with a result set?
|
||||
m_pResult = mysql_store_result( m_pSQL );
|
||||
if ( m_pResult )
|
||||
{
|
||||
// Store the field information.
|
||||
int count = mysql_field_count( m_pSQL );
|
||||
MYSQL_FIELD *pFields = mysql_fetch_fields( m_pResult );
|
||||
m_Fields.CopyArray( pFields, count );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No result set. Was a set expected?
|
||||
if ( mysql_field_count( m_pSQL ) != 0 )
|
||||
return 1; // error! The query expected data but didn't get it.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pError = mysql_error( m_pSQL );
|
||||
pError = pError;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
IMySQLRowSet* CMySQL::DuplicateRowSet()
|
||||
{
|
||||
CMySQLCopiedRowSet *pSet = new CMySQLCopiedRowSet;
|
||||
|
||||
pSet->m_iCurRow = -1;
|
||||
|
||||
pSet->m_ColumnNames.SetSize( m_Fields.Count() );
|
||||
for ( int i=0; i < m_Fields.Count(); i++ )
|
||||
pSet->m_ColumnNames[i] = CopyString( m_Fields[i].name );
|
||||
|
||||
while ( NextRow() )
|
||||
{
|
||||
CCopiedRow *pRow = new CCopiedRow;
|
||||
pSet->m_Rows.AddToTail( pRow );
|
||||
pRow->m_Columns.SetSize( m_Fields.Count() );
|
||||
|
||||
for ( int i=0; i < m_Fields.Count(); i++ )
|
||||
{
|
||||
pRow->m_Columns[i] = CopyString( m_Row[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return pSet;
|
||||
}
|
||||
|
||||
|
||||
unsigned long CMySQL::InsertID()
|
||||
{
|
||||
return mysql_insert_id( m_pSQL );
|
||||
}
|
||||
|
||||
|
||||
int CMySQL::NumFields()
|
||||
{
|
||||
return m_Fields.Count();
|
||||
}
|
||||
|
||||
|
||||
const char* CMySQL::GetFieldName( int iColumn )
|
||||
{
|
||||
return m_Fields[iColumn].name;
|
||||
}
|
||||
|
||||
|
||||
bool CMySQL::NextRow()
|
||||
{
|
||||
if ( !m_pResult )
|
||||
return false;
|
||||
|
||||
m_Row = mysql_fetch_row( m_pResult );
|
||||
if ( m_Row == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CMySQL::SeekToFirstRow()
|
||||
{
|
||||
if ( !m_pResult )
|
||||
return false;
|
||||
|
||||
mysql_data_seek( m_pResult, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CColumnValue CMySQL::GetColumnValue( int iColumn )
|
||||
{
|
||||
return CColumnValue( this, iColumn );
|
||||
}
|
||||
|
||||
|
||||
CColumnValue CMySQL::GetColumnValue( const char *pColumnName )
|
||||
{
|
||||
return CColumnValue( this, GetColumnIndex( pColumnName ) );
|
||||
}
|
||||
|
||||
|
||||
const char* CMySQL::GetColumnValue_String( int iColumn )
|
||||
{
|
||||
if ( m_Row && iColumn >= 0 && iColumn < m_Fields.Count() && m_Row[iColumn] )
|
||||
return m_Row[iColumn];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
long CMySQL::GetColumnValue_Int( int iColumn )
|
||||
{
|
||||
return atoi( GetColumnValue_String( iColumn ) );
|
||||
}
|
||||
|
||||
|
||||
int CMySQL::GetColumnIndex( const char *pColumnName )
|
||||
{
|
||||
for ( int i=0; i < m_Fields.Count(); i++ )
|
||||
{
|
||||
if ( stricmp( pColumnName, m_Fields[i].name ) == 0 )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void CMySQL::CancelIteration()
|
||||
{
|
||||
m_Fields.Purge();
|
||||
|
||||
if ( m_pResult )
|
||||
{
|
||||
mysql_free_result( m_pResult );
|
||||
m_pResult = NULL;
|
||||
}
|
||||
|
||||
m_Row = NULL;
|
||||
}
|
||||
|
||||
const char *CMySQL::GetLastError( void )
|
||||
{
|
||||
// Default to the last error if m_pSQL was not successfully initialized
|
||||
const char *pszLastError = m_szLastError;
|
||||
|
||||
if ( m_pSQL )
|
||||
{
|
||||
pszLastError = mysql_error( m_pSQL );
|
||||
}
|
||||
|
||||
return pszLastError;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// MYSQL_WRAPPER.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,..,..\mysql\include,..\..\vmpi"
|
||||
$PreprocessorDefinitions "$BASE;MYSQL_WRAPPER_EXPORTS"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Mysql_wrapper"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "mysql_wrapper.cpp"
|
||||
$File "StdAfx.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "..\..\vmpi\imysqlwrapper.h"
|
||||
$File "StdAfx.h"
|
||||
}
|
||||
|
||||
$Folder "Link Libraries"
|
||||
{
|
||||
$File "..\mysql\lib\opt\libmySQL.lib"
|
||||
$File "..\mysql\lib\opt\zlib.lib"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user