diff options
author | Sterling Hughes <sterling@php.net> | 2003-06-23 01:10:58 +0000 |
---|---|---|
committer | Sterling Hughes <sterling@php.net> | 2003-06-23 01:10:58 +0000 |
commit | d4cd1ef0843d0ef118cec86fa585517ac91d9cac (patch) | |
tree | 0e774c02c135aaa82759646ec1cd0f3344136b42 | |
parent | d520d2b80547add648fe678c4b61de815746f40a (diff) | |
download | php-git-d4cd1ef0843d0ef118cec86fa585517ac91d9cac.tar.gz |
remove the bundled libmysql, and update the config.m4 file as necessary.
this works locally, but everyone, *please* test
103 files changed, 4 insertions, 19916 deletions
diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4 index 95c40b8982..8f4e36c30b 100644 --- a/ext/mysql/config.m4 +++ b/ext/mysql/config.m4 @@ -2,11 +2,6 @@ dnl dnl $Id$ dnl -sinclude(ext/mysql/libmysql/acinclude.m4) -sinclude(ext/mysql/libmysql/mysql.m4) -sinclude(libmysql/acinclude.m4) -sinclude(libmysql/mysql.m4) - AC_DEFUN(MYSQL_LIB_CHK, [ str="$MYSQL_DIR/$1/libmysqlclient.*" for j in `echo $str`; do @@ -45,7 +40,7 @@ AC_DEFUN(PHP_MYSQL_SOCKET_SEARCH, [ PHP_ARG_WITH(mysql, for MySQL support, [ --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base directory. - If unspecified, the bundled MySQL library will be used.], yes) + If unspecified, the bundled MySQL library will be used.]) PHP_ARG_WITH(mysql-sock, for specified location of the MySQL UNIX socket, [ --with-mysql-sock[=DIR] MySQL: Location of the MySQL unix socket pointer. @@ -72,32 +67,8 @@ if test "$PHP_MYSQL" != "no"; then fi fi -if test "$PHP_MYSQL" = "yes"; then - MYSQL_MODULE_TYPE=builtin - MYSQL_CHECKS - sources="libmysql/libmysql.c libmysql/errmsg.c libmysql/net.c libmysql/violite.c libmysql/password.c \ - libmysql/my_init.c libmysql/my_lib.c libmysql/my_static.c libmysql/my_malloc.c libmysql/my_realloc.c libmysql/my_create.c \ - libmysql/my_delete.c libmysql/my_tempnam.c libmysql/my_open.c libmysql/mf_casecnv.c libmysql/my_read.c \ - libmysql/my_write.c libmysql/errors.c libmysql/my_error.c libmysql/my_getwd.c libmysql/my_div.c libmysql/mf_pack.c \ - libmysql/my_messnc.c libmysql/mf_dirname.c libmysql/mf_fn_ext.c libmysql/mf_wcomp.c libmysql/typelib.c libmysql/safemalloc.c \ - libmysql/my_alloc.c libmysql/mf_format.c libmysql/mf_path.c libmysql/mf_unixpath.c libmysql/my_fopen.c libmysql/mf_loadpath.c \ - libmysql/my_pthread.c libmysql/my_thr_init.c libmysql/thr_mutex.c libmysql/mulalloc.c libmysql/string.c libmysql/default.c \ - libmysql/my_compress.c libmysql/array.c libmysql/my_once.c libmysql/list.c libmysql/my_net.c libmysql/dbug.c \ - libmysql/strmov.c libmysql/strxmov.c libmysql/strnmov.c libmysql/strmake.c libmysql/strend.c libmysql/strfill.c \ - libmysql/is_prefix.c libmysql/int2str.c libmysql/str2int.c libmysql/strinstr.c \ - libmysql/strcont.c libmysql/strcend.c libmysql/bchange.c libmysql/bmove.c libmysql/bmove_upp.c \ - libmysql/longlong2str.c libmysql/strtoull.c libmysql/strtoll.c libmysql/charset.c libmysql/ctype.c" - - PHP_NEW_EXTENSION(mysql, php_mysql.c $sources, $ext_shared,,-I@ext_srcdir@/libmysql) - PHP_ADD_BUILD_DIR($ext_builddir/libmysql) - -elif test "$PHP_MYSQL" != "no"; then - - MYSQL_TYPE_CHECKS - - PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared) - - for i in $PHP_MYSQL; do +if test "$PHP_MYSQL" != "no"; then + for i in /usr /usr/local $PHP_MYSQL; do if test -r $i/include/mysql/mysql.h; then MYSQL_DIR=$i MYSQL_INC_DIR=$i/include/mysql @@ -111,8 +82,6 @@ elif test "$PHP_MYSQL" != "no"; then AC_MSG_ERROR(Cannot find MySQL header files under $PHP_MYSQL) fi - MYSQL_MODULE_TYPE=external - for i in lib lib/mysql; do MYSQL_LIB_CHK($i) done @@ -145,16 +114,7 @@ elif test "$PHP_MYSQL" != "no"; then ]) PHP_ADD_LIBRARY_WITH_PATH(mysqlclient, $MYSQL_LIB_DIR, MYSQL_SHARED_LIBADD) - MYSQL_LIBS="-L$MYSQL_LIB_DIR -lmysqlclient $MYSQL_LIBS" - PHP_ADD_INCLUDE($MYSQL_INC_DIR) - MYSQL_INCLUDE=-I$MYSQL_INC_DIR -else - MYSQL_MODULE_TYPE=none + PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared) fi - -PHP_SUBST(MYSQL_SHARED_LIBADD) -PHP_SUBST_OLD(MYSQL_MODULE_TYPE) -PHP_SUBST_OLD(MYSQL_LIBS) -PHP_SUBST_OLD(MYSQL_INCLUDE) diff --git a/ext/mysql/libmysql/acinclude.m4 b/ext/mysql/libmysql/acinclude.m4 deleted file mode 100644 index 1f2b42649d..0000000000 --- a/ext/mysql/libmysql/acinclude.m4 +++ /dev/null @@ -1,382 +0,0 @@ -# Local macros for automake & autoconf - -AC_DEFUN(MYSQL_FUNCTION_CHECKS,[ - -# Standard MySQL list -AC_CHECK_FUNCS(alarm bmove \ - chsize ftruncate rint finite fpsetmask fpresetsticky\ - cuserid fcntl fconvert \ - getrusage getpwuid getcwd getrlimit getwd index locking longjmp \ - perror pread realpath rename \ - socket strnlen madvise \ - strtoll strtoul strtoull snprintf tempnam thr_setconcurrency \ - gethostbyaddr_r gethostbyname_r getpwnam \ - bfill bzero bcmp strstr strpbrk strerror\ - tell atod memcpy memmove \ - setupterm strcasecmp sighold \ - vidattr setupterm lrand48 localtime_r \ - sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ - pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ - pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ - pthread_condattr_create rwlock_init \ - crypt dlopen dlerror fchmod getpass getpassphrase) - -# This is special for libmysql -AC_CHECK_FUNCS(strtok_r) - -MYSQL_CHECK_GETHOSTNAME_R -]) - -AC_DEFUN(MYSQL_CHECK_GETHOSTNAME_R,[ -# Check definition of gethostbyname_r (glibc2.0.100 is different from Solaris) -ac_save_CXXFLAGS="$CXXFLAGS" -AC_CACHE_CHECK([style of gethostname_r routines], mysql_cv_gethostname_style, -AC_LANG_SAVE -AC_LANG_CPLUSPLUS -if test "$ac_cv_prog_gxx" = "yes" -then - CXXFLAGS="$CXXFLAGS -Werror" -fi -AC_TRY_COMPILE( -[#if !defined(SCO) && !defined(__osf__) -#define _REENTRANT -#endif -#include <pthread.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h>], -[int skr; - - skr = gethostbyname_r((const char *) 0, - (struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, &skr);], -mysql_cv_gethostname_style=glibc2, mysql_cv_gethostname_style=other)) -AC_LANG_RESTORE -CXXFLAGS="$ac_save_CXXFLAGS" -if test "$mysql_cv_gethostname_style" = "glibc2" -then - AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE, , [ ]) -fi - -# Check 3rd argument of getthostbyname_r -ac_save_CXXFLAGS="$CXXFLAGS" -AC_CACHE_CHECK([3 argument to gethostname_r routines], mysql_cv_gethostname_arg, -AC_LANG_SAVE -AC_LANG_CPLUSPLUS -if test "$ac_cv_prog_gxx" = "yes" -then - CXXFLAGS="$CXXFLAGS -Werror" -fi -AC_TRY_COMPILE( -[#if !defined(SCO) && !defined(__osf__) -#define _REENTRANT -#endif -#include <pthread.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h>], -[int skr; - - skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (hostent_data*) 0);], -mysql_cv_gethostname_arg=hostent_data, mysql_cv_gethostname_arg=char)) -AC_LANG_RESTORE -CXXFLAGS="$ac_save_CXXFLAGS" -if test "$mysql_cv_gethostname_arg" = "hostent_data" -then - AC_DEFINE(HAVE_GETHOSTBYNAME_R_RETURN_INT, , [ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_SIGWAIT_STYLE,[ -# Check definition av posix sigwait() -AC_CACHE_CHECK("style of sigwait", mysql_cv_sigwait, -AC_TRY_LINK( -[#ifndef SCO -#define _REENTRANT -#endif -#define _POSIX_PTHREAD_SEMANTICS -#include <pthread.h> -#include <signal.h>], -[#ifndef _AIX -sigset_t set; -int sig; -sigwait(&set,&sig); -#endif], -mysql_cv_sigwait=POSIX, mysql_cv_sigwait=other)) -if test "$mysql_cv_sigwait" = "POSIX" -then - AC_DEFINE(HAVE_SIGWAIT,,[ ]) -fi - -if test "$mysql_cv_sigwait" != "POSIX" -then -unset mysql_cv_sigwait -# Check definition av posix sigwait() -AC_CACHE_CHECK("style of sigwait", mysql_cv_sigwait, -AC_TRY_LINK( -[#ifndef SCO -#define _REENTRANT -#endif -#define _POSIX_PTHREAD_SEMANTICS -#include <pthread.h> -#include <signal.h>], -[sigset_t set; -int sig; -sigwait(&set);], -mysql_cv_sigwait=NONPOSIX, mysql_cv_sigwait=other)) -if test "$mysql_cv_sigwait" = "NONPOSIX" -then - AC_DEFINE(HAVE_NONPOSIX_SIGWAIT,,[ ]) -fi -fi -]) - -AC_DEFUN(MYSQL_CHECK_READDIR_R_ARGS,[ -# Check definition of readdir_r -AC_CACHE_CHECK("args to readdir_r", mysql_cv_readdir_r, -AC_TRY_LINK( -[#ifndef SCO -#define _REENTRANT -#endif -#define _POSIX_PTHREAD_SEMANTICS -#include <pthread.h> -#include <dirent.h>], -[ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); -readdir_r((DIR *) NULL, (struct dirent *) NULL, (struct dirent **) NULL); ], -mysql_cv_readdir_r=POSIX, mysql_cv_readdir_r=other)) -if test "$mysql_cv_readdir_r" = "POSIX" -then - AC_DEFINE(HAVE_READDIR_R,,[ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_PTHREAD_MUTEX_INIT,[ - # Check definition of pthread_mutex_init - AC_CACHE_CHECK("args to pthread_mutex_init", mysql_cv_mutex_init_args, - AC_TRY_COMPILE( -[#ifndef SCO -#define _REENTRANT -#endif -#define _POSIX_PTHREAD_SEMANTICS -#include <pthread.h> ], -[ - pthread_mutexattr_t attr; - pthread_mutex_t mp; - pthread_mutex_init(&mp,&attr); ], -mysql_cv_mutex_init_args=POSIX, mysql_cv_mutex_init_args=other)) - if test "$mysql_cv_mutex_init_args" = "other" - then - AC_DEFINE(HAVE_NONPOSIX_PTHREAD_MUTEX_INIT,,[ ]) - fi -]) - -AC_DEFUN(MYSQL_CHECK_PTHREAD_GETSPECIFIC,[ - # Check definition of pthread_getspecific - AC_CACHE_CHECK("args to pthread_getspecific", mysql_cv_getspecific_args, - AC_TRY_COMPILE( -[#ifndef SCO -#define _REENTRANT -#endif -#define _POSIX_PTHREAD_SEMANTICS -#include <pthread.h> ], -[ void *pthread_getspecific(pthread_key_t key); -pthread_getspecific((pthread_key_t) NULL); ], -mysql_cv_getspecific_args=POSIX, mysql_cv_getspecific_args=other)) - if test "$mysql_cv_getspecific_args" = "other" - then - AC_DEFINE(HAVE_NONPOSIX_PTHREAD_GETSPECIFIC,,[ ]) - fi -]) - -AC_DEFUN(MYSQL_TYPE_ACCEPT, -[ac_save_CXXFLAGS="$CXXFLAGS" -AC_CACHE_CHECK([base type of last arg to accept], mysql_cv_btype_last_arg_accept, -AC_LANG_SAVE -AC_LANG_CPLUSPLUS -if test "$ac_cv_prog_gxx" = "yes" -then - CXXFLAGS="$CXXFLAGS -Werror" -fi -mysql_cv_btype_last_arg_accept=none -[AC_TRY_COMPILE([#include <stdlib.h> -#include <sys/types.h> -#include <sys/socket.h> -], -[int a = accept(1, (struct sockaddr *) 0, (socklen_t *) 0);], -mysql_cv_btype_last_arg_accept=socklen_t)] -if test $mysql_cv_btype_last_arg_accept = none; then -[AC_TRY_COMPILE([#include <stdlib.h> -#include <sys/types.h> -#include <sys/socket.h> -], -[int a = accept(1, (struct sockaddr *) 0, (size_t *) 0);], -mysql_cv_btype_last_arg_accept=size_t)] -fi -if test $mysql_cv_btype_last_arg_accept = none; then -mysql_cv_btype_last_arg_accept=int -fi) -AC_LANG_RESTORE -AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $mysql_cv_btype_last_arg_accept,[ ]) -CXXFLAGS="$ac_save_CXXFLAGS" -]) - -dnl Find type of qsort -AC_DEFUN(MYSQL_TYPE_QSORT, -[AC_CACHE_CHECK([return type of qsort], mysql_cv_type_qsort, -[AC_TRY_COMPILE([#include <stdlib.h> -#ifdef __cplusplus -extern "C" -#endif -void qsort(void *base, size_t nel, size_t width, - int (*compar) (const void *, const void *)); -], -[int i;], mysql_cv_type_qsort=void, mysql_cv_type_qsort=int)]) -AC_DEFINE_UNQUOTED(RETQSORTTYPE, $mysql_cv_type_qsort, [ ]) -if test "$mysql_cv_type_qsort" = "void" -then - AC_DEFINE_UNQUOTED(QSORT_TYPE_IS_VOID, 1, [ ]) -fi -]) - - -#---START: Used in for client configure -AC_DEFUN(MYSQL_CHECK_ULONG, -[AC_MSG_CHECKING(for type ulong) -AC_CACHE_VAL(ac_cv_ulong, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - ulong foo; - foo++; - exit(0); -}], ac_cv_ulong=yes, ac_cv_ulong=no, ac_cv_ulong=no)]) -AC_MSG_RESULT($ac_cv_ulong) -if test "$ac_cv_ulong" = "yes" -then - AC_DEFINE(HAVE_ULONG,,[ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_UCHAR, -[AC_MSG_CHECKING(for type uchar) -AC_CACHE_VAL(ac_cv_uchar, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - uchar foo; - foo++; - exit(0); -}], ac_cv_uchar=yes, ac_cv_uchar=no, ac_cv_uchar=no)]) -AC_MSG_RESULT($ac_cv_uchar) -if test "$ac_cv_uchar" = "yes" -then - AC_DEFINE(HAVE_UCHAR,,[ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_UINT, -[AC_MSG_CHECKING(for type uint) -AC_CACHE_VAL(ac_cv_uint, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - uint foo; - foo++; - exit(0); -}], ac_cv_uint=yes, ac_cv_uint=no, ac_cv_uint=no)]) -AC_MSG_RESULT($ac_cv_uint) -if test "$ac_cv_uint" = "yes" -then - AC_DEFINE(HAVE_UINT,,[ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_USHORT, -[AC_MSG_CHECKING(for type ushort) -AC_CACHE_VAL(ac_cv_ushort, -[AC_TRY_RUN([#include <stdio.h> -#include <sys/types.h> -main() -{ - ushort foo; - foo++; - exit(0); -}], ac_cv_ushort=yes, ac_cv_ushort=no, ac_cv_ushort=no)]) -AC_MSG_RESULT($ac_cv_ushort) -if test "$ac_cv_ushort" = "yes" -then - AC_DEFINE(HAVE_USHORT,,[ ]) -fi -]) - -AC_DEFUN(MYSQL_CHECK_INT_8_16_32, -[AC_MSG_CHECKING([for int8]) -AC_CACHE_VAL(ac_cv_int8, -[AC_TRY_RUN([ -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -int main() -{ - int8 i; - return 0; -} -], ac_cv_int8=yes, ac_cv_int8=no, ac_cv_int8=no)]) -AC_MSG_RESULT($ac_cv_int8) -if test "$ac_cv_int8" = "yes" -then - AC_DEFINE(HAVE_INT_8_16_32,,[ ]) -fi -]) - - -AC_DEFUN(MYSQL_HEADER_CHECKS,[ -AC_HEADER_STDC -AC_CHECK_HEADERS(sgtty.h sys/ioctl.h \ - fcntl.h float.h floatingpoint.h ieeefp.h limits.h \ - memory.h pwd.h select.h \ - stdlib.h stddef.h \ - strings.h string.h synch.h sys/mman.h sys/socket.h \ - sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \ - unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h) -]) - -AC_DEFUN(MYSQL_TYPE_CHECKS,[ - -AC_REQUIRE([AC_C_CONST]) -AC_REQUIRE([AC_C_INLINE]) -AC_CHECK_SIZEOF(char, 1) - -AC_CHECK_SIZEOF(int, 4) -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(long long, 8) -AC_TYPE_SIZE_T -AC_HEADER_TIME -AC_TYPE_UID_T - -MYSQL_CHECK_ULONG -MYSQL_CHECK_UCHAR -MYSQL_CHECK_UINT -MYSQL_CHECK_USHORT -MYSQL_CHECK_INT_8_16_32 - -MYSQL_TYPE_ACCEPT -MYSQL_TYPE_QSORT - -AC_REQUIRE([AC_TYPE_SIGNAL]) -]) diff --git a/ext/mysql/libmysql/array.c b/ext/mysql/libmysql/array.c deleted file mode 100644 index dcf1cb07b4..0000000000 --- a/ext/mysql/libmysql/array.c +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Handling of arrays that can grow dynamicly. */ - -#if defined(WIN32) || defined(__WIN__) -#undef SAFEMALLOC /* Problems with threads */ -#endif - -#include "mysys_priv.h" -#include "m_string.h" - -/* - Initiate array and alloc space for init_alloc elements. Array is usable - even if space allocation failed -*/ - -my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, - uint init_alloc, uint alloc_increment) -{ - DBUG_ENTER("init_dynamic_array"); - if (!alloc_increment) - { - alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16); - if (init_alloc > 8 && alloc_increment > init_alloc * 2) - alloc_increment=init_alloc*2; - } - - if (!init_alloc) - init_alloc=alloc_increment; - array->elements=0; - array->max_element=init_alloc; - array->alloc_increment=alloc_increment; - array->size_of_element=element_size; - if (!(array->buffer=(char*) my_malloc(element_size*init_alloc,MYF(MY_WME)))) - { - array->max_element=0; - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} - - -my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element) -{ - gptr buffer; - if (array->elements == array->max_element) - { /* Call only when nessesary */ - if (!(buffer=alloc_dynamic(array))) - return TRUE; - } - else - { - buffer=array->buffer+(array->elements * array->size_of_element); - array->elements++; - } - memcpy(buffer,element,(size_t) array->size_of_element); - return FALSE; -} - - - /* Alloc room for one element */ - -byte *alloc_dynamic(DYNAMIC_ARRAY *array) -{ - if (array->elements == array->max_element) - { - char *new_ptr; - if (!(new_ptr=(char*) my_realloc(array->buffer,(array->max_element+ - array->alloc_increment)* - array->size_of_element, - MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) - return 0; - array->buffer=new_ptr; - array->max_element+=array->alloc_increment; - } - return array->buffer+(array->elements++ * array->size_of_element); -} - - - /* remove last element from array and return it */ - -byte *pop_dynamic(DYNAMIC_ARRAY *array) -{ - if (array->elements) - return array->buffer+(--array->elements * array->size_of_element); - return 0; -} - - -my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) -{ - if (idx >= array->elements) - { - if (idx >= array->max_element) - { - uint size; - char *new_ptr; - size=(idx+array->alloc_increment)/array->alloc_increment; - size*= array->alloc_increment; - if (!(new_ptr=(char*) my_realloc(array->buffer,size* - array->size_of_element, - MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) - return TRUE; - array->buffer=new_ptr; - array->max_element=size; - } - bzero((gptr) (array->buffer+array->elements*array->size_of_element), - (idx - array->elements)*array->size_of_element); - array->elements=idx+1; - } - memcpy(array->buffer+(idx * array->size_of_element),element, - (size_t) array->size_of_element); - return FALSE; -} - - -void get_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) -{ - if (idx >= array->elements) - { - DBUG_PRINT("warning",("To big array idx: %d, array size is %d", - idx,array->elements)); - bzero(element,array->size_of_element); - return; - } - memcpy(element,array->buffer+idx*array->size_of_element, - (size_t) array->size_of_element); -} - - -void delete_dynamic(DYNAMIC_ARRAY *array) -{ - if (array->buffer) - { - my_free(array->buffer,MYF(MY_WME)); - array->buffer=0; - array->elements=array->max_element=0; - } -} - - -void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) -{ - char *ptr=array->buffer+array->size_of_element*idx; - array->elements--; - memmove(ptr,ptr+array->size_of_element, - (array->elements-idx)*array->size_of_element); -} - - -void freeze_size(DYNAMIC_ARRAY *array) -{ - uint elements=max(array->elements,1); - - if (array->buffer && array->max_element != elements) - { - array->buffer=(char*) my_realloc(array->buffer, - elements*array->size_of_element, - MYF(MY_WME)); - array->max_element=elements; - } -} diff --git a/ext/mysql/libmysql/bchange.c b/ext/mysql/libmysql/bchange.c deleted file mode 100644 index 95d363d52d..0000000000 --- a/ext/mysql/libmysql/bchange.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : bchange.c - Author : Michael widenius - Updated: 1987-03-20 - Defines: bchange() - - bchange(dst, old_length, src, new_length, tot_length) - replaces old_length characters at dst to new_length characters from - src in a buffer with tot_length bytes. -*/ - -#include <global.h> -#include "m_string.h" - -void bchange(register char *dst, uint old_length, register const char *src, uint new_length, uint tot_length) -{ - uint rest=tot_length-old_length; - if (old_length < new_length) - bmove_upp(dst+rest+new_length,dst+tot_length,rest); - else - bmove(dst+new_length,dst+old_length,rest); - memcpy(dst,src,new_length); -} diff --git a/ext/mysql/libmysql/bmove.c b/ext/mysql/libmysql/bmove.c deleted file mode 100644 index f63ff0bd4f..0000000000 --- a/ext/mysql/libmysql/bmove.c +++ /dev/null @@ -1,63 +0,0 @@ -/* File : bmove.c - Author : Richard A. O'Keefe. - Michael Widenius; ifdef MC68000 - Updated: 23 April 1984 - Defines: bmove() - - bmove(dst, src, len) moves exactly "len" bytes from the source "src" - to the destination "dst". It does not check for NUL characters as - strncpy() and strnmov() do. Thus if your C compiler doesn't support - structure assignment, you can simulate it with - bmove(&to, &from, sizeof from); - The standard 4.2bsd routine for this purpose is bcopy. But as bcopy - has its first two arguments the other way around you may find this a - bit easier to get right. - No value is returned. - - Note: the "b" routines are there to exploit certain VAX order codes, - but the MOVC3 instruction will only move 65535 characters. The asm - code is presented for your interest and amusement. -*/ - -#include <global.h> -#include "m_string.h" - -#if !defined(HAVE_BMOVE) && !defined(bmove) - -#if VaxAsm - -void bmove(dst, src, len) - char *dst, *src; - uint len; - { - asm("movc3 12(ap),*8(ap),*4(ap)"); - } - -#else -#if defined(MC68000) && defined(DS90) - -void bmove(dst, src, len) -char *dst,*src; -uint len; /* 0 <= len <= 65535 */ -{ -asm(" movl 12(a7),d0 "); -asm(" subql #1,d0 "); -asm(" blt .L5 "); -asm(" movl 4(a7),a1 "); -asm(" movl 8(a7),a0 "); -asm(".L4: movb (a0)+,(a1)+ "); -asm(" dbf d0,.L4 "); -asm(".L5: "); -} -#else - -void bmove(dst, src, len) -register char *dst; -register const char *src; -register uint len; -{ - while (len-- != 0) *dst++ = *src++; -} -#endif -#endif -#endif diff --git a/ext/mysql/libmysql/bmove_upp.c b/ext/mysql/libmysql/bmove_upp.c deleted file mode 100644 index e10f6978f7..0000000000 --- a/ext/mysql/libmysql/bmove_upp.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : bmove.c - Author : Michael widenius - Updated: 1987-03-20 - Defines: bmove_upp() - - bmove_upp(dst, src, len) moves exactly "len" bytes from the source - "src-len" to the destination "dst-len" counting downwards. -*/ - -#include <global.h> -#include "m_string.h" - -#if defined(MC68000) && defined(DS90) - -/* 0 <= len <= 65535 */ -void bmove_upp(byte *dst, const byte *src,uint len) -{ -asm(" movl 12(a7),d0 "); -asm(" subql #1,d0 "); -asm(" blt .L5 "); -asm(" movl 4(a7),a1 "); -asm(" movl 8(a7),a0 "); -asm(".L4: movb -(a0),-(a1) "); -asm(" dbf d0,.L4 "); -asm(".L5: "); -} -#else - -void bmove_upp(register char *dst, register const char *src, register uint len) -{ - while (len-- != 0) *--dst = *--src; -} - -#endif diff --git a/ext/mysql/libmysql/charset.c b/ext/mysql/libmysql/charset.c deleted file mode 100644 index 29df5c5bdf..0000000000 --- a/ext/mysql/libmysql/charset.c +++ /dev/null @@ -1,550 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <m_ctype.h> -#include <m_string.h> -#include <my_dir.h> - -typedef struct cs_id_st { - char *name; - uint number; -} CS_ID; - -const char *charsets_dir = NULL; -static DYNAMIC_ARRAY cs_info_table; -static CS_ID **available_charsets; -static int charset_initialized=0; - -#define MAX_LINE 1024 - -#define CTYPE_TABLE_SIZE 257 -#define TO_LOWER_TABLE_SIZE 256 -#define TO_UPPER_TABLE_SIZE 256 -#define SORT_ORDER_TABLE_SIZE 256 - -struct simpleconfig_buf_st { - FILE *f; - char buf[MAX_LINE]; - char *p; -}; - -/* Defined in strings/ctype.c */ - -CHARSET_INFO *find_compiled_charset(uint cs_number); -uint compiled_charset_number(const char *name); -const char *compiled_charset_name(uint charset_number); - - -static uint num_from_csname(CS_ID **cs, const char *name) -{ - CS_ID **c; - for (c = cs; *c; ++c) - if (!strcmp((*c)->name, name)) - return (*c)->number; - return 0; /* this mimics find_type() */ -} - -static char *name_from_csnum(CS_ID **cs, uint number) -{ - CS_ID **c; - if(cs) - for (c = cs; *c; ++c) - if ((*c)->number == number) - return (*c)->name; - return (char*) "?"; /* this mimics find_type() */ -} - -static my_bool get_word(struct simpleconfig_buf_st *fb, char *buf) -{ - char *endptr=fb->p; - - for (;;) - { - while (isspace(*endptr)) - ++endptr; - if (*endptr && *endptr != '#') /* Not comment */ - break; /* Found something */ - if ((fgets(fb->buf, sizeof(fb->buf), fb->f)) == NULL) - return TRUE; /* end of file */ - endptr = fb->buf; - } - - while (!isspace(*endptr)) - *buf++= *endptr++; - *buf=0; - fb->p = endptr; - - return FALSE; -} - - -char *get_charsets_dir(char *buf) -{ - const char *sharedir = SHAREDIR; - DBUG_ENTER("get_charsets_dir"); - - if (charsets_dir != NULL) - strmake(buf, charsets_dir, FN_REFLEN-1); - else - { - if (test_if_hard_path(sharedir) || - is_prefix(sharedir, DEFAULT_CHARSET_HOME)) - strxmov(buf, sharedir, "/", CHARSET_DIR, NullS); - else - strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR, - NullS); - } - convert_dirname(buf); - DBUG_PRINT("info",("charsets dir='%s'", buf)); - DBUG_RETURN(strend(buf)); -} - - -static my_bool read_charset_index(CS_ID ***charsets, myf myflags) -{ - struct simpleconfig_buf_st fb; - char buf[MAX_LINE], num_buf[MAX_LINE]; - DYNAMIC_ARRAY cs; - CS_ID *csid; - - strmov(get_charsets_dir(buf), "Index"); - - if ((fb.f = my_fopen(buf, O_RDONLY, myflags)) == NULL) - return TRUE; - fb.buf[0] = '\0'; - fb.p = fb.buf; - - if (init_dynamic_array(&cs, sizeof(CS_ID *), 32, 32)) - return TRUE; - - while (!get_word(&fb, buf) && !get_word(&fb, num_buf)) - { - uint csnum; - uint length; - - if (!(csnum = atoi(num_buf))) - { - /* corrupt Index file */ - my_fclose(fb.f,myflags); - return TRUE; - } - - if (!(csid = (CS_ID*) my_once_alloc(sizeof(CS_ID), myflags)) || - !(csid->name= - (char*) my_once_alloc(length= (uint) strlen(buf)+1, myflags))) - { - my_fclose(fb.f,myflags); - return TRUE; - } - memcpy(csid->name,buf,length); - csid->number = csnum; - - insert_dynamic(&cs, (gptr) &csid); - } - my_fclose(fb.f,myflags); - - - if (!(*charsets = - (CS_ID **) my_once_alloc((cs.elements + 1) * sizeof(CS_ID *), myflags))) - return TRUE; - /* unwarranted chumminess with dynamic_array implementation? */ - memcpy((byte *) *charsets, cs.buffer, cs.elements * sizeof(CS_ID *)); - (*charsets)[cs.elements] = NULL; - delete_dynamic(&cs); - - return FALSE; -} - - -static my_bool init_available_charsets(myf myflags) -{ - my_bool error=0; - /* - We have to use charset_initialized to not lock on THR_LOCK_charset - inside get_internal_charset... - */ - if (!charset_initialized) - { - /* - To make things thread safe we are not allowing other threads to interfere - while we may changing the cs_info_table - */ - pthread_mutex_lock(&THR_LOCK_charset); - if (!cs_info_table.buffer) /* If not initialized */ - { - init_dynamic_array(&cs_info_table, sizeof(CHARSET_INFO*), 16, 8); - error = read_charset_index(&available_charsets, myflags); - } - charset_initialized=1; - pthread_mutex_unlock(&THR_LOCK_charset); - } - if(!available_charsets || !available_charsets[0]) - error = TRUE; - return error; -} - - -void free_charsets(void) -{ - delete_dynamic(&cs_info_table); -} - - -static my_bool fill_array(uchar *array, int sz, struct simpleconfig_buf_st *fb) -{ - char buf[MAX_LINE]; - while (sz--) - { - if (get_word(fb, buf)) - { - DBUG_PRINT("error",("get_word failed, expecting %d more words", sz + 1)); - return 1; - } - *array++ = (uchar) strtol(buf, NULL, 16); - } - return 0; -} - - -static void get_charset_conf_name(uint cs_number, char *buf) -{ - strxmov(get_charsets_dir(buf), - name_from_csnum(available_charsets, cs_number), ".conf", NullS); -} - - -static my_bool read_charset_file(uint cs_number, CHARSET_INFO *set, - myf myflags) -{ - struct simpleconfig_buf_st fb; - char buf[FN_REFLEN]; - my_bool result; - DBUG_ENTER("read_charset_file"); - DBUG_PRINT("enter",("cs_number: %d", cs_number)); - - if (cs_number <= 0) - DBUG_RETURN(TRUE); - - get_charset_conf_name(cs_number, buf); - DBUG_PRINT("info",("file name: %s", buf)); - - if ((fb.f = my_fopen(buf, O_RDONLY, myflags)) == NULL) - DBUG_RETURN(TRUE); - - fb.buf[0] = '\0'; /* Init for get_word */ - fb.p = fb.buf; - - result=FALSE; - if (fill_array(set->ctype, CTYPE_TABLE_SIZE, &fb) || - fill_array(set->to_lower, TO_LOWER_TABLE_SIZE, &fb) || - fill_array(set->to_upper, TO_UPPER_TABLE_SIZE, &fb) || - fill_array(set->sort_order, SORT_ORDER_TABLE_SIZE, &fb)) - result=TRUE; - - my_fclose(fb.f, MYF(0)); - DBUG_RETURN(result); -} - - -uint get_charset_number(const char *charset_name) -{ - my_bool error; - error = init_available_charsets(MYF(0)); /* If it isn't initialized */ - if (error) - return compiled_charset_number(charset_name); - else - return num_from_csname(available_charsets, charset_name); -} - -const char *get_charset_name(uint charset_number) -{ - my_bool error; - error = init_available_charsets(MYF(0)); /* If it isn't initialized */ - if (error) - return compiled_charset_name(charset_number); - else - return name_from_csnum(available_charsets, charset_number); -} - - -static CHARSET_INFO *find_charset(CHARSET_INFO **table, uint cs_number, - size_t tablesz) -{ - uint i; - for (i = 0; i < tablesz; ++i) - if (table[i]->number == cs_number) - return table[i]; - return NULL; -} - -static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table, const char *name, - size_t tablesz) -{ - uint i; - for (i = 0; i < tablesz; ++i) - if (!strcmp(table[i]->name,name)) - return table[i]; - return NULL; -} - -static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name) -{ - CHARSET_INFO tmp_cs,*cs; - uchar tmp_ctype[CTYPE_TABLE_SIZE]; - uchar tmp_to_lower[TO_LOWER_TABLE_SIZE]; - uchar tmp_to_upper[TO_UPPER_TABLE_SIZE]; - uchar tmp_sort_order[SORT_ORDER_TABLE_SIZE]; - - /* Don't allocate memory if we are not sure we can find the char set */ - cs= &tmp_cs; - bzero((char*) cs, sizeof(*cs)); - cs->ctype=tmp_ctype; - cs->to_lower=tmp_to_lower; - cs->to_upper=tmp_to_upper; - cs->sort_order=tmp_sort_order; - if (read_charset_file(cs_number, cs, MYF(MY_WME))) - return NULL; - - cs = (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO), - MYF(MY_WME)); - *cs=tmp_cs; - cs->name = (char *) my_once_alloc((uint) strlen(cs_name)+1, MYF(MY_WME)); - cs->ctype = (uchar*) my_once_alloc(CTYPE_TABLE_SIZE, MYF(MY_WME)); - cs->to_lower = (uchar*) my_once_alloc(TO_LOWER_TABLE_SIZE, MYF(MY_WME)); - cs->to_upper = (uchar*) my_once_alloc(TO_UPPER_TABLE_SIZE, MYF(MY_WME)); - cs->sort_order=(uchar*) my_once_alloc(SORT_ORDER_TABLE_SIZE, MYF(MY_WME)); - cs->number = cs_number; - memcpy((char*) cs->name, (char*) cs_name, strlen(cs_name) + 1); - memcpy((char*) cs->ctype, (char*) tmp_ctype, sizeof(tmp_ctype)); - memcpy((char*) cs->to_lower, (char*) tmp_to_lower, sizeof(tmp_to_lower)); - memcpy((char*) cs->to_upper, (char*) tmp_to_upper, sizeof(tmp_to_upper)); - memcpy((char*) cs->sort_order, (char*) tmp_sort_order, - sizeof(tmp_sort_order)); - insert_dynamic(&cs_info_table, (gptr) &cs); - return cs; -} - -static CHARSET_INFO *get_internal_charset(uint cs_number) -{ - CHARSET_INFO *cs; - /* - To make things thread safe we are not allowing other threads to interfere - while we may changing the cs_info_table - */ - pthread_mutex_lock(&THR_LOCK_charset); - if (!(cs = find_charset((CHARSET_INFO**) cs_info_table.buffer, cs_number, - cs_info_table.elements))) - if (!(cs = find_compiled_charset(cs_number))) - cs=add_charset(cs_number, get_charset_name(cs_number)); - pthread_mutex_unlock(&THR_LOCK_charset); - return cs; -} - - -static CHARSET_INFO *get_internal_charset_by_name(const char *name) -{ - CHARSET_INFO *cs; - /* - To make things thread safe we are not allowing other threads to interfere - while we may changing the cs_info_table - */ - pthread_mutex_lock(&THR_LOCK_charset); - if (!(cs = find_charset_by_name((CHARSET_INFO**) cs_info_table.buffer, name, - cs_info_table.elements))) - if (!(cs = find_compiled_charset_by_name(name))) - cs=add_charset(get_charset_number(name), name); - pthread_mutex_unlock(&THR_LOCK_charset); - return cs; -} - - -CHARSET_INFO *get_charset(uint cs_number, myf flags) -{ - CHARSET_INFO *cs; - (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - cs=get_internal_charset(cs_number); - - if (!cs && (flags & MY_WME)) - { - char index_file[FN_REFLEN], cs_string[23]; - strmov(get_charsets_dir(index_file), "Index"); - cs_string[0]='#'; - int10_to_str(cs_number, cs_string+1, 10); - my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_string, index_file); - } - return cs; -} - -my_bool set_default_charset(uint cs, myf flags) -{ - CHARSET_INFO *new_charset; - DBUG_ENTER("set_default_charset"); - DBUG_PRINT("enter",("character set: %d",(int) cs)); - new_charset = get_charset(cs, flags); - if (!new_charset) - { - DBUG_PRINT("error",("Couldn't set default character set")); - DBUG_RETURN(TRUE); /* error */ - } - default_charset_info = new_charset; - DBUG_RETURN(FALSE); -} - -CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags) -{ - CHARSET_INFO *cs; - (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - cs=get_internal_charset_by_name(cs_name); - - if (!cs && (flags & MY_WME)) - { - char index_file[FN_REFLEN]; - strmov(get_charsets_dir(index_file), "Index"); - my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file); - } - - return cs; -} - -my_bool set_default_charset_by_name(const char *cs_name, myf flags) -{ - CHARSET_INFO *new_charset; - DBUG_ENTER("set_default_charset_by_name"); - DBUG_PRINT("enter",("character set: %s", cs_name)); - new_charset = get_charset_by_name(cs_name, flags); - if (!new_charset) - { - DBUG_PRINT("error",("Couldn't set default character set")); - DBUG_RETURN(TRUE); /* error */ - } - - default_charset_info = new_charset; - DBUG_RETURN(FALSE); -} - -/* Only append name if it doesn't exist from before */ - -static my_bool charset_in_string(const char *name, DYNAMIC_STRING *s) -{ - uint length= (uint) strlen(name); - const char *pos; - for (pos=s->str ; (pos=strstr(pos,name)) ; pos++) - { - if (! pos[length] || pos[length] == ' ') - return TRUE; /* Already existed */ - } - - return FALSE; -} - -static void charset_append(DYNAMIC_STRING *s, const char *name) -{ - if (!charset_in_string(name, s)) { - dynstr_append(s, name); - dynstr_append(s, " "); - } -} - - -/* Returns a dynamically-allocated string listing the character sets - requested. The caller is responsible for freeing the memory. */ - -char * list_charsets(myf want_flags) -{ - DYNAMIC_STRING s; - char *p; - - (void)init_available_charsets(MYF(0)); - init_dynamic_string(&s, NullS, 256, 1024); - - if (want_flags & MY_COMPILED_SETS) - { - CHARSET_INFO *cs; - for (cs = compiled_charsets; cs->number > 0; cs++) - { - dynstr_append(&s, cs->name); - dynstr_append(&s, " "); - } - } - - if (want_flags & MY_CONFIG_SETS) - { - CS_ID **c; - char buf[FN_REFLEN]; - MY_STAT status; - - if((c=available_charsets)) - for (; *c; ++c) - { - if (charset_in_string((*c)->name, &s)) - continue; - get_charset_conf_name((*c)->number, buf); - if (!my_stat(buf, &status, MYF(0))) - continue; /* conf file doesn't exist */ - dynstr_append(&s, (*c)->name); - dynstr_append(&s, " "); - } - } - - if (want_flags & MY_INDEX_SETS) - { - CS_ID **c; - for (c = available_charsets; *c; ++c) - charset_append(&s, (*c)->name); - } - - if (want_flags & MY_LOADED_SETS) - { - uint i; - for (i = 0; i < cs_info_table.elements; i++) - charset_append(&s, - dynamic_element(&cs_info_table, i, CHARSET_INFO *)->name); - } - s.str[s.length - 1] = '\0'; /* chop trailing space */ - p = my_strdup(s.str, MYF(MY_WME)); - dynstr_free(&s); - - return p; -} - -/**************************************************************************** -* Code for debugging. -****************************************************************************/ - - -static void _print_array(uint8 *data, uint size) -{ - uint i; - for (i = 0; i < size; ++i) - { - if (i == 0 || i % 16 == size % 16) printf(" "); - printf(" %02x", data[i]); - if ((i+1) % 16 == size % 16) printf("\n"); - } -} - -/* _print_csinfo is called from test_charset.c */ -void _print_csinfo(CHARSET_INFO *cs) -{ - printf("%s #%d\n", cs->name, cs->number); - printf("ctype:\n"); _print_array(cs->ctype, 257); - printf("to_lower:\n"); _print_array(cs->to_lower, 256); - printf("to_upper:\n"); _print_array(cs->to_upper, 256); - printf("sort_order:\n"); _print_array(cs->sort_order, 256); - printf("collate: %3s (%d, %p, %p, %p, %p, %p)\n", - cs->strxfrm_multiply ? "yes" : "no", - cs->strxfrm_multiply, - cs->strcoll, - cs->strxfrm, - cs->strnncoll, - cs->strnxfrm, - cs->like_range); - printf("multi-byte: %3s (%d, %p, %p, %p)\n", - cs->mbmaxlen ? "yes" : "no", - cs->mbmaxlen, - cs->ismbchar, - cs->ismbhead, - cs->mbcharlen); -} diff --git a/ext/mysql/libmysql/config-win.h b/ext/mysql/libmysql/config-win.h deleted file mode 100644 index 363daab39a..0000000000 --- a/ext/mysql/libmysql/config-win.h +++ /dev/null @@ -1,293 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 -- not with PHP, please */ - -#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 FN_LOWER_CASE TRUE /* Files are represented in lower case */ -#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)) diff --git a/ext/mysql/libmysql/ctype.c b/ext/mysql/libmysql/ctype.c deleted file mode 100644 index 49827a16ab..0000000000 --- a/ext/mysql/libmysql/ctype.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include <global.h> -#include <m_ctype.h> -#include <m_string.h> - -/* generated by make, using conf_to_src */ -#include "ctype_extra_sources.c" - -/* generated by configure */ -#include "ctype_autoconf.c" - -CHARSET_INFO *default_charset_info = &compiled_charsets[0]; - -CHARSET_INFO *find_compiled_charset(uint cs_number) -{ - CHARSET_INFO *cs; - for (cs = compiled_charsets; cs->number > 0; cs++) - if (cs->number == cs_number) - return cs; - - return NULL; -} - -CHARSET_INFO *find_compiled_charset_by_name(const char *name) -{ - CHARSET_INFO *cs; - for (cs = compiled_charsets; cs->number > 0; cs++) - if (!strcmp(cs->name, name)) - return cs; - - return NULL; -} - -uint compiled_charset_number(const char *name) -{ - CHARSET_INFO *cs; - for (cs = compiled_charsets; cs->number > 0; cs++) - if (!strcmp(cs->name, name)) - return cs->number; - - return 0; /* this mimics find_type() */ -} - -const char *compiled_charset_name(uint charset_number) -{ - CHARSET_INFO *cs; - for (cs = compiled_charsets; cs->number > 0; cs++) - if (cs->number == charset_number) - return cs->name; - - return "?"; /* this mimics get_type() */ -} diff --git a/ext/mysql/libmysql/ctype_autoconf.c b/ext/mysql/libmysql/ctype_autoconf.c deleted file mode 100644 index 22da693433..0000000000 --- a/ext/mysql/libmysql/ctype_autoconf.c +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is generated automatically by configure. */ - -CHARSET_INFO compiled_charsets[] = { - - /* this information is filled in by configure */ - { - 8, /* number */ - "latin1", /* name */ - ctype_latin1, - to_lower_latin1, - to_upper_latin1, - sort_order_latin1, - 0, /* strxfrm_multiply */ - NULL, /* strcoll */ - NULL, /* strxfrm */ - NULL, /* strnncoll */ - NULL, /* strnxfrm */ - NULL, /* like_range */ - 0, /* mbmaxlen */ - NULL, /* ismbchar */ - NULL, /* ismbhead */ - NULL /* mbcharlen */ - }, - - /* this information is filled in by configure */ - { - 0, /* end-of-list marker */ - NullS, - NULL, - NULL, - NULL, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - NULL, - NULL, - NULL - } -}; diff --git a/ext/mysql/libmysql/ctype_extra_sources.c b/ext/mysql/libmysql/ctype_extra_sources.c deleted file mode 100644 index 97f0d38646..0000000000 --- a/ext/mysql/libmysql/ctype_extra_sources.c +++ /dev/null @@ -1,82 +0,0 @@ -/* The latin1 character set. Generated automatically by configure and - * the ./conf_to_src program - */ - -uchar ctype_latin1[] = { - 0, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16, - 16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16, - 16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 16, 2, 2, 2, 2, 2, 2, 2, 2 -}; - -uchar to_lower_latin1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, - 112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95, - 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, - 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,215,248,249,250,251,252,253,254,223, - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 -}; - -uchar to_upper_latin1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127, - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, - 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, - 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,247,216,217,218,219,220,221,222,255 -}; - -uchar sort_order_latin1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127, - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, - 65, 65, 65, 65, 92, 91, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73, - 68, 78, 79, 79, 79, 79, 93,215,216, 85, 85, 85, 89, 89,222,223, - 65, 65, 65, 65, 92, 91, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73, - 68, 78, 79, 79, 79, 79, 93,247,216, 85, 85, 85, 89, 89,222,255 -}; - - diff --git a/ext/mysql/libmysql/dbug.c b/ext/mysql/libmysql/dbug.c deleted file mode 100644 index cfe4ca161c..0000000000 --- a/ext/mysql/libmysql/dbug.c +++ /dev/null @@ -1,2069 +0,0 @@ -/****************************************************************************** - * * - * N O T I C E * - * * - * Copyright Abandoned, 1987, Fred Fish * - * * - * * - * This previously copyrighted work has been placed into the public * - * domain by the author and may be freely used for any purpose, * - * private or commercial. * - * * - * Because of the number of inquiries I was receiving about the use * - * of this product in commercially developed works I have decided to * - * simply make it public domain to further its unrestricted use. I * - * specifically would be most happy to see this material become a * - * part of the standard Unix distributions by AT&T and the Berkeley * - * Computer Science Research Group, and a standard part of the GNU * - * system from the Free Software Foundation. * - * * - * I would appreciate it, as a courtesy, if this notice is left in * - * all copies and derivative works. Thank you. * - * * - * The author makes no warranty of any kind with respect to this * - * product and explicitly disclaims any implied warranties of mer- * - * chantability or fitness for any particular purpose. * - * * - ****************************************************************************** - */ - - -/* - * FILE - * - * dbug.c runtime support routines for dbug package - * - * SCCS - * - * @(#)dbug.c 1.25 7/25/89 - * - * DESCRIPTION - * - * These are the runtime support routines for the dbug package. - * The dbug package has two main components; the user include - * file containing various macro definitions, and the runtime - * support routines which are called from the macro expansions. - * - * Externally visible functions in the runtime support module - * use the naming convention pattern "_db_xx...xx_", thus - * they are unlikely to collide with user defined function names. - * - * AUTHOR(S) - * - * Fred Fish (base code) - * Enhanced Software Technologies, Tempe, AZ - * asuvax!mcdphx!estinc!fnf - * - * Binayak Banerjee (profiling enhancements) - * seismo!bpa!sjuvax!bbanerje - * - * Michael Widenius: - * DBUG_DUMP - To dump a pice of memory. - * PUSH_FLAG "O" - To be used insted of "o" if we don't - * want flushing (for slow systems) - * PUSH_FLAG "A" - as 'O', but we will append to the out file instead - * of creating a new one. - * Check of malloc on entry/exit (option "S") - */ - -#ifdef DBUG_OFF -#undef DBUG_OFF -#endif -#include <global.h> -#include <m_string.h> -#include <errno.h> -#if defined(MSDOS) || defined(__WIN__) -#include <process.h> -#endif - -#ifdef _DBUG_CONDITION_ -#define _DBUG_START_CONDITION_ "d:t" -#else -#define _DBUG_START_CONDITION_ "" -#endif - -/* - * Manifest constants that should not require any changes. - */ - -#define EOS '\000' /* End Of String marker */ - -/* - * Manifest constants which may be "tuned" if desired. - */ - -#define PRINTBUF 1024 /* Print buffer size */ -#define INDENT 2 /* Indentation per trace level */ -#define MAXDEPTH 200 /* Maximum trace depth default */ - -/* - * The following flags are used to determine which - * capabilities the user has enabled with the state - * push macro. - */ - -#define TRACE_ON 000001 /* Trace enabled */ -#define DEBUG_ON 000002 /* Debug enabled */ -#define FILE_ON 000004 /* File name print enabled */ -#define LINE_ON 000010 /* Line number print enabled */ -#define DEPTH_ON 000020 /* Function nest level print enabled */ -#define PROCESS_ON 000040 /* Process name print enabled */ -#define NUMBER_ON 000100 /* Number each line of output */ -#define PROFILE_ON 000200 /* Print out profiling code */ -#define PID_ON 000400 /* Identify each line with process id */ -#define SANITY_CHECK_ON 001000 /* Check safemalloc on DBUG_ENTER */ -#define FLUSH_ON_WRITE 002000 /* Flush on every write */ - -#define TRACING (stack -> flags & TRACE_ON) -#define DEBUGGING (stack -> flags & DEBUG_ON) -#define PROFILING (stack -> flags & PROFILE_ON) -#define STREQ(a,b) (strcmp(a,b) == 0) - -/* - * Typedefs to make things more obvious. - */ - -#ifndef __WIN__ -typedef int BOOLEAN; -#else -#define BOOLEAN BOOL -#endif - -/* - * Make it easy to change storage classes if necessary. - */ - -#define IMPORT extern /* Names defined externally */ -#define EXPORT /* Allocated here, available globally */ -#define AUTO auto /* Names to be allocated on stack */ -#define REGISTER register /* Names to be placed in registers */ - -/* - * The default file for profiling. Could also add another flag - * (G?) which allowed the user to specify this. - * - * If the automatic variables get allocated on the stack in - * reverse order from their declarations, then define AUTOS_REVERSE. - * This is used by the code that keeps track of stack usage. For - * forward allocation, the difference in the dbug frame pointers - * represents stack used by the callee function. For reverse allocation, - * the difference represents stack used by the caller function. - * - */ - -#define PROF_FILE "dbugmon.out" -#define PROF_EFMT "E\t%ld\t%s\n" -#define PROF_SFMT "S\t%lx\t%lx\t%s\n" -#define PROF_XFMT "X\t%ld\t%s\n" - -#ifdef M_I386 /* predefined by xenix 386 compiler */ -#define AUTOS_REVERSE 1 -#endif - -/* - * Variables which are available externally but should only - * be accessed via the macro package facilities. - */ - -EXPORT FILE *_db_fp_ = (FILE *) 0; /* Output stream, default stderr */ -EXPORT char *_db_process_ = (char*) "dbug"; /* Pointer to process name; argv[0] */ -EXPORT FILE *_db_pfp_ = (FILE *)0; /* Profile stream, 'dbugmon.out' */ -EXPORT BOOLEAN _db_on_ = FALSE; /* TRUE if debugging currently on */ -EXPORT BOOLEAN _db_pon_ = FALSE; /* TRUE if profile currently on */ -EXPORT BOOLEAN _no_db_ = FALSE; /* TRUE if no debugging at all */ - -/* - * Externally supplied functions. - */ - -#ifndef HAVE_PERROR -static void perror (); /* Fake system/library error print routine */ -#endif - -IMPORT int _sanity(const char *file,uint line); - -/* - * The user may specify a list of functions to trace or - * debug. These lists are kept in a linear linked list, - * a very simple implementation. - */ - -struct link { - char *str; /* Pointer to link's contents */ - struct link *next_link; /* Pointer to the next link */ -}; - -/* - * Debugging states can be pushed or popped off of a - * stack which is implemented as a linked list. Note - * that the head of the list is the current state and the - * stack is pushed by adding a new state to the head of the - * list or popped by removing the first link. - */ - -struct state { - int flags; /* Current state flags */ - int maxdepth; /* Current maximum trace depth */ - uint delay; /* Delay after each output line */ - int sub_level; /* Sub this from code_state->level */ - FILE *out_file; /* Current output stream */ - FILE *prof_file; /* Current profiling stream */ - char name[FN_REFLEN]; /* Name of output file */ - struct link *functions; /* List of functions */ - struct link *p_functions; /* List of profiled functions */ - struct link *keywords; /* List of debug keywords */ - struct link *processes; /* List of process names */ - struct state *next_state; /* Next state in the list */ -}; - - -/* - * Local variables not seen by user. - */ - - -static my_bool init_done = FALSE; /* Set to TRUE when initialization done */ -static struct state *stack=0; - -typedef struct st_code_state { - int lineno; /* Current debugger output line number */ - int level; /* Current function nesting level */ - const char *func; /* Name of current user function */ - const char *file; /* Name of current user file */ - char **framep; /* Pointer to current frame */ - int jmplevel; /* Remember nesting level at setjmp () */ - const char *jmpfunc; /* Remember current function for setjmp */ - const char *jmpfile; /* Remember current file for setjmp */ - -/* - * The following variables are used to hold the state information - * between the call to _db_pargs_() and _db_doprnt_(), during - * expansion of the DBUG_PRINT macro. This is the only macro - * that currently uses these variables. - * - * These variables are currently used only by _db_pargs_() and - * _db_doprnt_(). - */ - - uint u_line; /* User source code line number */ - const char *u_keyword; /* Keyword for current macro */ - int locked; /* If locked with _db_lock_file */ -} CODE_STATE; - - /* Parse a debug command string */ -static struct link *ListParse(char *ctlp); - /* Make a fresh copy of a string */ -static char *StrDup(const char *str); - /* Open debug output stream */ -static void DBUGOpenFile(const char *name, int append); -#ifndef THREAD - /* Open profile output stream */ -static FILE *OpenProfile(const char *name); - /* Profile if asked for it */ -static BOOLEAN DoProfile(void); -#endif - /* Return current user time (ms) */ -#ifndef THREAD -static unsigned long Clock (void); -#endif - /* Close debug output stream */ -static void CloseFile(FILE *fp); - /* Push current debug state */ -static void PushState(void); - /* Test for tracing enabled */ -static BOOLEAN DoTrace(CODE_STATE *state); - /* Test to see if file is writable */ -#if !(!defined(HAVE_ACCESS) || defined(MSDOS)) -static BOOLEAN Writable(char *pathname); - /* Change file owner and group */ -static void ChangeOwner(char *pathname); - /* Allocate memory for runtime support */ -#endif -static char *DbugMalloc(int size); - /* Remove leading pathname components */ -static char *BaseName(const char *pathname); -static void DoPrefix(uint line); -static void FreeList(struct link *linkp); -static void Indent(int indent); -static BOOLEAN InList(struct link *linkp,const char *cp); -static void dbug_flush(CODE_STATE *); -static void DbugExit(const char *why); -static int DelayArg(int value); - /* Supplied in Sys V runtime environ */ - /* Break string into tokens */ -static char *static_strtok(char *s1,pchar chr); - -/* - * Miscellaneous printf format strings. - */ - -#define ERR_MISSING_RETURN "%s: missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n" -#define ERR_OPEN "%s: can't open debug output stream \"%s\": " -#define ERR_CLOSE "%s: can't close debug file: " -#define ERR_ABORT "%s: debugger aborting because %s\n" -#define ERR_CHOWN "%s: can't change owner/group of \"%s\": " - -/* - * Macros and defines for testing file accessibility under UNIX and MSDOS. - */ - -#undef EXISTS -#if !defined(HAVE_ACCESS) || defined(MSDOS) -#define EXISTS(pathname) (FALSE) /* Assume no existance */ -#define Writable(name) (TRUE) -#else -#define EXISTS(pathname) (access (pathname, F_OK) == 0) -#define WRITABLE(pathname) (access (pathname, W_OK) == 0) -#endif -#ifndef MSDOS -#define ChangeOwner(name) -#endif - -/* - * Translate some calls among different systems. - */ - -#if defined(unix) || defined(xenix) || defined(VMS) || defined(__NetBSD__) -# define Delay(A) sleep((uint) A) -#elif defined(AMIGA) -IMPORT int Delay (); /* Pause for given number of ticks */ -#else -static int Delay(int ticks); -#endif - - -/* -** Macros to allow dbugging with threads -*/ - -#ifdef THREAD -#include <my_pthread.h> -pthread_mutex_t THR_LOCK_dbug; - -static void init_dbug_state(void) -{ - pthread_mutex_init(&THR_LOCK_dbug,MY_MUTEX_INIT_FAST); -} - -static CODE_STATE *code_state(void) -{ - CODE_STATE *state=0; - struct st_my_thread_var *tmp=my_thread_var; - if (tmp) - { - if (!(state=(CODE_STATE *) tmp->dbug)) - { - state=(CODE_STATE*) DbugMalloc(sizeof(*state)); - bzero((char*) state,sizeof(*state)); - state->func="?func"; - state->file="?file"; - tmp->dbug=(gptr) state; - } - } - return state; -} - -#else /* !THREAD */ - -#define init_dbug_state() -#define code_state() (&static_code_state) -#define pthread_mutex_lock(A) {} -#define pthread_mutex_unlock(A) {} -static CODE_STATE static_code_state = { 0,0,"?func","?file",NULL,0,NULL, - NULL,0,"?",0}; -#endif - - -/* - * FUNCTION - * - * _db_push_ push current debugger state and set up new one - * - * SYNOPSIS - * - * VOID _db_push_ (control) - * char *control; - * - * DESCRIPTION - * - * Given pointer to a debug control string in "control", pushes - * the current debug state, parses the control string, and sets - * up a new debug state. - * - * The only attribute of the new state inherited from the previous - * state is the current function nesting level. This can be - * overridden by using the "r" flag in the control string. - * - * The debug control string is a sequence of colon separated fields - * as follows: - * - * <field_1>:<field_2>:...:<field_N> - * - * Each field consists of a mandatory flag character followed by - * an optional "," and comma separated list of modifiers: - * - * flag[,modifier,modifier,...,modifier] - * - * The currently recognized flag characters are: - * - * d Enable output from DBUG_<N> macros for - * for the current state. May be followed - * by a list of keywords which selects output - * only for the DBUG macros with that keyword. - * A null list of keywords implies output for - * all macros. - * - * D Delay after each debugger output line. - * The argument is the number of tenths of seconds - * to delay, subject to machine capabilities. - * I.E. -#D,20 is delay two seconds. - * - * f Limit debugging and/or tracing, and profiling to the - * list of named functions. Note that a null list will - * disable all functions. The appropriate "d" or "t" - * flags must still be given, this flag only limits their - * actions if they are enabled. - * - * F Identify the source file name for each - * line of debug or trace output. - * - * i Identify the process with the pid for each line of - * debug or trace output. - * - * g Enable profiling. Create a file called 'dbugmon.out' - * containing information that can be used to profile - * the program. May be followed by a list of keywords - * that select profiling only for the functions in that - * list. A null list implies that all functions are - * considered. - * - * L Identify the source file line number for - * each line of debug or trace output. - * - * n Print the current function nesting depth for - * each line of debug or trace output. - * - * N Number each line of dbug output. - * - * o Redirect the debugger output stream to the - * specified file. The default output is stderr. - * - * O As O but the file is really flushed between each - * write. When neaded the file is closed and reopened - * between each write. - * - * p Limit debugger actions to specified processes. - * A process must be identified with the - * DBUG_PROCESS macro and match one in the list - * for debugger actions to occur. - * - * P Print the current process name for each - * line of debug or trace output. - * - * r When pushing a new state, do not inherit - * the previous state's function nesting level. - * Useful when the output is to start at the - * left margin. - * - * S Do function _sanity(_file_,_line_) at each - * debugged function until _sanity() returns - * something that differs from 0. - * (Moustly used with safemalloc) - * - * t Enable function call/exit trace lines. - * May be followed by a list (containing only - * one modifier) giving a numeric maximum - * trace level, beyond which no output will - * occur for either debugging or tracing - * macros. The default is a compile time - * option. - * - * Some examples of debug control strings which might appear - * on a shell command line (the "-#" is typically used to - * introduce a control string to an application program) are: - * - * -#d:t - * -#d:f,main,subr1:F:L:t,20 - * -#d,input,output,files:n - * - * For convenience, any leading "-#" is stripped off. - * - */ - -void _db_push_ (const char *control) -{ - reg1 char *scan; - reg2 struct link *temp; - CODE_STATE *state; - char *new_str; - - if (! _db_fp_) - _db_fp_= stderr; /* Output stream, default stderr */ - - if (control && *control == '-') - { - if (*++control == '#') - control++; - } - if (*control) - _no_db_=0; /* We are using dbug after all */ - - new_str = StrDup (control); - PushState (); - state=code_state(); - - scan = static_strtok (new_str, ':'); - for (; scan != NULL; scan = static_strtok ((char *)NULL, ':')) { - switch (*scan++) { - case 'd': - _db_on_ = TRUE; - stack -> flags |= DEBUG_ON; - if (*scan++ == ',') { - stack -> keywords = ListParse (scan); - } - break; - case 'D': - stack -> delay = 0; - if (*scan++ == ',') { - temp = ListParse (scan); - stack -> delay = DelayArg (atoi (temp -> str)); - FreeList (temp); - } - break; - case 'f': - if (*scan++ == ',') { - stack -> functions = ListParse (scan); - } - break; - case 'F': - stack -> flags |= FILE_ON; - break; - case 'i': - stack -> flags |= PID_ON; - break; -#ifndef THREAD - case 'g': - _db_pon_ = TRUE; - if (OpenProfile(PROF_FILE)) - { - stack -> flags |= PROFILE_ON; - if (*scan++ == ',') - stack -> p_functions = ListParse (scan); - } - break; -#endif - case 'L': - stack -> flags |= LINE_ON; - break; - case 'n': - stack -> flags |= DEPTH_ON; - break; - case 'N': - stack -> flags |= NUMBER_ON; - break; - case 'A': - case 'O': - stack -> flags |= FLUSH_ON_WRITE; - case 'a': - case 'o': - if (*scan++ == ',') { - temp = ListParse (scan); - DBUGOpenFile(temp -> str, (int) (scan[-2] == 'A' || scan[-2] == 'a')); - FreeList (temp); - } else { - DBUGOpenFile ("-",0); - } - break; - case 'p': - if (*scan++ == ',') { - stack -> processes = ListParse (scan); - } - break; - case 'P': - stack -> flags |= PROCESS_ON; - break; - case 'r': - stack->sub_level= state->level; - break; - case 't': - stack -> flags |= TRACE_ON; - if (*scan++ == ',') { - temp = ListParse (scan); - stack -> maxdepth = atoi (temp -> str); - FreeList (temp); - } - break; - case 'S': - stack -> flags |= SANITY_CHECK_ON; - break; - } - } - free (new_str); -} - - -/* - * FUNCTION - * - * _db_pop_ pop the debug stack - * - * DESCRIPTION - * - * Pops the debug stack, returning the debug state to its - * condition prior to the most recent _db_push_ invocation. - * Note that the pop will fail if it would remove the last - * valid state from the stack. This prevents user errors - * in the push/pop sequence from screwing up the debugger. - * Maybe there should be some kind of warning printed if the - * user tries to pop too many states. - * - */ - -void _db_pop_ () -{ - reg1 struct state *discard; - discard = stack; - if (discard != NULL && discard -> next_state != NULL) { - stack = discard -> next_state; - _db_fp_ = stack -> out_file; - _db_pfp_ = stack -> prof_file; - if (discard -> keywords != NULL) { - FreeList (discard -> keywords); - } - if (discard -> functions != NULL) { - FreeList (discard -> functions); - } - if (discard -> processes != NULL) { - FreeList (discard -> processes); - } - if (discard -> p_functions != NULL) { - FreeList (discard -> p_functions); - } - CloseFile (discard -> out_file); - if (discard -> prof_file) - CloseFile (discard -> prof_file); - free ((char *) discard); - if (!(stack->flags & DEBUG_ON)) - _db_on_=0; - } - else - { - _db_on_=0; - } -} - - -/* - * FUNCTION - * - * _db_enter_ process entry point to user function - * - * SYNOPSIS - * - * VOID _db_enter_ (_func_, _file_, _line_, - * _sfunc_, _sfile_, _slevel_, _sframep_) - * char *_func_; points to current function name - * char *_file_; points to current file name - * int _line_; called from source line number - * char **_sfunc_; save previous _func_ - * char **_sfile_; save previous _file_ - * int *_slevel_; save previous nesting level - * char ***_sframep_; save previous frame pointer - * - * DESCRIPTION - * - * Called at the beginning of each user function to tell - * the debugger that a new function has been entered. - * Note that the pointers to the previous user function - * name and previous user file name are stored on the - * caller's stack (this is why the ENTER macro must be - * the first "executable" code in a function, since it - * allocates these storage locations). The previous nesting - * level is also stored on the callers stack for internal - * self consistency checks. - * - * Also prints a trace line if tracing is enabled and - * increments the current function nesting depth. - * - * Note that this mechanism allows the debugger to know - * what the current user function is at all times, without - * maintaining an internal stack for the function names. - * - */ - -void _db_enter_ ( -const char *_func_, -const char *_file_, -uint _line_, -const char **_sfunc_, -const char **_sfile_, -uint *_slevel_, -char ***_sframep_ __attribute__((unused))) -{ - reg1 CODE_STATE *state; - - if (!_no_db_) - { - int save_errno=errno; - if (!init_done) - _db_push_ (_DBUG_START_CONDITION_); - state=code_state(); - - *_sfunc_ = state->func; - *_sfile_ = state->file; - state->func =(char*) _func_; - state->file = (char*) _file_; /* BaseName takes time !! */ - *_slevel_ = ++state->level; -#ifndef THREAD - *_sframep_ = state->framep; - state->framep = (char **) _sframep_; - if (DoProfile ()) - { - long stackused; - if (*state->framep == NULL) { - stackused = 0; - } else { - stackused = ((long)(*state->framep)) - ((long)(state->framep)); - stackused = stackused > 0 ? stackused : -stackused; - } - (void) fprintf (_db_pfp_, PROF_EFMT , Clock (), state->func); -#ifdef AUTOS_REVERSE - (void) fprintf (_db_pfp_, PROF_SFMT, state->framep, stackused, *_sfunc_); -#else - (void) fprintf (_db_pfp_, PROF_SFMT, (ulong) state->framep, stackused, - state->func); -#endif - (void) fflush (_db_pfp_); - } -#endif - if (DoTrace (state)) - { - if (!state->locked) - pthread_mutex_lock(&THR_LOCK_dbug); - DoPrefix (_line_); - Indent (state -> level); - (void) fprintf (_db_fp_, ">%s\n", state->func); - dbug_flush (state); /* This does a unlock */ - } -#ifdef SAFEMALLOC - if (stack -> flags & SANITY_CHECK_ON) - if (_sanity(_file_,_line_)) /* Check of safemalloc */ - stack -> flags &= ~SANITY_CHECK_ON; -#endif - errno=save_errno; - } -} - -/* - * FUNCTION - * - * _db_return_ process exit from user function - * - * SYNOPSIS - * - * VOID _db_return_ (_line_, _sfunc_, _sfile_, _slevel_) - * int _line_; current source line number - * char **_sfunc_; where previous _func_ is to be retrieved - * char **_sfile_; where previous _file_ is to be retrieved - * int *_slevel_; where previous level was stashed - * - * DESCRIPTION - * - * Called just before user function executes an explicit or implicit - * return. Prints a trace line if trace is enabled, decrements - * the current nesting level, and restores the current function and - * file names from the defunct function's stack. - * - */ - -void _db_return_ ( -uint _line_, -const char **_sfunc_, -const char **_sfile_, -uint *_slevel_) -{ - CODE_STATE *state; - - if (!_no_db_) - { - int save_errno=errno; - if (!init_done) - _db_push_ (""); - if (!(state=code_state())) - return; /* Only happens at end of program */ - if (stack->flags & (TRACE_ON | DEBUG_ON | PROFILE_ON)) - { - if (!state->locked) - pthread_mutex_lock(&THR_LOCK_dbug); - if (state->level != (int) *_slevel_) - (void) fprintf (_db_fp_, ERR_MISSING_RETURN, _db_process_, - state->func); - else - { -#ifdef SAFEMALLOC - if (stack -> flags & SANITY_CHECK_ON) - if (_sanity(*_sfile_,_line_)) - stack->flags &= ~SANITY_CHECK_ON; -#endif -#ifndef THREAD - if (DoProfile ()) - (void) fprintf (_db_pfp_, PROF_XFMT, Clock(), state->func); -#endif - if (DoTrace (state)) - { - DoPrefix (_line_); - Indent (state->level); - (void) fprintf (_db_fp_, "<%s\n", state->func); - } - } - dbug_flush(state); - } - state->level = *_slevel_-1; - state->func = *_sfunc_; - state->file = *_sfile_; -#ifndef THREAD - if (state->framep != NULL) - state->framep = (char **) *state->framep; -#endif - errno=save_errno; - } -} - - -/* - * FUNCTION - * - * _db_pargs_ log arguments for subsequent use by _db_doprnt_() - * - * SYNOPSIS - * - * VOID _db_pargs_ (_line_, keyword) - * int _line_; - * char *keyword; - * - * DESCRIPTION - * - * The new universal printing macro DBUG_PRINT, which replaces - * all forms of the DBUG_N macros, needs two calls to runtime - * support routines. The first, this function, remembers arguments - * that are used by the subsequent call to _db_doprnt_(). - * - */ - -void _db_pargs_ ( -uint _line_, -const char *keyword) -{ - CODE_STATE *state=code_state(); - state->u_line = _line_; - state->u_keyword = (char*) keyword; -} - - -/* - * FUNCTION - * - * _db_doprnt_ handle print of debug lines - * - * SYNOPSIS - * - * VOID _db_doprnt_ (format, va_alist) - * char *format; - * va_dcl; - * - * DESCRIPTION - * - * When invoked via one of the DBUG macros, tests the current keyword - * set by calling _db_pargs_() to see if that macro has been selected - * for processing via the debugger control string, and if so, handles - * printing of the arguments via the format string. The line number - * of the DBUG macro in the source is found in u_line. - * - * Note that the format string SHOULD NOT include a terminating - * newline, this is supplied automatically. - * - */ - -#include <stdarg.h> - -void _db_doprnt_ (const char *format,...) -{ - va_list args; - CODE_STATE *state; - state=code_state(); - - va_start(args,format); - - if (_db_keyword_ (state->u_keyword)) { - int save_errno=errno; - if (!state->locked) - pthread_mutex_lock(&THR_LOCK_dbug); - DoPrefix (state->u_line); - if (TRACING) { - Indent (state->level + 1); - } else { - (void) fprintf (_db_fp_, "%s: ", state->func); - } - (void) fprintf (_db_fp_, "%s: ", state->u_keyword); - (void) vfprintf (_db_fp_, format, args); - va_end(args); - (void) fputc('\n',_db_fp_); - dbug_flush(state); - errno=save_errno; - } - va_end(args); -} - - -/* - * FUNCTION - * - * _db_dump_ dump a string until '\0' is found - * - * SYNOPSIS - * - * void _db_dump_ (_line_,keyword,memory,length) - * int _line_; current source line number - * char *keyword; - * char *memory; Memory to print - * int length; Bytes to print - * - * DESCRIPTION - * Dump N characters in a binary array. - * Is used to examine corrputed memory or arrays. - */ - -void _db_dump_( -uint _line_, -const char *keyword, -const char *memory, -uint length) -{ - int pos; - char dbuff[90]; - CODE_STATE *state; - state=code_state(); - - if (_db_keyword_ ((char*) keyword)) - { - if (!state->locked) - pthread_mutex_lock(&THR_LOCK_dbug); - DoPrefix (_line_); - if (TRACING) - { - Indent (state->level + 1); - pos= min(max(state->level-stack->sub_level,0)*INDENT,80); - } - else - { - fprintf(_db_fp_, "%s: ", state->func); - } - sprintf(dbuff,"%s: Memory: %lx Bytes: (%d)\n", - keyword,(ulong) memory, length); - (void) fputs(dbuff,_db_fp_); - - pos=0; - while (length-- > 0) - { - uint tmp= *((unsigned char*) memory++); - if ((pos+=3) >= 80) - { - fputc('\n',_db_fp_); - pos=3; - } - fputc(_dig_vec[((tmp >> 4) & 15)], _db_fp_); - fputc(_dig_vec[tmp & 15], _db_fp_); - fputc(' ',_db_fp_); - } - (void) fputc('\n',_db_fp_); - dbug_flush(state); - } -} - -/* - * FUNCTION - * - * ListParse parse list of modifiers in debug control string - * - * SYNOPSIS - * - * static struct link *ListParse (ctlp) - * char *ctlp; - * - * DESCRIPTION - * - * Given pointer to a comma separated list of strings in "cltp", - * parses the list, building a list and returning a pointer to it. - * The original comma separated list is destroyed in the process of - * building the linked list, thus it had better be a duplicate - * if it is important. - * - * Note that since each link is added at the head of the list, - * the final list will be in "reverse order", which is not - * significant for our usage here. - * - */ - -static struct link *ListParse ( -char *ctlp) -{ - REGISTER char *start; - REGISTER struct link *new_malloc; - REGISTER struct link *head; - - head = NULL; - while (*ctlp != EOS) { - start = ctlp; - while (*ctlp != EOS && *ctlp != ',') { - ctlp++; - } - if (*ctlp == ',') { - *ctlp++ = EOS; - } - new_malloc = (struct link *) DbugMalloc (sizeof (struct link)); - new_malloc -> str = StrDup (start); - new_malloc -> next_link = head; - head = new_malloc; - } - return (head); -} - -/* - * FUNCTION - * - * InList test a given string for member of a given list - * - * SYNOPSIS - * - * static BOOLEAN InList (linkp, cp) - * struct link *linkp; - * char *cp; - * - * DESCRIPTION - * - * Tests the string pointed to by "cp" to determine if it is in - * the list pointed to by "linkp". Linkp points to the first - * link in the list. If linkp is NULL then the string is treated - * as if it is in the list (I.E all strings are in the null list). - * This may seem rather strange at first but leads to the desired - * operation if no list is given. The net effect is that all - * strings will be accepted when there is no list, and when there - * is a list, only those strings in the list will be accepted. - * - */ - -static BOOLEAN InList ( -struct link *linkp, -const char *cp) -{ - REGISTER struct link *scan; - REGISTER BOOLEAN result; - - if (linkp == NULL) { - result = TRUE; - } else { - result = FALSE; - for (scan = linkp; scan != NULL; scan = scan -> next_link) { - if (STREQ (scan -> str, cp)) { - result = TRUE; - break; - } - } - } - return (result); -} - - -/* - * FUNCTION - * - * PushState push current state onto stack and set up new one - * - * SYNOPSIS - * - * static VOID PushState () - * - * DESCRIPTION - * - * Pushes the current state on the state stack, and initializes - * a new state. The only parameter inherited from the previous - * state is the function nesting level. This action can be - * inhibited if desired, via the "r" flag. - * - * The state stack is a linked list of states, with the new - * state added at the head. This allows the stack to grow - * to the limits of memory if necessary. - * - */ - -static void PushState () -{ - REGISTER struct state *new_malloc; - - if (!init_done) - { - init_dbug_state(); - init_done=TRUE; - } - (void) code_state(); /* Alloc memory */ - new_malloc = (struct state *) DbugMalloc (sizeof (struct state)); - new_malloc -> flags = 0; - new_malloc -> delay = 0; - new_malloc -> maxdepth = MAXDEPTH; - new_malloc -> sub_level=0; - new_malloc -> out_file = stderr; - new_malloc -> prof_file = (FILE*) 0; - new_malloc -> functions = NULL; - new_malloc -> p_functions = NULL; - new_malloc -> keywords = NULL; - new_malloc -> processes = NULL; - new_malloc -> next_state = stack; - stack=new_malloc; -} - - -/* - * FUNCTION - * - * DoTrace check to see if tracing is current enabled - * - * SYNOPSIS - * - * static BOOLEAN DoTrace (stack) - * - * DESCRIPTION - * - * Checks to see if tracing is enabled based on whether the - * user has specified tracing, the maximum trace depth has - * not yet been reached, the current function is selected, - * and the current process is selected. Returns TRUE if - * tracing is enabled, FALSE otherwise. - * - */ - -static BOOLEAN DoTrace (CODE_STATE *state) -{ - reg2 BOOLEAN trace=FALSE; - - if (TRACING && - state->level <= stack -> maxdepth && - InList (stack -> functions, state->func) && - InList (stack -> processes, _db_process_)) - trace = TRUE; - return (trace); -} - - -/* - * FUNCTION - * - * DoProfile check to see if profiling is current enabled - * - * SYNOPSIS - * - * static BOOLEAN DoProfile () - * - * DESCRIPTION - * - * Checks to see if profiling is enabled based on whether the - * user has specified profiling, the maximum trace depth has - * not yet been reached, the current function is selected, - * and the current process is selected. Returns TRUE if - * profiling is enabled, FALSE otherwise. - * - */ - -#ifndef THREAD -static BOOLEAN DoProfile () -{ - REGISTER BOOLEAN profile; - CODE_STATE *state; - state=code_state(); - - profile = FALSE; - if (PROFILING && - state->level <= stack -> maxdepth && - InList (stack -> p_functions, state->func) && - InList (stack -> processes, _db_process_)) - profile = TRUE; - return (profile); -} -#endif - - -/* - * FUNCTION - * - * _db_keyword_ test keyword for member of keyword list - * - * SYNOPSIS - * - * BOOLEAN _db_keyword_ (keyword) - * char *keyword; - * - * DESCRIPTION - * - * Test a keyword to determine if it is in the currently active - * keyword list. As with the function list, a keyword is accepted - * if the list is null, otherwise it must match one of the list - * members. When debugging is not on, no keywords are accepted. - * After the maximum trace level is exceeded, no keywords are - * accepted (this behavior subject to change). Additionally, - * the current function and process must be accepted based on - * their respective lists. - * - * Returns TRUE if keyword accepted, FALSE otherwise. - * - */ - -BOOLEAN _db_keyword_ ( -const char *keyword) -{ - REGISTER BOOLEAN result; - CODE_STATE *state; - - if (!init_done) - _db_push_ (""); - state=code_state(); - result = FALSE; - if (DEBUGGING && - state->level <= stack -> maxdepth && - InList (stack -> functions, state->func) && - InList (stack -> keywords, keyword) && - InList (stack -> processes, _db_process_)) - result = TRUE; - return (result); -} - -/* - * FUNCTION - * - * Indent indent a line to the given indentation level - * - * SYNOPSIS - * - * static VOID Indent (indent) - * int indent; - * - * DESCRIPTION - * - * Indent a line to the given level. Note that this is - * a simple minded but portable implementation. - * There are better ways. - * - * Also, the indent must be scaled by the compile time option - * of character positions per nesting level. - * - */ - -static void Indent ( -int indent) -{ - REGISTER int count; - - indent= max(indent-1-stack->sub_level,0)*INDENT; - for (count = 0; count < indent ; count++) - { - if ((count % INDENT) == 0) - fputc('|',_db_fp_); - else - fputc(' ',_db_fp_); - } -} - - -/* - * FUNCTION - * - * FreeList free all memory associated with a linked list - * - * SYNOPSIS - * - * static VOID FreeList (linkp) - * struct link *linkp; - * - * DESCRIPTION - * - * Given pointer to the head of a linked list, frees all - * memory held by the list and the members of the list. - * - */ - -static void FreeList ( -struct link *linkp) -{ - REGISTER struct link *old; - - while (linkp != NULL) { - old = linkp; - linkp = linkp -> next_link; - if (old -> str != NULL) { - free (old -> str); - } - free ((char *) old); - } -} - - -/* - * FUNCTION - * - * StrDup make a duplicate of a string in new memory - * - * SYNOPSIS - * - * static char *StrDup (my_string) - * char *string; - * - * DESCRIPTION - * - * Given pointer to a string, allocates sufficient memory to make - * a duplicate copy, and copies the string to the newly allocated - * memory. Failure to allocated sufficient memory is immediately - * fatal. - * - */ - - -static char *StrDup ( -const char *str) -{ - reg1 char *new_malloc; - new_malloc = DbugMalloc ((int) strlen (str) + 1); - (void) strcpy (new_malloc, str); - return (new_malloc); -} - - -/* - * FUNCTION - * - * DoPrefix print debugger line prefix prior to indentation - * - * SYNOPSIS - * - * static VOID DoPrefix (_line_) - * int _line_; - * - * DESCRIPTION - * - * Print prefix common to all debugger output lines, prior to - * doing indentation if necessary. Print such information as - * current process name, current source file name and line number, - * and current function nesting depth. - * - */ - -static void DoPrefix ( -uint _line_) -{ - CODE_STATE *state; - state=code_state(); - - state->lineno++; - if (stack -> flags & PID_ON) { -#ifdef THREAD - (void) fprintf (_db_fp_, "%-7s: ", my_thread_name()); -#else - (void) fprintf (_db_fp_, "%5d: ", (int) getpid ()); -#endif - } - if (stack -> flags & NUMBER_ON) { - (void) fprintf (_db_fp_, "%5d: ", state->lineno); - } - if (stack -> flags & PROCESS_ON) { - (void) fprintf (_db_fp_, "%s: ", _db_process_); - } - if (stack -> flags & FILE_ON) { - (void) fprintf (_db_fp_, "%14s: ", BaseName(state->file)); - } - if (stack -> flags & LINE_ON) { - (void) fprintf (_db_fp_, "%5d: ", _line_); - } - if (stack -> flags & DEPTH_ON) { - (void) fprintf (_db_fp_, "%4d: ", state->level); - } -} - - -/* - * FUNCTION - * - * DBUGOpenFile open new output stream for debugger output - * - * SYNOPSIS - * - * static VOID DBUGOpenFile (name) - * char *name; - * - * DESCRIPTION - * - * Given name of a new file (or "-" for stdout) opens the file - * and sets the output stream to the new file. - * - */ - -static void DBUGOpenFile (const char *name,int append) -{ - REGISTER FILE *fp; - REGISTER BOOLEAN newfile; - - if (name != NULL) - { - strmov(stack->name,name); - if (strcmp (name, "-") == 0) - { - _db_fp_ = stdout; - stack -> out_file = _db_fp_; - stack -> flags |= FLUSH_ON_WRITE; - } - else - { - if (!Writable((char*)name)) - { - (void) fprintf (stderr, ERR_OPEN, _db_process_, name); - perror (""); - fflush(stderr); - } - else - { - newfile= !EXISTS (name); - if (!(fp = fopen(name, append ? "a+" : "w"))) - { - (void) fprintf (stderr, ERR_OPEN, _db_process_, name); - perror (""); - fflush(stderr); - } - else - { - _db_fp_ = fp; - stack -> out_file = fp; - if (newfile) { - ChangeOwner (name); - } - } - } - } - } -} - - -/* - * FUNCTION - * - * OpenProfile open new output stream for profiler output - * - * SYNOPSIS - * - * static FILE *OpenProfile (name) - * char *name; - * - * DESCRIPTION - * - * Given name of a new file, opens the file - * and sets the profiler output stream to the new file. - * - * It is currently unclear whether the prefered behavior is - * to truncate any existing file, or simply append to it. - * The latter behavior would be desirable for collecting - * accumulated runtime history over a number of separate - * runs. It might take some changes to the analyzer program - * though, and the notes that Binayak sent with the profiling - * diffs indicated that append was the normal mode, but this - * does not appear to agree with the actual code. I haven't - * investigated at this time [fnf; 24-Jul-87]. - */ - -#ifndef THREAD -static FILE *OpenProfile (const char *name) -{ - REGISTER FILE *fp; - REGISTER BOOLEAN newfile; - - fp=0; - if (!Writable (name)) - { - (void) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); - perror (""); - dbug_flush(0); - (void) Delay (stack -> delay); - } - else - { - newfile= !EXISTS (name); - if (!(fp = fopen (name, "w"))) - { - (void) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); - perror (""); - dbug_flush(0); - } - else - { - _db_pfp_ = fp; - stack -> prof_file = fp; - if (newfile) - { - ChangeOwner (name); - } - } - } - return fp; -} -#endif - -/* - * FUNCTION - * - * CloseFile close the debug output stream - * - * SYNOPSIS - * - * static VOID CloseFile (fp) - * FILE *fp; - * - * DESCRIPTION - * - * Closes the debug output stream unless it is standard output - * or standard error. - * - */ - -static void CloseFile ( -FILE *fp) -{ - if (fp != stderr && fp != stdout) { - if (fclose (fp) == EOF) { - pthread_mutex_lock(&THR_LOCK_dbug); - (void) fprintf (_db_fp_, ERR_CLOSE, _db_process_); - perror (""); - dbug_flush(0); - } - } -} - - -/* - * FUNCTION - * - * DbugExit print error message and exit - * - * SYNOPSIS - * - * static VOID DbugExit (why) - * char *why; - * - * DESCRIPTION - * - * Prints error message using current process name, the reason for - * aborting (typically out of memory), and exits with status 1. - * This should probably be changed to use a status code - * defined in the user's debugger include file. - * - */ - -static void DbugExit (const char *why) -{ - (void) fprintf (stderr, ERR_ABORT, _db_process_, why); - (void) fflush (stderr); - exit (1); -} - - -/* - * FUNCTION - * - * DbugMalloc allocate memory for debugger runtime support - * - * SYNOPSIS - * - * static long *DbugMalloc (size) - * int size; - * - * DESCRIPTION - * - * Allocate more memory for debugger runtime support functions. - * Failure to to allocate the requested number of bytes is - * immediately fatal to the current process. This may be - * rather unfriendly behavior. It might be better to simply - * print a warning message, freeze the current debugger state, - * and continue execution. - * - */ - -static char *DbugMalloc ( -int size) -{ - register char *new_malloc; - - if (!(new_malloc = (char*) malloc ((unsigned int) size))) - DbugExit ("out of memory"); - return (new_malloc); -} - - -/* - * As strtok but two separators in a row are changed to one - * separator (to allow directory-paths in dos). - */ - -static char *static_strtok ( -char *s1, -pchar separator) -{ - static char *end = NULL; - reg1 char *rtnval,*cpy; - - rtnval = NULL; - if (s1 != NULL) - end = s1; - if (end != NULL && *end != EOS) - { - rtnval=cpy=end; - do - { - if ((*cpy++ = *end++) == separator) - { - if (*end != separator) - { - cpy--; /* Point at separator */ - break; - } - end++; /* Two separators in a row, skipp one */ - } - } while (*end != EOS); - *cpy=EOS; /* Replace last separator */ - } - return (rtnval); -} - - -/* - * FUNCTION - * - * BaseName strip leading pathname components from name - * - * SYNOPSIS - * - * static char *BaseName (pathname) - * char *pathname; - * - * DESCRIPTION - * - * Given pointer to a complete pathname, locates the base file - * name at the end of the pathname and returns a pointer to - * it. - * - */ - -static char *BaseName (const char *pathname) -{ - register const char *base; - - base = strrchr (pathname, FN_LIBCHAR); - if (base++ == NullS) - base = pathname; - return ((char*) base); -} - - -/* - * FUNCTION - * - * Writable test to see if a pathname is writable/creatable - * - * SYNOPSIS - * - * static BOOLEAN Writable (pathname) - * char *pathname; - * - * DESCRIPTION - * - * Because the debugger might be linked in with a program that - * runs with the set-uid-bit (suid) set, we have to be careful - * about opening a user named file for debug output. This consists - * of checking the file for write access with the real user id, - * or checking the directory where the file will be created. - * - * Returns TRUE if the user would normally be allowed write or - * create access to the named file. Returns FALSE otherwise. - * - */ - - -#ifndef Writable - -static BOOLEAN Writable ( -char *pathname) -{ - REGISTER BOOLEAN granted; - REGISTER char *lastslash; - - granted = FALSE; - if (EXISTS (pathname)) { - if (WRITABLE (pathname)) { - granted = TRUE; - } - } else { - lastslash = strrchr (pathname, '/'); - if (lastslash != NULL) { - *lastslash = EOS; - } else { - pathname = "."; - } - if (WRITABLE (pathname)) { - granted = TRUE; - } - if (lastslash != NULL) { - *lastslash = '/'; - } - } - return (granted); -} -#endif - - -/* - * FUNCTION - * - * ChangeOwner change owner to real user for suid programs - * - * SYNOPSIS - * - * static VOID ChangeOwner (pathname) - * - * DESCRIPTION - * - * For unix systems, change the owner of the newly created debug - * file to the real owner. This is strictly for the benefit of - * programs that are running with the set-user-id bit set. - * - * Note that at this point, the fact that pathname represents - * a newly created file has already been established. If the - * program that the debugger is linked to is not running with - * the suid bit set, then this operation is redundant (but - * harmless). - * - */ - -#ifndef ChangeOwner -static void ChangeOwner ( -char *pathname) -{ - if (chown (pathname, getuid (), getgid ()) == -1) - { - (void) fprintf (stderr, ERR_CHOWN, _db_process_, pathname); - perror (""); - (void) fflush (stderr); - } -} -#endif - - -/* - * FUNCTION - * - * _db_setjmp_ save debugger environment - * - * SYNOPSIS - * - * VOID _db_setjmp_ () - * - * DESCRIPTION - * - * Invoked as part of the user's DBUG_SETJMP macro to save - * the debugger environment in parallel with saving the user's - * environment. - * - */ - -#ifdef HAVE_LONGJMP - -EXPORT void _db_setjmp_ () -{ - CODE_STATE *state; - state=code_state(); - - state->jmplevel = state->level; - state->jmpfunc = state->func; - state->jmpfile = state->file; -} - -/* - * FUNCTION - * - * _db_longjmp_ restore previously saved debugger environment - * - * SYNOPSIS - * - * VOID _db_longjmp_ () - * - * DESCRIPTION - * - * Invoked as part of the user's DBUG_LONGJMP macro to restore - * the debugger environment in parallel with restoring the user's - * previously saved environment. - * - */ - -EXPORT void _db_longjmp_ () -{ - CODE_STATE *state; - state=code_state(); - - state->level = state->jmplevel; - if (state->jmpfunc) { - state->func = state->jmpfunc; - } - if (state->jmpfile) { - state->file = state->jmpfile; - } -} -#endif - -/* - * FUNCTION - * - * DelayArg convert D flag argument to appropriate value - * - * SYNOPSIS - * - * static int DelayArg (value) - * int value; - * - * DESCRIPTION - * - * Converts delay argument, given in tenths of a second, to the - * appropriate numerical argument used by the system to delay - * that that many tenths of a second. For example, on the - * amiga, there is a system call "Delay()" which takes an - * argument in ticks (50 per second). On unix, the sleep - * command takes seconds. Thus a value of "10", for one - * second of delay, gets converted to 50 on the amiga, and 1 - * on unix. Other systems will need to use a timing loop. - * - */ - -#ifdef AMIGA -#define HZ (50) /* Probably in some header somewhere */ -#endif - -static int DelayArg ( -int value) -{ - uint delayarg = 0; - -#if (unix || xenix) - delayarg = value / 10; /* Delay is in seconds for sleep () */ -#endif -#ifdef AMIGA - delayarg = (HZ * value) / 10; /* Delay in ticks for Delay () */ -#endif - return (delayarg); -} - - -/* - * A dummy delay stub for systems that do not support delays. - * With a little work, this can be turned into a timing loop. - */ - -#if ! defined(Delay) && ! defined(AMIGA) -static int Delay ( -int ticks) -{ - return ticks; -} -#endif - - -/* - * FUNCTION - * - * perror perror simulation for systems that don't have it - * - * SYNOPSIS - * - * static VOID perror (s) - * char *s; - * - * DESCRIPTION - * - * Perror produces a message on the standard error stream which - * provides more information about the library or system error - * just encountered. The argument string s is printed, followed - * by a ':', a blank, and then a message and a newline. - * - * An undocumented feature of the unix perror is that if the string - * 's' is a null string (NOT a NULL pointer!), then the ':' and - * blank are not printed. - * - * This version just complains about an "unknown system error". - * - */ - -#ifndef HAVE_PERROR -static void perror (s) -char *s; -{ - if (s && *s != EOS) { - (void) fprintf (stderr, "%s: ", s); - } - (void) fprintf (stderr, "<unknown system error>\n"); -} -#endif /* HAVE_PERROR */ - - - /* flush dbug-stream, free mutex lock & wait delay */ - /* This is because some systems (MSDOS!!) dosn't flush fileheader */ - /* and dbug-file isn't readable after a system crash !! */ - -static void dbug_flush(CODE_STATE *state) -{ -#ifndef THREAD - if (stack->flags & FLUSH_ON_WRITE) -#endif - { -#if defined(MSDOS) || defined(__WIN__) - if (_db_fp_ != stdout && _db_fp_ != stderr) - { - if (!(freopen(stack->name,"a",_db_fp_))) - { - (void) fprintf(stderr, ERR_OPEN, _db_process_); - fflush(stderr); - _db_fp_ = stdout; - stack -> out_file = _db_fp_; - stack -> flags|=FLUSH_ON_WRITE; - } - } - else -#endif - { - (void) fflush (_db_fp_); - if (stack->delay) - (void) Delay (stack->delay); - } - } - if (!state || !state->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); -} /* dbug_flush */ - - -void _db_lock_file() -{ - CODE_STATE *state; - state=code_state(); - pthread_mutex_lock(&THR_LOCK_dbug); - state->locked=1; -} - -void _db_unlock_file() -{ - CODE_STATE *state; - state=code_state(); - state->locked=0; - pthread_mutex_unlock(&THR_LOCK_dbug); -} - -/* - * Here we need the definitions of the clock routine. Add your - * own for whatever system that you have. - */ - -#ifndef THREAD -#if defined(HAVE_GETRUSAGE) - -#include <sys/param.h> -#include <sys/resource.h> - -/* extern int getrusage(int, struct rusage *); */ - -/* - * Returns the user time in milliseconds used by this process so - * far. - */ - -static unsigned long Clock () -{ - struct rusage ru; - - (void) getrusage (RUSAGE_SELF, &ru); - return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000)); -} - -#elif defined(MSDOS) || defined(__WIN__) || defined(OS2) - -static ulong Clock() -{ - return clock()*(1000/CLOCKS_PER_SEC); -} -#elif defined (amiga) - -struct DateStamp { /* Yes, this is a hack, but doing it right */ - long ds_Days; /* is incredibly ugly without splitting this */ - long ds_Minute; /* off into a separate file */ - long ds_Tick; -}; - -static int first_clock = TRUE; -static struct DateStamp begin; -static struct DateStamp elapsed; - -static unsigned long Clock () -{ - register struct DateStamp *now; - register unsigned long millisec = 0; - extern VOID *AllocMem (); - - now = (struct DateStamp *) AllocMem ((long) sizeof (struct DateStamp), 0L); - if (now != NULL) { - if (first_clock == TRUE) { - first_clock = FALSE; - (void) DateStamp (now); - begin = *now; - } - (void) DateStamp (now); - millisec = 24 * 3600 * (1000 / HZ) * (now -> ds_Days - begin.ds_Days); - millisec += 60 * (1000 / HZ) * (now -> ds_Minute - begin.ds_Minute); - millisec += (1000 / HZ) * (now -> ds_Tick - begin.ds_Tick); - (void) FreeMem (now, (long) sizeof (struct DateStamp)); - } - return (millisec); -} -#else -static unsigned long Clock () -{ - return (0); -} -#endif /* RUSAGE */ -#endif /* THREADS */ - -#ifdef NO_VARARGS - -/* - * Fake vfprintf for systems that don't support it. If this - * doesn't work, you are probably SOL... - */ - -static int vfprintf (stream, format, ap) -FILE *stream; -char *format; -va_list ap; -{ - int rtnval; - ARGS_DCL; - - ARG0 = va_arg (ap, ARGS_TYPE); - ARG1 = va_arg (ap, ARGS_TYPE); - ARG2 = va_arg (ap, ARGS_TYPE); - ARG3 = va_arg (ap, ARGS_TYPE); - ARG4 = va_arg (ap, ARGS_TYPE); - ARG5 = va_arg (ap, ARGS_TYPE); - ARG6 = va_arg (ap, ARGS_TYPE); - ARG7 = va_arg (ap, ARGS_TYPE); - ARG8 = va_arg (ap, ARGS_TYPE); - ARG9 = va_arg (ap, ARGS_TYPE); - rtnval = fprintf (stream, format, ARGS_LIST); - return (rtnval); -} - -#endif /* NO_VARARGS */ diff --git a/ext/mysql/libmysql/dbug.h b/ext/mysql/libmysql/dbug.h deleted file mode 100644 index aa45079eab..0000000000 --- a/ext/mysql/libmysql/dbug.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#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 diff --git a/ext/mysql/libmysql/default.c b/ext/mysql/libmysql/default.c deleted file mode 100644 index 63aea98212..0000000000 --- a/ext/mysql/libmysql/default.c +++ /dev/null @@ -1,384 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/**************************************************************************** -** Add all options from files named "group".cnf from the default_directories -** before the command line arguments. -** On Windows defaults will also search in the Windows directory for a file -** called 'group'.ini -** As long as the program uses the last argument for conflicting -** options one only have to add a call to "load_defaults" to enable -** use of default values. -** pre- and end 'blank space' are removed from options and values. The -** following escape sequences are recognized in values: \b \t \n \r \\ -** -** The following arguments are handled automaticly; If used, they must be -** first argument on the command line! -** --no-defaults ; no options are read. -** --defaults-file=full-path-to-default-file ; Only this file will be read. -** --defaults-extra-file=full-path-to-default-file ; Read this file before ~/ -** --print-defaults ; Print the modified command line and exit -****************************************************************************/ - -#undef SAFEMALLOC /* safe_malloc is not yet initailized */ - -#include "mysys_priv.h" -#include "m_string.h" -#include "m_ctype.h" - -char *defaults_extra_file=0; - -/* Which directories are searched for options (and in which order) */ - -const char *default_directories[]= { -#ifdef __WIN__ -"C:/", -#else -"/etc/", -#endif -#ifdef DATADIR -DATADIR, -#endif -"", /* Place for defaults_extra_dir */ -#ifndef __WIN__ -"~/", -#endif -NullS, -}; - -#define default_ext ".cnf" /* extension for config file */ -#ifdef __WIN__ -#include <winbase.h> -#define windows_ext ".ini" -#endif - -static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, - const char *dir, const char *config_file, - const char *ext, TYPELIB *group); - - -void load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv) -{ - DYNAMIC_ARRAY args; - const char **dirs, *forced_default_file; - TYPELIB group; - my_bool found_print_defaults=0; - uint args_used=0; - MEM_ROOT alloc; - char *ptr,**res; - DBUG_ENTER("load_defaults"); - - init_alloc_root(&alloc,128,0); - if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults")) - { - /* remove the --no-defaults argument and return only the other arguments */ - uint i; - if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+ - (*argc + 1)*sizeof(char*)))) - goto err; - res= (char**) (ptr+sizeof(alloc)); - res[0]= **argv; /* Copy program name */ - for (i=2 ; i < (uint) *argc ; i++) - res[i-1]=argv[0][i]; - (*argc)--; - *argv=res; - *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ - DBUG_VOID_RETURN; - } - - /* Check if we want to force the use a specific default file */ - forced_default_file=0; - if (*argc >= 2) - { - if (is_prefix(argv[0][1],"--defaults-file=")) - { - forced_default_file=strchr(argv[0][1],'=')+1; - args_used++; - } - else if (is_prefix(argv[0][1],"--defaults-extra-file=")) - { - defaults_extra_file=strchr(argv[0][1],'=')+1; - args_used++; - } - } - - group.count=0; - group.name= "defaults"; - group.type_names= groups; - for (; *groups ; groups++) - group.count++; - - if (init_dynamic_array(&args, sizeof(char*),*argc, 32)) - goto err; - if (forced_default_file) - { - if (search_default_file(&args, &alloc, "", forced_default_file, "", - &group)) - goto err; - } - else if (dirname_length(conf_file)) - { - if (search_default_file(&args, &alloc, NullS, conf_file, default_ext, - &group)) - goto err; - } - else - { -#ifdef __WIN__ - char system_dir[FN_REFLEN]; - GetWindowsDirectory(system_dir,sizeof(system_dir)); - if (search_default_file(&args, &alloc, system_dir, conf_file, windows_ext, - &group)) - goto err; -#endif -#if defined(__EMX__) || defined(OS2) - if (getenv("ETC") && - search_default_file(&args, &alloc, getenv("ETC"), conf_file, - default_ext, &group)) - goto err; -#endif - for (dirs=default_directories ; *dirs; dirs++) - { - int error=0; - if (**dirs) - error=search_default_file(&args, &alloc, *dirs, conf_file, - default_ext, &group); - else if (defaults_extra_file) - error=search_default_file(&args, &alloc, NullS, defaults_extra_file, - default_ext, &group); - if (error) - goto err; - } - } - if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+ - (args.elements + *argc +1) *sizeof(char*)))) - goto err; - res= (char**) (ptr+sizeof(alloc)); - - /* copy name + found arguments + command line arguments to new array */ - res[0]=argv[0][0]; - memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); - /* Skipp --defaults-file and --defaults-extra-file */ - (*argc)-= args_used; - (*argv)+= args_used; - - /* Check if we wan't to see the new argument list */ - if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults")) - { - found_print_defaults=1; - --*argc; ++*argv; /* skipp argument */ - } - - memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), - (*argc-1)*sizeof(char*)); - res[args.elements+ *argc]=0; /* last null */ - - (*argc)+=args.elements; - *argv= (char**) res; - *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ - delete_dynamic(&args); - if (found_print_defaults) - { - int i; - printf("%s would have been started with the following arguments:\n", - **argv); - for (i=1 ; i < *argc ; i++) - printf("%s ", (*argv)[i]); - puts(""); - exit(1); - } - DBUG_VOID_RETURN; - - err: - fprintf(stderr,"Program aborted\n"); - exit(1); -} - - -void free_defaults(char **argv) -{ - MEM_ROOT ptr; - memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr)); - free_root(&ptr,MYF(0)); -} - - -static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, - const char *dir, const char *config_file, - const char *ext, TYPELIB *group) -{ - char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp; - FILE *fp; - uint line=0; - my_bool read_values=0,found_group=0; - - if ((dir ? strlen(dir) : 0 )+strlen(config_file) >= FN_REFLEN-3) - return 0; /* Ignore wrong paths */ - if (dir) - { - strmov(name,dir); - convert_dirname(name); - if (dir[0] == FN_HOMELIB) /* Add . to filenames in home */ - strcat(name,"."); - strxmov(strend(name),config_file,ext,NullS); - } - else - { - strmov(name,config_file); - } - if (!(fp = my_fopen(fn_format(name,name,"","",4),O_RDONLY,MYF(0)))) - return 0; /* Ignore wrong files */ - - while (fgets(buff,sizeof(buff)-1,fp)) - { - line++; - /* Ignore comment and empty lines */ - for (ptr=buff ; isspace(*ptr) ; ptr++ ) ; - if (*ptr == '#' || *ptr == ';' || !*ptr) - continue; - if (*ptr == '[') /* Group name */ - { - found_group=1; - if (!(end=(char *) strchr(++ptr,']'))) - { - fprintf(stderr, - "error: Wrong group definition in config file: %s at line %d\n", - name,line); - goto err; - } - for ( ; isspace(end[-1]) ; end--) ; /* Remove end space */ - end[0]=0; - read_values=find_type(ptr,group,3) > 0; - continue; - } - if (!found_group) - { - fprintf(stderr, - "error: Found option without preceding group in config file: %s at line: %d\n", - name,line); - goto err; - } - if (!read_values) - continue; - if (!(end=value=strchr(ptr,'='))) - end=strend(ptr); /* Option without argument */ - for ( ; isspace(end[-1]) ; end--) ; - if (!value) - { - if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3))) - goto err; - strmake(strmov(tmp,"--"),ptr,(uint) (end-ptr)); - if (insert_dynamic(args,(gptr) &tmp)) - goto err; - } - else - { - /* Remove pre- and end space */ - char *value_end; - for (value++ ; isspace(*value); value++) ; - value_end=strend(value); - for ( ; isspace(value_end[-1]) ; value_end--) ; - if (value_end < value) /* Empty string */ - value_end=value; - if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3 + - (uint) (value_end-value)+1))) - goto err; - if (insert_dynamic(args,(gptr) &tmp)) - goto err; - ptr=strnmov(strmov(tmp,"--"),ptr,(uint) (end-ptr)); - *ptr++= '='; - for ( ; value != value_end; value++) - { - if (*value == '\\' && value != value_end-1) - { - switch(*++value) { - case 'n': - *ptr++='\n'; - break; - case 't': - *ptr++= '\t'; - break; - case 'r': - *ptr++ = '\r'; - break; - case 'b': - *ptr++ = '\b'; - break; - case 's': - *ptr++= ' '; /* space */ - break; - case '\\': - *ptr++= '\\'; - break; - default: /* Unknown; Keep '\' */ - *ptr++= '\\'; - *ptr++= *value; - break; - } - } - else - *ptr++= *value; - } - *ptr=0; - } - } - my_fclose(fp,MYF(0)); - return(0); - - err: - my_fclose(fp,MYF(0)); - return 1; -} - - -void print_defaults(const char *conf_file, const char **groups) -{ -#ifdef __WIN__ - bool have_ext=fn_ext(conf_file)[0] != 0; -#endif - char name[FN_REFLEN]; - const char **dirs; - puts("\nDefault options are read from the following files in the given order:"); - - if (dirname_length(conf_file)) - fputs(conf_file,stdout); - else - { -#ifdef __WIN__ - GetWindowsDirectory(name,sizeof(name)); - printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext); -#endif -#if defined(__EMX__) || defined(OS2) - if (getenv("ETC")) - printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext); -#endif - for (dirs=default_directories ; *dirs; dirs++) - { - if (**dirs) - strmov(name,*dirs); - else if (defaults_extra_file) - strmov(name,defaults_extra_file); - else - continue; - convert_dirname(name); - if (name[0] == FN_HOMELIB) /* Add . to filenames in home */ - strcat(name,"."); - strxmov(strend(name),conf_file,default_ext," ",NullS); - fputs(name,stdout); - } - puts(""); - } - fputs("The following groups are read:",stdout); - for ( ; *groups ; groups++) - { - fputc(' ',stdout); - fputs(*groups,stdout); - } - puts("\nThe following options may be given as the first argument:\n\ ---print-defaults Print the program argument list and exit\n\ ---no-defaults Don't read default options from any options file\n\ ---defaults-file=# Only read default options from the given file #\n\ ---defaults-extra-file=# Read this file after the global files are read"); -} - diff --git a/ext/mysql/libmysql/dll.c b/ext/mysql/libmysql/dll.c deleted file mode 100644 index e69de29bb2..0000000000 --- a/ext/mysql/libmysql/dll.c +++ /dev/null diff --git a/ext/mysql/libmysql/errmsg.c b/ext/mysql/libmysql/errmsg.c deleted file mode 100644 index 18e13b9c11..0000000000 --- a/ext/mysql/libmysql/errmsg.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Error messages for MySQL clients */ -/* error messages for the demon is in share/language/errmsg.sys */ - -#include <global.h> -#include <my_sys.h> -#include "errmsg.h" - -#ifdef GERMAN -const char *client_errors[]= -{ - "Unbekannter MySQL Fehler", - "Kann UNIX-Socket nicht anlegen (%d)", - "Keine Verbindung zu lokalem MySQL Server, socket: '%-.64s' (%d)", - "Keine Verbindung zu MySQL Server auf %-.64s (%d)", - "Kann TCP/IP-Socket nicht anlegen (%d)", - "Unbekannter MySQL Server Host (%-.64s) (%d)", - "MySQL Server nicht vorhanden", - "Protokolle ungleich. Server Version = % d Client Version = %d", - "MySQL client got out of memory", - "Wrong host info", - "Localhost via UNIX socket", - "%-.64s via TCP/IP", - "Error in server handshake", - "Lost connection to MySQL server during query", - "Commands out of sync; You can't run this command now", - "Verbindung ueber Named Pipe; Host: %-.64s", - "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", - "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", - "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", - "Got packet bigger than 'max_allowed_packet'" -}; - -/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ - -#elif defined PORTUGUESE -const char *client_errors[]= -{ - "Erro desconhecido do MySQL", - "Não pode criar 'UNIX socket' (%d)", - "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.64s' (%d)", - "Não pode se conectar ao servidor MySQL em '%-.64s' (%d)", - "Não pode criar 'socket TCP/IP' (%d)", - "'Host' servidor MySQL '%-.64s' (%d) desconhecido", - "Servidor MySQL desapareceu", - "Incompatibilidade de protocolos. Versão do Servidor: %d - Versão do Cliente: %d", - "Cliente do MySQL com falta de memória", - "Informação inválida de 'host'", - "Localhost via 'UNIX socket'", - "%-.64s via 'TCP/IP'", - "Erro na negociação de acesso ao servidor", - "Conexão perdida com servidor MySQL durante 'query'", - "Comandos fora de sincronismo. Você não pode executar este comando agora", - "%-.64s via 'named pipe'", - "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode inicializar conjunto de caracteres %-.64s (caminho %-.64s)", - "Obteve pacote maior do que 'max_allowed_packet'" -}; - -#else /* ENGLISH */ -const char *client_errors[]= -{ - "Unknown MySQL error", - "Can't create UNIX socket (%d)", - "Can't connect to local MySQL server through socket '%-.64s' (%d)", - "Can't connect to MySQL server on '%-.64s' (%d)", - "Can't create TCP/IP socket (%d)", - "Unknown MySQL Server Host '%-.64s' (%d)", - "MySQL server has gone away", - "Protocol mismatch. Server Version = %d Client Version = %d", - "MySQL client run out of memory", - "Wrong host info", - "Localhost via UNIX socket", - "%-.64s via TCP/IP", - "Error in server handshake", - "Lost connection to MySQL server during query", - "Commands out of sync; You can't run this command now", - "%-.64s via named pipe", - "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", - "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", - "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", - "Got packet bigger than 'max_allowed_packet'" -}; -#endif - - -void init_client_errs(void) -{ - my_errmsg[CLIENT_ERRMAP] = &client_errors[0]; -} diff --git a/ext/mysql/libmysql/errmsg.h b/ext/mysql/libmysql/errmsg.h deleted file mode 100644 index 233abfca59..0000000000 --- a/ext/mysql/libmysql/errmsg.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 diff --git a/ext/mysql/libmysql/errors.c b/ext/mysql/libmysql/errors.c deleted file mode 100644 index 9b11bfb47a..0000000000 --- a/ext/mysql/libmysql/errors.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "mysys_err.h" - -#ifndef SHARED_LIBRARY - -const char * NEAR globerrs[GLOBERRS]= -{ - "File '%s' not found (Errcode: %d)", - "Can't create/write to file '%s' (Errcode: %d)", - "Error reading file '%s' (Errcode: %d)", - "Error writing file '%s' (Errcode: %d)", - "Error on close of '%s' (Errcode: %d)", - "Out of memory (Needed %u bytes)", - "Error on delete of '%s' (Errcode: %d)", - "Error on rename of '%s' to '%s' (Errcode: %d)", - "", - "Unexpected eof found when reading file '%s' (Errcode: %d)", - "Can't lock file (Errcode: %d)", - "Can't unlock file (Errcode: %d)", - "Can't read dir of '%s' (Errcode: %d)", - "Can't get stat of '%s' (Errcode: %d)", - "Can't change size of file (Errcode: %d)", - "Can't open stream from handle (Errcode: %d)", - "Can't get working dirctory (Errcode: %d)", - "Can't change dir to '%s' (Errcode: %d)", - "Warning: '%s' had %d links", - "%d files and %d streams is left open\n", - "Disk is full writing '%s'. Waiting for someone to free space...", - "Can't create directory '%s' (Errcode: %d)", - "Character set '%s' is not a compiled character set and is not specified in the '%s' file", - "Out of resources when opening file '%s' (Errcode: %d)", - "Can't read value for symlink '%s' (Error %d)", - "Can't create symlink '%s' pointing at '%s' (Error %d)", - "Error on realpath() on '%s' (Error %d)", -}; - -void init_glob_errs(void) -{ - my_errmsg[GLOB] = & globerrs[0]; -} /* init_glob_errs */ - -#else - -void init_glob_errs() -{ - my_errmsg[GLOB] = & globerrs[0]; - - EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; - EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %d)"; - EE(EE_READ) = "Error reading file '%s' (Errcode: %d)"; - EE(EE_WRITE) = "Error writing file '%s' (Errcode: %d)"; - EE(EE_BADCLOSE) = "Error on close of '%'s (Errcode: %d)"; - EE(EE_OUTOFMEMORY) = "Out of memory (Needed %u bytes)"; - EE(EE_DELETE) = "Error on delete of '%s' (Errcode: %d)"; - EE(EE_LINK) = "Error on rename of '%s' to '%s' (Errcode: %d)"; - EE(EE_EOFERR) = "Unexpected eof found when reading file '%s' (Errcode: %d)"; - EE(EE_CANTLOCK) = "Can't lock file (Errcode: %d)"; - EE(EE_CANTUNLOCK) = "Can't unlock file (Errcode: %d)"; - EE(EE_DIR) = "Can't read dir of '%s' (Errcode: %d)"; - EE(EE_STAT) = "Can't get stat of '%s' (Errcode: %d)"; - EE(EE_CANT_CHSIZE) = "Can't change size of file (Errcode: %d)"; - EE(EE_CANT_OPEN_STREAM)= "Can't open stream from handle (Errcode: %d)"; - EE(EE_GETWD) = "Can't get working dirctory (Errcode: %d)"; - EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %d)"; - EE(EE_LINK_WARNING) = "Warning: '%s' had %d links"; - EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n"; - EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space..."; - EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)"; - EE(EE_UNKNOWN_CHARSET)= "Character set is not a compiled character set and is not specified in the %s file"; - EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %d)"; - EE(EE_CANT_READLINK)="Can't read value for symlink '%s' (Error %d)"; - EE(EE_CANT_SYMLINK)="Can't create symlink '%s' pointing at '%s' (Error %d)"; - EE(EE_REALPATH)="Error on realpath() on '%s' (Error %d)"; -} -#endif diff --git a/ext/mysql/libmysql/fix_copyright b/ext/mysql/libmysql/fix_copyright deleted file mode 100755 index a4d479ecc0..0000000000 --- a/ext/mysql/libmysql/fix_copyright +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -# -# This script removes the Copyright messages and inserts -# Copyright Abandoned messages. -# - - -if test -z "$1"; then - echo "Usage: $0 files" - echo - echo 'Usual parameters: *.c *.h' - exit 1 -fi - - -for i in $@; do - sed \ - -e '/Copyright Abandoned.*MySQL.*/,/NO WARRANTY of any kind/c\ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB \ -This file is public domain and comes with NO WARRANTY of any kind */' \ - -e '/Copyright.*MySQL.*/,/MA 02111/c\ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB \ -This file is public domain and comes with NO WARRANTY of any kind */' \ - -e '/Copyright (C) .*MySQL.*TCX/,/For a more info/c\ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB \ -This file is public domain and comes with NO WARRANTY of any kind */' \ - -e '/Copyright (C) .*TCX.*Monty/,/For a more info/c\ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB \ -This file is public domain and comes with NO WARRANTY of any kind */' \ - -e '/Copyright (C) .... Monty.*/,/be preserved on all copies/c\ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB \ -This file is public domain and comes with NO WARRANTY of any kind */' \ - < $i > tmp - cp tmp $i -done diff --git a/ext/mysql/libmysql/get_password.c b/ext/mysql/libmysql/get_password.c deleted file mode 100644 index 9d39beac01..0000000000 --- a/ext/mysql/libmysql/get_password.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* -** Ask for a password from tty -** This is an own file to avoid conflicts with curses -*/ -#include <global.h> -#include <my_sys.h> -#include "mysql.h" -#include <m_string.h> -#include <m_ctype.h> -#include <dbug.h> - -#if defined(HAVE_BROKEN_GETPASS) && !defined(HAVE_GETPASSPHRASE) -#undef HAVE_GETPASS -#endif - -#ifdef HAVE_GETPASS -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif /* HAVE_PWD_H */ -#else /* ! HAVE_GETPASS */ -#if !defined( __WIN__) && !defined(OS2) -#include <sys/ioctl.h> -#ifdef HAVE_TERMIOS_H /* For tty-password */ -#include <termios.h> -#define TERMIO struct termios -#else -#ifdef HAVE_TERMIO_H /* For tty-password */ -#include <termio.h> -#define TERMIO struct termio -#else -#include <sgtty.h> -#define TERMIO struct sgttyb -#endif -#endif -#ifdef alpha_linux_port -#include <asm/ioctls.h> /* QQ; Fix this in configure */ -#include <asm/termiobits.h> -#endif -#else -#include <conio.h> -#endif /* __WIN__ */ -#endif /* HAVE_GETPASS */ - -#ifdef HAVE_GETPASSPHRASE /* For Solaris */ -#define getpass(A) getpassphrase(A) -#endif - -#if defined( __WIN__) || defined(OS2) -/* were just going to fake it here and get input from the keyboard */ - -char *get_tty_password(char *opt_message) -{ - char to[80]; - char *pos=to,*end=to+sizeof(to)-1; - int i=0; - DBUG_ENTER("get_tty_password"); - fprintf(stdout,opt_message ? opt_message : "Enter password: "); - for (;;) - { - char tmp; - tmp=_getch(); - if (tmp == '\b' || (int) tmp == 127) - { - if (pos != to) - { - _cputs("\b \b"); - pos--; - continue; - } - } - if (tmp == '\n' || tmp == '\r' || tmp == 3) - break; - if (iscntrl(tmp) || pos == end) - continue; - _cputs("*"); - *(pos++) = tmp; - } - while (pos != to && isspace(pos[-1]) == ' ') - pos--; /* Allow dummy space at end */ - *pos=0; - _cputs("\n"); - DBUG_RETURN(my_strdup(to,MYF(MY_FAE))); -} - -#else - - -#ifndef HAVE_GETPASS -/* -** Can't use fgets, because readline will get confused -** length is max number of chars in to, not counting \0 -* to will not include the eol characters. -*/ - -static void get_password(char *to,uint length,int fd,bool echo) -{ - char *pos=to,*end=to+length; - - for (;;) - { - char tmp; - if (my_read(fd,&tmp,1,MYF(0)) != 1) - break; - if (tmp == '\b' || (int) tmp == 127) - { - if (pos != to) - { - if (echo) - { - fputs("\b \b",stdout); - fflush(stdout); - } - pos--; - continue; - } - } - if (tmp == '\n' || tmp == '\r' || tmp == 3) - break; - if (iscntrl(tmp) || pos == end) - continue; - if (echo) - { - fputc('*',stdout); - fflush(stdout); - } - *(pos++) = tmp; - } - while (pos != to && isspace(pos[-1]) == ' ') - pos--; /* Allow dummy space at end */ - *pos=0; - return; -} -#endif /* ! HAVE_GETPASS */ - - -char *get_tty_password(char *opt_message) -{ -#ifdef HAVE_GETPASS - char *passbuff; -#else /* ! HAVE_GETPASS */ - TERMIO org,tmp; -#endif /* HAVE_GETPASS */ - char buff[80]; - - DBUG_ENTER("get_tty_password"); - -#ifdef HAVE_GETPASS - passbuff = getpass(opt_message ? opt_message : "Enter password: "); - - /* copy the password to buff and clear original (static) buffer */ - strnmov(buff, passbuff, sizeof(buff) - 1); -#ifdef _PASSWORD_LEN - memset(passbuff, 0, _PASSWORD_LEN); -#endif -#else - if (isatty(fileno(stdout))) - { - fputs(opt_message ? opt_message : "Enter password: ",stdout); - fflush(stdout); - } -#if defined(HAVE_TERMIOS_H) - tcgetattr(fileno(stdin), &org); - tmp = org; - tmp.c_lflag &= ~(ECHO | ISIG | ICANON); - tmp.c_cc[VMIN] = 1; - tmp.c_cc[VTIME] = 0; - tcsetattr(fileno(stdin), TCSADRAIN, &tmp); - get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout))); - tcsetattr(fileno(stdin), TCSADRAIN, &org); -#elif defined(HAVE_TERMIO_H) - ioctl(fileno(stdin), (int) TCGETA, &org); - tmp=org; - tmp.c_lflag &= ~(ECHO | ISIG | ICANON); - tmp.c_cc[VMIN] = 1; - tmp.c_cc[VTIME]= 0; - ioctl(fileno(stdin),(int) TCSETA, &tmp); - get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout))); - ioctl(fileno(stdin),(int) TCSETA, &org); -#else - gtty(fileno(stdin), &org); - tmp=org; - tmp.sg_flags &= ~ECHO; - tmp.sg_flags |= RAW; - stty(fileno(stdin), &tmp); - get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout))); - stty(fileno(stdin), &org); -#endif - if (isatty(fileno(stdout))) - fputc('\n',stdout); -#endif /* HAVE_GETPASS */ - - DBUG_RETURN(my_strdup(buff,MYF(MY_FAE))); -} -#endif /*__WIN__*/ diff --git a/ext/mysql/libmysql/global.h b/ext/mysql/libmysql/global.h deleted file mode 100644 index 968c2bddb6..0000000000 --- a/ext/mysql/libmysql/global.h +++ /dev/null @@ -1,952 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* This is the main include file that should included 'first' in every - C file. */ - -#ifndef _global_h -#define _global_h - -#if defined( __EMX__) && !defined( MYSQL_SERVER) -/* moved here to use below VOID macro redefinition */ -#define INCL_BASE -#define INCL_NOPMAPI -#include <os2.h> -#endif /* __EMX__ */ - -#ifdef __CYGWIN__ -/* We use a Unix API, so pretend it's not Windows */ -#undef WIN -#undef WIN32 -#undef _WIN -#undef _WIN32 -#undef _WIN64 -#undef __WIN__ -#undef __WIN32__ -#define HAVE_ERRNO_AS_DEFINE -#endif /* __CYGWIN__ */ - - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#include <config-win.h> -#elif defined(OS2) -#include <config-os2.h> -#else -#include <my_config.h> -#if defined(__cplusplus) && defined(inline) -#undef inline /* fix configure problem */ -#endif -#endif /* _WIN32... */ - -/* Fix problem with S_ISLNK() on Linux */ -#if defined(HAVE_LINUXTHREADS) -#undef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -/* The client defines this to avoid all thread code */ -#if defined(UNDEF_THREADS_HACK) -#undef THREAD -#undef HAVE_mit_thread -#undef HAVE_LINUXTHREADS -#undef HAVE_UNIXWARE7_THREADS -#endif - -#ifdef HAVE_THREADS_WITHOUT_SOCKETS -/* MIT pthreads does not work with unix sockets */ -#undef HAVE_SYS_UN_H -#endif - -#define __EXTENSIONS__ 1 /* We want some extension */ -#ifndef __STDC_EXT__ -#define __STDC_EXT__ 1 /* To get large file support on hpux */ -#endif - -#if defined(THREAD) && !defined(__WIN__) && !defined(OS2) -#ifndef _POSIX_PTHREAD_SEMANTICS -#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ -#endif -/* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */ -#if !defined(SCO) -#define _REENTRANT 1 /* Some thread libraries require this */ -#endif -#if !defined(_THREAD_SAFE) && !defined(_AIX) -#define _THREAD_SAFE /* Required for OSF1 */ -#endif -#ifndef HAVE_mit_thread -#ifdef HAVE_UNIXWARE7_THREADS -#include <thread.h> -#else -#include <pthread.h> /* AIX must have this included first */ -#endif /* HAVE_UNIXWARE7_THREADS */ -#endif /* HAVE_mit_thread */ -#if !defined(SCO) && !defined(_REENTRANT) -#define _REENTRANT 1 /* Threads requires reentrant code */ -#endif -#endif /* THREAD */ - -/* Go around some bugs in different OS and compilers */ -#ifdef _AIX /* By soren@t.dk */ -#define _H_STRINGS -#define _SYS_STREAM_H -#define _AIX32_CURSES -#endif - -#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ -#undef HAVE_SNPRINTF -#endif -#ifdef HAVE_BROKEN_PREAD /* These doesn't work on HPUX 11.x */ -#undef HAVE_PREAD -#undef HAVE_PWRITE -#endif - -#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */ -#undef HAVE_GETHOSTBYNAME_R -#endif -#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */ -#undef HAVE_INITGROUPS -#endif - -/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */ -#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) -#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */ -#define __LONG_MAX__ 2147483647 -#endif - -/* egcs 1.1.2 has a problem with memcpy on Alpha */ -#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -#define BAD_MEMCPY -#endif - -/* In Linux-alpha we have atomic.h if we are using gcc */ -#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD) -#define HAVE_ATOMIC_ADD -#define HAVE_ATOMIC_SUB -#endif - -/* In Linux-ia64 including atomic.h will give us an error */ -#if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__ia64__)) || !defined(THREAD) -#undef HAVE_ATOMIC_ADD -#undef HAVE_ATOMIC_SUB -#endif - -#if defined(_lint) && !defined(lint) -#define lint -#endif -#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) -#define _LONG_LONG 1 /* For AIX string library */ -#endif - -#ifndef stdin -#include <stdio.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif - -#include <math.h> -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif -#ifdef HAVE_FLOAT_H -#include <float.h> -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_SYS_TIMEB_H -#include <sys/timeb.h> /* Avoid warnings on SCO */ -#endif -#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif /* TIME_WITH_SYS_TIME */ -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) -#undef HAVE_ALLOCA -#undef HAVE_ALLOCA_H -#endif -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif -#ifdef HAVE_ATOMIC_ADD -#define __SMP__ -#include <asm/atomic.h> -#endif - -/* Go around some bugs in different OS and compilers */ -#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H) -#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */ -#define HAVE_ULONG -#endif -#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ -#undef HAVE_FINITE -#endif -#if defined(HPUX) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) -/* Fix bug in setrlimit */ -#undef setrlimit -#define setrlimit cma_setrlimit64 -#endif - -/* We can not live without these */ - -#define USE_MYFUNC 1 /* Must use syscall indirection */ -#define MASTER 1 /* Compile without unireg */ -#define ENGLISH 1 /* Messages in English */ -#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ -#define USE_REGEX 1 /* We want the use the regex library */ -/* Do not define for ultra sparcs */ -#ifndef OS2 -#define USE_BMOVE512 1 /* Use this unless the system bmove is faster */ -#endif - -/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */ -#ifdef I_AM_PARANOID -#define DONT_ALLOW_USER_CHANGE 1 -#define DONT_USE_MYSQL_PWD 1 -#endif - -/* #define USE_some_charset 1 was deprecated by changes to configure */ -/* my_ctype my_to_upper, my_to_lower, my_sort_order gain theit right value */ -/* automagically during configuration */ - -/* Does the system remember a signal handler after a signal ? */ -#ifndef HAVE_BSD_SIGNALS -#define DONT_REMEMBER_SIGNAL -#endif - -/* Define void to stop lint from generating "null effekt" comments */ -#ifndef DONT_DEFINE_VOID -#ifdef _lint -int __void__; -#define VOID(X) (__void__ = (int) (X)) -#else -#undef VOID -#define VOID(X) (X) -#endif -#endif /* DONT_DEFINE_VOID */ - -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) -#define LINT_INIT(var) var=0 /* No uninitialize-warning */ -#else -#define LINT_INIT(var) -#endif - -/* Define som useful general macros */ -#if defined(__cplusplus) && defined(__GNUC__) -#define max(a, b) ((a) >? (b)) -#define min(a, b) ((a) <? (b)) -#elif !defined(max) -#define max(a, b) ((a) > (b) ? (a) : (b)) -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#if defined(__EMX__) || !defined(HAVE_UINT) -typedef unsigned int uint; -typedef unsigned short ushort; -#endif - -#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) -#define swap(t,a,b) { register t dummy; dummy = a; a = b; b = dummy; } -#define test(a) ((a) ? 1 : 0) -#define set_if_bigger(a,b) { if ((a) < (b)) (a)=(b); } -#define set_if_smaller(a,b) { if ((a) > (b)) (a)=(b); } -#define test_all_bits(a,b) (((a) & (b)) == (b)) -#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) -#ifndef HAVE_RINT -#define rint(A) floor((A)+0.5) -#endif - -/* Define som general constants */ -#ifndef TRUE -#define TRUE (1) /* Logical true */ -#define FALSE (0) /* Logical false */ -#endif - -#if defined(__GNUC__) -#define function_volatile volatile -#define my_reinterpret_cast(A) reinterpret_cast<A> -#define my_const_cast(A) const_cast<A> -#elif !defined(my_reinterpret_cast) -#define my_reinterpret_cast(A) (A) -#define my_const_cast(A) (A) -#endif -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) -#define __attribute__(A) -#endif - -/* From old s-system.h */ - -/* Support macros for non ansi & other old compilers. Since such - things are no longer supported we do nothing. We keep then since - some of our code may still be needed to upgrade old customers. */ -#define _VARARGS(X) X -#define _STATIC_VARARGS(X) X -#define _PC(X) X - -#if defined(DBUG_ON) && defined(DBUG_OFF) -#undef DBUG_OFF -#endif - -#if defined(_lint) && !defined(DBUG_OFF) -#define DBUG_OFF -#endif - -#include <dbug.h> -#ifndef DBUG_OFF -#define dbug_assert(A) assert(A) -#else -#define dbug_assert(A) -#endif - -#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ -#define ASCII_BITS_USED 8 /* Bit char used */ -#define NEAR_F /* No near function handling */ - -/* Some types that is different between systems */ - -typedef int File; /* File descriptor */ -#ifndef Socket_defined -typedef int my_socket; /* File descriptor for sockets */ -#define INVALID_SOCKET -1 -#endif -/* Type for fuctions that handles signals */ -#define sig_handler RETSIGTYPE -typedef void (*sig_return)();/* Returns type from signal */ -#if defined(__GNUC__) && !defined(_lint) -typedef char pchar; /* Mixed prototypes can take char */ -typedef char puchar; /* Mixed prototypes can take char */ -typedef char pbool; /* Mixed prototypes can take char */ -typedef short pshort; /* Mixed prototypes can take short int */ -typedef float pfloat; /* Mixed prototypes can take float */ -#else -typedef int pchar; /* Mixed prototypes can't take char */ -typedef uint puchar; /* Mixed prototypes can't take char */ -typedef int pbool; /* Mixed prototypes can't take char */ -typedef int pshort; /* Mixed prototypes can't take short int */ -typedef double pfloat; /* Mixed prototypes can't take float */ -#endif -typedef int (*qsort_cmp)(const void *,const void *); -#ifdef HAVE_mit_thread -#define qsort_t void -#undef QSORT_TYPE_IS_VOID -#define QSORT_TYPE_IS_VOID -#else -#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */ -#endif -#ifdef HAVE_mit_thread -#define size_socket socklen_t /* Type of last arg to accept */ -#else -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -typedef SOCKET_SIZE_TYPE size_socket; -#endif - -#ifndef SOCKOPT_OPTLEN_TYPE -#define SOCKOPT_OPTLEN_TYPE size_socket -#endif - -/* file create flags */ - -#ifndef O_SHARE -#define O_SHARE 0 /* Flag to my_open for shared files */ -#ifndef O_BINARY -#define O_BINARY 0 /* Flag to my_open for binary files */ -#endif -#define FILE_BINARY 0 /* Flag to my_fopen for binary streams */ -#ifdef HAVE_FCNTL -#define HAVE_FCNTL_LOCK -#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ -#endif -#endif /* O_SHARE */ -#ifndef O_TEMPORARY -#define O_TEMPORARY 0 -#endif -#ifndef O_SHORT_LIVED -#define O_SHORT_LIVED 0 -#endif - -/* #define USE_RECORD_LOCK */ - - /* Unsigned types supported by the compiler */ -#define UNSINT8 /* unsigned int8 (char) */ -#define UNSINT16 /* unsigned int16 */ -#define UNSINT32 /* unsigned int32 */ - - /* General constants */ -#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */ -#define FN_LEN 256 /* Max file name len */ -#define FN_HEADLEN 253 /* Max length of filepart of file name */ -#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ -#define FN_REFLEN 512 /* Max length of full path-name */ -#define FN_EXTCHAR '.' -#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ -#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ -#define FN_PARENTDIR ".." /* Parentdirectory; Must be a string */ -#define FN_DEVCHAR ':' - -#ifndef FN_LIBCHAR -#ifdef __EMX__ -#define FN_LIBCHAR '\\' -#define FN_ROOTDIR "\\" -#else -#define FN_LIBCHAR '/' -#define FN_ROOTDIR "/" -#endif -#define MY_NFILE 1024 /* This is only used to save filenames */ -#endif - -/* #define EXT_IN_LIBNAME */ -/* #define FN_NO_CASE_SENCE */ -/* #define FN_UPPER_CASE TRUE */ - -/* Io buffer size; Must be a power of 2 and a multiple of 512. May be - smaller what the disk page size. This influences the speed of the - isam btree library. eg to big to slow. */ -#define IO_SIZE 4096 -/* How much overhead does malloc have. The code often allocates - something like 1024-MALLOC_OVERHEAD bytes */ -#ifdef SAFEMALLOC -#define MALLOC_OVERHEAD (8+24+4) -#else -#define MALLOC_OVERHEAD 8 -#endif - /* get memory in huncs */ -#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD) - /* Typical record cash */ -#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD) - /* Typical key cash */ -#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD) - - /* Some things that this system doesn't have */ - -#define ONLY_OWN_DATABASES /* We are using only databases by monty */ -#define NO_PISAM /* Not needed anymore */ -#define NO_MISAM /* Not needed anymore */ -#define NO_HASH /* Not needed anymore */ -#ifdef __WIN__ -#define NO_DIR_LIBRARY /* Not standar dir-library */ -#define USE_MY_STAT_STRUCT /* For my_lib */ -#endif - -/* Some things that this system does have */ - -#ifndef HAVE_ITOA -#define USE_MY_ITOA /* There is no itoa */ -#endif - -/* Some defines of functions for portability */ - -#ifndef HAVE_ATOD -#define atod atof -#endif -#ifdef USE_MY_ATOF -#define atof my_atof -extern void init_my_atof(void); -extern double my_atof(const char*); -#endif -#undef remove /* Crashes MySQL on SCO 5.0.0 */ -#ifndef __WIN__ -#ifdef OS2 -#define closesocket(A) soclose(A) -#else -#define closesocket(A) close(A) -#endif -#ifndef ulonglong2double -#define ulonglong2double(A) ((double) (A)) -#define my_off_t2double(A) ((double) (A)) -#endif -#endif - -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif -#define ulong_to_double(X) ((double) (ulong) (X)) -#define SET_STACK_SIZE(X) /* Not needed on real machines */ - -#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R) -#define strtok_r(A,B,C) strtok((A),(B)) -#endif - -#ifdef HAVE_LINUXTHREADS -/* #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) */ -/* #define sigset(A,B) signal((A),(B)) */ -#endif - -/* Remove some things that mit_thread break or doesn't support */ -#if defined(HAVE_mit_thread) && defined(THREAD) -#undef HAVE_PREAD -#undef HAVE_REALPATH -#undef HAVE_MLOCK -#undef HAVE_TEMPNAM /* Use ours */ -#undef HAVE_PTHREAD_SETPRIO -#undef HAVE_FTRUNCATE -#undef HAVE_READLINK -#endif - -/* This is from the old m-machine.h file */ - -#if SIZEOF_LONG_LONG > 4 -#define HAVE_LONG_LONG 1 -#endif - -#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) -#define LONGLONG_MIN ((long long) 0x8000000000000000LL) -#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) -#endif - -#if SIZEOF_LONG == 4 -#define INT_MIN32 (long) 0x80000000L -#define INT_MAX32 (long) 0x7FFFFFFFL -#define INT_MIN24 ((long) 0xff800000L) -#define INT_MAX24 0x007fffffL -#define INT_MIN16 ((short int) 0x8000) -#define INT_MAX16 0x7FFF -#define INT_MIN8 ((char) 0x80) -#define INT_MAX8 ((char) 0x7F) -#else /* Probably Alpha */ -#define INT_MIN32 ((long) (int) 0x80000000) -#define INT_MAX32 ((long) (int) 0x7FFFFFFF) -#define INT_MIN24 ((long) (int) 0xff800000) -#define INT_MAX24 ((long) (int) 0x007fffff) -#define INT_MIN16 ((short int) 0xffff8000) -#define INT_MAX16 ((short int) 0x00007FFF) -#endif - -/* From limits.h instead */ -#ifndef DBL_MIN -#define DBL_MIN 4.94065645841246544e-324 -#define FLT_MIN ((float)1.40129846432481707e-45) -#endif -#ifndef DBL_MAX -#define DBL_MAX 1.79769313486231470e+308 -#define FLT_MAX ((float)3.40282346638528860e+38) -#endif - -/* Max size that must be added to a so that we know Size to make - adressable obj. */ -typedef long my_ptrdiff_t; -#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) -#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) -/* Size to make adressable obj. */ -#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) - /* Offset of filed f in structure t */ -#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) -#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) -#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) - -#define NullS (char *) 0 -/* Nowdays we do not support MessyDos */ -#ifndef NEAR -#define NEAR /* Who needs segments ? */ -#define FAR /* On a good machine */ -#ifndef HUGE_PTR -#define HUGE_PTR -#endif -#endif -#if defined(__IBMC__) || defined(__IBMCPP__) -#define STDCALL _System _Export -#elif !defined( STDCALL) -#define STDCALL -#endif - -/* Typdefs for easyier portability */ - -#if defined(VOIDTYPE) -typedef void *gptr; /* Generic pointer */ -#else -typedef char *gptr; /* Generic pointer */ -#endif -#ifndef HAVE_INT_8_16_32 -typedef char int8; /* Signed integer >= 8 bits */ -typedef short int16; /* Signed integer >= 16 bits */ -#endif -#ifndef HAVE_UCHAR -typedef unsigned char uchar; /* Short for unsigned char */ -#endif -typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */ -typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */ - -#if SIZEOF_INT == 4 -#ifndef HAVE_INT_8_16_32 -typedef int int32; -#endif -typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */ -#elif SIZEOF_LONG == 4 -#ifndef HAVE_INT_8_16_32 -typedef long int32; -#endif -typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */ -#else -error "Neither int or long is of 4 bytes width" -#endif - -#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC) -typedef unsigned long ulong; /* Short for unsigned long */ -#endif -#ifndef longlong_defined -#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 -typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ -typedef long long int longlong; -#else -typedef unsigned long ulonglong; /* ulong or unsigned long long */ -typedef long longlong; -#endif -#endif - -#ifdef USE_RAID -/* The following is done with a if to not get problems with pre-processors - with late define evaluation */ -#if SIZEOF_OFF_T == 4 -#define SYSTEM_SIZEOF_OFF_T 4 -#else -#define SYSTEM_SIZEOF_OFF_T 8 -#endif -#undef SIZEOF_OFF_T -#define SIZEOF_OFF_T 8 -#else -#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T -#endif /* USE_RAID */ - -#if SIZEOF_OFF_T > 4 -typedef ulonglong my_off_t; -#else -typedef unsigned long my_off_t; -#endif -#define MY_FILEPOS_ERROR (~(my_off_t) 0) -#if !defined(__WIN__) && !defined(OS2) -typedef off_t os_off_t; -#endif - -#if defined(__WIN__) -#define socket_errno WSAGetLastError() -#define SOCKET_EINTR WSAEINTR -#define SOCKET_EAGAIN WSAEINPROGRESS -#define SOCKET_ENFILE ENFILE -#define SOCKET_EMFILE EMFILE -#elif defined(OS2) -#define socket_errno sock_errno() -#define SOCKET_EINTR SOCEINTR -#define SOCKET_EAGAIN SOCEINPROGRESS -#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK -#define SOCKET_ENFILE SOCENFILE -#define SOCKET_EMFILE SOCEMFILE -#define closesocket(A) soclose(A) -#else /* Unix */ -#define socket_errno errno -#define closesocket(A) close(A) -#define SOCKET_EINTR EINTR -#define SOCKET_EAGAIN EAGAIN -#define SOCKET_EWOULDBLOCK EWOULDBLOCK -#define SOCKET_ENFILE ENFILE -#define SOCKET_EMFILE EMFILE -#endif - -typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ -typedef short int15; /* Most effective integer 0 <= x <= 32767 */ -typedef char *my_string; /* String of characters */ -typedef unsigned long size_s; /* Size of strings (In string-funcs) */ -typedef int myf; /* Type of MyFlags in my_funcs */ -#ifndef byte_defined -typedef char byte; /* Smallest addressable unit */ -#endif -typedef char my_bool; /* Small bool */ -#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus)) -typedef char bool; /* Ordinary boolean values 0 1 */ -#endif - /* Macros for converting *constants* to the right type */ -#define INT8(v) (int8) (v) -#define INT16(v) (int16) (v) -#define INT32(v) (int32) (v) -#define MYF(v) (myf) (v) - -/* Defines to make it possible to prioritize register assignments. No - longer needed with moder compilers */ -#ifndef USING_X -#define reg1 register -#define reg2 register -#define reg3 register -#define reg4 register -#define reg5 register -#define reg6 register -#define reg7 register -#define reg8 register -#define reg9 register -#define reg10 register -#define reg11 register -#define reg12 register -#define reg13 register -#define reg14 register -#define reg15 register -#define reg16 register -#endif - -/* Defines for time function */ -#define SCALE_SEC 100 -#define SCALE_USEC 10000 -#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ -#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ - -/* -** Define-funktions for reading and storing in machine independent format -** (low byte first) -*/ - -/* Optimized store functions for Intel x86 */ -#ifdef __i386__ -#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) - -typedef union { - double v; - long m[2]; -} doubleget_union; -#define doubleget(V,M) { ((doubleget_union *)&V)->m[0] = *((long*) M); \ - ((doubleget_union *)&V)->m[1] = *(((long*) M)+1); } -#define doublestore(T,V) { *((long *) T) = ((doubleget_union *)&V)->m[0]; \ - *(((long *) T)+1) = ((doubleget_union *)&V)->m[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)) -#endif /* __i386__ */ - -#ifndef sint2korr -#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ - ((int16) ((int16) (A)[1]) << 8)) -#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ - (((uint32) 255L << 24) | \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0])) : \ - (((uint32) (uchar) (A)[2]) << 16) |\ - (((uint32) (uchar) (A)[1]) << 8) | \ - ((uint32) (uchar) (A)[0]))) -#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\ - (((int32) ((uchar) (A)[1]) << 8)) +\ - (((int32) ((uchar) (A)[2]) << 16)) +\ - (((int32) ((int16) (A)[3]) << 24))) -#define sint8korr(A) (longlong) uint8korr(A) -#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\ - ((uint16) ((uchar) (A)[1]) << 8)) -#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16)) -#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) -#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) ((uchar) (A)[4])) << 32)) -#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ - (((uint32) ((uchar) (A)[1])) << 8) +\ - (((uint32) ((uchar) (A)[2])) << 16) +\ - (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) (((uint32) ((uchar) (A)[4])) +\ - (((uint32) ((uchar) (A)[5])) << 8) +\ - (((uint32) ((uchar) (A)[6])) << 16) +\ - (((uint32) ((uchar) (A)[7])) << 24))) <<\ - 32)) -#define int2store(T,A) { uint def_temp= (uint) (A) ;\ - *((uchar*) (T))= (uchar)(def_temp); \ - *((uchar*) (T+1))=(uchar)((def_temp >> 8)); } -#define int3store(T,A) { /*lint -save -e734 */\ - *((T))=(char) ((A));\ - *((T)+1)=(char) (((A) >> 8));\ - *((T)+2)=(char) (((A) >> 16)); \ - /*lint -restore */} -#define int4store(T,A) { *(T)=(char) ((A));\ - *((T)+1)=(char) (((A) >> 8));\ - *((T)+2)=(char) (((A) >> 16));\ - *((T)+3)=(char) (((A) >> 24)); } -#define int5store(T,A) { *(T)=((A));\ - *((T)+1)=(((A) >> 8));\ - *((T)+2)=(((A) >> 16));\ - *((T)+3)=(((A) >> 24)); \ - *((T)+4)=(((A) >> 32)); } -#define int8store(T,A) { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \ - int4store((T),def_temp); \ - int4store((T+4),def_temp2); \ - } -#ifdef WORDS_BIGENDIAN -#define float4store(T,A) { *(T)= ((byte *) &A)[3];\ - *((T)+1)=(char) ((byte *) &A)[2];\ - *((T)+2)=(char) ((byte *) &A)[1];\ - *((T)+3)=(char) ((byte *) &A)[0]; } - -#define float4get(V,M) { float def_temp;\ - ((byte*) &def_temp)[0]=(M)[3];\ - ((byte*) &def_temp)[1]=(M)[2];\ - ((byte*) &def_temp)[2]=(M)[1];\ - ((byte*) &def_temp)[3]=(M)[0];\ - (V)=def_temp; } -#define float8store(T,V) { *(T)= ((byte *) &V)[7];\ - *((T)+1)=(char) ((byte *) &V)[6];\ - *((T)+2)=(char) ((byte *) &V)[5];\ - *((T)+3)=(char) ((byte *) &V)[4];\ - *((T)+4)=(char) ((byte *) &V)[3];\ - *((T)+5)=(char) ((byte *) &V)[2];\ - *((T)+6)=(char) ((byte *) &V)[1];\ - *((T)+7)=(char) ((byte *) &V)[0]; } - -#define float8get(V,M) { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[7];\ - ((byte*) &def_temp)[1]=(M)[6];\ - ((byte*) &def_temp)[2]=(M)[5];\ - ((byte*) &def_temp)[3]=(M)[4];\ - ((byte*) &def_temp)[4]=(M)[3];\ - ((byte*) &def_temp)[5]=(M)[2];\ - ((byte*) &def_temp)[6]=(M)[1];\ - ((byte*) &def_temp)[7]=(M)[0];\ - (V) = def_temp; } -#else -#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) -#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) - -#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) -#define doublestore(T,V) { *(T)= ((byte *) &V)[4];\ - *((T)+1)=(char) ((byte *) &V)[5];\ - *((T)+2)=(char) ((byte *) &V)[6];\ - *((T)+3)=(char) ((byte *) &V)[7];\ - *((T)+4)=(char) ((byte *) &V)[0];\ - *((T)+5)=(char) ((byte *) &V)[1];\ - *((T)+6)=(char) ((byte *) &V)[2];\ - *((T)+7)=(char) ((byte *) &V)[3]; } -#define doubleget(V,M) { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[4];\ - ((byte*) &def_temp)[1]=(M)[5];\ - ((byte*) &def_temp)[2]=(M)[6];\ - ((byte*) &def_temp)[3]=(M)[7];\ - ((byte*) &def_temp)[4]=(M)[0];\ - ((byte*) &def_temp)[5]=(M)[1];\ - ((byte*) &def_temp)[6]=(M)[2];\ - ((byte*) &def_temp)[7]=(M)[3];\ - (V) = def_temp; } -#endif /* __FLOAT_WORD_ORDER */ - -#define float8get(V,M) doubleget((V),(M)) -#define float8store(V,M) doublestore((V),(M)) -#endif /* WORDS_BIGENDIAN */ - -#endif /* sint2korr */ - -/* Define-funktions for reading and storing in machine format from/to - short/long to/from some place in memory V should be a (not - register) variable, M is a pointer to byte */ - -#ifdef WORDS_BIGENDIAN - -#define ushortget(V,M) { V = (uint16) (((uint16) ((uchar) (M)[1]))+\ - ((uint16) ((uint16) (M)[0]) << 8)); } -#define shortget(V,M) { V = (short) (((short) ((uchar) (M)[1]))+\ - ((short) ((short) (M)[0]) << 8)); } -#define longget(V,M) { int32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ - (V)=def_temp; } -#define ulongget(V,M) { uint32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ - (V)=def_temp; } -#define shortstore(T,A) { uint def_temp=(uint) (A) ;\ - *(T+1)=(char)(def_temp); \ - *(T+0)=(char)(def_temp >> 8); } -#define longstore(T,A) { *((T)+3)=((A));\ - *((T)+2)=(((A) >> 8));\ - *((T)+1)=(((A) >> 16));\ - *((T)+0)=(((A) >> 24)); } - -#define doubleget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double)) -#define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong)) - -#else - -#define ushortget(V,M) { V = uint2korr(M); } -#define shortget(V,M) { V = sint2korr(M); } -#define longget(V,M) { V = sint4korr(M); } -#define ulongget(V,M) { V = uint4korr(M); } -#define shortstore(T,V) int2store(T,V) -#define longstore(T,V) int4store(T,V) -#ifndef doubleget -#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) -#endif /* doubleget */ -#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) - -#endif /* WORDS_BIGENDIAN */ - -/* sprintf does not always return the number of bytes :- */ -#ifdef SPRINTF_RETURNS_INT -#define my_sprintf(buff,args) sprintf args -#else -#ifdef SPRINTF_RETURNS_PTR -#define my_sprintf(buff,args) ((int)(sprintf args - buff)) -#else -#define my_sprintf(buff,args) sprintf args,strlen(buff) -#endif -#endif - -#ifndef THREAD -#define thread_safe_increment(V,L) (V)++ -#define thread_safe_add(V,C,L) (V)+=(C) -#define thread_safe_sub(V,C,L) (V)-=(C) -#define statistic_increment(V,L) (V)++ -#define statistic_add(V,C,L) (V)+=(C) -#endif - -#endif /* _global_h */ diff --git a/ext/mysql/libmysql/int2str.c b/ext/mysql/libmysql/int2str.c deleted file mode 100644 index bb12b00cdc..0000000000 --- a/ext/mysql/libmysql/int2str.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Defines: int2str(), itoa(), ltoa() - - int2str(dst, radix, val) - converts the (long) integer "val" to character form and moves it to - the destination string "dst" followed by a terminating NUL. The - result is normally a pointer to this NUL character, but if the radix - is dud the result will be NullS and nothing will be changed. - - If radix is -2..-36, val is taken to be SIGNED. - If radix is 2.. 36, val is taken to be UNSIGNED. - That is, val is signed if and only if radix is. You will normally - use radix -10 only through itoa and ltoa, for radix 2, 8, or 16 - unsigned is what you generally want. - - _dig_vec is public just in case someone has a use for it. - The definitions of itoa and ltoa are actually macros in m_string.h, - but this is where the code is. - - Note: The standard itoa() returns a pointer to the argument, when int2str - returns the pointer to the end-null. - itoa assumes that 10 -base numbers are allways signed and other arn't. -*/ - -#include <global.h> -#include "m_string.h" - -char NEAR _dig_vec[] = - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - -char *int2str(register long int val, register char *dst, register int radix) -{ - char buffer[65]; - register char *p; - long int new_val; - - if (radix < 0) { - if (radix < -36 || radix > -2) return NullS; - if (val < 0) { - *dst++ = '-'; - val = -val; - } - radix = -radix; - } else { - if (radix > 36 || radix < 2) return NullS; - } - /* The slightly contorted code which follows is due to the - fact that few machines directly support unsigned long / and %. - Certainly the VAX C compiler generates a subroutine call. In - the interests of efficiency (hollow laugh) I let this happen - for the first digit only; after that "val" will be in range so - that signed integer division will do. Sorry 'bout that. - CHECK THE CODE PRODUCED BY YOUR C COMPILER. The first % and / - should be unsigned, the second % and / signed, but C compilers - tend to be extraordinarily sensitive to minor details of style. - This works on a VAX, that's all I claim for it. - */ - p = &buffer[sizeof(buffer)-1]; - *p = '\0'; - new_val=(ulong) val / (ulong) radix; - *--p = _dig_vec[(uchar) ((ulong) val- (ulong) new_val*(ulong) radix)]; - val = new_val; -#ifdef HAVE_LDIV - while (val != 0) - { - ldiv_t res; - res=ldiv(val,radix); - *--p = _dig_vec[res.rem]; - val= res.quot; - } -#else - while (val != 0) - { - new_val=val/radix; - *--p = _dig_vec[(uchar) (val-new_val*radix)]; - val= new_val; - } -#endif - while ((*dst++ = *p++) != 0) ; - return dst-1; -} - - -/* - This is a faster version of the above optimized for the normal case of - radix 10 / -10 -*/ - -char *int10_to_str(long int val,char *dst,int radix) -{ - char buffer[65]; - register char *p; - long int new_val; - - if (radix < 0) /* -10 */ - { - if (val < 0) - { - *dst++ = '-'; - val = -val; - } - } - - p = &buffer[sizeof(buffer)-1]; - *p = '\0'; - new_val= (long) ((unsigned long int) val / 10); - *--p = '0'+ (char) ((unsigned long int) val - (unsigned long) new_val * 10); - val = new_val; - - while (val != 0) - { - new_val=val/10; - *--p = '0' + (char) (val-new_val*10); - val= new_val; - } - while ((*dst++ = *p++) != 0) ; - return dst-1; -} - - -#ifdef USE_MY_ITOA - - /* Change to less general itoa interface */ - -char *my_itoa(int val, char *dst, int radix) -{ - VOID(int2str((long) val,dst,(radix == 10 ? -10 : radix))); - return dst; -} - -char *my_ltoa(long int val, char *dst, int radix) -{ - VOID(int2str((long) val,dst,(radix == 10 ? -10 : radix))); - return dst; -} - -#endif diff --git a/ext/mysql/libmysql/is_prefix.c b/ext/mysql/libmysql/is_prefix.c deleted file mode 100644 index c0ed472103..0000000000 --- a/ext/mysql/libmysql/is_prefix.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : is_prefix.c - Author : Michael Widenius - Defines: is_prefix() - - is_prefix(s, t) returns 1 if s starts with t. - A empty t is allways a prefix. -*/ - -#include <global.h> -#include "m_string.h" - -int is_prefix(register const char *s, register const char *t) -{ - while (*t) - if (*s++ != *t++) return 0; - return 1; /* WRONG */ -} diff --git a/ext/mysql/libmysql/libmysql.c b/ext/mysql/libmysql/libmysql.c deleted file mode 100644 index 433de0380e..0000000000 --- a/ext/mysql/libmysql/libmysql.c +++ /dev/null @@ -1,2604 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include <global.h> -#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) -#include <winsock.h> -#include <odbcinst.h> -#endif -#include <my_sys.h> -#include <mysys_err.h> -#include <m_string.h> -#include <m_ctype.h> -#include "mysql.h" -#include "mysql_version.h" -#include "mysqld_error.h" -#include "errmsg.h" -#include <violite.h> -#include <sys/stat.h> -#include <signal.h> -#include <time.h> -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif -#if !defined(MSDOS) && !defined(__WIN__) -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#ifdef HAVE_SELECT_H -# include <select.h> -#endif -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -#endif -#ifdef HAVE_SYS_UN_H -# include <sys/un.h> -#endif -#if defined(THREAD) && !defined(__WIN__) -#include <my_pthread.h> /* because of signal() */ -#endif -#ifndef INADDR_NONE -#define INADDR_NONE -1 -#endif - -static my_bool mysql_client_init=0; -uint mysql_port=0; -my_string mysql_unix_port=0; - -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS) - -#ifdef __WIN__ -#define CONNECT_TIMEOUT 20 -#else -#define CONNECT_TIMEOUT 0 -#endif - -#if defined(MSDOS) || defined(__WIN__) -/* socket_errno is defined in global.h for all platforms */ -#define perror(A) -#else -#include <errno.h> -#define SOCKET_ERROR -1 -#endif /* __WIN__ */ - -static void mysql_once_init(void); -static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields, - uint field_count); -static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, - ulong *lengths); -static void end_server(MYSQL *mysql); -static void read_user_name(char *name); -static void append_wild(char *to,char *end,const char *wild); -static my_bool mysql_reconnect(MYSQL *mysql); -static int send_file_to_server(MYSQL *mysql,const char *filename); -static sig_handler pipe_sig_handler(int sig); -static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, - const char *from, ulong length); - -/* - Let the user specify that we don't want SIGPIPE; This doesn't however work - with threaded applications as we can have multiple read in progress. -*/ - -#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD) -#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0; -#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler) -#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler); -#else -#define init_sigpipe_variables -#define set_sigpipe(mysql) -#define reset_sigpipe(mysql) -#endif - -/**************************************************************************** -* A modified version of connect(). connect2() allows you to specify -* a timeout value, in seconds, that we should wait until we -* derermine we can't connect to a particular host. If timeout is 0, -* connect2() will behave exactly like connect(). -* -* Base version coded by Steve Bernacki, Jr. <steve@navinet.net> -*****************************************************************************/ - -static int connect2(my_socket s, const struct sockaddr *name, uint namelen, - uint timeout) -{ -#if defined(__WIN__) || defined(OS2) - return connect(s, (struct sockaddr*) name, namelen); -#else - int flags, res, s_err; - SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint); - fd_set sfds; - struct timeval tv; - time_t start_time, now_time; - - /* If they passed us a timeout of zero, we should behave - * exactly like the normal connect() call does. - */ - - if (timeout == 0) - return connect(s, (struct sockaddr*) name, namelen); - - flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */ -#ifdef O_NONBLOCK - fcntl(s, F_SETFL, flags | O_NONBLOCK); /* and save the flags.. */ -#endif - - res = connect(s, (struct sockaddr*) name, namelen); - s_err = errno; /* Save the error... */ - fcntl(s, F_SETFL, flags); - if ((res != 0) && (s_err != EINPROGRESS)) - { - errno = s_err; /* Restore it */ - return(-1); - } - if (res == 0) /* Connected quickly! */ - return(0); - - /* Otherwise, our connection is "in progress." We can use - * the select() call to wait up to a specified period of time - * for the connection to suceed. If select() returns 0 - * (after waiting howevermany seconds), our socket never became - * writable (host is probably unreachable.) Otherwise, if - * select() returns 1, then one of two conditions exist: - * - * 1. An error occured. We use getsockopt() to check for this. - * 2. The connection was set up sucessfully: getsockopt() will - * return 0 as an error. - * - * Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk> - * who posted this method of timing out a connect() in - * comp.unix.programmer on August 15th, 1997. - */ - - FD_ZERO(&sfds); - FD_SET(s, &sfds); - /* - * select could be interrupted by a signal, and if it is, - * the timeout should be adjusted and the select restarted - * to work around OSes that don't restart select and - * implementations of select that don't adjust tv upon - * failure to reflect the time remaining - */ - start_time = time(NULL); - for (;;) - { - tv.tv_sec = (long) timeout; - tv.tv_usec = 0; - if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) - break; - now_time=time(NULL); - timeout-= (uint) (now_time - start_time); - if (errno != EINTR || (int) timeout <= 0) - return -1; - } - - /* select() returned something more interesting than zero, let's - * see if we have any errors. If the next two statements pass, - * we've got an open socket! - */ - - s_err=0; - if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0) - return(-1); - - if (s_err) - { /* getsockopt could succeed */ - errno = s_err; - return(-1); /* but return an error... */ - } - return(0); /* It's all good! */ -#endif -} - -/* -** Create a named pipe connection -*/ - -#ifdef __WIN__ - -HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, - char **arg_unix_socket) -{ - HANDLE hPipe=INVALID_HANDLE_VALUE; - char szPipeName [ 257 ]; - DWORD dwMode; - int i; - my_bool testing_named_pipes=0; - char *host= *arg_host, *unix_socket= *arg_unix_socket; - - if ( ! unix_socket || (unix_socket)[0] == 0x00) - unix_socket = mysql_unix_port; - if (!host || !strcmp(host,LOCAL_HOST)) - host=LOCAL_HOST_NAMEDPIPE; - - sprintf( szPipeName, "\\\\%s\\pipe\\%s", host, unix_socket); - DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s", - host, unix_socket)); - - for (i=0 ; i < 100 ; i++) /* Don't retry forever */ - { - if ((hPipe = CreateFile(szPipeName, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL )) != INVALID_HANDLE_VALUE) - break; - if (GetLastError() != ERROR_PIPE_BUSY) - { - net->last_errno=CR_NAMEDPIPEOPEN_ERROR; - sprintf(net->last_error,ER(net->last_errno),host, unix_socket, - (ulong) GetLastError()); - return INVALID_HANDLE_VALUE; - } - /* wait for for an other instance */ - if (! WaitNamedPipe(szPipeName, connect_timeout*1000) ) - { - net->last_errno=CR_NAMEDPIPEWAIT_ERROR; - sprintf(net->last_error,ER(net->last_errno),host, unix_socket, - (ulong) GetLastError()); - return INVALID_HANDLE_VALUE; - } - } - if (hPipe == INVALID_HANDLE_VALUE) - { - net->last_errno=CR_NAMEDPIPEOPEN_ERROR; - sprintf(net->last_error,ER(net->last_errno),host, unix_socket, - (ulong) GetLastError()); - return INVALID_HANDLE_VALUE; - } - dwMode = PIPE_READMODE_BYTE | PIPE_WAIT; - if ( !SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL) ) - { - CloseHandle( hPipe ); - net->last_errno=CR_NAMEDPIPESETSTATE_ERROR; - sprintf(net->last_error,ER(net->last_errno),host, unix_socket, - (ulong) GetLastError()); - return INVALID_HANDLE_VALUE; - } - *arg_host=host ; *arg_unix_socket=unix_socket; /* connect arg */ - return (hPipe); -} -#endif - - -/***************************************************************************** -** read a packet from server. Give error message if socket was down -** or packet is an error message -*****************************************************************************/ - -uint -net_safe_read(MYSQL *mysql) -{ - NET *net= &mysql->net; - uint len=0; - init_sigpipe_variables - - /* Don't give sigpipe errors if the client doesn't want them */ - set_sigpipe(mysql); - if (net->vio != 0) - len=my_net_read(net); - reset_sigpipe(mysql); - - if (len == packet_error || len == 0) - { - DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", - vio_description(net->vio),len)); - end_server(mysql); - net->last_errno=(net->last_errno == ER_NET_PACKET_TOO_LARGE ? - CR_NET_PACKET_TOO_LARGE: - CR_SERVER_LOST); - strmov(net->last_error,ER(net->last_errno)); - return(packet_error); - } - if (net->read_pos[0] == 255) - { - if (len > 3) - { - char *pos=(char*) net->read_pos+1; - if (mysql->protocol_version > 9) - { /* New client protocol */ - net->last_errno=uint2korr(pos); - pos+=2; - len-=2; - } - else - { - net->last_errno=CR_UNKNOWN_ERROR; - len--; - } - (void) strmake(net->last_error,(char*) pos, - min(len,sizeof(net->last_error)-1)); - } - else - { - net->last_errno=CR_UNKNOWN_ERROR; - (void) strmov(net->last_error,ER(net->last_errno)); - } - DBUG_PRINT("error",("Got error: %d (%s)", net->last_errno, - net->last_error)); - return(packet_error); - } - return len; -} - - -/* Get the length of next field. Change parameter to point at fieldstart */ -static ulong -net_field_length(uchar **packet) -{ - reg1 uchar *pos= *packet; - if (*pos < 251) - { - (*packet)++; - return (ulong) *pos; - } - if (*pos == 251) - { - (*packet)++; - return NULL_LENGTH; - } - if (*pos == 252) - { - (*packet)+=3; - return (ulong) uint2korr(pos+1); - } - if (*pos == 253) - { - (*packet)+=4; - return (ulong) uint3korr(pos+1); - } - (*packet)+=9; /* Must be 254 when here */ - return (ulong) uint4korr(pos+1); -} - -/* Same as above, but returns ulonglong values */ - -static my_ulonglong -net_field_length_ll(uchar **packet) -{ - reg1 uchar *pos= *packet; - if (*pos < 251) - { - (*packet)++; - return (my_ulonglong) *pos; - } - if (*pos == 251) - { - (*packet)++; - return (my_ulonglong) NULL_LENGTH; - } - if (*pos == 252) - { - (*packet)+=3; - return (my_ulonglong) uint2korr(pos+1); - } - if (*pos == 253) - { - (*packet)+=4; - return (my_ulonglong) uint3korr(pos+1); - } - (*packet)+=9; /* Must be 254 when here */ -#ifdef NO_CLIENT_LONGLONG - return (my_ulonglong) uint4korr(pos+1); -#else - return (my_ulonglong) uint8korr(pos+1); -#endif -} - - -static void free_rows(MYSQL_DATA *cur) -{ - if (cur) - { - free_root(&cur->alloc,MYF(0)); - my_free((gptr) cur,MYF(0)); - } -} - - -int -simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, - uint length, my_bool skipp_check) -{ - NET *net= &mysql->net; - int result= -1; - init_sigpipe_variables - - /* Don't give sigpipe errors if the client doesn't want them */ - set_sigpipe(mysql); - if (mysql->net.vio == 0) - { /* Do reconnect if possible */ - if (mysql_reconnect(mysql)) - { - net->last_errno=CR_SERVER_GONE_ERROR; - strmov(net->last_error,ER(net->last_errno)); - goto end; - } - } - if (mysql->status != MYSQL_STATUS_READY) - { - strmov(net->last_error,ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); - goto end; - } - - mysql->net.last_error[0]=0; - mysql->net.last_errno=0; - mysql->info=0; - mysql->affected_rows= ~(my_ulonglong) 0; - net_clear(net); /* Clear receive buffer */ - if (!arg) - arg=""; - - if (net_write_command(net,(uchar) command,arg, - length ? length : (ulong) strlen(arg))) - { - DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno)); - end_server(mysql); - if (mysql_reconnect(mysql) || - net_write_command(net,(uchar) command,arg, - length ? length : (ulong) strlen(arg))) - { - net->last_errno=CR_SERVER_GONE_ERROR; - strmov(net->last_error,ER(net->last_errno)); - goto end; - } - } - result=0; - if (!skipp_check) - result= ((mysql->packet_length=net_safe_read(mysql)) == packet_error ? - -1 : 0); - end: - reset_sigpipe(mysql); - return result; -} - - -static void free_old_query(MYSQL *mysql) -{ - DBUG_ENTER("free_old_query"); - if (mysql->fields) - free_root(&mysql->field_alloc,MYF(0)); - init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */ - mysql->fields=0; - mysql->field_count=0; /* For API */ - DBUG_VOID_RETURN; -} - -#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL) -struct passwd *getpwuid(uid_t); -char* getlogin(void); -#endif - -#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2) -static void read_user_name(char *name) -{ - DBUG_ENTER("read_user_name"); - if (geteuid() == 0) - (void) strmov(name,"root"); /* allow use of surun */ - else - { -#ifdef HAVE_GETPWUID - struct passwd *skr; - const char *str; - if ((str=getlogin()) == NULL) - { - if ((skr=getpwuid(geteuid())) != NULL) - str=skr->pw_name; - else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) && - !(str=getenv("LOGIN"))) - str="UNKNOWN_USER"; - } - (void) strmake(name,str,USERNAME_LENGTH); -#elif HAVE_CUSERID - (void) cuserid(name); -#else - strmov(name,"UNKNOWN_USER"); -#endif - } - DBUG_VOID_RETURN; -} - -#else /* If MSDOS || VMS */ - -static void read_user_name(char *name) -{ - char *str=getenv("USER"); /* ODBC will send user variable */ - strmake(name,str ? str : "ODBC", USERNAME_LENGTH); -} - -#endif - -#ifdef __WIN__ -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif - -/* -** Expand wildcard to a sql string -*/ - -static void -append_wild(char *to, char *end, const char *wild) -{ - end-=5; /* Some extra */ - if (wild && wild[0]) - { - to=strmov(to," like '"); - while (*wild && to < end) - { - if (*wild == '\\' || *wild == '\'') - *to++='\\'; - *to++= *wild++; - } - if (*wild) /* Too small buffer */ - *to++='%'; /* Nicer this way */ - to[0]='\''; - to[1]=0; - } -} - - - -/************************************************************************** -** Init debugging if MYSQL_DEBUG environment variable is found -**************************************************************************/ - -void STDCALL -mysql_debug(const char *debug __attribute__((unused))) -{ -#ifndef DBUG_OFF - char *env; - if (_db_on_) - return; /* Already using debugging */ - if (debug) - { - DEBUGGER_ON; - DBUG_PUSH(debug); - } - else if ((env = getenv("MYSQL_DEBUG"))) - { - DEBUGGER_ON; - DBUG_PUSH(env); -#if !defined(_WINVER) && !defined(WINVER) - puts("\n-------------------------------------------------------"); - puts("MYSQL_DEBUG found. libmysql started with the following:"); - puts(env); - puts("-------------------------------------------------------\n"); -#else - { - char buff[80]; - strmov(strmov(buff,"libmysql: "),env); - MessageBox((HWND) 0,"Debugging variable MYSQL_DEBUG used",buff,MB_OK); - } -#endif - } -#endif -} - - -/************************************************************************** -** Close the server connection if we get a SIGPIPE - ARGSUSED -**************************************************************************/ - -static sig_handler -pipe_sig_handler(int sig __attribute__((unused))) -{ - DBUG_PRINT("info",("Hit by signal %d",sig)); -#ifdef DONT_REMEMBER_SIGNAL - (void) signal(SIGPIPE,pipe_sig_handler); -#endif -} - - -/************************************************************************** -** Shut down connection -**************************************************************************/ - -static void -end_server(MYSQL *mysql) -{ - DBUG_ENTER("end_server"); - if (mysql->net.vio != 0) - { - init_sigpipe_variables - DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio))); - set_sigpipe(mysql); - vio_delete(mysql->net.vio); - reset_sigpipe(mysql); - mysql->net.vio= 0; /* Marker */ - } - net_end(&mysql->net); - free_old_query(mysql); - DBUG_VOID_RETURN; -} - - -void STDCALL -mysql_free_result(MYSQL_RES *result) -{ - DBUG_ENTER("mysql_free_result"); - DBUG_PRINT("enter",("mysql_res: %lx",result)); - if (result) - { - if (result->handle && result->handle->status == MYSQL_STATUS_USE_RESULT) - { - DBUG_PRINT("warning",("Not all rows in set were read; Ignoring rows")); - for (;;) - { - uint pkt_len; - if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error) - break; - if (pkt_len == 1 && result->handle->net.read_pos[0] == 254) - break; /* End of data */ - } - result->handle->status=MYSQL_STATUS_READY; - } - free_rows(result->data); - if (result->fields) - free_root(&result->field_alloc,MYF(0)); - if (result->row) - my_free((gptr) result->row,MYF(0)); - my_free((gptr) result,MYF(0)); - } - DBUG_VOID_RETURN; -} - - -/**************************************************************************** -** Get options from my.cnf -****************************************************************************/ - -static const char *default_options[]= -{ - "port","socket","compress","password","pipe", "timeout", "user", - "init-command", "host", "database", "debug", "return-found-rows", - "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", - "character-set-dir", "default-character-set", "interactive-timeout", - "connect-timeout", "local-infile", "disable-local-infile", - NullS -}; - -static TYPELIB option_types={array_elements(default_options)-1, - "options",default_options}; - -static void mysql_read_default_options(struct st_mysql_options *options, - const char *filename,const char *group) -{ - int argc; - char *argv_buff[1],**argv; - const char *groups[3]; - DBUG_ENTER("mysql_read_default_options"); - DBUG_PRINT("enter",("file: %s group: %s",filename,group ? group :"NULL")); - - argc=1; argv=argv_buff; argv_buff[0]= (char*) "client"; - groups[0]= (char*) "client"; groups[1]= (char*) group; groups[2]=0; - - load_defaults(filename, groups, &argc, &argv); - if (argc != 1) /* If some default option */ - { - char **option=argv; - while (*++option) - { - /* DBUG_PRINT("info",("option: %s",option[0])); */ - if (option[0][0] == '-' && option[0][1] == '-') - { - char *end=strcend(*option,'='); - char *opt_arg=0; - if (*end) - { - opt_arg=end+1; - *end=0; /* Remove '=' */ - } - /* Change all '_' in variable name to '-' */ - for (end= *option ; (end= strcend(end,'_')) ; ) - *end= '-'; - switch (find_type(*option+2,&option_types,2)) { - case 1: /* port */ - if (opt_arg) - options->port=atoi(opt_arg); - break; - case 2: /* socket */ - if (opt_arg) - { - my_free(options->unix_socket,MYF(MY_ALLOW_ZERO_PTR)); - options->unix_socket=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 3: /* compress */ - options->compress=1; - break; - case 4: /* password */ - if (opt_arg) - { - my_free(options->password,MYF(MY_ALLOW_ZERO_PTR)); - options->password=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 5: /* pipe */ - options->named_pipe=1; /* Force named pipe */ - break; - case 20: /* connect_timeout */ - case 6: /* timeout */ - if (opt_arg) - options->connect_timeout=atoi(opt_arg); - break; - case 7: /* user */ - if (opt_arg) - { - my_free(options->user,MYF(MY_ALLOW_ZERO_PTR)); - options->user=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 8: /* init-command */ - if (opt_arg) - { - my_free(options->init_command,MYF(MY_ALLOW_ZERO_PTR)); - options->init_command=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 9: /* host */ - if (opt_arg) - { - my_free(options->host,MYF(MY_ALLOW_ZERO_PTR)); - options->host=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 10: /* database */ - if (opt_arg) - { - my_free(options->db,MYF(MY_ALLOW_ZERO_PTR)); - options->db=my_strdup(opt_arg,MYF(MY_WME)); - } - break; - case 11: /* debug */ - mysql_debug(opt_arg ? opt_arg : "d:t:o,/tmp/client.trace"); - break; - case 12: /* return-found-rows */ - options->client_flag|=CLIENT_FOUND_ROWS; - break; -#ifdef HAVE_OPENSSL - case 13: /* ssl_key */ - my_free(options->ssl_key, MYF(MY_ALLOW_ZERO_PTR)); - options->ssl_key = my_strdup(opt_arg, MYF(MY_WME)); - break; - case 14: /* ssl_cert */ - my_free(options->ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); - options->ssl_cert = my_strdup(opt_arg, MYF(MY_WME)); - break; - case 15: /* ssl_ca */ - my_free(options->ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); - options->ssl_ca = my_strdup(opt_arg, MYF(MY_WME)); - break; - case 16: /* ssl_capath */ - my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); - options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME)); - break; -#else - case 13: /* Ignore SSL options */ - case 14: - case 15: - case 16: - break; -#endif /* HAVE_OPENSSL */ - case 17: /* charset-lib */ - my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR)); - options->charset_dir = my_strdup(opt_arg, MYF(MY_WME)); - break; - case 18: - my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR)); - options->charset_name = my_strdup(opt_arg, MYF(MY_WME)); - break; - case 19: /* Interactive-timeout */ - options->client_flag|= CLIENT_INTERACTIVE; - break; - case 21: - if (!opt_arg || atoi(opt_arg) != 0) - options->client_flag|= CLIENT_LOCAL_FILES; - else - options->client_flag&= ~CLIENT_LOCAL_FILES; - break; - case 22: - options->client_flag&= CLIENT_LOCAL_FILES; - break; - default: - DBUG_PRINT("warning",("unknown option: %s",option[0])); - } - } - } - } - free_defaults(argv); - DBUG_VOID_RETURN; -} - - -/*************************************************************************** -** Change field rows to field structs -***************************************************************************/ - -static MYSQL_FIELD * -unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, - my_bool default_value, my_bool long_flag_protocol) -{ - MYSQL_ROWS *row; - MYSQL_FIELD *field,*result; - DBUG_ENTER("unpack_fields"); - - field=result=(MYSQL_FIELD*) alloc_root(alloc,sizeof(MYSQL_FIELD)*fields); - if (!result) - DBUG_RETURN(0); - - for (row=data->data; row ; row = row->next,field++) - { - field->table= strdup_root(alloc,(char*) row->data[0]); - field->name= strdup_root(alloc,(char*) row->data[1]); - field->length= (uint) uint3korr(row->data[2]); - field->type= (enum enum_field_types) (uchar) row->data[3][0]; - if (long_flag_protocol) - { - field->flags= uint2korr(row->data[4]); - field->decimals=(uint) (uchar) row->data[4][2]; - } - else - { - field->flags= (uint) (uchar) row->data[4][0]; - field->decimals=(uint) (uchar) row->data[4][1]; - } - if (INTERNAL_NUM_FIELD(field)) - field->flags|= NUM_FLAG; - if (default_value && row->data[5]) - field->def=strdup_root(alloc,(char*) row->data[5]); - else - field->def=0; - field->max_length= 0; - } - free_rows(data); /* Free old data */ - DBUG_RETURN(result); -} - - -/* Read all rows (fields or data) from server */ - -static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - uint fields) -{ - uint field,pkt_len; - ulong len; - uchar *cp; - char *to, *end_to; - MYSQL_DATA *result; - MYSQL_ROWS **prev_ptr,*cur; - NET *net = &mysql->net; - DBUG_ENTER("read_rows"); - - if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error) - DBUG_RETURN(0); - if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), - MYF(MY_WME | MY_ZEROFILL)))) - { - net->last_errno=CR_OUT_OF_MEMORY; - strmov(net->last_error,ER(net->last_errno)); - DBUG_RETURN(0); - } - init_alloc_root(&result->alloc,8192,0); /* Assume rowlength < 8192 */ - result->alloc.min_malloc=sizeof(MYSQL_ROWS); - prev_ptr= &result->data; - result->rows=0; - result->fields=fields; - - while (*(cp=net->read_pos) != 254 || pkt_len != 1) - { - result->rows++; - if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc, - sizeof(MYSQL_ROWS))) || - !(cur->data= ((MYSQL_ROW) - alloc_root(&result->alloc, - (fields+1)*sizeof(char *)+pkt_len)))) - { - free_rows(result); - net->last_errno=CR_OUT_OF_MEMORY; - strmov(net->last_error,ER(net->last_errno)); - DBUG_RETURN(0); - } - *prev_ptr=cur; - prev_ptr= &cur->next; - to= (char*) (cur->data+fields+1); - end_to = to + pkt_len - 1; - for (field=0 ; field < fields ; field++) - { - if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH) - { /* null field */ - cur->data[field] = 0; - } - else - { - cur->data[field] = to; - if (len > end_to - to) - { - free_rows(result); - net->last_errno = CR_UNKNOWN_ERROR; - strmov(net->last_error, ER(net->last_errno)); - DBUG_RETURN(0); - } - memcpy(to,(char*) cp,len); to[len]=0; - to+=len+1; - cp+=len; - if (mysql_fields) - { - if (mysql_fields[field].max_length < len) - mysql_fields[field].max_length=len; - } - } - } - cur->data[field]=to; /* End of last field */ - if ((pkt_len=net_safe_read(mysql)) == packet_error) - { - free_rows(result); - DBUG_RETURN(0); - } - } - *prev_ptr=0; /* last pointer is null */ - DBUG_PRINT("exit",("Got %d rows",result->rows)); - DBUG_RETURN(result); -} - - -/* -** Read one row. Uses packet buffer as storage for fields. -** When next packet is read, the previous field values are destroyed -*/ - - -static int -read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) -{ - uint field; - ulong pkt_len,len; - uchar *pos,*prev_pos,*end_pos; - - if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error) - return -1; - if (pkt_len == 1 && mysql->net.read_pos[0] == 254) - return 1; /* End of data */ - prev_pos= 0; /* allowed to write at packet[-1] */ - pos=mysql->net.read_pos; - end_pos=pos+pkt_len; - for (field=0 ; field < fields ; field++) - { - if ((len=(ulong) net_field_length(&pos)) == NULL_LENGTH) - { /* null field */ - row[field] = 0; - *lengths++=0; - } - else - { - if (len > end_pos - pos) - { - mysql->net.last_errno=CR_UNKNOWN_ERROR; - strmov(mysql->net.last_error, ER(mysql->net.last_errno)); - return -1; - } - row[field] = (char*) pos; - pos+=len; - *lengths++=len; - } - if (prev_pos) - *prev_pos=0; /* Terminate prev field */ - prev_pos=pos; - } - row[field]=(char*) prev_pos+1; /* End of last field */ - *prev_pos=0; /* Terminate last field */ - return 0; -} - -/**************************************************************************** -** Init MySQL structure or allocate one -****************************************************************************/ - -MYSQL * STDCALL -mysql_init(MYSQL *mysql) -{ - mysql_once_init(); - if (!mysql) - { - if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL)))) - return 0; - mysql->free_me=1; - mysql->net.vio = 0; - } - else - bzero((char*) (mysql),sizeof(*(mysql))); - mysql->options.connect_timeout=CONNECT_TIMEOUT; -#if defined(SIGPIPE) && defined(THREAD) && !defined(__WIN__) - if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE)) - (void) signal(SIGPIPE,pipe_sig_handler); -#endif - -/* - Only enable LOAD DATA INFILE by default if configured with - --with-enabled-local-inflile -*/ -#ifdef ENABLED_LOCAL_INFILE - mysql->options.client_flag|= CLIENT_LOCAL_FILES; -#endif - return mysql; -} - - -static void mysql_once_init() -{ - if (!mysql_client_init) - { - mysql_client_init=1; - my_init(); /* Will init threads */ - init_client_errs(); - if (!mysql_port) - { - mysql_port = MYSQL_PORT; -#ifndef MSDOS - { - struct servent *serv_ptr; - char *env; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); - if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port =(uint) atoi(env); - } -#endif - } - if (!mysql_unix_port) - { - char *env; -#ifdef __WIN__ - mysql_unix_port = (char*) MYSQL_NAMEDPIPE; -#else - mysql_unix_port = (char*) MYSQL_UNIX_ADDR; -#endif - if ((env = getenv("MYSQL_UNIX_PORT"))) - mysql_unix_port = env; - } - mysql_debug(NullS); -#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__) - (void) signal(SIGPIPE,SIG_IGN); -#endif - } -#ifdef THREAD - else - my_thread_init(); /* Init if new thread */ -#endif -} - -#ifdef HAVE_OPENSSL -/************************************************************************** -** Fill in SSL part of MYSQL structure and set 'use_ssl' flag. -** NB! Errors are not reported until you do mysql_real_connect. -**************************************************************************/ - -int STDCALL -mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, - const char *ca, const char *capath) -{ - mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0)); - mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0)); - mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0)); - mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0)); - mysql->options.use_ssl = true; - mysql->connector_fd = new_VioSSLConnectorFd(key, cert, ca, capath); - return 0; -} - -/************************************************************************** -**************************************************************************/ - -char * STDCALL -mysql_ssl_cipher(MYSQL *mysql) -{ - return (char *)mysql->net.vio->cipher_description(); -} - - -/************************************************************************** -** Free strings in the SSL structure and clear 'use_ssl' flag. -** NB! Errors are not reported until you do mysql_real_connect. -**************************************************************************/ - -int STDCALL -mysql_ssl_clear(MYSQL *mysql) -{ - my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.ssl_key = 0; - mysql->options.ssl_cert = 0; - mysql->options.ssl_ca = 0; - mysql->options.ssl_capath = 0; - mysql->options.use_ssl = false; - mysql->connector_fd->delete(); - mysql->connector_fd = 0; - return 0; -} -#endif /* HAVE_OPENSSL */ - -/************************************************************************** -** Connect to sql server -** If host == 0 then use localhost -**************************************************************************/ - -MYSQL * STDCALL -mysql_connect(MYSQL *mysql,const char *host, - const char *user, const char *passwd) -{ - MYSQL *res; - mysql=mysql_init(mysql); /* Make it thread safe */ - { - DBUG_ENTER("mysql_connect"); - if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0))) - { - if (mysql->free_me) - my_free((gptr) mysql,MYF(0)); - } - DBUG_RETURN(res); - } -} - - -/* -** Note that the mysql argument must be initialized with mysql_init() -** before calling mysql_real_connect ! -*/ - -MYSQL * STDCALL -mysql_real_connect(MYSQL *mysql,const char *host, const char *user, - const char *passwd, const char *db, - uint port, const char *unix_socket,uint client_flag) -{ - char buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16]; - char *end,*host_info,*charset_name; - my_socket sock; - uint32 ip_addr; - struct sockaddr_in sock_addr; - uint pkt_length; - NET *net= &mysql->net; -#ifdef __WIN__ - HANDLE hPipe=INVALID_HANDLE_VALUE; -#endif -#ifdef HAVE_SYS_UN_H - struct sockaddr_un UNIXaddr; -#endif - init_sigpipe_variables - DBUG_ENTER("mysql_real_connect"); - - DBUG_PRINT("enter",("host: %s db: %s user: %s", - host ? host : "(Null)", - db ? db : "(Null)", - user ? user : "(Null)")); - - /* Don't give sigpipe errors if the client doesn't want them */ - set_sigpipe(mysql); - net->vio = 0; /* If something goes wrong */ - /* use default options */ - if (mysql->options.my_cnf_file || mysql->options.my_cnf_group) - { - mysql_read_default_options(&mysql->options, - (mysql->options.my_cnf_file ? - mysql->options.my_cnf_file : "my"), - mysql->options.my_cnf_group); - my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.my_cnf_file=mysql->options.my_cnf_group=0; - } - - /* Some empty-string-tests are done because of ODBC */ - if (!host || !host[0]) - host=mysql->options.host; - if (!user || !user[0]) - user=mysql->options.user; - if (!passwd) - { - passwd=mysql->options.password; -#ifndef DONT_USE_MYSQL_PWD - if (!passwd) - passwd=getenv("MYSQL_PWD"); /* get it from environment (haneke) */ -#endif - } - if (!db || !db[0]) - db=mysql->options.db; - if (!port) - port=mysql->options.port; - if (!unix_socket) - unix_socket=mysql->options.unix_socket; - - mysql->reconnect=1; /* Reconnect as default */ - mysql->server_status=SERVER_STATUS_AUTOCOMMIT; - - /* - ** Grab a socket and connect it to the server - */ - -#if defined(HAVE_SYS_UN_H) - if ((!host || !strcmp(host,LOCAL_HOST)) && (unix_socket || mysql_unix_port)) - { - host=LOCAL_HOST; - if (!unix_socket) - unix_socket=mysql_unix_port; - host_info=(char*) ER(CR_LOCALHOST_CONNECTION); - DBUG_PRINT("info",("Using UNIX sock '%s'",unix_socket)); - if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) - { - net->last_errno=CR_SOCKET_CREATE_ERROR; - sprintf(net->last_error,ER(net->last_errno),socket_errno); - goto error; - } - net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); - bzero((char*) &UNIXaddr,sizeof(UNIXaddr)); - UNIXaddr.sun_family = AF_UNIX; - strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path) - 1); - if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), - mysql->options.connect_timeout) <0) - { - DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno)); - net->last_errno=CR_CONNECTION_ERROR; - sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); - goto error; - } - } - else -#elif defined(__WIN__) - { - if ((unix_socket || - !host && is_NT() || - host && !strcmp(host,LOCAL_HOST_NAMEDPIPE) || - mysql->options.named_pipe || !have_tcpip)) - { - sock=0; - if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout, - (char**) &host, (char**) &unix_socket)) == - INVALID_HANDLE_VALUE) - { - DBUG_PRINT("error", - ("host: '%s' socket: '%s' named_pipe: %d have_tcpip: %d", - host ? host : "<null>", - unix_socket ? unix_socket : "<null>", - (int) mysql->options.named_pipe, - (int) have_tcpip)); - if (mysql->options.named_pipe || - (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || - (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE))) - goto error; /* User only requested named pipes */ - /* Try also with TCP/IP */ - } - else - { - net->vio=vio_new_win32pipe(hPipe); - sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host, - unix_socket); - } - } - } - if (hPipe == INVALID_HANDLE_VALUE) -#endif - { - unix_socket=0; /* This is not used */ - if (!port) - port=mysql_port; - if (!host) - host=LOCAL_HOST; - sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); - DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); - /* _WIN64 ; Assume that the (int) range is enough for socket() */ - if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) - { - net->last_errno=CR_IPSOCK_ERROR; - sprintf(net->last_error,ER(net->last_errno),socket_errno); - goto error; - } - net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); - bzero((char*) &sock_addr,sizeof(sock_addr)); - sock_addr.sin_family = AF_INET; - - /* - ** The server name may be a host name or IP address - */ - - if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE) - { - memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr)); - } - else -#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD) - { - int tmp_errno; - struct hostent tmp_hostent,*hp; - char buff2[GETHOSTBYNAME_BUFF_SIZE]; - hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2), - &tmp_errno); - if (!hp) - { - net->last_errno=CR_UNKNOWN_HOST; - sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno); - goto error; - } - memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); - } -#else - { - struct hostent *hp; - if (!(hp=gethostbyname(host))) - { - net->last_errno=CR_UNKNOWN_HOST; - sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno); - goto error; - } - memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); - } -#endif - sock_addr.sin_port = (ushort) htons((ushort) port); - if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), - mysql->options.connect_timeout) <0) - { - DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,host)); - net->last_errno= CR_CONN_HOST_ERROR; - sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); - goto error; - } - } - - if (!net->vio || my_net_init(net, net->vio)) - { - vio_delete(net->vio); - net->vio = 0; - net->last_errno=CR_OUT_OF_MEMORY; - strmov(net->last_error,ER(net->last_errno)); - goto error; - } - vio_keepalive(net->vio,TRUE); - - /* Get version info */ - mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ - if (mysql->options.connect_timeout && - vio_poll_read(net->vio, mysql->options.connect_timeout)) - { - net->last_errno= CR_SERVER_LOST; - strmov(net->last_error,ER(net->last_errno)); - goto error; - } - if ((pkt_length=net_safe_read(mysql)) == packet_error) - goto error; - - /* Check if version of protocoll matches current one */ - - mysql->protocol_version= net->read_pos[0]; - DBUG_DUMP("packet",(char*) net->read_pos,10); - DBUG_PRINT("info",("mysql protocol version %d, server=%d", - PROTOCOL_VERSION, mysql->protocol_version)); - if (mysql->protocol_version != PROTOCOL_VERSION && - mysql->protocol_version != PROTOCOL_VERSION-1) - { - net->last_errno= CR_VERSION_ERROR; - sprintf(net->last_error, ER(CR_VERSION_ERROR), mysql->protocol_version, - PROTOCOL_VERSION); - goto error; - } - end=strend((char*) net->read_pos+1); - mysql->thread_id=uint4korr(end+1); - end+=5; - strmake(mysql->scramble_buff,end,8); - end+=9; - if (pkt_length >= (uint) (end+1 - (char*) net->read_pos)) - mysql->server_capabilities=uint2korr(end); - if (pkt_length >= (uint) (end+18 - (char*) net->read_pos)) - { - /* New protocol with 16 bytes to describe server characteristics */ - mysql->server_language=end[2]; - mysql->server_status=uint2korr(end+3); - } - - /* Set character set */ - if ((charset_name=mysql->options.charset_name)) - { - const char *save=charsets_dir; - if (mysql->options.charset_dir) - charsets_dir=mysql->options.charset_dir; - mysql->charset=get_charset_by_name(mysql->options.charset_name, - MYF(MY_WME)); - charsets_dir=save; - } - else if (mysql->server_language) - { - charset_name=charset_name_buff; - sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */ - if (!(mysql->charset = - get_charset((uint8) mysql->server_language, MYF(MY_WME)))) - mysql->charset = default_charset_info; /* shouldn't be fatal */ - - } - else - mysql->charset=default_charset_info; - - if (!mysql->charset) - { - net->last_errno=CR_CANT_READ_CHARSET; - if (mysql->options.charset_dir) - sprintf(net->last_error,ER(net->last_errno), - charset_name ? charset_name : "unknown", - mysql->options.charset_dir); - else - { - char cs_dir_name[FN_REFLEN]; - get_charsets_dir(cs_dir_name); - sprintf(net->last_error,ER(net->last_errno), - charset_name ? charset_name : "unknown", - cs_dir_name); - } - goto error; - } - - /* Save connection information */ - if (!user) user=""; - if (!passwd) passwd=""; - if (!my_multi_malloc(MYF(0), - &mysql->host_info, (uint) strlen(host_info)+1, - &mysql->host, (uint) strlen(host)+1, - &mysql->unix_socket,unix_socket ? - (uint) strlen(unix_socket)+1 : (uint) 1, - &mysql->server_version, - (uint) (end - (char*) net->read_pos), - NullS) || - !(mysql->user=my_strdup(user,MYF(0))) || - !(mysql->passwd=my_strdup(passwd,MYF(0)))) - { - strmov(net->last_error, ER(net->last_errno=CR_OUT_OF_MEMORY)); - goto error; - } - strmov(mysql->host_info,host_info); - strmov(mysql->host,host); - if (unix_socket) - strmov(mysql->unix_socket,unix_socket); - else - mysql->unix_socket=0; - strmov(mysql->server_version,(char*) net->read_pos+1); - mysql->port=port; - client_flag|=mysql->options.client_flag; - - /* Send client information for access check */ - client_flag|=CLIENT_CAPABILITIES; - -#ifdef HAVE_OPENSSL - if (mysql->options.use_ssl) - client_flag|=CLIENT_SSL; -#endif /* HAVE_OPENSSL */ - if (db) - client_flag|=CLIENT_CONNECT_WITH_DB; -#ifdef HAVE_COMPRESS - if ((mysql->server_capabilities & CLIENT_COMPRESS) && - (mysql->options.compress || (client_flag & CLIENT_COMPRESS))) - client_flag|=CLIENT_COMPRESS; /* We will use compression */ - else -#endif - client_flag&= ~CLIENT_COMPRESS; - -#ifdef HAVE_OPENSSL - if ((mysql->server_capabilities & CLIENT_SSL) && - (mysql->options.use_ssl || (client_flag & CLIENT_SSL))) - { - DBUG_PRINT("info", ("Changing IO layer to SSL")); - client_flag |= CLIENT_SSL; - } - else - { - if (client_flag & CLIENT_SSL) - { - DBUG_PRINT("info", ("Leaving IO layer intact because server doesn't support SSL")); - } - client_flag &= ~CLIENT_SSL; - } -#endif /* HAVE_OPENSSL */ - - int2store(buff,client_flag); - mysql->client_flag=client_flag; - -#ifdef HAVE_OPENSSL - /* Oops.. are we careful enough to not send ANY information */ - /* without encryption? */ - if (client_flag & CLIENT_SSL) - { - if (my_net_write(net,buff,(uint) (2)) || net_flush(net)) - goto error; - /* Do the SSL layering. */ - DBUG_PRINT("info", ("IO layer change in progress...")); - VioSSLConnectorFd* connector_fd = (VioSSLConnectorFd*) - (mysql->connector_fd); - VioSocket* vio_socket = (VioSocket*)(mysql->net.vio); - VioSSL* vio_ssl = connector_fd->connect(vio_socket); - mysql->net.vio = (NetVio*)(vio_ssl); - } -#endif /* HAVE_OPENSSL */ - - DBUG_PRINT("info",("Server version = '%s' capabilites: %ld status: %d client_flag: %d", - mysql->server_version,mysql->server_capabilities, - mysql->server_status, client_flag)); - - int3store(buff+2,max_allowed_packet); - if (user && user[0]) - strmake(buff+5,user,32); /* Max user name */ - else - read_user_name((char*) buff+5); -#ifdef _CUSTOMCONFIG_ -#include "_cust_libmysql.h"; -#endif - DBUG_PRINT("info",("user: %s",buff+5)); - end=scramble(strend(buff+5)+1, mysql->scramble_buff, passwd, - (my_bool) (mysql->protocol_version == 9)); - if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) - { - end=strmake(end+1,db,NAME_LEN); - mysql->db=my_strdup(db,MYF(MY_WME)); - db=0; - } - if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net) || - net_safe_read(mysql) == packet_error) - goto error; - if (client_flag & CLIENT_COMPRESS) /* We will use compression */ - net->compress=1; - if (db && mysql_select_db(mysql,db)) - goto error; - if (mysql->options.init_command) - { - my_bool reconnect=mysql->reconnect; - mysql->reconnect=0; - if (mysql_query(mysql,mysql->options.init_command)) - goto error; - mysql_free_result(mysql_use_result(mysql)); - mysql->reconnect=reconnect; - } - - DBUG_PRINT("exit",("Mysql handler: %lx",mysql)); - reset_sigpipe(mysql); - DBUG_RETURN(mysql); - -error: - reset_sigpipe(mysql); - DBUG_PRINT("error",("message: %u (%s)",net->last_errno,net->last_error)); - { - /* Free alloced memory */ - my_bool free_me=mysql->free_me; - end_server(mysql); - mysql->free_me=0; - mysql_close(mysql); - mysql->free_me=free_me; - } - DBUG_RETURN(0); -} - - -static my_bool mysql_reconnect(MYSQL *mysql) -{ - MYSQL tmp_mysql; - DBUG_ENTER("mysql_reconnect"); - - if (!mysql->reconnect || - (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info) - { - /* Allov reconnect next time */ - mysql->server_status&= ~SERVER_STATUS_IN_TRANS; - DBUG_RETURN(1); - } - mysql_init(&tmp_mysql); - tmp_mysql.options=mysql->options; - bzero((char*) &mysql->options,sizeof(mysql->options)); - if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, - mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) - DBUG_RETURN(1); - tmp_mysql.free_me=mysql->free_me; - mysql->free_me=0; - mysql_close(mysql); - *mysql=tmp_mysql; - net_clear(&mysql->net); - mysql->affected_rows= ~(my_ulonglong) 0; - DBUG_RETURN(0); -} - - -/************************************************************************** -** Change user and database -**************************************************************************/ - -my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, - const char *passwd, const char *db) -{ - char buff[512],*pos=buff; - DBUG_ENTER("mysql_change_user"); - - if (!user) - user=""; - if (!passwd) - passwd=""; - - pos=strmov(pos,user)+1; - pos=scramble(pos, mysql->scramble_buff, passwd, - (my_bool) (mysql->protocol_version == 9)); - pos=strmov(pos+1,db ? db : ""); - if (simple_command(mysql,COM_CHANGE_USER, buff,(uint) (pos-buff),0)) - DBUG_RETURN(1); - - my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); - - mysql->user= my_strdup(user,MYF(MY_WME)); - mysql->passwd=my_strdup(passwd,MYF(MY_WME)); - mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0; - DBUG_RETURN(0); -} - - -/************************************************************************** -** Set current database -**************************************************************************/ - -int STDCALL -mysql_select_db(MYSQL *mysql, const char *db) -{ - int error; - DBUG_ENTER("mysql_select_db"); - DBUG_PRINT("enter",("db: '%s'",db)); - - if ((error=simple_command(mysql,COM_INIT_DB,db,(uint) strlen(db),0))) - DBUG_RETURN(error); - my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); - mysql->db=my_strdup(db,MYF(MY_WME)); - DBUG_RETURN(0); -} - - -/************************************************************************* -** Send a QUIT to the server and close the connection -** If handle is alloced by mysql connect free it. -*************************************************************************/ - -void STDCALL -mysql_close(MYSQL *mysql) -{ - DBUG_ENTER("mysql_close"); - if (mysql) /* Some simple safety */ - { - if (mysql->net.vio != 0) - { - free_old_query(mysql); - mysql->status=MYSQL_STATUS_READY; /* Force command */ - mysql->reconnect=0; - simple_command(mysql,COM_QUIT,NullS,0,1); - end_server(mysql); - } - my_free((gptr) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); - /* Clear pointers for better safety */ - mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; - bzero((char*) &mysql->options,sizeof(mysql->options)); - mysql->net.vio = 0; -#ifdef HAVE_OPENSSL - ((VioConnectorFd*)(mysql->connector_fd))->delete(); - mysql->connector_fd = 0; -#endif /* HAVE_OPENSSL */ - if (mysql->free_me) - my_free((gptr) mysql,MYF(0)); - } - DBUG_VOID_RETURN; -} - - -/************************************************************************** -** Do a query. If query returned rows, free old rows. -** Read data by mysql_store_result or by repeat call of mysql_fetch_row -**************************************************************************/ - -int STDCALL -mysql_query(MYSQL *mysql, const char *query) -{ - return mysql_real_query(mysql,query, (uint) strlen(query)); -} - -/* - Send the query and return so we can do something else. - Needs to be followed by mysql_read_query_result() when we want to - finish processing it. -*/ - -int STDCALL -mysql_send_query(MYSQL* mysql, const char* query, uint length) -{ - return simple_command(mysql, COM_QUERY, query, length, 1); -} - -int STDCALL mysql_read_query_result(MYSQL *mysql) -{ - uchar *pos; - ulong field_count; - MYSQL_DATA *fields; - uint length; - DBUG_ENTER("mysql_read_query_result"); - - if ((length = net_safe_read(mysql)) == packet_error) - DBUG_RETURN(-1); - free_old_query(mysql); /* Free old result */ -get_info: - pos=(uchar*) mysql->net.read_pos; - if ((field_count= net_field_length(&pos)) == 0) - { - mysql->affected_rows= net_field_length_ll(&pos); - mysql->insert_id= net_field_length_ll(&pos); - if (mysql->server_capabilities & CLIENT_TRANSACTIONS) - { - mysql->server_status=uint2korr(pos); pos+=2; - } - if (pos < mysql->net.read_pos+length && net_field_length(&pos)) - mysql->info=(char*) pos; - DBUG_RETURN(0); - } - if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */ - { - int error=send_file_to_server(mysql,(char*) pos); - if ((length=net_safe_read(mysql)) == packet_error || error) - DBUG_RETURN(-1); - goto get_info; /* Get info packet */ - } - if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) - mysql->server_status|= SERVER_STATUS_IN_TRANS; - - mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */ - if (!(fields=read_rows(mysql,(MYSQL_FIELD*) 0,5))) - DBUG_RETURN(-1); - if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc, - (uint) field_count,0, - (my_bool) test(mysql->server_capabilities & - CLIENT_LONG_FLAG)))) - DBUG_RETURN(-1); - mysql->status=MYSQL_STATUS_GET_RESULT; - mysql->field_count=field_count; - DBUG_RETURN(0); -} - -int STDCALL -mysql_real_query(MYSQL *mysql, const char *query, uint length) -{ - DBUG_ENTER("mysql_real_query"); - DBUG_PRINT("enter",("handle: %lx",mysql)); - DBUG_PRINT("query",("Query = \"%s\"",query)); - if (simple_command(mysql,COM_QUERY,query,length,1)) - DBUG_RETURN(-1); - DBUG_RETURN(mysql_read_query_result(mysql)); -} - -static int -send_file_to_server(MYSQL *mysql, const char *filename) -{ - int fd, readcount; - char buf[IO_SIZE*15],*tmp_name; - DBUG_ENTER("send_file_to_server"); - - fn_format(buf,filename,"","",4); /* Convert to client format */ - if (!(tmp_name=my_strdup(buf,MYF(0)))) - { - strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY)); - DBUG_RETURN(-1); - } - if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0) - { - mysql->net.last_errno=EE_FILENOTFOUND; - sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); - strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); - my_net_write(&mysql->net,"",0); net_flush(&mysql->net); - my_free(tmp_name,MYF(0)); - DBUG_RETURN(-1); - } - - while ((readcount = (int) my_read(fd,buf,sizeof(buf),MYF(0))) > 0) - { - if (my_net_write(&mysql->net,buf,readcount)) - { - mysql->net.last_errno=CR_SERVER_LOST; - strmov(mysql->net.last_error,ER(mysql->net.last_errno)); - DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file")); - (void) my_close(fd,MYF(0)); - my_free(tmp_name,MYF(0)); - DBUG_RETURN(-1); - } - } - (void) my_close(fd,MYF(0)); - /* Send empty packet to mark end of file */ - if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net)) - { - mysql->net.last_errno=CR_SERVER_LOST; - sprintf(mysql->net.last_error,ER(mysql->net.last_errno),socket_errno); - my_free(tmp_name,MYF(0)); - DBUG_RETURN(-1); - } - if (readcount < 0) - { - mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */ - sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); - strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); - my_free(tmp_name,MYF(0)); - DBUG_RETURN(-1); - } - DBUG_RETURN(0); -} - - -/************************************************************************** -** Alloc result struct for buffered results. All rows are read to buffer. -** mysql_data_seek may be used. -**************************************************************************/ - -MYSQL_RES * STDCALL -mysql_store_result(MYSQL *mysql) -{ - MYSQL_RES *result; - DBUG_ENTER("mysql_store_result"); - - if (!mysql->fields) - DBUG_RETURN(0); - if (mysql->status != MYSQL_STATUS_GET_RESULT) - { - strmov(mysql->net.last_error, - ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); - DBUG_RETURN(0); - } - mysql->status=MYSQL_STATUS_READY; /* server is ready */ - if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+ - sizeof(ulong)*mysql->field_count, - MYF(MY_WME | MY_ZEROFILL)))) - { - mysql->net.last_errno=CR_OUT_OF_MEMORY; - strmov(mysql->net.last_error, ER(mysql->net.last_errno)); - DBUG_RETURN(0); - } - result->eof=1; /* Marker for buffered */ - result->lengths=(ulong*) (result+1); - if (!(result->data=read_rows(mysql,mysql->fields,mysql->field_count))) - { - my_free((gptr) result,MYF(0)); - DBUG_RETURN(0); - } - mysql->affected_rows= result->row_count= result->data->rows; - result->data_cursor= result->data->data; - result->fields= mysql->fields; - result->field_alloc= mysql->field_alloc; - result->field_count= mysql->field_count; - result->current_field=0; - result->current_row=0; /* Must do a fetch first */ - mysql->fields=0; /* fields is now in result */ - DBUG_RETURN(result); /* Data fetched */ -} - - -/************************************************************************** -** Alloc struct for use with unbuffered reads. Data is fetched by domand -** when calling to mysql_fetch_row. -** mysql_data_seek is a noop. -** -** No other queries may be specified with the same MYSQL handle. -** There shouldn't be much processing per row because mysql server shouldn't -** have to wait for the client (and will not wait more than 30 sec/packet). -**************************************************************************/ - -MYSQL_RES * STDCALL -mysql_use_result(MYSQL *mysql) -{ - MYSQL_RES *result; - DBUG_ENTER("mysql_use_result"); - - if (!mysql->fields) - DBUG_RETURN(0); - if (mysql->status != MYSQL_STATUS_GET_RESULT) - { - strmov(mysql->net.last_error, - ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); - DBUG_RETURN(0); - } - if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+ - sizeof(ulong)*mysql->field_count, - MYF(MY_WME | MY_ZEROFILL)))) - DBUG_RETURN(0); - result->lengths=(ulong*) (result+1); - if (!(result->row=(MYSQL_ROW) - my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) - { /* Ptrs: to one row */ - my_free((gptr) result,MYF(0)); - DBUG_RETURN(0); - } - result->fields= mysql->fields; - result->field_alloc= mysql->field_alloc; - result->field_count= mysql->field_count; - result->current_field=0; - result->handle= mysql; - result->current_row= 0; - mysql->fields=0; /* fields is now in result */ - mysql->status=MYSQL_STATUS_USE_RESULT; - DBUG_RETURN(result); /* Data is read to be fetched */ -} - - - -/************************************************************************** -** Return next field of the query results -**************************************************************************/ - -MYSQL_FIELD * STDCALL -mysql_fetch_field(MYSQL_RES *result) -{ - if (result->current_field >= result->field_count) - return(NULL); - return &result->fields[result->current_field++]; -} - - -/************************************************************************** -** Return next row of the query results -**************************************************************************/ - -MYSQL_ROW STDCALL -mysql_fetch_row(MYSQL_RES *res) -{ - DBUG_ENTER("mysql_fetch_row"); - if (!res->data) - { /* Unbufferred fetch */ - if (!res->eof) - { - if (!(read_one_row(res->handle,res->field_count,res->row, res->lengths))) - { - res->row_count++; - DBUG_RETURN(res->current_row=res->row); - } - else - { - DBUG_PRINT("info",("end of data")); - res->eof=1; - res->handle->status=MYSQL_STATUS_READY; - /* Don't clear handle in mysql_free_results */ - res->handle=0; - } - } - DBUG_RETURN((MYSQL_ROW) NULL); - } - { - MYSQL_ROW tmp; - if (!res->data_cursor) - { - DBUG_PRINT("info",("end of data")); - DBUG_RETURN(res->current_row=(MYSQL_ROW) NULL); - } - tmp = res->data_cursor->data; - res->data_cursor = res->data_cursor->next; - DBUG_RETURN(res->current_row=tmp); - } -} - -/************************************************************************** -** Get column lengths of the current row -** If one uses mysql_use_result, res->lengths contains the length information, -** else the lengths are calculated from the offset between pointers. -**************************************************************************/ - -ulong * STDCALL -mysql_fetch_lengths(MYSQL_RES *res) -{ - ulong *lengths,*prev_length; - byte *start; - MYSQL_ROW column,end; - - if (!(column=res->current_row)) - return 0; /* Something is wrong */ - if (res->data) - { - start=0; - prev_length=0; /* Keep gcc happy */ - lengths=res->lengths; - for (end=column+res->field_count+1 ; column != end ; column++,lengths++) - { - if (!*column) - { - *lengths=0; /* Null */ - continue; - } - if (start) /* Found end of prev string */ - *prev_length= (uint) (*column-start-1); - start= *column; - prev_length=lengths; - } - } - return res->lengths; -} - -/************************************************************************** -** Move to a specific row and column -**************************************************************************/ - -void STDCALL -mysql_data_seek(MYSQL_RES *result, my_ulonglong row) -{ - MYSQL_ROWS *tmp=0; - DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); - if (result->data) - for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; - result->current_row=0; - result->data_cursor = tmp; -} - -/************************************************************************* -** put the row or field cursor one a position one got from mysql_row_tell() -** This doesn't restore any data. The next mysql_fetch_row or -** mysql_fetch_field will return the next row or field after the last used -*************************************************************************/ - -MYSQL_ROW_OFFSET STDCALL -mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET row) -{ - MYSQL_ROW_OFFSET return_value=result->data_cursor; - result->current_row= 0; - result->data_cursor= row; - return return_value; -} - - -MYSQL_FIELD_OFFSET STDCALL -mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET field_offset) -{ - MYSQL_FIELD_OFFSET return_value=result->current_field; - result->current_field=field_offset; - return return_value; -} - -/***************************************************************************** -** List all databases -*****************************************************************************/ - -MYSQL_RES * STDCALL -mysql_list_dbs(MYSQL *mysql, const char *wild) -{ - char buff[255]; - DBUG_ENTER("mysql_list_dbs"); - - append_wild(strmov(buff,"show databases"),buff+sizeof(buff),wild); - if (mysql_query(mysql,buff)) - DBUG_RETURN(0); - DBUG_RETURN (mysql_store_result(mysql)); -} - - -/***************************************************************************** -** List all tables in a database -** If wild is given then only the tables matching wild is returned -*****************************************************************************/ - -MYSQL_RES * STDCALL -mysql_list_tables(MYSQL *mysql, const char *wild) -{ - char buff[255]; - DBUG_ENTER("mysql_list_tables"); - - append_wild(strmov(buff,"show tables"),buff+sizeof(buff),wild); - if (mysql_query(mysql,buff)) - DBUG_RETURN(0); - DBUG_RETURN (mysql_store_result(mysql)); -} - - -/************************************************************************** -** List all fields in a table -** If wild is given then only the fields matching wild is returned -** Instead of this use query: -** show fields in 'table' like "wild" -**************************************************************************/ - -MYSQL_RES * STDCALL -mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) -{ - MYSQL_RES *result; - MYSQL_DATA *query; - char buff[257],*end; - DBUG_ENTER("mysql_list_fields"); - DBUG_PRINT("enter",("table: '%s' wild: '%s'",table,wild ? wild : "")); - - LINT_INIT(query); - - end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128); - if (simple_command(mysql,COM_FIELD_LIST,buff,(uint) (end-buff),1) || - !(query = read_rows(mysql,(MYSQL_FIELD*) 0,6))) - DBUG_RETURN(NULL); - - free_old_query(mysql); - if (!(result = (MYSQL_RES *) my_malloc(sizeof(MYSQL_RES), - MYF(MY_WME | MY_ZEROFILL)))) - { - free_rows(query); - DBUG_RETURN(NULL); - } - result->field_alloc=mysql->field_alloc; - mysql->fields=0; - result->field_count = (uint) query->rows; - result->fields= unpack_fields(query,&result->field_alloc, - result->field_count,1, - (my_bool) test(mysql->server_capabilities & - CLIENT_LONG_FLAG)); - result->eof=1; - DBUG_RETURN(result); -} - -/* List all running processes (threads) in server */ - -MYSQL_RES * STDCALL -mysql_list_processes(MYSQL *mysql) -{ - MYSQL_DATA *fields; - uint field_count; - uchar *pos; - DBUG_ENTER("mysql_list_processes"); - - LINT_INIT(fields); - if (simple_command(mysql,COM_PROCESS_INFO,0,0,0)) - DBUG_RETURN(0); - free_old_query(mysql); - pos=(uchar*) mysql->net.read_pos; - field_count=(uint) net_field_length(&pos); - if (!(fields = read_rows(mysql,(MYSQL_FIELD*) 0,5))) - DBUG_RETURN(NULL); - if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,field_count,0, - (my_bool) test(mysql->server_capabilities & - CLIENT_LONG_FLAG)))) - DBUG_RETURN(0); - mysql->status=MYSQL_STATUS_GET_RESULT; - mysql->field_count=field_count; - DBUG_RETURN(mysql_store_result(mysql)); -} - - -int STDCALL -mysql_create_db(MYSQL *mysql, const char *db) -{ - DBUG_ENTER("mysql_createdb"); - DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (uint) strlen(db),0)); -} - - -int STDCALL -mysql_drop_db(MYSQL *mysql, const char *db) -{ - DBUG_ENTER("mysql_drop_db"); - DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(uint) strlen(db),0)); -} - - -int STDCALL -mysql_shutdown(MYSQL *mysql) -{ - DBUG_ENTER("mysql_shutdown"); - DBUG_RETURN(simple_command(mysql,COM_SHUTDOWN,0,0,0)); -} - - -int STDCALL -mysql_refresh(MYSQL *mysql,uint options) -{ - uchar bits[1]; - DBUG_ENTER("mysql_refresh"); - bits[0]= (uchar) options; - DBUG_RETURN(simple_command(mysql,COM_REFRESH,(char*) bits,1,0)); -} - -int STDCALL -mysql_kill(MYSQL *mysql,ulong pid) -{ - char buff[12]; - DBUG_ENTER("mysql_kill"); - int4store(buff,pid); - DBUG_RETURN(simple_command(mysql,COM_PROCESS_KILL,buff,4,0)); -} - - -int STDCALL -mysql_dump_debug_info(MYSQL *mysql) -{ - DBUG_ENTER("mysql_dump_debug_info"); - DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); -} - -char * STDCALL -mysql_stat(MYSQL *mysql) -{ - DBUG_ENTER("mysql_stat"); - if (simple_command(mysql,COM_STATISTICS,0,0,0)) - return mysql->net.last_error; - mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ - if (!mysql->net.read_pos[0]) - { - mysql->net.last_errno=CR_WRONG_HOST_INFO; - strmov(mysql->net.last_error, ER(mysql->net.last_errno)); - return mysql->net.last_error; - } - DBUG_RETURN((char*) mysql->net.read_pos); -} - - -int STDCALL -mysql_ping(MYSQL *mysql) -{ - DBUG_ENTER("mysql_ping"); - DBUG_RETURN(simple_command(mysql,COM_PING,0,0,0)); -} - - -char * STDCALL -mysql_get_server_info(MYSQL *mysql) -{ - return((char*) mysql->server_version); -} - - -char * STDCALL -mysql_get_host_info(MYSQL *mysql) -{ - return(mysql->host_info); -} - - -uint STDCALL -mysql_get_proto_info(MYSQL *mysql) -{ - return (mysql->protocol_version); -} - -char * STDCALL -mysql_get_client_info(void) -{ - return (char*) MYSQL_SERVER_VERSION; -} - - -int STDCALL -mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) -{ - DBUG_ENTER("mysql_option"); - DBUG_PRINT("enter",("option: %d",(int) option)); - switch (option) { - case MYSQL_OPT_CONNECT_TIMEOUT: - mysql->options.connect_timeout= *(uint*) arg; - break; - case MYSQL_OPT_COMPRESS: - mysql->options.compress= 1; /* Remember for connect */ - break; - case MYSQL_OPT_NAMED_PIPE: - mysql->options.named_pipe=1; /* Force named pipe */ - break; - case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/ - if (!arg || test(*(uint*) arg)) - mysql->options.client_flag|= CLIENT_LOCAL_FILES; - else - mysql->options.client_flag&= ~CLIENT_LOCAL_FILES; - break; - case MYSQL_INIT_COMMAND: - my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.init_command=my_strdup(arg,MYF(MY_WME)); - break; - case MYSQL_READ_DEFAULT_FILE: - my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME)); - break; - case MYSQL_READ_DEFAULT_GROUP: - my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME)); - break; - case MYSQL_SET_CHARSET_DIR: - my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME)); - break; - case MYSQL_SET_CHARSET_NAME: - my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); - mysql->options.charset_name=my_strdup(arg,MYF(MY_WME)); - break; - default: - DBUG_RETURN(-1); - } - DBUG_RETURN(0); -} - -/**************************************************************************** -** Functions to get information from the MySQL structure -** These are functions to make shared libraries more usable. -****************************************************************************/ - -/* MYSQL_RES */ -my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res) -{ - return res->row_count; -} - -unsigned int STDCALL mysql_num_fields(MYSQL_RES *res) -{ - return res->field_count; -} - -my_bool STDCALL mysql_eof(MYSQL_RES *res) -{ - return res->eof; -} - -MYSQL_FIELD * STDCALL mysql_fetch_field_direct(MYSQL_RES *res,uint fieldnr) -{ - return &(res)->fields[fieldnr]; -} - -MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res) -{ - return (res)->fields; -} - -MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res) -{ - return res->data_cursor; -} - -uint STDCALL mysql_field_tell(MYSQL_RES *res) -{ - return (res)->current_field; -} - -/* MYSQL */ - -unsigned int STDCALL mysql_field_count(MYSQL *mysql) -{ - return mysql->field_count; -} - -my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql) -{ - return (mysql)->affected_rows; -} - -my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql) -{ - return (mysql)->insert_id; -} - -uint STDCALL mysql_errno(MYSQL *mysql) -{ - return (mysql)->net.last_errno; -} - -char * STDCALL mysql_error(MYSQL *mysql) -{ - return (mysql)->net.last_error; -} - -char *STDCALL mysql_info(MYSQL *mysql) -{ - return (mysql)->info; -} - -ulong STDCALL mysql_thread_id(MYSQL *mysql) -{ - return (mysql)->thread_id; -} - -const char * STDCALL mysql_character_set_name(MYSQL *mysql) -{ - return mysql->charset->name; -} - - -uint STDCALL mysql_thread_safe(void) -{ -#ifdef THREAD - return 1; -#else - return 0; -#endif -} - -/**************************************************************************** -** Some support functions -****************************************************************************/ - -/* -** Add escape characters to a string (blob?) to make it suitable for a insert -** to should at least have place for length*2+1 chars -** Returns the length of the to string -*/ - -ulong STDCALL -mysql_escape_string(char *to,const char *from,ulong length) -{ - return mysql_sub_escape_string(default_charset_info,to,from,length); -} - -ulong STDCALL -mysql_real_escape_string(MYSQL *mysql, char *to,const char *from, - ulong length) -{ - return mysql_sub_escape_string(mysql->charset,to,from,length); -} - - -static ulong -mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, - const char *from, ulong length) -{ - const char *to_start=to; - const char *end; -#ifdef USE_MB - my_bool use_mb_flag=use_mb(charset_info); -#endif - for (end=from+length; from != end ; from++) - { -#ifdef USE_MB - int l; - if (use_mb_flag && (l = my_ismbchar(charset_info, from, end))) - { - while (l--) - *to++ = *from++; - from--; - continue; - } -#endif - switch (*from) { - case 0: /* Must be escaped for 'mysql' */ - *to++= '\\'; - *to++= '0'; - break; - case '\n': /* Must be escaped for logs */ - *to++= '\\'; - *to++= 'n'; - break; - case '\r': - *to++= '\\'; - *to++= 'r'; - break; - case '\\': - *to++= '\\'; - *to++= '\\'; - break; - case '\'': - *to++= '\\'; - *to++= '\''; - break; - case '"': /* Better safe than sorry */ - *to++= '\\'; - *to++= '"'; - break; - case '\032': /* This gives problems on Win32 */ - *to++= '\\'; - *to++= 'Z'; - break; - default: - *to++= *from; - } - } - *to=0; - return (ulong) (to-to_start); -} - - -char * STDCALL -mysql_odbc_escape_string(MYSQL *mysql, - char *to, ulong to_length, - const char *from, ulong from_length, - void *param, - char * (*extend_buffer) - (void *, char *, ulong *)) -{ - char *to_end=to+to_length-5; - const char *end; -#ifdef USE_MB - my_bool use_mb_flag=use_mb(mysql->charset); -#endif - - for (end=from+from_length; from != end ; from++) - { - if (to >= to_end) - { - to_length = (ulong) (end-from)+512; /* We want this much more */ - if (!(to=(*extend_buffer)(param, to, &to_length))) - return to; - to_end=to+to_length-5; - } -#ifdef USE_MB - { - int l; - if (use_mb_flag && (l = my_ismbchar(mysql->charset, from, end))) - { - while (l--) - *to++ = *from++; - from--; - continue; - } - } -#endif - switch (*from) { - case 0: /* Must be escaped for 'mysql' */ - *to++= '\\'; - *to++= '0'; - break; - case '\n': /* Must be escaped for logs */ - *to++= '\\'; - *to++= 'n'; - break; - case '\r': - *to++= '\\'; - *to++= 'r'; - break; - case '\\': - *to++= '\\'; - *to++= '\\'; - break; - case '\'': - *to++= '\\'; - *to++= '\''; - break; - case '"': /* Better safe than sorry */ - *to++= '\\'; - *to++= '"'; - break; - case '\032': /* This gives problems on Win32 */ - *to++= '\\'; - *to++= 'Z'; - break; - default: - *to++= *from; - } - } - return to; -} - -void STDCALL -myodbc_remove_escape(MYSQL *mysql,char *name) -{ - char *to; -#ifdef USE_MB - my_bool use_mb_flag=use_mb(mysql->charset); - char *end; - LINT_INIT(end); - if (use_mb_flag) - for (end=name; *end ; end++) ; -#endif - - for (to=name ; *name ; name++) - { -#ifdef USE_MB - int l; - if (use_mb_flag && (l = my_ismbchar( mysql->charset, name , end ) ) ) - { - while (l--) - *to++ = *name++; - name--; - continue; - } -#endif - if (*name == '\\' && name[1]) - name++; - *to++= *name; - } - *to=0; -} diff --git a/ext/mysql/libmysql/libmysql.dsp b/ext/mysql/libmysql/libmysql.dsp deleted file mode 100644 index 4525a51ab8..0000000000 --- a/ext/mysql/libmysql/libmysql.dsp +++ /dev/null @@ -1,585 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libmysql" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libmysql - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "libmysql.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "libmysql.mak" CFG="libmysql - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "libmysql - Win32 Debug_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Release_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Release_TS_inline" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Release_inline" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmysql - Win32 Release_TSDbg" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libmysql - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libmysql___Win32_Debug"
-# PROP BASE Intermediate_Dir "libmysql___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libmysql___Win32_Release"
-# PROP BASE Intermediate_Dir "libmysql___Win32_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Release_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libmysql___Win32_Release_inline"
-# PROP BASE Intermediate_Dir "libmysql___Win32_Release_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_inline"
-# PROP Intermediate_Dir "Release_inline"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libmysql - Win32 Release_TSDbg"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libmysql___Win32_Release_TSDbg"
-# PROP BASE Intermediate_Dir "libmysql___Win32_Release_TSDbg"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TSDbg"
-# PROP Intermediate_Dir "Release_TSDbg"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "." /D "NDEBUG" /D "_LIB" /D "__WIN32__" /D "USE_TLS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF
-
-# Begin Target
-
-# Name "libmysql - Win32 Debug_TS"
-# Name "libmysql - Win32 Release_TS"
-# Name "libmysql - Win32 Release_TS_inline"
-# Name "libmysql - Win32 Debug"
-# Name "libmysql - Win32 Release"
-# Name "libmysql - Win32 Release_inline"
-# Name "libmysql - Win32 Release_TSDbg"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\array.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bchange.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bmove.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bmove_upp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\charset.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ctype.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dbug.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\default.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dll.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\errmsg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\errors.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\get_password.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\int2str.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\is_prefix.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libmysql.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\list.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\longlong2str.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_casecnv.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_dirname.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_fn_ext.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_format.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_loadpath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_pack.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_path.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_unixpath.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mf_wcomp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mulalloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_alloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_compress.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_create.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_delete.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_div.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_error.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_fopen.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_getwd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_init.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_lib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_malloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_messnc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_net.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_once.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_open.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_pthread.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_read.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_realloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_static.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_tempnam.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_thr_init.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_wincond.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_winthread.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_write.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\net.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\password.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\safemalloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\str2int.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strcend.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strcont.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strend.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strfill.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\string.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strinstr.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strmake.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strmov.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strnmov.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strtoll.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strtoull.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strxmov.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\thr_mutex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\typelib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\violite.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\acconfig.h
-# End Source File
-# Begin Source File
-
-SOURCE=".\config-win.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\dbug.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\errmsg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\global.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\m_ctype.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\m_string.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_alarm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_dir.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_list.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_net.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_pthread.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_static.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\my_sys.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysql.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysql_com.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysql_version.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysqld_error.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysys_err.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysys_priv.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\thr_alarm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\violite.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/mysql/libmysql/list.c b/ext/mysql/libmysql/list.c deleted file mode 100644 index fce5455ab8..0000000000 --- a/ext/mysql/libmysql/list.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Code for handling dubble-linked lists in C -*/ - -#include "mysys_priv.h" -#include <my_list.h> - - - - /* Add a element to start of list */ - -LIST *list_add(LIST *root, LIST *element) -{ - DBUG_ENTER("list_add"); - DBUG_PRINT("enter",("root: %lx element: %lx", root, element)); - if (root) - { - if (root->prev) /* If add in mid of list */ - root->prev->next= element; - element->prev=root->prev; - root->prev=element; - } - else - element->prev=0; - element->next=root; - DBUG_RETURN(element); /* New root */ -} - - -LIST *list_delete(LIST *root, LIST *element) -{ - if (element->prev) - element->prev->next=element->next; - else - root=element->next; - if (element->next) - element->next->prev=element->prev; - return root; -} - - -void list_free(LIST *root, pbool free_data) -{ - LIST *next; - while (root) - { - next=root->next; - if (free_data) - my_free((gptr) root->data,MYF(0)); - my_free((gptr) root,MYF(0)); - root=next; - } -} - - -LIST *list_cons(void *data, LIST *list) -{ - LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE)); - if (!new_charset) - return 0; - new_charset->data=data; - return list_add(list,new_charset); -} - - -LIST *list_reverse(LIST *root) -{ - LIST *last; - - last=root; - while (root) - { - last=root; - root=root->next; - last->next=last->prev; - last->prev=root; - } - return last; -} - -uint list_length(LIST *list) -{ - uint count; - for (count=0 ; list ; list=list->next, count++) ; - return count; -} - - -int list_walk(LIST *list, list_walk_action action, gptr argument) -{ - int error=0; - while (list) - { - if ((error = (*action)(list->data,argument))) - return error; - list=rest(list); - } - return 0; -} diff --git a/ext/mysql/libmysql/longlong2str.c b/ext/mysql/libmysql/longlong2str.c deleted file mode 100644 index 1899386862..0000000000 --- a/ext/mysql/libmysql/longlong2str.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Defines: longlong2str(); - - longlong2str(dst, radix, val) - converts the (longlong) integer "val" to character form and moves it to - the destination string "dst" followed by a terminating NUL. The - result is normally a pointer to this NUL character, but if the radix - is dud the result will be NullS and nothing will be changed. - - If radix is -2..-36, val is taken to be SIGNED. - If radix is 2.. 36, val is taken to be UNSIGNED. - That is, val is signed if and only if radix is. You will normally - use radix -10 only through itoa and ltoa, for radix 2, 8, or 16 - unsigned is what you generally want. - - _dig_vec is public just in case someone has a use for it. - The definitions of itoa and ltoa are actually macros in m_string.h, - but this is where the code is. - - Note: The standard itoa() returns a pointer to the argument, when int2str - returns the pointer to the end-null. - itoa assumes that 10 -base numbers are allways signed and other arn't. -*/ - -#include <global.h> -#include "m_string.h" - -#if defined(HAVE_LONG_LONG) && !defined(longlong2str) && !defined(HAVE_LONGLONG2STR) - -extern char NEAR _dig_vec[]; - -/* - This assumes that longlong multiplication is faster than longlong division. -*/ - -char *longlong2str(longlong val,char *dst,int radix) -{ - char buffer[65]; - register char *p; - long long_val; - - if (radix < 0) - { - if (radix < -36 || radix > -2) return (char*) 0; - if (val < 0) { - *dst++ = '-'; - val = -val; - } - radix = -radix; - } - else - { - if (radix > 36 || radix < 2) return (char*) 0; - } - if (val == 0) - { - *dst++='0'; - *dst='\0'; - return dst; - } - p = &buffer[sizeof(buffer)-1]; - *p = '\0'; - - while ((ulonglong) val > (ulonglong) LONG_MAX) - { - ulonglong quo=(ulonglong) val/(uint) radix; - uint rem= (uint) (val- quo* (uint) radix); - *--p = _dig_vec[rem]; - val= quo; - } - long_val= (long) val; - while (long_val != 0) - { - long quo= long_val/radix; - *--p = _dig_vec[(uchar) (long_val - quo*radix)]; - long_val= quo; - } - while ((*dst++ = *p++) != 0) ; - return dst-1; -} - -#endif - -#ifndef longlong10_to_str -char *longlong10_to_str(longlong val,char *dst,int radix) -{ - char buffer[65]; - register char *p; - long long_val; - - if (radix < 0) - { - if (val < 0) - { - *dst++ = '-'; - val = -val; - } - } - - if (val == 0) - { - *dst++='0'; - *dst='\0'; - return dst; - } - p = &buffer[sizeof(buffer)-1]; - *p = '\0'; - - while ((ulonglong) val > (ulonglong) LONG_MAX) - { - ulonglong quo=(ulonglong) val/(uint) 10; - uint rem= (uint) (val- quo* (uint) 10); - *--p = _dig_vec[rem]; - val= quo; - } - long_val= (long) val; - while (long_val != 0) - { - long quo= long_val/10; - *--p = _dig_vec[(uchar) (long_val - quo*10)]; - long_val= quo; - } - while ((*dst++ = *p++) != 0) ; - return dst-1; -} -#endif diff --git a/ext/mysql/libmysql/m_ctype.h b/ext/mysql/libmysql/m_ctype.h deleted file mode 100644 index e322ac8f1a..0000000000 --- a/ext/mysql/libmysql/m_ctype.h +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - 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 */ diff --git a/ext/mysql/libmysql/m_string.h b/ext/mysql/libmysql/m_string.h deleted file mode 100644 index 64aa183a7d..0000000000 --- a/ext/mysql/libmysql/m_string.h +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 diff --git a/ext/mysql/libmysql/mf_casecnv.c b/ext/mysql/libmysql/mf_casecnv.c deleted file mode 100644 index 3abc6ae0f0..0000000000 --- a/ext/mysql/libmysql/mf_casecnv.c +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Functions to convert to lover_case and to upper_case in scandinavia. - - case_sort converts a character string to a representaion that can - be compared by strcmp to find with is alfabetical bigger. - (lower- and uppercase letters is compared as the same) -*/ - -#include "mysys_priv.h" -#include <m_ctype.h> -#include <m_string.h> - - /* string to uppercase */ - -void caseup_str(my_string str) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register char *end=str+(uint) strlen(str); - while (*str) - { - if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; - else *str=toupper(*str),++str; - } - } - else -#endif - while ((*str = toupper(*str)) != 0) - str++; -} /* caseup_str */ - - /* string to lowercase */ - -void casedn_str(my_string str) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register char *end=str+(uint) strlen(str); - while (*str) - { - if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; - else *str=tolower(*str),++str; - } - } - else -#endif - while ((*str= tolower(*str)) != 0) - str++; -} /* casedn_str */ - - - /* to uppercase */ - -void caseup(my_string str, uint length) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register char *end=str+length; - while (str<end) - { - if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; - else *str=toupper(*str),++str; - } - } - else -#endif - for ( ; length>0 ; length--, str++) - *str= toupper(*str); -} /* caseup */ - - /* to lowercase */ - -void casedn(my_string str, uint length) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register char *end=str+length; - while (str<end) - { - if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; - else *str=tolower(*str),++str; - } - } - else -#endif - for ( ; length>0 ; length--, str++) - *str= tolower(*str); -} /* casedn */ - - /* to sort-string that can be compared to get text in order */ - -void case_sort(my_string str, uint length) -{ - for ( ; length>0 ; length--, str++) - *str= (char) my_sort_order[(uchar) *str]; -} /* case_sort */ - - /* find string in another with no case_sensivity */ - -/* ToDo: This function should be modified to support multibyte charset. - However it is not used untill 3.23.5. - Wei He (hewei@mail.ied.ac.cn) -*/ - -my_string my_strcasestr(const char *str, const char *search) -{ - uchar *i,*j,*pos; - - pos=(uchar*) str; -skipp: - while (*pos != '\0') - { - if (toupper((uchar) *pos++) == toupper((uchar) *search)) - { - i=(uchar*) pos; j=(uchar*) search+1; - while (*j) - if (toupper(*i++) != toupper(*j++)) goto skipp; - return ((char*) pos-1); - } - } - return ((my_string) 0); -} /* strcstr */ - - - /* compare strings without regarding to case */ - -int my_strcasecmp(const char *s, const char *t) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register const char *end=s+(uint) strlen(s); - while (s<end) - { - if ((l=my_ismbchar(default_charset_info, s,end))) - { - while (l--) - if (*s++ != *t++) return 1; - } - else if (my_ismbhead(default_charset_info, *t)) return 1; - else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1; - } - return *t; - } - else -#endif - { - while (toupper((uchar) *s) == toupper((uchar) *t++)) - if (!*s++) return 0; - return ((int) toupper((uchar) s[0]) - (int) toupper((uchar) t[-1])); - } -} - - -int my_casecmp(const char *s, const char *t, uint len) -{ -#ifdef USE_MB - if (use_mb(default_charset_info)) - { - register uint32 l; - register const char *end=s+len; - while (s<end) - { - if ((l=my_ismbchar(default_charset_info, s,end))) - { - while (l--) - if (*s++ != *t++) return 1; - } - else if (my_ismbhead(default_charset_info, *t)) return 1; - else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1; - } - return 0; - } - else -#endif - { - while (len-- != 0 && toupper(*s++) == toupper(*t++)) ; - return (int) len+1; - } -} - - -int my_strsortcmp(const char *s, const char *t) -{ -#ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) - return my_strcoll(default_charset_info, (uchar *)s, (uchar *)t); - else -#endif - { - while (my_sort_order[(uchar) *s] == my_sort_order[(uchar) *t++]) - if (!*s++) return 0; - return ((int) my_sort_order[(uchar) s[0]] - - (int) my_sort_order[(uchar) t[-1]]); - } -} - -int my_sortcmp(const char *s, const char *t, uint len) -{ -#ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) - return my_strnncoll(default_charset_info, - (uchar *)s, len, (uchar *)t, len); - else -#endif - { - while (len--) - { - if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++]) - return ((int) my_sort_order[(uchar) s[-1]] - - (int) my_sort_order[(uchar) t[-1]]); - } - return 0; - } -} - -int my_sortncmp(const char *s, uint s_len, const char *t, uint t_len) -{ -#ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) - return my_strnncoll(default_charset_info, - (uchar *)s, s_len, (uchar *)t, t_len); - else -#endif - { - uint len= min(s_len,t_len); - while (len--) - { - if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++]) - return ((int) my_sort_order[(uchar) s[-1]] - - (int) my_sort_order[(uchar) t[-1]]); - } - return (int) (s_len - t_len); - } -} diff --git a/ext/mysql/libmysql/mf_dirname.c b/ext/mysql/libmysql/mf_dirname.c deleted file mode 100644 index 88f6101cbe..0000000000 --- a/ext/mysql/libmysql/mf_dirname.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> - - /* Functions definied in this file */ - -uint dirname_length(const char *name) -{ - register my_string pos,gpos; -#ifdef FN_DEVCHAR - if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0) -#endif - pos=(char*) name-1; - - gpos= pos++; - for ( ; *pos ; pos++) /* Find last FN_LIBCHAR */ - if (*pos == FN_LIBCHAR || *pos == '/' -#ifdef FN_C_AFTER_DIR - || *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2 -#endif - ) - gpos=pos; - return ((uint) (uint) (gpos+1-(char*) name)); -} - - - /* Gives directory part of filename. Directory ends with '/' */ - /* Returns length of directory part */ - -uint dirname_part(my_string to, const char *name) -{ - uint length; - DBUG_ENTER("dirname_part"); - DBUG_PRINT("enter",("'%s'",name)); - - length=dirname_length(name); - (void) strmake(to,(char*) name,min(length,FN_REFLEN-2)); - convert_dirname(to); /* Convert chars */ - DBUG_RETURN(length); -} /* dirname */ - - - /* convert dirname to use under this system */ - /* If MSDOS converts '/' to '\' */ - /* If VMS converts '<' to '[' and '>' to ']' */ - /* Adds a '/' to end if there isn't one and the last isn't a dev_char */ - /* ARGSUSED */ - -#ifndef FN_DEVCHAR -#define FN_DEVCHAR '\0' /* For easier code */ -#endif - -char *convert_dirname(my_string to) -{ - reg1 char *pos; -#ifdef FN_UPPER_CASE - caseup_str(to); -#endif -#ifdef FN_LOWER_CASE - casedn_str(to); -#endif -#if FN_LIBCHAR != '/' - { - pos=to-1; /* Change from '/' */ - while ((pos=strchr(pos+1,'/')) != 0) - *pos=FN_LIBCHAR; - } -#endif -#ifdef FN_C_BEFORE_DIR_2 - { - for (pos=to ; *pos ; pos++) - { - if (*pos == FN_C_BEFORE_DIR_2) - *pos=FN_C_BEFORE_DIR; - if (*pos == FN_C_AFTER_DIR_2) - *pos=FN_C_AFTER_DIR; - } - } -#else - { /* Append FN_LIBCHAR if not there */ - pos=strend(to); - if (pos != to && (pos[-1] != FN_LIBCHAR && pos[-1] != FN_DEVCHAR)) - { - *pos++=FN_LIBCHAR; - *pos=0; - } - } -#endif - return pos; /* Pointer to end of dir */ -} /* convert_dirname */ diff --git a/ext/mysql/libmysql/mf_fn_ext.c b/ext/mysql/libmysql/mf_fn_ext.c deleted file mode 100644 index 71a10108b7..0000000000 --- a/ext/mysql/libmysql/mf_fn_ext.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Returnerar en pekare till filnamnets extension. */ - -#include "mysys_priv.h" -#include <m_string.h> - - /* Return a pointerto the extension of the filename - The pointer points at the extension character (normally '.')) - If there isn't any extension, the pointer points at the end - NULL of the filename - */ - -my_string fn_ext(const char *name) -{ - register my_string pos,gpos; - DBUG_ENTER("fn_ext"); - DBUG_PRINT("mfunkt",("name: '%s'",name)); - -#if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) - { - char buff[FN_REFLEN]; - gpos=(my_string) name+dirname_part(buff,(char*) name); - } -#else - if (!(gpos=strrchr(name,FNLIBCHAR))) - gpos=name; -#endif - pos=strrchr(gpos,FN_EXTCHAR); - DBUG_RETURN (pos ? pos : strend(gpos)); -} /* fn_ext */ diff --git a/ext/mysql/libmysql/mf_format.c b/ext/mysql/libmysql/mf_format.c deleted file mode 100644 index 7b2336e36e..0000000000 --- a/ext/mysql/libmysql/mf_format.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> -#ifdef HAVE_REALPATH -#include <sys/param.h> -#include <sys/stat.h> -#endif - - /* format a filename with replace of library and extension */ - /* params to and name may be identicall */ - /* function doesn't change name if name != to */ - /* Flag may be: 1 replace filenames library with 'dsk' */ - /* 2 replace extension with 'form' */ - /* 4 Unpack filename (replace ~ with home) */ - /* 8 Pack filename as short as possibly */ - /* 16 Resolve symbolic links for filename */ - /* 32 Resolve filename to full path */ - /* 64 Return NULL if too long path */ - -#ifdef SCO -#define BUFF_LEN 4097 -#else -#ifdef MAXPATHLEN -#define BUFF_LEN MAXPATHLEN -#else -#define BUFF_LEN FN_LEN -#endif -#endif - -my_string fn_format(my_string to, const char *name, const char *dsk, - const char *form, int flag) -{ - reg1 uint length; - char dev[FN_REFLEN], buff[BUFF_LEN], *pos, *startpos; - const char *ext; - DBUG_ENTER("fn_format"); - DBUG_PRINT("enter",("name: %s dsk: %s form: %s flag: %d", - name,dsk,form,flag)); - - /* Kopiera & skippa enheten */ - name+=(length=dirname_part(dev,(startpos=(my_string) name))); - if (length == 0 || flag & 1) - { - (void) strmake(dev,dsk, sizeof(dev) - 2); - /* Use given directory */ - convert_dirname(dev); /* Fix to this OS */ - } - if (flag & 8) - pack_dirname(dev,dev); /* Put in ./.. and ~/.. */ - if (flag & 4) - (void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */ - if ((pos=(char*)strchr(name,FN_EXTCHAR)) != NullS) - { - if ((flag & 2) == 0) /* Skall vi byta extension ? */ - { - length=strlength(name); /* Old extension */ - ext = ""; - } - else - { - length=(uint) (pos-(char*) name); /* Change extension */ - ext= form; - } - } - else - { - length=strlength(name); /* Har ingen ext- tag nya */ - ext=form; - } - - if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN ) - { /* To long path, return original */ - uint tmp_length; - if (flag & 64) - return 0; - tmp_length=strlength(startpos); - DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length)); - (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1)); - } - else - { - if (to == startpos) - { - bmove(buff,(char*) name,length); /* Save name for last copy */ - name=buff; - } - pos=strmake(strmov(to,dev),name,length); -#ifdef FN_UPPER_CASE - caseup_str(to); -#endif -#ifdef FN_LOWER_CASE - casedn_str(to); -#endif - (void) strmov(pos,ext); /* Don't convert extension */ - } - /* Purify gives a lot of UMR errors when using realpath */ -#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH) - if (flag & 16) - { - struct stat stat_buff; - if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode))) - { - if (realpath(to,buff)) - strmake(to,buff,FN_REFLEN-1); - } - } -#endif - DBUG_RETURN (to); -} /* fn_format */ - - - /* - strlength(const string str) - Return length of string with end-space:s not counted. - */ - -size_s strlength(const char *str) -{ - reg1 my_string pos; - reg2 my_string found; - DBUG_ENTER("strlength"); - - pos=found=(char*) str; - - while (*pos) - { - if (*pos != ' ') - { - while (*++pos && *pos != ' ') {}; - if (!*pos) - { - found=pos; /* String ends here */ - break; - } - } - found=pos; - while (*++pos == ' ') {}; - } - DBUG_RETURN((size_s) (found-(char*) str)); -} /* strlength */ diff --git a/ext/mysql/libmysql/mf_loadpath.c b/ext/mysql/libmysql/mf_loadpath.c deleted file mode 100644 index 4a1c250b3d..0000000000 --- a/ext/mysql/libmysql/mf_loadpath.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> - - /* Returns full load-path for a file. to may be = path */ - /* if path is a hard-path return path */ - /* if path starts with home-dir return path */ - /* if path starts with current dir or parent-dir unpack path */ - /* if there is no path, prepend with own_path_prefix if given */ - /* else unpack path according to current dir */ - -my_string my_load_path(my_string to, const char *path, - const char *own_path_prefix) -{ - char buff[FN_REFLEN]; - DBUG_ENTER("my_load_path"); - DBUG_PRINT("enter",("path: %s prefix: %s",path, - own_path_prefix ? own_path_prefix : "")); - - if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) || - test_if_hard_path(path)) - VOID(strmov(buff,path)); - else if ((path[0] == FN_CURLIB && path[1] == FN_LIBCHAR) || - (is_prefix((gptr) path,FN_PARENTDIR) && - path[strlen(FN_PARENTDIR)] == FN_LIBCHAR) || - ! own_path_prefix) - { - if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)),MYF(0))) - VOID(strcat(buff,path)); - else - VOID(strmov(buff,path)); - } - else - VOID(strxmov(buff,own_path_prefix,path,NullS)); - strmov(to,buff); - DBUG_PRINT("exit",("to: %s",to)); - DBUG_RETURN(to); -} /* my_load_path */ diff --git a/ext/mysql/libmysql/mf_pack.c b/ext/mysql/libmysql/mf_pack.c deleted file mode 100644 index b6b079bdac..0000000000 --- a/ext/mysql/libmysql/mf_pack.c +++ /dev/null @@ -1,518 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif -#ifdef VMS -#include <rms.h> -#include <iodef.h> -#include <descrip.h> -#endif /* VMS */ - -static my_string NEAR_F expand_tilde(my_string *path); - - /* Pack a dirname ; Changes HOME to ~/ and current dev to ./ */ - /* from is a dirname (from dirname() ?) ending with FN_LIBCHAR */ - /* to may be == from */ - -void pack_dirname(my_string to, const char *from) -{ - int cwd_err; - uint d_length,length,buff_length; - my_string start; - char buff[FN_REFLEN]; - DBUG_ENTER("pack_dirname"); - - (void) intern_filename(to,from); /* Change to intern name */ - -#ifdef FN_DEVCHAR - if ((start=strrchr(to,FN_DEVCHAR)) != 0) /* Skipp device part */ - start++; - else -#endif - start=to; - - LINT_INIT(buff_length); - if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0)))) - { - buff_length= (uint) strlen(buff); - d_length=(uint) (start-to); - if ((start == to || - (buff_length == d_length && !bcmp(buff,start,d_length))) && - *start != FN_LIBCHAR && *start) - { /* Put current dir before */ - bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1); - } - } - - if ((d_length= cleanup_dirname(to,to)) != 0) - { - length=0; - if (home_dir) - { - length= (uint) strlen(home_dir); - if (home_dir[length-1] == FN_LIBCHAR) - length--; /* Don't test last '/' */ - } - if (length > 1 && length < d_length) - { /* test if /xx/yy -> ~/yy */ - if (bcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR) - { - to[0]=FN_HOMELIB; /* Filename begins with ~ */ - (void) strmov_overlapp(to+1,to+length); - } - } - if (! cwd_err) - { /* Test if cwd is ~/... */ - if (length > 1 && length < buff_length) - { - if (bcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR) - { - buff[0]=FN_HOMELIB; - (void) strmov_overlapp(buff+1,buff+length); - } - } - if (is_prefix(to,buff)) - { - length= (uint) strlen(buff); - if (to[length]) - (void) strmov_overlapp(to,to+length); /* Remove everything before */ - else - { - to[0]= FN_CURLIB; /* Put ./ instead of cwd */ - to[1]= FN_LIBCHAR; - to[2]= '\0'; - } - } - } - } - DBUG_PRINT("exit",("to: '%s'",to)); - DBUG_VOID_RETURN; -} /* pack_dirname */ - - - /* remove unwanted chars from dirname */ - /* if "/../" removes prev dir; "/~/" removes all before ~ */ - /* "//" is same as "/", except on Win32 at start of a file */ - /* "/./" is removed */ - /* Unpacks home_dir if "~/.." used */ - /* Unpacks current dir if if "./.." used */ - -uint cleanup_dirname(register my_string to, const char *from) - /* to may be == from */ - -{ - reg5 uint length; - reg2 my_string pos; - reg3 my_string from_ptr; - reg4 my_string start; - char parent[5], /* for "FN_PARENTDIR" */ - buff[FN_REFLEN+1],*end_parentdir; - DBUG_ENTER("cleanup_dirname"); - DBUG_PRINT("enter",("from: '%s'",from)); - - start=buff; - from_ptr=(my_string) from; -#ifdef FN_DEVCHAR - if ((pos=strrchr(from_ptr,FN_DEVCHAR)) != 0) - { /* Skipp device part */ - length=(uint) (pos-from_ptr)+1; - start=strnmov(buff,from_ptr,length); from_ptr+=length; - } -#endif - - parent[0]=FN_LIBCHAR; - length=(uint) (strmov(parent+1,FN_PARENTDIR)-parent); - for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++) - { - if (*pos == '/') - *pos = FN_LIBCHAR; - if (*pos == FN_LIBCHAR) - { - if ((uint) (pos-start) > length && bcmp(pos-length,parent,length) == 0) - { /* If .../../; skipp prev */ - pos-=length; - if (pos != start) - { /* not /../ */ - pos--; - if (*pos == FN_HOMELIB && (pos == start || pos[-1] == FN_LIBCHAR)) - { - if (!home_dir) - { - pos+=length+1; /* Don't unpack ~/.. */ - continue; - } - pos=strmov(buff,home_dir)-1; /* Unpacks ~/.. */ - if (*pos == FN_LIBCHAR) - pos--; /* home ended with '/' */ - } - if (*pos == FN_CURLIB && (pos == start || pos[-1] == FN_LIBCHAR)) - { - if (my_getwd(curr_dir,FN_REFLEN,MYF(0))) - { - pos+=length+1; /* Don't unpack ./.. */ - continue; - } - pos=strmov(buff,curr_dir)-1; /* Unpacks ./.. */ - if (*pos == FN_LIBCHAR) - pos--; /* home ended with '/' */ - } - end_parentdir=pos; - while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */ - pos--; - if (pos[1] == FN_HOMELIB || bcmp(pos,parent,length) == 0) - { /* Don't remove ~user/ */ - pos=strmov(end_parentdir+1,parent); - *pos=FN_LIBCHAR; - continue; - } - } - } - else if ((uint) (pos-start) == length-1 && - !bcmp(start,parent+1,length-1)) - start=pos; /* Starts with "../" */ - else if (pos-start > 0 && pos[-1] == FN_LIBCHAR) - { -#ifdef FN_NETWORK_DRIVES - if (pos-start != 1) -#endif - pos--; /* Remove dupplicate '/' */ - } - else if (pos-start > 1 && pos[-1] == FN_CURLIB && pos[-2] == FN_LIBCHAR) - pos-=2; /* Skipp /./ */ - else if (pos > buff+1 && pos[-1] == FN_HOMELIB && pos[-2] == FN_LIBCHAR) - { /* Found ..../~/ */ - buff[0]=FN_HOMELIB; - buff[1]=FN_LIBCHAR; - start=buff; pos=buff+1; - } - } - } - (void) strmov(to,buff); - DBUG_PRINT("exit",("to: '%s'",to)); - DBUG_RETURN((uint) (pos-buff)); -} /* cleanup_dirname */ - - - /* - On system where you don't have symbolic links, the following - code will allow you to create a file: - directory-name.lnk that should contain the real path - to the directory. This will be used if the directory name - doesn't exists - */ - - -my_bool my_use_symdir=0; /* Set this if you want to use symdirs */ - -#ifdef USE_SYMDIR -void symdirget(char *dir) -{ - char buff[FN_REFLEN]; - char *pos=strend(dir); - if (dir[0] && pos[-1] != FN_DEVCHAR && access(dir, F_OK)) - { - FILE *fp; - char temp= *(--pos); /* May be "/" or "\" */ - strmov(pos,".sym"); - fp = my_fopen(dir, O_RDONLY,MYF(0)); - *pos++=temp; *pos=0; /* Restore old filename */ - if (fp) - { - if (fgets(buff, sizeof(buff)-1, fp)) - { - for (pos=strend(buff); - pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ; - pos --); - - /* Ensure that the symlink ends with the directory symbol */ - if (pos == buff || pos[-1] != FN_LIBCHAR) - *pos++=FN_LIBCHAR; - - strmake(dir,buff, (uint) (pos-buff)); - } - my_fclose(fp,MYF(0)); - } - } -} -#endif /* USE_SYMDIR */ - - /* Unpacks dirname to name that can be used by open... */ - /* Make that last char of to is '/' if from not empty and - from doesn't end in FN_DEVCHAR */ - /* Uses cleanup_dirname and changes ~/.. to home_dir/.. */ - /* Returns length of new directory */ - -uint unpack_dirname(my_string to, const char *from) - - /* to may be == from */ -{ - uint length,h_length; - char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion; - DBUG_ENTER("unpack_dirname"); - - (void) intern_filename(buff,from); /* Change to intern name */ - length= (uint) strlen(buff); /* Fix that '/' is last */ - if (length && -#ifdef FN_DEVCHAR - buff[length-1] != FN_DEVCHAR && -#endif - buff[length-1] != FN_LIBCHAR && buff[length-1] != '/') - { - buff[length]=FN_LIBCHAR; - buff[length+1]= '\0'; - } - - length=cleanup_dirname(buff,buff); - if (buff[0] == FN_HOMELIB) - { - suffix=buff+1; tilde_expansion=expand_tilde(&suffix); - if (tilde_expansion) - { - length-=(uint) (suffix-buff)-1; - if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN) - { - if (tilde_expansion[h_length-1] == FN_LIBCHAR) - h_length--; - if (buff+h_length < suffix) - bmove(buff+h_length,suffix,length); - else - bmove_upp(buff+h_length+length,suffix+length,length); - bmove(buff,tilde_expansion,h_length); - } - } - } -#ifdef USE_SYMDIR - if (my_use_symdir) - symdirget(buff); -#endif - DBUG_RETURN(system_filename(to,buff)); /* Fix for open */ -} /* unpack_dirname */ - - - /* Expand tilde to home or user-directory */ - /* Path is reset to point at FN_LIBCHAR after ~xxx */ - -static my_string NEAR_F expand_tilde(my_string *path) -{ - if (path[0][0] == FN_LIBCHAR) - return home_dir; /* ~/ expanded to home */ -#ifdef HAVE_GETPWNAM - { - char *str,save; - struct passwd *user_entry; - - if (!(str=strchr(*path,FN_LIBCHAR))) - str=strend(*path); - save= *str; *str= '\0'; - user_entry=getpwnam(*path); - *str=save; - endpwent(); - if (user_entry) - { - *path=str; - return user_entry->pw_dir; - } - } -#endif - return (my_string) 0; -} - - /* fix filename so it can be used by open, create .. */ - /* to may be == from */ - /* Returns to */ - -my_string unpack_filename(my_string to, const char *from) -{ - uint length,n_length; - char buff[FN_REFLEN]; - DBUG_ENTER("unpack_filename"); - - length=dirname_part(buff,from); /* copy & convert dirname */ - n_length=unpack_dirname(buff,buff); - if (n_length+strlen(from+length) < FN_REFLEN) - { - (void) strmov(buff+n_length,from+length); - (void) system_filename(to,buff); /* Fix to usably filename */ - } - else - (void) system_filename(to,from); /* Fix to usably filename */ - DBUG_RETURN(to); -} /* unpack_filename */ - - - /* Convert filename (unix standard) to system standard */ - /* Used before system command's like open(), create() .. */ - /* Returns to */ - -uint system_filename(my_string to, const char *from) -{ -#ifndef FN_C_BEFORE_DIR - return (uint) (strmake(to,from,FN_REFLEN-1)-to); -#else /* VMS */ - - /* change 'dev:lib/xxx' to 'dev:[lib]xxx' */ - /* change 'dev:xxx' to 'dev:xxx' */ - /* change './xxx' to 'xxx' */ - /* change './lib/' or lib/ to '[.lib]' */ - /* change '/x/y/z to '[x.y]x' */ - /* change 'dev:/x' to 'dev:[000000]x' */ - - int libchar_found,length; - my_string to_pos,from_pos,pos; - char buff[FN_REFLEN]; - DBUG_ENTER("system_filename"); - - libchar_found=0; - (void) strmov(buff,from); /* If to == from */ - from_pos= buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */ - { - pos++; - to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); - from_pos=pos; - } - else - to_pos=to; - - if (from_pos[0] == FN_CURLIB && from_pos[1] == FN_LIBCHAR) - from_pos+=2; /* Skipp './' */ - if (strchr(from_pos,FN_LIBCHAR)) - { - *(to_pos++) = FN_C_BEFORE_DIR; - if (strinstr(from_pos,FN_ROOTDIR) == 1) - { - from_pos+=strlen(FN_ROOTDIR); /* Actually +1 but... */ - if (! strchr(from_pos,FN_LIBCHAR)) - { /* No dir, use [000000] */ - to_pos=strmov(to_pos,FN_C_ROOT_DIR); - libchar_found++; - } - } - else - *(to_pos++)=FN_C_DIR_SEP; /* '.' gives current dir */ - - while ((pos=strchr(from_pos,FN_LIBCHAR))) - { - if (libchar_found++) - *(to_pos++)=FN_C_DIR_SEP; /* Add '.' between dirs */ - if (strinstr(from_pos,FN_PARENTDIR) == 1 && - from_pos+strlen(FN_PARENTDIR) == pos) - to_pos=strmov(to_pos,FN_C_PARENT_DIR); /* Found '../' */ - else - to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos)); - from_pos=pos+1; - } - *(to_pos++)=FN_C_AFTER_DIR; - } - length=(int) (strmov(to_pos,from_pos)-to); - DBUG_PRINT("exit",("name: '%s'",to)); - DBUG_RETURN((uint) length); -#endif -} /* system_filename */ - - - /* Fix a filename to intern (UNIX format) */ - -my_string intern_filename(my_string to, const char *from) -{ -#ifndef VMS - { - uint length; - char buff[FN_REFLEN]; - if (from == to) - { /* Dirname may destroy from */ - strmov(buff,from); - from=buff; - } - length=dirname_part(to,from); /* Copy dirname & fix chars */ - (void) strcat(to,from+length); - return (to); - } -#else /* VMS */ - - /* change 'dev:[lib]xxx' to 'dev:lib/xxx' */ - /* change 'dev:xxx' to 'dev:xxx' */ - /* change 'dev:x/y/[.lib]' to 'dev:x/y/lib/ */ - /* change '[.lib]' to './lib/' */ - /* change '[x.y]' or '[x.][y]' or '[x][.y]' to '/x/y/' */ - /* change '[000000.x] or [x.000000]' to '/x/' */ - - int par_length,root_length; - my_string pos,from_pos,to_pos,end_pos; - char buff[FN_REFLEN]; - - (void) strmov(buff,from); - convert_dirname(buff); /* change '<>' to '[]' */ - from_pos=buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */ - { - pos++; - to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); - from_pos=pos; - } - else - to_pos=to; - - root_length=strlen(FN_C_ROOT_DIR); - if ((pos = strchr(from_pos,FN_C_BEFORE_DIR)) && - (end_pos = strrchr(pos+1,FN_C_AFTER_DIR))) - { - to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos)); - /* Copy all between ':' and '[' */ - from_pos=pos+1; - if (strinstr(from_pos,FN_C_ROOT_DIR) == 1 && - (from_pos[root_length] == FN_C_DIR_SEP || - from_pos[root_length] == FN_C_AFTER_DIR)) - { - from_pos+=root_length+1; - } - else if (*from_pos == FN_C_DIR_SEP) - *(to_pos++) = FN_CURLIB; /* Set ./ first */ - *(to_pos++) = FN_LIBCHAR; - - par_length=strlen(FN_C_PARENT_DIR); - pos=to_pos; - for (; from_pos <= end_pos ; from_pos++) - { - switch (*from_pos) { - case FN_C_DIR_SEP: - case FN_C_AFTER_DIR: - if (pos != to_pos) - { - if ((int) (to_pos-pos) == root_length && - is_suffix(pos,FN_C_ROOT_DIR)) - to_pos=pos; /* remove root-pos */ - else - { - *(to_pos++)=FN_LIBCHAR; /* Find lib */ - pos=to_pos; - } - } - break; - case FN_C_BEFORE_DIR: - break; - case '-': /* *(FN_C_PARENT_DIR): */ - if (to_pos[-1] == FN_LIBCHAR && - strncmp(from_pos,FN_C_PARENT_DIR,par_length) == 0) - { /* Change '-' to '..' */ - to_pos=strmov(to_pos,FN_PARENTDIR); - *(to_pos++)=FN_LIBCHAR; - pos=to_pos; - from_pos+=par_length-1; - break; - } - /* Fall through */ - default: - *(to_pos++)= *from_pos; - break; - } - } - } - (void) strmov(to_pos,from_pos); - return (to); -#endif /* VMS */ -} /* intern_filename */ diff --git a/ext/mysql/libmysql/mf_path.c b/ext/mysql/libmysql/mf_path.c deleted file mode 100644 index 6258c28df9..0000000000 --- a/ext/mysql/libmysql/mf_path.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> - -static char *find_file_in_path(char *to,const char *name); - - /* Finds where program can find it's files. - pre_pathname is found by first locking at progname (argv[0]). - if progname contains path the path is returned. - else if progname is found in path, return it - else if progname is given and POSIX environment variable "_" is set - then path is taken from "_". - If filename doesn't contain a path append MY_BASEDIR_VERSION or - MY_BASEDIR if defined, else append "/my/running". - own_path_name_part is concatinated to result. - my_path puts result in to and returns to */ - -my_string my_path(my_string to, const char *progname, - const char *own_pathname_part) -{ - my_string start,end,prog; - DBUG_ENTER("my_path"); - - start=to; /* Return this */ - if (progname && (dirname_part(to, progname) || - find_file_in_path(to,progname) || - ((prog=getenv("_")) != 0 && dirname_part(to,prog)))) - { - VOID(intern_filename(to,to)); - if (!test_if_hard_path(to)) - { - if (!my_getwd(curr_dir,FN_REFLEN,MYF(0))) - bchange(to,0,curr_dir, (uint) strlen(curr_dir), (uint) strlen(to)+1); - } - } - else - { - if ((end = getenv("MY_BASEDIR_VERSION")) == 0 && - (end = getenv("MY_BASEDIR")) == 0) - { -#ifdef DEFAULT_BASEDIR - end= (char*) DEFAULT_BASEDIR; -#else - end= (char*) "/my/"; -#endif - } - VOID(intern_filename(to,end)); - to=strend(to); - if (to != start && to[-1] != FN_LIBCHAR) - *to++ = FN_LIBCHAR; - VOID(strmov(to,own_pathname_part)); - } - DBUG_PRINT("exit",("to: '%s'",start)); - DBUG_RETURN(start); -} /* my_path */ - - - /* test if file without filename is found in path */ - /* Returns to if found and to has dirpart if found, else NullS */ - -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) -#define F_OK 0 -#define PATH_SEP ';' -#define PROGRAM_EXTENSION ".exe" -#else -#define PATH_SEP ':' -#endif - -static char *find_file_in_path(char *to, const char *name) -{ - char *path,*pos,dir[2]; - const char *ext=""; - - if (!(path=getenv("PATH"))) - return NullS; - dir[0]=FN_LIBCHAR; dir[1]=0; -#ifdef PROGRAM_EXTENSION - if (!fn_ext(name)[0]) - ext=PROGRAM_EXTENSION; -#endif - - for (pos=path ; (pos=strchr(pos,PATH_SEP)) ; path= ++pos) - { - if (path != pos) - { - strxmov(strnmov(to,path,(uint) (pos-path)),dir,name,ext,NullS); - if (!access(to,F_OK)) - { - to[(uint) (pos-path)+1]=0; /* Return path only */ - return to; - } - } - } -#ifdef __WIN__ - to[0]=FN_CURLIB; - strxmov(to+1,dir,name,ext,NullS); - if (!access(to,F_OK)) /* Test in current dir */ - { - to[2]=0; /* Leave ".\" */ - return to; - } -#endif - return NullS; /* File not found */ -} diff --git a/ext/mysql/libmysql/mf_unixpath.c b/ext/mysql/libmysql/mf_unixpath.c deleted file mode 100644 index 79a99b4323..0000000000 --- a/ext/mysql/libmysql/mf_unixpath.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include <m_string.h> - - /* convert filename to unix style filename */ - /* If MSDOS converts '\' to '/' */ - -void to_unix_path(my_string to __attribute__((unused))) -{ -#if FN_LIBCHAR != '/' - { - to--; - while ((to=strchr(to+1,FN_LIBCHAR)) != 0) - *to='/'; - } -#endif -} diff --git a/ext/mysql/libmysql/mf_wcomp.c b/ext/mysql/libmysql/mf_wcomp.c deleted file mode 100644 index 73e847f1c4..0000000000 --- a/ext/mysql/libmysql/mf_wcomp.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Funktions for comparing with wild-cards */ - -#include "mysys_priv.h" - - /* Test if a string is "comparable" to a wild-card string */ - /* returns 0 if the strings are "comparable" */ - -char wild_many='*'; -char wild_one='?'; -char wild_prefix=0; - -int wild_compare(register const char *str, register const char *wildstr) -{ - reg3 int flag; - DBUG_ENTER("wild_compare"); - - while (*wildstr) - { - while (*wildstr && *wildstr != wild_many && *wildstr != wild_one) - { - if (*wildstr == wild_prefix && wildstr[1]) - wildstr++; - if (*wildstr++ != *str++) DBUG_RETURN(1); - } - if (! *wildstr ) DBUG_RETURN (*str != 0); - if (*wildstr++ == wild_one) - { - if (! *str++) DBUG_RETURN (1); /* One char; skipp */ - } - else - { /* Found '*' */ - if (!*wildstr) DBUG_RETURN(0); /* '*' as last char: OK */ - flag=(*wildstr != wild_many && *wildstr != wild_one); - do - { - if (flag) - { - char cmp; - if ((cmp= *wildstr) == wild_prefix && wildstr[1]) - cmp=wildstr[1]; - while (*str && *str != cmp) - str++; - if (!*str) DBUG_RETURN (1); - } - if (wild_compare(str,wildstr) == 0) DBUG_RETURN (0); - } while (*str++ && wildstr[0] != wild_many); - DBUG_RETURN(1); - } - } - DBUG_RETURN (*str != '\0'); -} /* wild_compare */ diff --git a/ext/mysql/libmysql/mulalloc.c b/ext/mysql/libmysql/mulalloc.c deleted file mode 100644 index 793858afd4..0000000000 --- a/ext/mysql/libmysql/mulalloc.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - - /* Malloc many pointers at the same time */ - /* format myFlags,ptr,length,ptr,length ... until null ptr */ - -#include "mysys_priv.h" -#include <stdarg.h> - -gptr my_multi_malloc(myf myFlags, ...) -{ - va_list args; - char **ptr,*start,*res; - uint tot_length,length; - DBUG_ENTER("my_multi_malloc"); - - va_start(args,myFlags); - tot_length=0; - while ((ptr=va_arg(args, char **))) - { - length=va_arg(args,uint); - tot_length+=ALIGN_SIZE(length); - } - va_end(args); - - if (!(start=(char *) my_malloc(tot_length,myFlags))) - DBUG_RETURN(0); /* purecov: inspected */ - - va_start(args,myFlags); - res=start; - while ((ptr=va_arg(args, char **))) - { - *ptr=res; - length=va_arg(args,uint); - res+=ALIGN_SIZE(length); - } - va_end(args); - DBUG_RETURN((gptr) start); -} diff --git a/ext/mysql/libmysql/my_alarm.h b/ext/mysql/libmysql/my_alarm.h deleted file mode 100644 index b0fc91d74f..0000000000 --- a/ext/mysql/libmysql/my_alarm.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - File to include when we want to use alarm or a loop_counter to display - some information when a program is running -*/ -#ifndef _my_alarm_h -#define _my_alarm_h -#ifdef __cplusplus -extern "C" { -#endif - -extern int volatile my_have_got_alarm; -extern ulong my_time_to_wait_for_lock; - -#if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP) -#include <signal.h> -#define ALARM_VARIABLES uint alarm_old=0; \ - sig_return alarm_signal=0 -#define ALARM_INIT my_have_got_alarm=0 ; \ - alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \ - alarm_signal=signal(SIGALRM,my_set_alarm_variable); -#define ALARM_END VOID(signal(SIGALRM,alarm_signal)); \ - VOID(alarm(alarm_old)); -#define ALARM_TEST my_have_got_alarm -#ifdef DONT_REMEMBER_SIGNAL -#define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \ - VOID(signal(SIGALRM,my_set_alarm_variable));\ - my_have_got_alarm=0; -#else -#define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \ - my_have_got_alarm=0; -#endif /* DONT_REMEMBER_SIGNAL */ -#else -#define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1 -#define ALARM_INIT -#define ALARM_END -#define ALARM_TEST (alarm_pos++ >= alarm_end_pos) -#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE -#endif /* HAVE_ALARM */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ext/mysql/libmysql/my_alloc.c b/ext/mysql/libmysql/my_alloc.c deleted file mode 100644 index a33f86fa00..0000000000 --- a/ext/mysql/libmysql/my_alloc.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Routines to handle mallocing of results which will be freed the same time */ - -#include <global.h> -#include <my_sys.h> -#include <m_string.h> - -void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size) -{ - mem_root->free=mem_root->used=0; - mem_root->min_malloc=32; - mem_root->block_size=block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8; - mem_root->error_handler=0; -#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) - if (pre_alloc_size) - { - if ((mem_root->free = mem_root->pre_alloc= - (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)), - MYF(0)))) - { - mem_root->free->size=pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM)); - mem_root->free->left=pre_alloc_size; - mem_root->free->next=0; - } - } -#endif -} - -gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) -{ -#if defined(HAVE_purify) && defined(EXTRA_DEBUG) - reg1 USED_MEM *next; - Size+=ALIGN_SIZE(sizeof(USED_MEM)); - - if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME)))) - { - if (mem_root->error_handler) - (*mem_root->error_handler)(); - return((gptr) 0); /* purecov: inspected */ - } - next->next=mem_root->used; - mem_root->used=next; - return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))); -#else - uint get_size,max_left; - gptr point; - reg1 USED_MEM *next; - reg2 USED_MEM **prev; - - Size= ALIGN_SIZE(Size); - prev= &mem_root->free; - max_left=0; - for (next= *prev ; next && next->left < Size ; next= next->next) - { - if (next->left > max_left) - max_left=next->left; - prev= &next->next; - } - if (! next) - { /* Time to alloc new block */ - get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); - if (max_left*4 < mem_root->block_size && get_size < mem_root->block_size) - get_size=mem_root->block_size; /* Normal alloc */ - - if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME)))) - { - if (mem_root->error_handler) - (*mem_root->error_handler)(); - return((gptr) 0); /* purecov: inspected */ - } - next->next= *prev; - next->size= get_size; - next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); - *prev=next; - } - point= (gptr) ((char*) next+ (next->size-next->left)); - if ((next->left-= Size) < mem_root->min_malloc) - { /* Full block */ - *prev=next->next; /* Remove block from list */ - next->next=mem_root->used; - mem_root->used=next; - } - return(point); -#endif -} - - /* deallocate everything used by alloc_root */ - -void free_root(MEM_ROOT *root, myf MyFlags) -{ - reg1 USED_MEM *next,*old; - DBUG_ENTER("free_root"); - - if (!root) - DBUG_VOID_RETURN; /* purecov: inspected */ - if (!(MyFlags & MY_KEEP_PREALLOC)) - root->pre_alloc=0; - - for ( next=root->used; next ;) - { - old=next; next= next->next ; - if (old != root->pre_alloc) - my_free((gptr) old,MYF(0)); - } - for (next= root->free ; next ; ) - { - old=next; next= next->next ; - if (old != root->pre_alloc) - my_free((gptr) old,MYF(0)); - } - root->used=root->free=0; - if (root->pre_alloc) - { - root->free=root->pre_alloc; - root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM)); - root->free->next=0; - } - DBUG_VOID_RETURN; -} - - -char *strdup_root(MEM_ROOT *root,const char *str) -{ - uint len= (uint) strlen(str)+1; - char *pos; - if ((pos=alloc_root(root,len))) - memcpy(pos,str,len); - return pos; -} - - -char *memdup_root(MEM_ROOT *root,const char *str,uint len) -{ - char *pos; - if ((pos=alloc_root(root,len))) - memcpy(pos,str,len); - return pos; -} diff --git a/ext/mysql/libmysql/my_compress.c b/ext/mysql/libmysql/my_compress.c deleted file mode 100644 index 79e8ceac7c..0000000000 --- a/ext/mysql/libmysql/my_compress.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Written by Sinisa Milivojevic <sinisa@coresinc.com> */ - -#include <global.h> -#ifdef HAVE_COMPRESS -#include <my_sys.h> -#include <m_string.h> -#include <zlib.h> - -/* -** This replaces the packet with a compressed packet -** Returns 1 on error -** *complen is 0 if the packet wasn't compressed -*/ - -my_bool my_compress(byte *packet, ulong *len, ulong *complen) -{ - if (*len < MIN_COMPRESS_LENGTH) - *complen=0; - else - { - byte *compbuf=my_compress_alloc(packet,len,complen); - if (!compbuf) - return *complen ? 0 : 1; - memcpy(packet,compbuf,*len); - my_free(compbuf,MYF(MY_WME)); } - return 0; -} - - -byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen) -{ - byte *compbuf; - *complen = *len * 120 / 100 + 12; - if (!(compbuf = (byte *) my_malloc(*complen,MYF(MY_WME)))) - return 0; /* Not enough memory */ - if (compress((Bytef*) compbuf,(ulong *) complen, (Bytef*) packet, - (uLong) *len ) != Z_OK) - { - my_free(compbuf,MYF(MY_WME)); - return 0; - } - if (*complen >= *len) - { - *complen=0; - my_free(compbuf,MYF(MY_WME)); - return 0; - } - swap(ulong,*len,*complen); /* *len is now packet length */ - return compbuf; -} - - -my_bool my_uncompress (byte *packet, ulong *len, ulong *complen) -{ - if (*complen) /* If compressed */ - { - byte *compbuf = (byte *) my_malloc (*complen,MYF(MY_WME)); - if (!compbuf) - return 1; /* Not enough memory */ - if (uncompress((Bytef*) compbuf, complen, (Bytef*) packet, *len) != Z_OK) - { /* Probably wrong packet */ - my_free (compbuf,MYF(MY_WME)); - return 1; - } - *len = *complen; - memcpy(packet,compbuf,*len); - my_free(compbuf,MYF(MY_WME)); - } - return 0; -} -#endif /* HAVE_COMPRESS */ diff --git a/ext/mysql/libmysql/my_config.h b/ext/mysql/libmysql/my_config.h deleted file mode 100644 index 73a3f6d66e..0000000000 --- a/ext/mysql/libmysql/my_config.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <php_config.h> - -/* PHP might define ulong, but we want to use our own typedef */ -#ifdef ulong -#undef ulong -#endif - -/* The client doesn't use multiple charsets, so only the compiled-in - default is really needed */ -#define SHAREDIR "NONEXISTENT" -#define DEFAULT_CHARSET_HOME SHAREDIR diff --git a/ext/mysql/libmysql/my_create.c b/ext/mysql/libmysql/my_create.c deleted file mode 100644 index a779b3f142..0000000000 --- a/ext/mysql/libmysql/my_create.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#define USES_TYPES -#include "mysys_priv.h" -#include <my_dir.h> -#include "mysys_err.h" -#include <errno.h> -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) -#include <share.h> -#endif - - /* - ** Create a new file - ** Arguments: - ** Path-name of file - ** Read | write on file (umask value) - ** Read & Write on open file - ** Special flags - */ - - -File my_create(const char *FileName, int CreateFlags, int access_flags, - myf MyFlags) -{ - int fd; - DBUG_ENTER("my_create"); - DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d", - FileName, CreateFlags, access_flags, MyFlags)); - -#if !defined(NO_OPEN_3) && !defined(__EMX__) - fd = open((my_string) FileName, access_flags | O_CREAT, - CreateFlags ? CreateFlags : my_umask); -#elif defined(VMS) - fd = open((my_string) FileName, access_flags | O_CREAT, 0, - "ctx=stm","ctx=bin"); -#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) - if (access_flags & O_SHARE) - fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY, - SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); - else - fd = open((my_string) FileName, access_flags | O_CREAT | O_BINARY, - MY_S_IREAD | MY_S_IWRITE); -#else - fd = open(FileName, access_flags); -#endif - - DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_CREATE, - EE_CANTCREATEFILE, MyFlags)); -} /* my_create */ diff --git a/ext/mysql/libmysql/my_delete.c b/ext/mysql/libmysql/my_delete.c deleted file mode 100644 index f1ffada90f..0000000000 --- a/ext/mysql/libmysql/my_delete.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" - -#include "mysys_err.h" - -int my_delete(const char *name, myf MyFlags) -{ - int err; - DBUG_ENTER("my_delete"); - DBUG_PRINT("my",("name %s MyFlags %d", name, MyFlags)); - - if ((err = unlink(name)) == -1) - { - my_errno=errno; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_DELETE,MYF(ME_BELL+ME_WAITTANG+(MyFlags & ME_NOINPUT)), - name,errno); - } - DBUG_RETURN(err); -} /* my_delete */ diff --git a/ext/mysql/libmysql/my_dir.h b/ext/mysql/libmysql/my_dir.h deleted file mode 100644 index e0c79dadfe..0000000000 --- a/ext/mysql/libmysql/my_dir.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#ifndef _my_dir_h -#define _my_dir_h -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef MY_DIR_H -#define MY_DIR_H - -#include <sys/stat.h> - - /* Defines for my_dir and my_stat */ - -#define MY_S_IFMT S_IFMT /* type of file */ -#define MY_S_IFDIR S_IFDIR /* directory */ -#define MY_S_IFCHR S_IFCHR /* character special */ -#define MY_S_IFBLK S_IFBLK /* block special */ -#define MY_S_IFREG S_IFREG /* regular */ -#define MY_S_IFIFO S_IFIFO /* fifo */ -#define MY_S_ISUID S_ISUID /* set user id on execution */ -#define MY_S_ISGID S_ISGID /* set group id on execution */ -#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */ -#define MY_S_IREAD S_IREAD /* read permission, owner */ -#define MY_S_IWRITE S_IWRITE /* write permission, owner */ -#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */ - -#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR) -#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR) -#define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK) -#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG) -#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) - -#define MY_DONT_SORT 512 /* my_lib; Don't sort files */ -#define MY_WANT_STAT 1024 /* my_lib; stat files */ - - /* typedefs for my_dir & my_stat */ - -#ifdef USE_MY_STAT_STRUCT - -typedef struct my_stat -{ - dev_t st_dev; /* major & minor device numbers */ - ino_t st_ino; /* inode number */ - ushort st_mode; /* file permissons (& suid sgid .. bits) */ - short st_nlink; /* number of links to file */ - ushort st_uid; /* user id */ - ushort st_gid; /* group id */ - dev_t st_rdev; /* more major & minor device numbers (???) */ - off_t st_size; /* size of file */ - time_t st_atime; /* time for last read */ - time_t st_mtime; /* time for last contens modify */ - time_t st_ctime; /* time for last inode or contents modify */ -} MY_STAT; - -#else - -#define MY_STAT struct stat /* Orginal struct have what we need */ - -#endif /* USE_MY_STAT_STRUCT */ - -typedef struct fileinfo /* Struct returned from my_dir & my_stat */ -{ - char *name; - MY_STAT mystat; -} FILEINFO; - -typedef struct st_my_dir /* Struct returned from my_dir */ -{ - struct fileinfo *dir_entry; - uint number_off_files; -} MY_DIR; - -extern MY_DIR *my_dir(const char *path,myf MyFlags); -extern void my_dirend(MY_DIR *buffer); -extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags); -extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags); - -#endif /* MY_DIR_H */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ext/mysql/libmysql/my_div.c b/ext/mysql/libmysql/my_div.c deleted file mode 100644 index fc3ad59b4a..0000000000 --- a/ext/mysql/libmysql/my_div.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" - -my_string my_filename(File fd) -{ - DBUG_ENTER("my_filename"); - if (fd >= MY_NFILE) - DBUG_RETURN((char*) "UNKNOWN"); - if (fd >= 0 && my_file_info[fd].type != UNOPEN) - { - DBUG_RETURN(my_file_info[fd].name); - } - else - DBUG_RETURN((char*) "UNOPENED"); /* Debug message */ -} diff --git a/ext/mysql/libmysql/my_error.c b/ext/mysql/libmysql/my_error.c deleted file mode 100644 index 21dc3ec268..0000000000 --- a/ext/mysql/libmysql/my_error.c +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <m_string.h> -#include <stdarg.h> -#include <m_ctype.h> - -/* Define some external variables for error handling */ - -const char ** NEAR my_errmsg[MAXMAPS]={0,0,0,0}; -char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; - -/* Error message to user */ -/*VARARGS2*/ - -int my_error(int nr,myf MyFlags, ...) -{ - va_list ap; - uint olen, plen; - reg1 const char *tpos; - reg2 char *endpos; - char * par; - char ebuff[ERRMSGSIZE+20]; - DBUG_ENTER("my_error"); - - va_start(ap,MyFlags); - DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno)); - - if (nr / ERRMOD == GLOB && my_errmsg[GLOB] == 0) - init_glob_errs(); - - olen=(uint) strlen(tpos=my_errmsg[nr / ERRMOD][nr % ERRMOD]); - endpos=ebuff; - - while (*tpos) - { - if (tpos[0] != '%') - { - *endpos++= *tpos++; /* Copy ordinary char */ - olen++; - continue; - } - if (*++tpos == '%') /* test if %% */ - { - olen--; - } - else - { - /* Skipp if max size is used (to be compatible with printf) */ - while (isdigit(*tpos) || *tpos == '.' || *tpos == '-') - tpos++; - if (*tpos == 'l') /* Skipp 'l' argument */ - tpos++; - if (*tpos == 's') /* String parameter */ - { - par = va_arg(ap, char *); - plen = (uint) strlen(par); - if (olen + plen < ERRMSGSIZE+2) /* Replace if possible */ - { - endpos=strmov(endpos,par); - tpos++; - olen+=plen-2; - continue; - } - } - else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */ - { - register int iarg; - iarg = va_arg(ap, int); - if (*tpos == 'd') - plen= (uint) (int2str((long) iarg,endpos, -10) - endpos); - else - plen= (uint) (int2str((long) (uint) iarg,endpos,10)- endpos); - if (olen + plen < ERRMSGSIZE+2) /* Replace parameter if possible */ - { - endpos+=plen; - tpos++; - olen+=plen-2; - continue; - } - } - } - *endpos++='%'; /* % used as % or unknown code */ - } - *endpos='\0'; /* End of errmessage */ - va_end(ap); - DBUG_RETURN((*error_handler_hook)(nr, ebuff, MyFlags)); -} - - /* Error as printf */ - -int my_printf_error (uint error, const char *format, myf MyFlags, ...) -{ - va_list args; - char ebuff[ERRMSGSIZE+20]; - - va_start(args,MyFlags); - (void) vsprintf (ebuff,format,args); - va_end(args); - return (*error_handler_hook)(error, ebuff, MyFlags); -} - - /* Give message using error_handler_hook */ - -int my_message(uint error, const char *str, register myf MyFlags) -{ - return (*error_handler_hook)(error, str, MyFlags); -} diff --git a/ext/mysql/libmysql/my_fopen.c b/ext/mysql/libmysql/my_fopen.c deleted file mode 100644 index 5e6cd6682a..0000000000 --- a/ext/mysql/libmysql/my_fopen.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "my_static.h" -#include <errno.h> -#include "mysys_err.h" - -static void make_ftype(my_string to,int flag); - - /* Open a file as stream */ - -FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) - /* Path-name of file */ - /* Read | write .. */ - /* Special flags */ -{ - FILE *fd; - char type[5]; - DBUG_ENTER("my_fopen"); - DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", - FileName, Flags, MyFlags)); - - make_ftype(type,Flags); - if ((fd = fopen(FileName, type)) != 0) - { - /* - The test works if MY_NFILE < 128. The problem is that fileno() is char - on some OS (SUNOS). Actually the filename save isn't that important - so we can ignore if this doesn't work. - */ - if ((uint) fileno(fd) >= MY_NFILE) - { - thread_safe_increment(my_stream_opened,&THR_LOCK_open); - DBUG_RETURN(fd); /* safeguard */ - } - pthread_mutex_lock(&THR_LOCK_open); - if ((my_file_info[fileno(fd)].name = (char*) - my_strdup(FileName,MyFlags))) - { - my_stream_opened++; - my_file_info[fileno(fd)].type = STREAM_BY_FOPEN; - pthread_mutex_unlock(&THR_LOCK_open); - DBUG_PRINT("exit",("stream: %lx",fd)); - DBUG_RETURN(fd); - } - pthread_mutex_unlock(&THR_LOCK_open); - (void) my_fclose(fd,MyFlags); - my_errno=ENOMEM; - } - else - my_errno=errno; - DBUG_PRINT("error",("Got error %d on open",my_errno)); - if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) - my_error((Flags & O_RDONLY) || (Flags == O_RDONLY ) ? EE_FILENOTFOUND : - EE_CANTCREATEFILE, - MYF(ME_BELL+ME_WAITTANG), FileName,my_errno); - DBUG_RETURN((FILE*) 0); -} /* my_fopen */ - - - /* Close a stream */ - -int my_fclose(FILE *fd, myf MyFlags) -{ - int err,file; - DBUG_ENTER("my_fclose"); - DBUG_PRINT("my",("stream: %lx MyFlags: %d",fd, MyFlags)); - - pthread_mutex_lock(&THR_LOCK_open); - file=fileno(fd); - if ((err = fclose(fd)) < 0) - { - my_errno=errno; - if (MyFlags & (MY_FAE | MY_WME)) - my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG), - my_filename(file),errno); - } - else - my_stream_opened--; - if ((uint) file < MY_NFILE && my_file_info[file].type != UNOPEN) - { - my_file_info[file].type = UNOPEN; - my_free(my_file_info[file].name, MYF(MY_ALLOW_ZERO_PTR)); - } - pthread_mutex_unlock(&THR_LOCK_open); - DBUG_RETURN(err); -} /* my_fclose */ - - - /* Make a stream out of a file handle */ - /* Name may be 0 */ - -FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags) -{ - FILE *fd; - char type[5]; - DBUG_ENTER("my_fdopen"); - DBUG_PRINT("my",("Fd: %d Flags: %d MyFlags: %d", - Filedes, Flags, MyFlags)); - - make_ftype(type,Flags); - if ((fd = fdopen(Filedes, type)) == 0) - { - my_errno=errno; - if (MyFlags & (MY_FAE | MY_WME)) - my_error(EE_CANT_OPEN_STREAM, MYF(ME_BELL+ME_WAITTANG),errno); - } - else - { - pthread_mutex_lock(&THR_LOCK_open); - my_stream_opened++; - if (Filedes < MY_NFILE) - { - if (my_file_info[Filedes].type != UNOPEN) - { - my_file_opened--; /* File is opened with my_open ! */ - } - else - { - my_file_info[Filedes].name= my_strdup(name,MyFlags); - } - my_file_info[Filedes].type = STREAM_BY_FDOPEN; - } - pthread_mutex_unlock(&THR_LOCK_open); - } - - DBUG_PRINT("exit",("stream: %lx",fd)); - DBUG_RETURN(fd); -} /* my_fdopen */ - - - /* Make a filehandler-open-typestring from ordinary inputflags */ - -static void make_ftype(register my_string to, register int flag) -{ -#if FILE_BINARY /* If we have binary-files */ - reg3 int org_flag=flag; -#endif - flag&= ~FILE_BINARY; /* remove binary bit */ - if (flag == O_RDONLY) - *to++= 'r'; - else if (flag == O_WRONLY) - *to++= 'w'; - else - { /* Add '+' after theese */ - if (flag == O_RDWR) - *to++= 'r'; - else if (flag & O_APPEND) - *to++= 'a'; - else - *to++= 'w'; /* Create file */ - *to++= '+'; - } -#if FILE_BINARY /* If we have binary-files */ - if (org_flag & FILE_BINARY) - *to++='b'; -#endif - *to='\0'; -} /* make_ftype */ diff --git a/ext/mysql/libmysql/my_getwd.c b/ext/mysql/libmysql/my_getwd.c deleted file mode 100644 index 0797db25f5..0000000000 --- a/ext/mysql/libmysql/my_getwd.c +++ /dev/null @@ -1,180 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* my_setwd() and my_getwd() works with intern_filenames !! */ - -#include "mysys_priv.h" -#include <m_string.h> -#include "mysys_err.h" -#ifdef HAVE_GETWD -#include <sys/param.h> -#endif -#if defined(MSDOS) || defined(__WIN__) -#include <m_ctype.h> -#include <dos.h> -#include <direct.h> -#endif -#if defined(OS2) -#include <direct.h> -#endif - -#ifdef __EMX__ -/* chdir2 support also drive change */ -#define chdir _chdir2 -#endif - - /* Gets current working directory in buff. Directory is allways ended - with FN_LIBCHAR */ - /* One must pass a buffer to my_getwd. One can allways use - curr_dir[] */ - -int my_getwd(my_string buf, uint size, myf MyFlags) -{ - my_string pos; - DBUG_ENTER("my_getwd"); - DBUG_PRINT("my",("buf: %lx size: %d MyFlags %d", buf,size,MyFlags)); - -#if ! defined(MSDOS) - if (curr_dir[0]) /* Current pos is saved here */ - VOID(strmake(buf,&curr_dir[0],size-1)); - else -#endif - { -#if defined(HAVE_GETCWD) - if (!getcwd(buf,size-2) && MyFlags & MY_WME) - { - my_errno=errno; - my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno); - return(-1); - } -#elif defined(HAVE_GETWD) - { - char pathname[MAXPATHLEN]; - getwd(pathname); - strmake(buf,pathname,size-1); - } -#elif defined(VMS) - if (!getcwd(buf,size-2,1) && MyFlags & MY_WME) - { - my_errno=errno; - my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno); - return(-1); - } - intern_filename(buf,buf); -#else -#error "No way to get current directory" -#endif - if (*((pos=strend(buf))-1) != FN_LIBCHAR) /* End with FN_LIBCHAR */ - { - pos[0]= FN_LIBCHAR; - pos[1]=0; - } - (void) strmake(&curr_dir[0],buf,(size_s) (FN_REFLEN-1)); - } - DBUG_RETURN(0); -} /* my_getwd */ - - - /* Set new working directory */ - -int my_setwd(const char *dir, myf MyFlags) -{ - int res; - size_s length; - my_string start,pos; -#if defined(VMS) || defined(MSDOS) || defined(OS2) - char buff[FN_REFLEN]; -#endif - DBUG_ENTER("my_setwd"); - DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags)); - - start=(my_string) dir; -#if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */ -#if !defined(_DDL) && !defined(WIN32) - if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0) - { - uint drive,drives; - - pos++; /* Skipp FN_DEVCHAR */ - drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1; - if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32) - { -#ifdef OS2 - _chdrive(drive); - drives = _getdrive(); -#else - _dos_setdrive(drive,&drives); - _dos_getdrive(&drives); -#endif - } - if (drive != drives) - { - *pos='\0'; /* Dir is now only drive */ - my_errno=errno; - my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),dir,ENOENT); - DBUG_RETURN(-1); - } - dir=pos; /* drive changed, change now path */ - } -#endif - if (*((pos=strend(dir)-1)) == FN_LIBCHAR && pos != dir) - { - strmov(buff,dir)[-1]=0; /* Remove last '/' */ - dir=buff; - } -#endif /* MSDOS*/ - if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0)) - dir=FN_ROOTDIR; -#ifdef VMS - { - pos=strmov(buff,dir); - if (pos[-1] != FN_LIBCHAR) - { - pos[0]=FN_LIBCHAR; /* Mark as directory */ - pos[1]=0; - } - system_filename(buff,buff); /* Change to VMS format */ - dir=buff; - } -#endif /* VMS */ - if ((res=chdir((char*) dir)) != 0) - { - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),start,errno); - } - else - { - if (test_if_hard_path(start)) - { /* Hard pathname */ - pos=strmake(&curr_dir[0],start,(size_s) FN_REFLEN-1); - if (pos[-1] != FN_LIBCHAR) - { - length=(uint) (pos-(char*) curr_dir); - curr_dir[length]=FN_LIBCHAR; /* must end with '/' */ - curr_dir[length+1]='\0'; - } - } - else - curr_dir[0]='\0'; /* Don't save name */ - } - DBUG_RETURN(res); -} /* my_setwd */ - - - - /* Test if hard pathname */ - /* Returns 1 if dirname is a hard path */ - -int test_if_hard_path(register const char *dir_name) -{ - if (dir_name[0] == FN_HOMELIB && dir_name[1] == FN_LIBCHAR) - return (home_dir != NullS && test_if_hard_path(home_dir)); - if (dir_name[0] == FN_LIBCHAR) - return (TRUE); -#ifdef FN_DEVCHAR - return (strchr(dir_name,FN_DEVCHAR) != 0); -#else - return FALSE; -#endif -} /* test_if_hard_path */ diff --git a/ext/mysql/libmysql/my_init.c b/ext/mysql/libmysql/my_init.c deleted file mode 100644 index 472721c952..0000000000 --- a/ext/mysql/libmysql/my_init.c +++ /dev/null @@ -1,312 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "my_static.h" -#include "mysys_err.h" -#include "m_ctype.h" -#include <m_string.h> -#include <m_ctype.h> -#ifdef THREAD -#include <my_pthread.h> -#endif -#ifdef HAVE_GETRUSAGE -#include <sys/resource.h> -/* extern int getrusage(int, struct rusage *); */ -#endif -#include <signal.h> -#ifdef VMS -#include <my_static.c> -#include <m_ctype.h> -#endif -#ifdef __WIN__ -#ifdef _MSC_VER -#include <locale.h> -#include <crtdbg.h> -#endif -my_bool have_tcpip=0; -static void my_win_init(void); -static my_bool win32_have_tcpip(void); -static my_bool win32_init_tcp_ip(); -#else -#define my_win_init() -#endif -static my_bool my_init_done=0; - - - -static ulong atoi_octal(const char *str) -{ - long int tmp; - while (*str && isspace(*str)) - str++; - str2int(str, - (*str == '0' ? 8 : 10), /* Octalt or decimalt */ - 0, INT_MAX, &tmp); - return (ulong) tmp; -} - - - /* Init my_sys functions and my_sys variabels */ - -void my_init(void) -{ - my_string str; - if (my_init_done) - return; - my_init_done=1; -#ifdef THREAD -#if defined(HAVE_PTHREAD_INIT) - pthread_init(); /* Must be called before DBUG_ENTER */ -#endif - my_thread_global_init(); -#if !defined( __WIN__) && !defined(OS2) - sigfillset(&my_signals); /* signals blocked by mf_brkhant */ -#endif -#endif /* THREAD */ -#ifdef UNIXWARE_7 - (void) isatty(0); /* Go around connect() bug in UW7 */ -#endif - { - DBUG_ENTER("my_init"); - DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown"); - if (!home_dir) - { /* Don't initialize twice */ - my_win_init(); - if ((home_dir=getenv("HOME")) != 0) - home_dir=intern_filename(home_dir_buff,home_dir); -#ifndef VMS - /* Default creation of new files */ - if ((str=getenv("UMASK")) != 0) - my_umask=(int) (atoi_octal(str) | 0600); - /* Default creation of new dir's */ - if ((str=getenv("UMASK_DIR")) != 0) - my_umask_dir=(int) (atoi_octal(str) | 0700); -#endif -#ifdef VMS - init_ctype(); /* Stupid linker don't link _ctype.c */ -#endif - DBUG_PRINT("exit",("home: '%s'",home_dir)); - } -#ifdef __WIN__ - win32_init_tcp_ip(); -#endif - DBUG_VOID_RETURN; - } -} /* my_init */ - - - /* End my_sys */ - -void my_end(int infoflag) -{ - FILE *info_file; - if (!(info_file=DBUG_FILE)) - info_file=stderr; - if (infoflag & MY_CHECK_ERROR || info_file != stderr) - { /* Test if some file is left open */ - if (my_file_opened | my_stream_opened) - { - sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened); - (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL); - DBUG_PRINT("error",("%s",errbuff[0])); - } - } - free_charsets(); - if (infoflag & MY_GIVE_INFO || info_file != stderr) - { -#ifdef HAVE_GETRUSAGE - struct rusage rus; - if (!getrusage(RUSAGE_SELF, &rus)) - fprintf(info_file,"\n\ -User time %.2f, System time %.2f\n\ -Maximum resident set size %ld, Integral resident set size %ld\n\ -Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\ -Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\ -Voluntary context switches %ld, Involuntary context switches %ld\n", - (rus.ru_utime.tv_sec * SCALE_SEC + - rus.ru_utime.tv_usec / SCALE_USEC) / 100.0, - (rus.ru_stime.tv_sec * SCALE_SEC + - rus.ru_stime.tv_usec / SCALE_USEC) / 100.0, - rus.ru_maxrss, rus.ru_idrss, - rus.ru_minflt, rus.ru_majflt, - rus.ru_nswap, rus.ru_inblock, rus.ru_oublock, - rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals, - rus.ru_nvcsw, rus.ru_nivcsw); -#endif -#if defined(MSDOS) && !defined(__WIN__) - fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); -#endif -#if defined(SAFEMALLOC) - TERMINATE(stderr); /* Give statistic on screen */ -#elif defined(__WIN__) && defined(_MSC_VER) - _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); - _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR ); - _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR ); - _CrtCheckMemory(); - _CrtDumpMemoryLeaks(); -#endif - } -#ifdef THREAD - pthread_mutex_destroy(&THR_LOCK_keycache); - pthread_mutex_destroy(&THR_LOCK_malloc); - pthread_mutex_destroy(&THR_LOCK_open); - DBUG_POP(); /* Must be done before my_thread_end */ - my_thread_end(); - my_thread_global_end(); -#endif -#ifdef __WIN__ - if (have_tcpip); - WSACleanup( ); -#endif /* __WIN__ */ - my_init_done=0; -} /* my_end */ - -#ifdef __WIN__ - -/* - This code is specially for running MySQL, but it should work in - other cases too. - - Inizializzazione delle variabili d'ambiente per Win a 32 bit. - - Vengono inserite nelle variabili d'ambiente (utilizzando cosi' - le funzioni getenv e putenv) i valori presenti nelle chiavi - del file di registro: - - HKEY_LOCAL_MACHINE\software\MySQL - - Se la kiave non esiste nonn inserisce nessun valore -*/ - -/* Crea la stringa d'ambiente */ - -void setEnvString(char *ret, const char *name, const char *value) -{ - DBUG_ENTER("setEnvString"); - strxmov(ret, name,"=",value,NullS); - DBUG_VOID_RETURN ; -} - -static void my_win_init(void) -{ - HKEY hSoftMysql ; - DWORD dimName = 256 ; - DWORD dimData = 1024 ; - DWORD dimNameValueBuffer = 256 ; - DWORD dimDataValueBuffer = 1024 ; - DWORD indexValue = 0 ; - long retCodeEnumValue ; - char NameValueBuffer[256] ; - char DataValueBuffer[1024] ; - char EnvString[1271] ; - const char *targetKey = "Software\\MySQL" ; - DBUG_ENTER("my_win_init"); - - setlocale(LC_CTYPE, ""); /* To get right sortorder */ - - /* apre la chiave HKEY_LOCAL_MACHINES\software\MySQL */ - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,(LPCTSTR)targetKey,0, - KEY_READ,&hSoftMysql) != ERROR_SUCCESS) - DBUG_VOID_RETURN; - - /* - ** Ne legge i valori e li inserisce nell'ambiente - ** suppone che tutti i valori letti siano di tipo stringa + '\0' - ** Legge il valore con indice 0 e lo scarta - */ - retCodeEnumValue = RegEnumValue(hSoftMysql, indexValue++, - (LPTSTR)NameValueBuffer, &dimNameValueBuffer, - NULL, NULL, (LPBYTE)DataValueBuffer, - &dimDataValueBuffer) ; - - while (retCodeEnumValue != ERROR_NO_MORE_ITEMS) - { - char *my_env; - /* Crea la stringa d'ambiente */ - setEnvString(EnvString, NameValueBuffer, DataValueBuffer) ; - - /* Inserisce i dati come variabili d'ambiente */ - my_env=strdup(EnvString); /* variable for putenv must be allocated ! */ - putenv(EnvString) ; - - dimNameValueBuffer = dimName ; - dimDataValueBuffer = dimData ; - - retCodeEnumValue = RegEnumValue(hSoftMysql, indexValue++, - NameValueBuffer, &dimNameValueBuffer, - NULL, NULL, (LPBYTE)DataValueBuffer, - &dimDataValueBuffer) ; - } - - /* chiude la chiave */ - RegCloseKey(hSoftMysql) ; - DBUG_VOID_RETURN ; -} - - -/*------------------------------------------------------------------ -** Name: CheckForTcpip| Desc: checks if tcpip has been installed on system -** According to Microsoft Developers documentation the first registry -** entry should be enough to check if TCP/IP is installed, but as expected -** this doesn't work on all Win32 machines :( -------------------------------------------------------------------*/ - -#define TCPIPKEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" -#define WINSOCK2KEY "SYSTEM\\CurrentControlSet\\Services\\Winsock2\\Parameters" -#define WINSOCKKEY "SYSTEM\\CurrentControlSet\\Services\\Winsock\\Parameters" - -static my_bool win32_have_tcpip(void) -{ - HKEY hTcpipRegKey; - if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, TCPIPKEY, 0, KEY_READ, - &hTcpipRegKey) != ERROR_SUCCESS) - { - if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, WINSOCK2KEY, 0, KEY_READ, - &hTcpipRegKey) != ERROR_SUCCESS) - { - if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, WINSOCKKEY, 0, KEY_READ, - &hTcpipRegKey) != ERROR_SUCCESS) - if (!getenv("HAVE_TCPIP") || have_tcpip) /* Provide a workaround */ - return (FALSE); - } - } - RegCloseKey ( hTcpipRegKey); - return (TRUE); -} - -static my_bool win32_init_tcp_ip() -{ - if (win32_have_tcpip()) - { - WORD wVersionRequested = MAKEWORD( 2, 0 ); - WSADATA wsaData; - /* Be a good citizen: maybe another lib has already initialised - sockets, so dont clobber them unless necessary */ - if (WSAStartup( wVersionRequested, &wsaData )) - { - /* Load failed, maybe because of previously loaded - incompatible version; try again */ - WSACleanup( ); - if (!WSAStartup( wVersionRequested, &wsaData )) - have_tcpip=1; - } - else - { - if (wsaData.wVersion != wVersionRequested) - { - /* Version is no good, try again */ - WSACleanup( ); - if (!WSAStartup( wVersionRequested, &wsaData )) - have_tcpip=1; - } - else - have_tcpip=1; - } - } - return(0); -} -#endif diff --git a/ext/mysql/libmysql/my_lib.c b/ext/mysql/libmysql/my_lib.c deleted file mode 100644 index 259a7222b4..0000000000 --- a/ext/mysql/libmysql/my_lib.c +++ /dev/null @@ -1,600 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* TODO: check for overun of memory for names. */ -/* Convert MSDOS-TIME to standar time_t */ - -#define USES_TYPES /* sys/types is included */ -#include "mysys_priv.h" -#include <m_string.h> -#include <my_dir.h> /* Structs used by my_dir,includes sys/types */ -#include "mysys_err.h" -#if defined(HAVE_DIRENT_H) -# include <dirent.h> -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -#ifndef OS2 -# define dirent direct -#endif -# define NAMLEN(dirent) (dirent)->d_namlen -# if defined(HAVE_SYS_NDIR_H) -# include <sys/ndir.h> -# endif -# if defined(HAVE_SYS_DIR_H) -# include <sys/dir.h> -# endif -# if defined(HAVE_NDIR_H) -# include <ndir.h> -# endif -# if defined(MSDOS) || defined(__WIN__) -# include <dos.h> -# ifdef __BORLANDC__ -# include <dir.h> -# endif -# endif -#endif -#ifdef VMS -#include <rms.h> -#include <iodef.h> -#include <descrip.h> -#endif - -#ifdef OS2 -#include "my_os2dirsrch.h" -#endif - -#if defined(THREAD) && defined(HAVE_READDIR_R) -#define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C) -#else -#define READDIR(A,B,C) (!(C=readdir(A))) -#endif - - -#define STARTSIZE ONCE_ALLOC_INIT*8 /* some mallocmargin */ - -static int comp_names(struct fileinfo *a,struct fileinfo *b); - - - /* We need this because program don't know with malloc we used */ - -void my_dirend(MY_DIR *buffer) -{ - DBUG_ENTER("my_dirend"); - if (buffer) - my_free((gptr) buffer,MYF(0)); - DBUG_VOID_RETURN; -} /* my_dirend */ - - - /* Compare in sort of filenames */ - -static int comp_names(struct fileinfo *a, struct fileinfo *b) -{ - return (strcmp(a->name,b->name)); -} /* comp_names */ - - -#if !defined(MSDOS) && !defined(__WIN__) - -MY_DIR *my_dir(const char *path, myf MyFlags) -{ - DIR *dirp; - struct dirent *dp; - struct fileinfo *fnames; - char *buffer, *obuffer, *tempptr; - uint fcnt,i,size,firstfcnt, maxfcnt,length; - char tmp_path[FN_REFLEN+1],*tmp_file; - my_ptrdiff_t diff; - bool eof; -#ifdef THREAD - char dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1]; -#endif - DBUG_ENTER("my_dir"); - DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags)); - -#if defined(THREAD) && !defined(HAVE_READDIR_R) - pthread_mutex_lock(&THR_LOCK_open); -#endif - - dirp = opendir(directory_file_name(tmp_path,(my_string) path)); - size = STARTSIZE; - if (dirp == NULL || ! (buffer = (char *) my_malloc(size, MyFlags))) - goto error; - - fcnt = 0; - tmp_file=strend(tmp_path); - firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) / - (sizeof(struct fileinfo) + FN_LEN); - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr = (char *) (fnames + maxfcnt); - -#ifdef THREAD - dp= (struct dirent*) dirent_tmp; -#else - dp=0; -#endif - eof=0; - for (;;) - { - while (fcnt < maxfcnt && - !(eof= READDIR(dirp,(struct dirent*) dirent_tmp,dp))) - { - bzero((gptr) (fnames+fcnt),sizeof(fnames[0])); /* for purify */ - fnames[fcnt].name = tempptr; - tempptr = strmov(tempptr,dp->d_name) + 1; - if (MyFlags & MY_WANT_STAT) - { - VOID(strmov(tmp_file,dp->d_name)); - VOID(my_stat(tmp_path, &fnames[fcnt].mystat, MyFlags)); - } - ++fcnt; - } - if (eof) - break; - size += STARTSIZE; obuffer = buffer; - if (!(buffer = (char *) my_realloc((gptr) buffer, size, - MyFlags | MY_FREE_ON_ERROR))) - goto error; /* No memory */ - length= (uint) (sizeof(struct fileinfo ) * firstfcnt); - diff= PTR_BYTE_DIFF(buffer , obuffer) + (int) length; - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr= ADD_TO_PTR(tempptr,diff,char*); - for (i = 0; i < maxfcnt; i++) - fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*); - - /* move filenames upp a bit */ - maxfcnt += firstfcnt; - bmove_upp(tempptr,tempptr-length, - (uint) (tempptr- (char*) (fnames+maxfcnt))); - } - - (void) closedir(dirp); - { - MY_DIR * s = (MY_DIR *) buffer; - s->number_off_files = (uint) fcnt; - s->dir_entry = fnames; - } - if (!(MyFlags & MY_DONT_SORT)) - qsort((void *) fnames, (size_s) fcnt, sizeof(struct fileinfo), - (qsort_cmp) comp_names); -#if defined(THREAD) && !defined(HAVE_READDIR_R) - pthread_mutex_unlock(&THR_LOCK_open); -#endif - DBUG_RETURN((MY_DIR *) buffer); - - error: -#if defined(THREAD) && !defined(HAVE_READDIR_R) - pthread_mutex_unlock(&THR_LOCK_open); -#endif - my_errno=errno; - if (dirp) - (void) closedir(dirp); - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno); - DBUG_RETURN((MY_DIR *) NULL); -} /* my_dir */ - - -/* - * Convert from directory name to filename. - * On VMS: - * xyzzy:[mukesh.emacs] => xyzzy:[mukesh]emacs.dir.1 - * xyzzy:[mukesh] => xyzzy:[000000]mukesh.dir.1 - * On UNIX, it's simple: just make sure there is a terminating / - - * Returns pointer to dst; - */ - -my_string directory_file_name (my_string dst, const char *src) -{ -#ifndef VMS - - /* Process as Unix format: just remove test the final slash. */ - - my_string end; - - if (src[0] == 0) - src= (char*) "."; /* Use empty as current */ - end=strmov(dst, src); - if (end[-1] != FN_LIBCHAR) - { - end[0]=FN_LIBCHAR; /* Add last '/' */ - end[1]='\0'; - } - return dst; - -#else /* VMS */ - - long slen; - long rlen; - my_string ptr, rptr; - char bracket; - struct FAB fab = cc$rms_fab; - struct NAM nam = cc$rms_nam; - char esa[NAM$C_MAXRSS]; - - if (! src[0]) - src="[.]"; /* Empty is == current dir */ - - slen = strlen (src) - 1; - if (src[slen] == FN_C_AFTER_DIR || src[slen] == FN_C_AFTER_DIR_2 || - src[slen] == FN_DEVCHAR) - { - /* VMS style - convert [x.y.z] to [x.y]z, [x] to [000000]x */ - fab.fab$l_fna = src; - fab.fab$b_fns = slen + 1; - fab.fab$l_nam = &nam; - fab.fab$l_fop = FAB$M_NAM; - - nam.nam$l_esa = esa; - nam.nam$b_ess = sizeof esa; - nam.nam$b_nop |= NAM$M_SYNCHK; - - /* We call SYS$PARSE to handle such things as [--] for us. */ - if (SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL) - { - slen = nam.nam$b_esl - 1; - if (esa[slen] == ';' && esa[slen - 1] == '.') - slen -= 2; - esa[slen + 1] = '\0'; - src = esa; - } - if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2) - { - /* what about when we have logical_name:???? */ - if (src[slen] == FN_DEVCHAR) - { /* Xlate logical name and see what we get */ - VOID(strmov(dst,src)); - dst[slen] = 0; /* remove colon */ - if (!(src = getenv (dst))) - return dst; /* Can't translate */ - - /* should we jump to the beginning of this procedure? - Good points: allows us to use logical names that xlate - to Unix names, - Bad points: can be a problem if we just translated to a device - name... - For now, I'll punt and always expect VMS names, and hope for - the best! */ - - slen = strlen (src) - 1; - if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2) - { /* no recursion here! */ - VOID(strmov(dst, src)); - return(dst); - } - } - else - { /* not a directory spec */ - VOID(strmov(dst, src)); - return(dst); - } - } - - bracket = src[slen]; /* End char */ - if (!(ptr = strchr (src, bracket - 2))) - { /* no opening bracket */ - VOID(strmov (dst, src)); - return dst; - } - if (!(rptr = strrchr (src, '.'))) - rptr = ptr; - slen = rptr - src; - VOID(strmake (dst, src, slen)); - - if (*rptr == '.') - { /* Put bracket and add */ - dst[slen++] = bracket; /* (rptr+1) after this */ - } - else - { - /* If we have the top-level of a rooted directory (i.e. xx:[000000]), - then translate the device and recurse. */ - - if (dst[slen - 1] == ':' - && dst[slen - 2] != ':' /* skip decnet nodes */ - && strcmp(src + slen, "[000000]") == 0) - { - dst[slen - 1] = '\0'; - if ((ptr = getenv (dst)) - && (rlen = strlen (ptr) - 1) > 0 - && (ptr[rlen] == FN_C_AFTER_DIR || ptr[rlen] == FN_C_AFTER_DIR_2) - && ptr[rlen - 1] == '.') - { - VOID(strmov(esa,ptr)); - esa[rlen - 1] = FN_C_AFTER_DIR; - esa[rlen] = '\0'; - return (directory_file_name (dst, esa)); - } - else - dst[slen - 1] = ':'; - } - VOID(strmov(dst+slen,"[000000]")); - slen += 8; - } - VOID(strmov(strmov(dst+slen,rptr+1)-1,".DIR.1")); - return dst; - } - VOID(strmov(dst, src)); - if (dst[slen] == '/' && slen > 1) - dst[slen] = 0; - return dst; -#endif /* VMS */ -} /* directory_file_name */ - -#elif defined(WIN32) - -/* -***************************************************************************** -** Read long filename using windows rutines -***************************************************************************** -*/ - -MY_DIR *my_dir(const char *path, myf MyFlags) -{ - struct fileinfo *fnames; - char *buffer, *obuffer, *tempptr; - int eof,i,fcnt,firstfcnt,length,maxfcnt; - uint size; -#ifdef __BORLANDC__ - struct ffblk find; -#else - struct _finddata_t find; -#endif - ushort mode; - char tmp_path[FN_REFLEN],*tmp_file,attrib; - my_ptrdiff_t diff; -#ifdef _WIN64 - __int64 handle; -#else - long handle; -#endif - DBUG_ENTER("my_dir"); - DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags)); - - /* Put LIB-CHAR as last path-character if not there */ - - tmp_file=tmp_path; - if (!*path) - *tmp_file++ ='.'; /* From current dir */ - tmp_file= strmov(tmp_file,path); - if (tmp_file[-1] == FN_DEVCHAR) - *tmp_file++= '.'; /* From current dev-dir */ - if (tmp_file[-1] != FN_LIBCHAR) - *tmp_file++ =FN_LIBCHAR; - tmp_file[0]='*'; /* MSDOS needs this !??? */ - tmp_file[1]='.'; - tmp_file[2]='*'; - tmp_file[3]='\0'; - -#ifdef __BORLANDC__ - if ((handle= findfirst(tmp_path,&find,0)) == -1L) - goto error; -#else - if ((handle=_findfirst(tmp_path,&find)) == -1L) - goto error; -#endif - - size = STARTSIZE; - firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) / - (sizeof(struct fileinfo) + FN_LEN); - if ((buffer = (char *) my_malloc(size, MyFlags)) == 0) - goto error; - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr = (char *) (fnames + maxfcnt); - - fcnt = 0; - for (;;) - { - do - { - fnames[fcnt].name = tempptr; -#ifdef __BORLANDC__ - tempptr = strmov(tempptr,find.ff_name) + 1; - fnames[fcnt].mystat.st_size=find.ff_fsize; - fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0; - mode=MY_S_IREAD; attrib=find.ff_attrib; -#else - tempptr = strmov(tempptr,find.name) + 1; - fnames[fcnt].mystat.st_size=find.size; - fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0; - mode=MY_S_IREAD; attrib=find.attrib; -#endif - if (!(attrib & _A_RDONLY)) - mode|=MY_S_IWRITE; - if (attrib & _A_SUBDIR) - mode|=MY_S_IFDIR; - fnames[fcnt].mystat.st_mode=mode; -#ifdef __BORLANDC__ - fnames[fcnt].mystat.st_mtime=((uint32) find.ff_ftime); -#else - fnames[fcnt].mystat.st_mtime=((uint32) find.time_write); -#endif - ++fcnt; -#ifdef __BORLANDC__ - } while ((eof= findnext(&find)) == 0 && fcnt < maxfcnt); -#else - } while ((eof= _findnext(handle,&find)) == 0 && fcnt < maxfcnt); -#endif - - DBUG_PRINT("test",("eof: %d errno: %d",eof,errno)); - if (eof) - break; - size += STARTSIZE; obuffer = buffer; - if (!(buffer = (char *) my_realloc((gptr) buffer, size, - MyFlags | MY_FREE_ON_ERROR))) - goto error; - length= sizeof(struct fileinfo ) * firstfcnt; - diff= PTR_BYTE_DIFF(buffer , obuffer) +length; - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr= ADD_TO_PTR(tempptr,diff,char*); - for (i = 0; i < maxfcnt; i++) - fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*); - - /* move filenames upp a bit */ - maxfcnt += firstfcnt; - bmove_upp(tempptr,ADD_TO_PTR(tempptr,-length,char*), - (int) PTR_BYTE_DIFF(tempptr,fnames+maxfcnt)); - } - { - MY_DIR * s = (MY_DIR *) buffer; - s->number_off_files = (uint) fcnt; - s->dir_entry = fnames; - } - if (!(MyFlags & MY_DONT_SORT)) - qsort(fnames,fcnt,sizeof(struct fileinfo),(qsort_cmp) comp_names); -#ifndef __BORLANDC__ - _findclose(handle); -#endif - DBUG_RETURN((MY_DIR *) buffer); - -error: - my_errno=errno; -#ifndef __BORLANDC__ - if (handle != -1) - _findclose(handle); -#endif - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,errno); - DBUG_RETURN((MY_DIR *) NULL); -} /* my_dir */ - -#else /* MSDOS and not WIN32 */ - - -/****************************************************************************** -** At MSDOS you always get stat of files, but time is in packed MSDOS-format -******************************************************************************/ - -MY_DIR *my_dir(const char* path, myf MyFlags) -{ - struct fileinfo *fnames; - char *buffer, *obuffer, *tempptr; - int eof,i,fcnt,firstfcnt,length,maxfcnt; - uint size; - struct find_t find; - ushort mode; - char tmp_path[FN_REFLEN],*tmp_file,attrib; - my_ptrdiff_t diff; - DBUG_ENTER("my_dir"); - DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags)); - - /* Put LIB-CHAR as last path-character if not there */ - - tmp_file=tmp_path; - if (!*path) - *tmp_file++ ='.'; /* From current dir */ - tmp_file= strmov(tmp_file,path); - if (tmp_file[-1] == FN_DEVCHAR) - *tmp_file++= '.'; /* From current dev-dir */ - if (tmp_file[-1] != FN_LIBCHAR) - *tmp_file++ =FN_LIBCHAR; - tmp_file[0]='*'; /* MSDOS needs this !??? */ - tmp_file[1]='.'; - tmp_file[2]='*'; - tmp_file[3]='\0'; - - if (_dos_findfirst(tmp_path,_A_NORMAL | _A_SUBDIR, &find)) - goto error; - - size = STARTSIZE; - firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) / - (sizeof(struct fileinfo) + FN_LEN); - if ((buffer = (char *) my_malloc(size, MyFlags)) == 0) - goto error; - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr = (char *) (fnames + maxfcnt); - - fcnt = 0; - for (;;) - { - do - { - fnames[fcnt].name = tempptr; - tempptr = strmov(tempptr,find.name) + 1; - fnames[fcnt].mystat.st_size=find.size; - fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0; - mode=MY_S_IREAD; attrib=find.attrib; - if (!(attrib & _A_RDONLY)) - mode|=MY_S_IWRITE; - if (attrib & _A_SUBDIR) - mode|=MY_S_IFDIR; - fnames[fcnt].mystat.st_mode=mode; - fnames[fcnt].mystat.st_mtime=((uint32) find.wr_date << 16) + - find.wr_time; - ++fcnt; - } while ((eof= _dos_findnext(&find)) == 0 && fcnt < maxfcnt); - - DBUG_PRINT("test",("eof: %d errno: %d",eof,errno)); - if (eof) - break; - size += STARTSIZE; obuffer = buffer; - if (!(buffer = (char *) my_realloc((gptr) buffer, size, - MyFlags | MY_FREE_ON_ERROR))) - goto error; - length= sizeof(struct fileinfo ) * firstfcnt; - diff= PTR_BYTE_DIFF(buffer , obuffer) +length; - fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR)); - tempptr= ADD_TO_PTR(tempptr,diff,char*); - for (i = 0; i < maxfcnt; i++) - fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*); - - /* move filenames upp a bit */ - maxfcnt += firstfcnt; - bmove_upp(tempptr,ADD_TO_PTR(tempptr,-length,char*), - (int) PTR_BYTE_DIFF(tempptr,fnames+maxfcnt)); - } - { - MY_DIR * s = (MY_DIR *) buffer; - s->number_off_files = (uint) fcnt; - s->dir_entry = fnames; - } - if (!(MyFlags & MY_DONT_SORT)) - qsort(fnames,fcnt,sizeof(struct fileinfo),(qsort_cmp) comp_names); - DBUG_RETURN((MY_DIR *) buffer); - -error: - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,errno); - DBUG_RETURN((MY_DIR *) NULL); -} /* my_dir */ - -#endif /* WIN32 && MSDOS */ - -/**************************************************************************** -** File status -** Note that MY_STAT is assumed to be same as struct stat -****************************************************************************/ - -int my_fstat(int Filedes, MY_STAT *stat_area, myf MyFlags ) -{ - DBUG_ENTER("my_fstat"); - DBUG_PRINT("my",("fd: %d MyFlags: %d",Filedes,MyFlags)); - DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area)); -} - -MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags) -{ - int m_used; - DBUG_ENTER("my_stat"); - DBUG_PRINT("my", ("path: '%s', stat_area: %lx, MyFlags: %d", path, - (byte *) stat_area, my_flags)); - - if ((m_used= (stat_area == NULL))) - if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags))) - goto error; - if ( ! stat((my_string) path, (struct stat *) stat_area) ) - DBUG_RETURN(stat_area); - my_errno=errno; - if (m_used) /* Free if new area */ - my_free((gptr) stat_area,MYF(0)); - -error: - if (my_flags & (MY_FAE+MY_WME)) - { - my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),path,my_errno); - DBUG_RETURN((MY_STAT *) NULL); - } - DBUG_RETURN((MY_STAT *) NULL); -} /* my_stat */ - diff --git a/ext/mysql/libmysql/my_list.h b/ext/mysql/libmysql/my_list.h deleted file mode 100644 index 46a6a8f65f..0000000000 --- a/ext/mysql/libmysql/my_list.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#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 diff --git a/ext/mysql/libmysql/my_malloc.c b/ext/mysql/libmysql/my_malloc.c deleted file mode 100644 index cb006e31e4..0000000000 --- a/ext/mysql/libmysql/my_malloc.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <m_string.h> - - /* My memory allocator */ - -gptr my_malloc(unsigned int Size, myf MyFlags) -{ - gptr point; - DBUG_ENTER("my_malloc"); - DBUG_PRINT("my",("Size: %u MyFlags: %d",Size, MyFlags)); - - if (!Size) - Size=1; /* Safety */ - if ((point = (char*)malloc(Size)) == NULL) - { - my_errno=errno; - if (MyFlags & MY_FAE) - error_handler_hook=fatal_error_handler_hook; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); - if (MyFlags & MY_FAE) - exit(1); - } - else if (MyFlags & MY_ZEROFILL) - bzero(point,Size); - DBUG_PRINT("exit",("ptr: %lx",point)); - DBUG_RETURN(point); -} /* my_malloc */ - - - /* Free memory allocated with my_malloc */ - /*ARGSUSED*/ - -void my_no_flags_free(gptr ptr) -{ - DBUG_ENTER("my_free"); - DBUG_PRINT("my",("ptr: %lx",ptr)); - if (ptr) - free(ptr); - DBUG_VOID_RETURN; -} /* my_free */ - - - /* malloc and copy */ - -gptr my_memdup(const byte *from, uint length, myf MyFlags) -{ - gptr ptr; - if ((ptr=my_malloc(length,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return(ptr); -} - - -my_string my_strdup(const char *from, myf MyFlags) -{ - gptr ptr; - uint length=(uint) strlen(from)+1; - if ((ptr=my_malloc(length,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return((my_string) ptr); -} diff --git a/ext/mysql/libmysql/my_messnc.c b/ext/mysql/libmysql/my_messnc.c deleted file mode 100644 index 48ed852f39..0000000000 --- a/ext/mysql/libmysql/my_messnc.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" - -int my_message_no_curses(uint error __attribute__((unused)), - const char *str, myf MyFlags) -{ - DBUG_ENTER("my_message_no_curses"); - DBUG_PRINT("enter",("message: %s",str)); - (void) fflush(stdout); - if (MyFlags & ME_BELL) - (void) fputc('\007',stderr); /* Bell */ - if (my_progname) - { - (void)fputs(my_progname,stderr); (void)fputs(": ",stderr); - } - (void)fputs(str,stderr); - (void)fputc('\n',stderr); - (void)fflush(stderr); - DBUG_RETURN(0); -} diff --git a/ext/mysql/libmysql/my_net.c b/ext/mysql/libmysql/my_net.c deleted file mode 100644 index 6fad295a22..0000000000 --- a/ext/mysql/libmysql/my_net.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* thread safe version of some common functions */ - -#include "mysys_priv.h" -#include <m_string.h> - -/* for thread safe my_inet_ntoa */ -#if !defined(MSDOS) && !defined(__WIN__) -#include <netdb.h> -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif /* !defined(MSDOS) && !defined(__WIN__) */ - -#ifndef THREAD -#define pthread_mutex_lock(A) -#define pthread_mutex_unlock(A) -#endif - -void my_inet_ntoa(struct in_addr in, char *buf) -{ - char *ptr; - pthread_mutex_lock(&THR_LOCK_net); - ptr=inet_ntoa(in); - strmov(buf,ptr); - pthread_mutex_unlock(&THR_LOCK_net); -} diff --git a/ext/mysql/libmysql/my_net.h b/ext/mysql/libmysql/my_net.h deleted file mode 100644 index 4633f3dfbd..0000000000 --- a/ext/mysql/libmysql/my_net.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* thread safe version of some common functions */ - -/* for thread safe my_inet_ntoa */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__) -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif /* !defined(MSDOS) && !defined(__WIN__) */ - -void my_inet_ntoa(struct in_addr in, char *buf); - -#ifdef __cplusplus -} -#endif diff --git a/ext/mysql/libmysql/my_once.c b/ext/mysql/libmysql/my_once.c deleted file mode 100644 index 99aad4d4e7..0000000000 --- a/ext/mysql/libmysql/my_once.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Not MT-SAFE */ - -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif - -#include "mysys_priv.h" -#include "my_static.h" -#include "mysys_err.h" - - /* alloc for things we don't nead to free */ - /* No DBUG_ENTER... here to get smaller dbug-startup */ - -gptr my_once_alloc(unsigned int Size, myf MyFlags) -{ - uint get_size,max_left; - gptr point; - reg1 USED_MEM *next; - reg2 USED_MEM **prev; - - Size= ALIGN_SIZE(Size); - prev= &my_once_root_block; - max_left=0; - for (next=my_once_root_block ; next && next->left < Size ; next= next->next) - { - if (next->left > max_left) - max_left=next->left; - prev= &next->next; - } - if (! next) - { /* Time to alloc new block */ - get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); - if (max_left*4 < my_once_extra && get_size < my_once_extra) - get_size=my_once_extra; /* Normal alloc */ - - if ((next = (USED_MEM*) malloc(get_size)) == 0) - { - my_errno=errno; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),get_size); - return((gptr) 0); - } - DBUG_PRINT("test",("my_once_malloc %u byte malloced",get_size)); - next->next= 0; - next->size= get_size; - next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); - *prev=next; - } - point= (gptr) ((char*) next+ (next->size-next->left)); - next->left-= Size; - - return(point); -} /* my_once_alloc */ - - - /* deallocate everything used by my_once_alloc */ - -void my_once_free(void) -{ - reg1 USED_MEM *next,*old; - DBUG_ENTER("my_once_free"); - - for (next=my_once_root_block ; next ; ) - { - old=next; next= next->next ; - free((gptr) old); - } - my_once_root_block=0; - - DBUG_VOID_RETURN; -} /* my_once_free */ diff --git a/ext/mysql/libmysql/my_open.c b/ext/mysql/libmysql/my_open.c deleted file mode 100644 index 901f0122c8..0000000000 --- a/ext/mysql/libmysql/my_open.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#define USES_TYPES -#include "mysys_priv.h" -#include "mysys_err.h" -#include <my_dir.h> -#include <errno.h> -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) -#include <share.h> -#endif - - /* Open a file */ - -File my_open(const char *FileName, int Flags, myf MyFlags) - /* Path-name of file */ - /* Read | write .. */ - /* Special flags */ -{ - File fd; - DBUG_ENTER("my_open"); - DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", - FileName, Flags, MyFlags)); -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) - if (Flags & O_SHARE) - fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, - MY_S_IREAD | MY_S_IWRITE); - else - fd = open((my_string) FileName, Flags | O_BINARY, - MY_S_IREAD | MY_S_IWRITE); -#elif !defined(NO_OPEN_3) - fd = open(FileName, Flags, my_umask); /* Normal unix */ -#else - fd = open((my_string) FileName, Flags); -#endif - DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN, - EE_FILENOTFOUND, MyFlags)); -} /* my_open */ - - - /* Close a file */ - -int my_close(File fd, myf MyFlags) -{ - int err; - DBUG_ENTER("my_close"); - DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); - - pthread_mutex_lock(&THR_LOCK_open); - if ((err = close(fd))) - { - DBUG_PRINT("error",("Got error %d on close",err)); - my_errno=errno; - if (MyFlags & (MY_FAE | MY_WME)) - my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno); - } - if ((uint) fd < MY_NFILE && my_file_info[fd].type != UNOPEN) - { - my_free(my_file_info[fd].name, MYF(0)); -#if defined(THREAD) && !defined(HAVE_PREAD) - pthread_mutex_destroy(&my_file_info[fd].mutex); -#endif - my_file_info[fd].type = UNOPEN; - } - my_file_opened--; - pthread_mutex_unlock(&THR_LOCK_open); - DBUG_RETURN(err); -} /* my_close */ - - -File my_register_filename(File fd, const char *FileName, enum file_type - type_of_file, uint error_message_number, myf MyFlags) -{ - if ((int) fd >= 0) - { - if ((int) fd >= MY_NFILE) - { -#if defined(THREAD) && !defined(HAVE_PREAD) - (void) my_close(fd,MyFlags); - my_errno=EMFILE; - if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) - my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG), - FileName, my_errno); - return(-1); -#endif - thread_safe_increment(my_file_opened,&THR_LOCK_open); - return(fd); /* safeguard */ - } - pthread_mutex_lock(&THR_LOCK_open); - if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags))) - { - my_file_opened++; - my_file_info[fd].type = type_of_file; -#if defined(THREAD) && !defined(HAVE_PREAD) - pthread_mutex_init(&my_file_info[fd].mutex,MY_MUTEX_INIT_FAST); -#endif - pthread_mutex_unlock(&THR_LOCK_open); - DBUG_PRINT("exit",("fd: %d",fd)); - return(fd); - } - pthread_mutex_unlock(&THR_LOCK_open); - (void) my_close(fd, MyFlags); - my_errno=ENOMEM; - } - else - my_errno=errno; - DBUG_PRINT("error",("Got error %d on open",my_errno)); - if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) - my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG), - FileName, my_errno); - return(fd); -} diff --git a/ext/mysql/libmysql/my_pthread.c b/ext/mysql/libmysql/my_pthread.c deleted file mode 100644 index d1f580071b..0000000000 --- a/ext/mysql/libmysql/my_pthread.c +++ /dev/null @@ -1,462 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Functions to get threads more portable */ - -#include "mysys_priv.h" -#ifdef THREAD -#include <signal.h> -#include <m_string.h> -#include <thr_alarm.h> -#include <assert.h> -#if !defined(MSDOS) && !defined(__WIN__) -#include <netdb.h> -#endif - -#if (defined(__BSD__) || defined(_BSDI_VERSION)) && !defined(HAVE_mit_thread) -#define SCHED_POLICY SCHED_RR -#else -#define SCHED_POLICY SCHED_OTHER -#endif - -#ifndef my_pthread_setprio -void my_pthread_setprio(pthread_t thread_id,int prior) -{ -#ifdef HAVE_PTHREAD_SETSCHEDPARAM - struct sched_param tmp_sched_param; - bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param)); - tmp_sched_param.sched_priority=prior; - VOID(pthread_setschedparam(thread_id,SCHED_POLICY,&tmp_sched_param)); -#endif -} -#endif - -#ifndef my_pthread_getprio -int my_pthread_getprio(pthread_t thread_id) -{ -#ifdef HAVE_PTHREAD_SETSCHEDPARAM - struct sched_param tmp_sched_param; - int policy; - if (!pthread_getschedparam(thread_id,&policy,&tmp_sched_param)) - { - DBUG_PRINT("thread",("policy: %d priority: %d", - policy,tmp_sched_param.sched_priority)); - return tmp_sched_param.sched_priority; - } -#endif - return -1; -} -#endif - -#ifndef my_pthread_attr_setprio -void my_pthread_attr_setprio(pthread_attr_t *attr, int priority) -{ -#ifdef HAVE_PTHREAD_SETSCHEDPARAM - struct sched_param tmp_sched_param; - bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param)); - tmp_sched_param.sched_priority=priority; - VOID(pthread_attr_setschedparam(attr,&tmp_sched_param)); -#endif -} -#endif - - -/* To allow use of pthread_getspecific with two arguments */ - -#ifdef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC -#undef pthread_getspecific -#ifdef HAVE_UNIXWARE7_THREADS -#define pthread_getspecific thr_getspecific -#endif - -void *my_pthread_getspecific_imp(pthread_key_t key) -{ - void *value; - if (pthread_getspecific(key,(void *) &value)) - return 0; - return value; -} -#endif - - -/* Some functions for RTS threads, AIX, Siemens Unix and UnixWare 7 - (and DEC OSF/1 3.2 too) */ - -int my_pthread_create_detached=1; - -#if defined(HAVE_NONPOSIX_SIGWAIT) || defined(HAVE_DEC_3_2_THREADS) - -int my_sigwait(const sigset_t *set,int *sig) -{ - int signal=sigwait((sigset_t*) set); - if (signal < 0) - return errno; - *sig=signal; - return 0; -} -#endif - -/* localtime_r for SCO 3.2V4.2 */ - -#ifndef HAVE_LOCALTIME_R - -extern pthread_mutex_t LOCK_localtime_r; - -struct tm *localtime_r(const time_t *clock, struct tm *res) -{ - struct tm *tmp; - pthread_mutex_lock(&LOCK_localtime_r); - tmp=localtime(clock); - *res= *tmp; - pthread_mutex_unlock(&LOCK_localtime_r); - return res; -} -#endif - - -/**************************************************************************** -** Replacement of sigwait if the system doesn't have one (like BSDI 3.0) -** -** Note: -** This version of sigwait() is assumed to called in a loop so the signalmask -** is permanently modified to reflect the signal set. This is done to get -** a much faster implementation. -** -** This implementation isn't thread safe: It assumes that only one -** thread is using sigwait. -** -** If one later supplies a different signal mask, all old signals that -** was used before are unblocked and set to SIGDFL. -** -** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty -****************************************************************************/ - -#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(OS2) - -#if !defined(DONT_USE_SIGSUSPEND) - -static sigset_t sigwait_set,rev_sigwait_set,px_recd; - -void px_handle_sig(int sig) -{ - sigaddset(&px_recd, sig); -} - - -void sigwait_setup(sigset_t *set) -{ - int i; - struct sigaction sact,sact1; - sigset_t unblock_mask; - - sact.sa_flags = 0; - sact.sa_handler = px_handle_sig; - memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */ - sigemptyset(&unblock_mask); - pthread_sigmask(SIG_UNBLOCK,(sigset_t*) 0,&rev_sigwait_set); - - for (i = 1; i <= sizeof(sigwait_set)*8; i++) - { - if (sigismember(set,i)) - { - sigdelset(&rev_sigwait_set,i); - if (!sigismember(&sigwait_set,i)) - sigaction(i, &sact, (struct sigaction*) 0); - } - else - { - sigdelset(&px_recd,i); /* Don't handle this */ - if (sigismember(&sigwait_set,i)) - { /* Remove the old handler */ - sigaddset(&unblock_mask,i); - sigdelset(&rev_sigwait_set,i); - sact1.sa_flags = 0; - sact1.sa_handler = SIG_DFL; - sigemptyset(&sact1.sa_mask); - sigaction(i, &sact1, 0); - } - } - } - memcpy_fixed(&sigwait_set,set,sizeof(*set)); - pthread_sigmask(SIG_BLOCK,(sigset_t*) set,(sigset_t*) 0); - pthread_sigmask(SIG_UNBLOCK,&unblock_mask,(sigset_t*) 0); -} - - -int sigwait(sigset_t *setp, int *sigp) -{ - if (memcmp(setp,&sigwait_set,sizeof(sigwait_set))) - sigwait_setup(setp); /* Init or change of set */ - - for (;;) - { - /* - This is a fast, not 100% portable implementation to find the signal. - Because the handler is blocked there should be at most 1 bit set, but - the specification on this is somewhat shady so we use a set instead a - single variable. - */ - - ulong *ptr= (ulong*) &px_recd; - ulong *end=ptr+sizeof(px_recd)/sizeof(ulong); - - for ( ; ptr != end ; ptr++) - { - if (*ptr) - { - ulong set= *ptr; - int found= (int) ((char*) ptr - (char*) &px_recd)*8+1; - while (!(set & 1)) - { - found++; - set>>=1; - } - *sigp=found; - sigdelset(&px_recd,found); - return 0; - } - } - sigsuspend(&rev_sigwait_set); - } - return 0; -} -#else /* !DONT_USE_SIGSUSPEND */ - -/**************************************************************************** -** Replacement of sigwait if the system doesn't have one (like BSDI 3.0) -** -** Note: -** This version of sigwait() is assumed to called in a loop so the signalmask -** is permanently modified to reflect the signal set. This is done to get -** a much faster implementation. -** -** This implementation uses a extra thread to handle the signals and one -** must always call sigwait() with the same signal mask! -** -** BSDI 3.0 NOTE: -** -** pthread_kill() doesn't work on a thread in a select() or sleep() loop? -** After adding the sleep to sigwait_thread, all signals are checked and -** delivered every second. This isn't that terrible performance vice, but -** someone should report this to BSDI and ask for a fix! -** Another problem is that when the sleep() ends, every select() in other -** threads are interrupted! -****************************************************************************/ - -static sigset_t pending_set; -static bool inited=0; -static pthread_cond_t COND_sigwait; -static pthread_mutex_t LOCK_sigwait; - - -void sigwait_handle_sig(int sig) -{ - pthread_mutex_lock(&LOCK_sigwait); - sigaddset(&pending_set, sig); - VOID(pthread_cond_signal(&COND_sigwait)); /* inform sigwait() about signal */ - pthread_mutex_unlock(&LOCK_sigwait); -} - -extern pthread_t alarm_thread; - -void *sigwait_thread(void *set_arg) -{ - sigset_t *set=(sigset_t*) set_arg; - - int i; - struct sigaction sact; - sact.sa_flags = 0; - sact.sa_handler = sigwait_handle_sig; - memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */ - sigemptyset(&pending_set); - - for (i = 1; i <= sizeof(pending_set)*8; i++) - { - if (sigismember(set,i)) - { - sigaction(i, &sact, (struct sigaction*) 0); - } - } - sigaddset(set,THR_CLIENT_ALARM); - pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0); - alarm_thread=pthread_self(); /* For thr_alarm */ - - for (;;) - { /* Wait for signals */ -#ifdef HAVE_NOT_BROKEN_SELECT - fd_set fd; - FD_ZERO(&fd); - select(0,&fd,0,0,0); -#else - sleep(1); /* Because of broken BSDI */ -#endif - } -} - - -int sigwait(sigset_t *setp, int *sigp) -{ - if (!inited) - { - pthread_attr_t thr_attr; - pthread_t sigwait_thread_id; - inited=1; - sigemptyset(&pending_set); - pthread_mutex_init(&LOCK_sigwait,MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_sigwait,NULL); - - pthread_attr_init(&thr_attr); - pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS); - pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize(&thr_attr,8196); - my_pthread_attr_setprio(&thr_attr,100); /* Very high priority */ - VOID(pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp)); - VOID(pthread_attr_destroy(&thr_attr)); - } - - pthread_mutex_lock(&LOCK_sigwait); - for (;;) - { - ulong *ptr= (ulong*) &pending_set; - ulong *end=ptr+sizeof(pending_set)/sizeof(ulong); - - for ( ; ptr != end ; ptr++) - { - if (*ptr) - { - ulong set= *ptr; - int found= (int) ((char*) ptr - (char*) &pending_set)*8+1; - while (!(set & 1)) - { - found++; - set>>=1; - } - *sigp=found; - sigdelset(&pending_set,found); - pthread_mutex_unlock(&LOCK_sigwait); - return 0; - } - } - VOID(pthread_cond_wait(&COND_sigwait,&LOCK_sigwait)); - } - return 0; -} - -#endif /* DONT_USE_SIGSUSPEND */ -#endif /* HAVE_SIGWAIT */ - -/***************************************************************************** -** Implement pthread_signal for systems that can't use signal() with threads -** Currently this is only used with BSDI 3.0 -*****************************************************************************/ - -#ifdef USE_PTHREAD_SIGNAL - -int pthread_signal(int sig, void (*func)()) -{ - struct sigaction sact; - sact.sa_flags= 0; - sact.sa_handler= func; - sigemptyset(&sact.sa_mask); - sigaction(sig, &sact, (struct sigaction*) 0); - return 0; -} - -#endif - -/***************************************************************************** -** Patches for AIX and DEC OSF/1 3.2 -*****************************************************************************/ - -#if (defined(HAVE_NONPOSIX_PTHREAD_MUTEX_INIT) && !defined(HAVE_UNIXWARE7_THREADS)) || defined(HAVE_DEC_3_2_THREADS) -#undef pthread_mutex_init -#undef pthread_cond_init - -#include <netdb.h> - -int my_pthread_mutex_init(pthread_mutex_t *mp, const pthread_mutexattr_t *attr) -{ - int error; - if (!attr) - error=pthread_mutex_init(mp,pthread_mutexattr_default); - else - error=pthread_mutex_init(mp,*attr); - return error; -} - -int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr) -{ - int error; - if (!attr) - error=pthread_cond_init(mp,pthread_condattr_default); - else - error=pthread_cond_init(mp,*attr); - return error; -} - -#endif - -/* -** Emulate SOLARIS style calls, not because it's better, but just to make the -** usage of getbostbyname_r simpler. -*/ - -#if !defined(my_gethostbyname_r) && defined(HAVE_GETHOSTBYNAME_R) - -#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) - -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop) -{ - struct hostent *hp; - dbug_assert((size_t) buflen >= sizeof(*result)); - if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop)) - return 0; - return hp; -} - -#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT) - -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop) -{ - dbug_assert(buflen >= sizeof(struct hostent_data)); - if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1) - { - *h_errnop= errno; - return 0; - } - return result; -} - -#else - -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop) -{ - struct hostent *hp; - dbug_assert(buflen >= sizeof(struct hostent_data)); - hp= gethostbyname_r(name,result,(struct hostent_data *) buffer); - *h_errnop= errno; - return hp; -} - -#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */ -#endif - - -/* Some help functions */ - -int pthread_no_free(void *not_used __attribute__((unused))) -{ - return 0; -} - -int pthread_dummy(int ret) -{ - return ret; -} -#endif /* THREAD */ diff --git a/ext/mysql/libmysql/my_pthread.h b/ext/mysql/libmysql/my_pthread.h deleted file mode 100644 index 655ebbf703..0000000000 --- a/ext/mysql/libmysql/my_pthread.h +++ /dev/null @@ -1,613 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 -int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *); -int pthread_mutex_lock (pthread_mutex_t *); -int pthread_mutex_unlock (pthread_mutex_t *); -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_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(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 - -#if defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) -#if !defined(HPUX) -struct hostent; -#endif /* HPUX */ -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop); -#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) -#define GETHOSTBYNAME_BUFF_SIZE 2048 -#else -#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) -#endif /* defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */ - -#else -#ifdef HAVE_GETHOSTBYNAME_R_RETURN_INT -#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop); -#else -#define GETHOSTBYNAME_BUFF_SIZE 2048 -#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E)) -#endif /* HAVE_GETHOSTBYNAME_R_RETURN_INT */ -#endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */ - -#endif /* defined(__WIN__) */ - - /* 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 -#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 -#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_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_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_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 * ); -#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 */ diff --git a/ext/mysql/libmysql/my_read.c b/ext/mysql/libmysql/my_read.c deleted file mode 100644 index 3ca5bfb95a..0000000000 --- a/ext/mysql/libmysql/my_read.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <errno.h> - - - /* Read a chunk of bytes from a file */ - -uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) - /* File descriptor */ - /* Buffer must be at least count bytes */ - /* Max number of bytes returnd */ - /* Flags on what to do on error */ -{ - uint readbytes; - DBUG_ENTER("my_read"); - DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); - - for (;;) - { - errno=0; /* Linux doesn't reset this */ - if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count) - { - my_errno=errno ? errno : -1; - DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", - readbytes,Count,Filedes,my_errno)); -#ifdef THREAD - if (readbytes == 0 && errno == EINTR) - continue; /* Interrupted */ -#endif - if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) - { - if ((int) readbytes == -1) - my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); - else if (MyFlags & (MY_NABP | MY_FNABP)) - my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); - } - if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP))) - DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ - } - - if (MyFlags & (MY_NABP | MY_FNABP)) - readbytes=0; /* Ok on read */ - break; - } - DBUG_RETURN(readbytes); -} /* my_read */ diff --git a/ext/mysql/libmysql/my_realloc.c b/ext/mysql/libmysql/my_realloc.c deleted file mode 100644 index 7e85c1c861..0000000000 --- a/ext/mysql/libmysql/my_realloc.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif - -#include "mysys_priv.h" -#include "mysys_err.h" - - /* My memory re allocator */ - -gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags) -{ - gptr point; - DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: %lx Size: %u MyFlags: %d",oldpoint, Size, MyFlags)); - - if (!oldpoint && (MyFlags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(my_malloc(Size,MyFlags)); -#ifdef USE_HALLOC - if (!(point = malloc(Size))) - { - if (MyFlags & MY_FREE_ON_ERROR) - my_free(oldpoint,MyFlags); - if (MyFlags & MY_HOLD_ON_ERROR) - DBUG_RETURN(oldpoint); - my_errno=errno; - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); - } - else - { - memcpy(point,oldpoint,Size); - free(oldpoint); - } -#else - if ((point = (char*)realloc(oldpoint,Size)) == NULL) - { - if (MyFlags & MY_FREE_ON_ERROR) - my_free(oldpoint,MyFLAGS); - if (MyFlags & MY_HOLD_ON_ERROR) - DBUG_RETURN(oldpoint); - my_errno=errno; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), Size); - } -#endif - DBUG_PRINT("exit",("ptr: %lx",point)); - DBUG_RETURN(point); -} /* my_realloc */ diff --git a/ext/mysql/libmysql/my_static.c b/ext/mysql/libmysql/my_static.c deleted file mode 100644 index 92cdac6d93..0000000000 --- a/ext/mysql/libmysql/my_static.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Static variables for mysys library. All definied here for easy making of - a shared library -*/ - -#if !defined(stdin) || defined(OS2) -#include "mysys_priv.h" -#include "my_static.h" -#include "my_alarm.h" -#endif - - /* from my_init */ -my_string home_dir=0,my_progname=0; -char NEAR curr_dir[FN_REFLEN]= {0}, - NEAR home_dir_buff[FN_REFLEN]= {0}; -ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0; -int NEAR my_umask=0664, NEAR my_umask_dir=0777; -#ifndef THREAD -int NEAR my_errno=0; -#endif -struct my_file_info my_file_info[MY_NFILE]= {{0,UNOPEN}}; - - /* From mf_brkhant */ -int NEAR my_dont_interrupt=0; -volatile int _my_signals=0; -struct st_remember _my_sig_remember[MAX_SIGNALS]={{0,0}}; -#ifdef THREAD -sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif - - /* from mf_keycache.c */ -my_bool key_cache_inited=0; - - /* from mf_reccache.c */ -ulong my_default_record_cache_size=RECORD_CACHE_SIZE; - - /* from soundex.c */ - /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ - /* :::::::::::::::::::::::::: */ -const char *soundex_map= "01230120022455012623010202"; - - /* from my_malloc */ -USED_MEM* my_once_root_block=0; /* pointer to first block */ -uint my_once_extra=ONCE_ALLOC_INIT; /* Memory to alloc / block */ - - /* from my_tempnam */ -#ifndef HAVE_TEMPNAM -int _my_tempnam_used=0; -#endif - - /* from safe_malloc */ -uint sf_malloc_prehunc=0, /* If you have problem with core- */ - sf_malloc_endhunc=0, /* dump when malloc-message.... */ - /* set theese to 64 or 128 */ - sf_malloc_quick=0; /* set if no calls to sanity */ -long lCurMemory = 0L; /* Current memory usage */ -long lMaxMemory = 0L; /* Maximum memory usage */ -uint cNewCount = 0; /* Number of times NEW() was called */ -byte *sf_min_adress= (byte*) ~(unsigned long) 0L, - *sf_max_adress= (byte*) 0L; - -/* Root of the linked list of remembers */ -struct remember *pRememberRoot = NULL; - - /* from my_alarm */ -int volatile my_have_got_alarm=0; /* declare variable to reset */ -ulong my_time_to_wait_for_lock=2; /* In seconds */ - - /* from errors.c */ -#ifdef SHARED_LIBRARY -char * NEAR globerrs[GLOBERRS]; /* my_error_messages is here */ -#endif -void (*my_abort_hook)(int) = (void(*)(int)) exit; -int (*error_handler_hook)(uint error,const char *str,myf MyFlags)= - my_message_no_curses; -int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= - my_message_no_curses; - - /* How to disable options */ -my_bool NEAR my_disable_locking=0; -my_bool NEAR my_disable_async_io=0; -my_bool NEAR my_disable_flush_key_blocks=0; -my_bool NEAR my_disable_symlinks=0; -my_bool NEAR mysys_uses_curses=0; diff --git a/ext/mysql/libmysql/my_static.h b/ext/mysql/libmysql/my_static.h deleted file mode 100644 index 29a9b74026..0000000000 --- a/ext/mysql/libmysql/my_static.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Static variables for mysys library. All definied here for easy making of - a shared library -*/ - -#include "mysys_priv.h" -#include <signal.h> - -#define MAX_SIGNALS 10 /* Max signals under a dont-allow */ -#define MIN_KEYBLOCK (min(IO_SIZE,1024)) -#define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */ -#define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK - -struct st_remember { - int number; - sig_handler (*func)(int number); -}; - -struct irem { - struct remember *_pNext; /* Linked list of structures */ - struct remember *_pPrev; /* Other link */ - my_string _sFileName; /* File in which memory was new'ed */ - uint _uLineNum; /* Line number in above file */ - uint _uDataSize; /* Size requested */ - long _lSpecialValue; /* Underrun marker value */ -}; - -struct remember { - struct irem tInt; - char aData[1]; -}; - -extern char NEAR curr_dir[FN_REFLEN],NEAR home_dir_buff[FN_REFLEN]; - -extern volatile int _my_signals; -extern struct st_remember _my_sig_remember[MAX_SIGNALS]; - -extern const char *soundex_map; - -extern USED_MEM* my_once_root_block; -extern uint my_once_extra; - -#ifndef HAVE_TEMPNAM -extern int _my_tempnam_used; -#endif - -extern byte *sf_min_adress,*sf_max_adress; -extern uint cNewCount; -extern struct remember *pRememberRoot; - -#if defined(THREAD) && !defined(__WIN__) -extern sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif diff --git a/ext/mysql/libmysql/my_sys.h b/ext/mysql/libmysql/my_sys.h deleted file mode 100644 index 8f9f0c35fd..0000000000 --- a/ext/mysql/libmysql/my_sys.h +++ /dev/null @@ -1,592 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#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_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; -#else -#define my_checkmalloc() (0) -#undef TERMINATE -#define TERMINATE(A) {} -#define QUICK_SAFEMALLOC -#define NORMAL_SAFEMALLOC -extern gptr my_malloc(uint Size,myf MyFlags); -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) -#endif -#ifdef HAVE_ALLOCA -#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 stripp_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); -extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, - uint init_alloc,uint alloc_increment); -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 */ diff --git a/ext/mysql/libmysql/my_tempnam.c b/ext/mysql/libmysql/my_tempnam.c deleted file mode 100644 index 1daca61f85..0000000000 --- a/ext/mysql/libmysql/my_tempnam.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - This function is only used by some old ISAM code. - When we remove ISAM support from MySQL, we should also delete this file - - One should instead use the functions in mf_tempfile.c -*/ - -#include "mysys_priv.h" -#include <m_string.h> - -/* HPUX 11.0 doesn't allow us to change the environ pointer */ -#ifdef HPUX11 -#undef HAVE_TEMPNAM -#endif - -#include "my_static.h" -#include "mysys_err.h" - -#define TMP_EXT ".tmp" /* Extension of tempfile */ -#if ! defined(P_tmpdir) -#define P_tmpdir "" -#endif - -#ifdef HAVE_TEMPNAM -#if !defined( MSDOS) && !defined(OS2) && !defined(__NETWARE__) -extern char **environ; -#endif -#endif - -/* Make a uniq temp file name by using dir and adding something after - pfx to make name uniq. Name is made by adding a uniq 8 length-string and - TMP_EXT after pfx. - Returns pointer to malloced area for filename. Should be freed by - free(). - The name should be uniq, but it isn't checked if it file allready exists. - Uses tempnam() if function exist on system. - This function fixes that if dir is given it's used. For example - MSDOS tempnam() uses always TMP environment-variable if it exists. -*/ - /* ARGSUSED */ - -my_string my_tempnam(const char *dir, const char *pfx, - myf MyFlags __attribute__((unused))) -{ -#ifdef _MSC_VER - char temp[FN_REFLEN],*end,*res,**old_env,*temp_env[1]; - old_env=environ; - if (dir) - { - end=strend(dir)-1; - if (!dir[0]) - { /* Change empty string to current dir */ - temp[0]= FN_CURLIB; - temp[1]= 0; - dir=temp; - } - else if (*end == FN_DEVCHAR) - { /* Get current dir for drive */ - _fullpath(temp,dir,FN_REFLEN); - dir=temp; - } - else if (*end == FN_LIBCHAR && dir < end && end[-1] != FN_DEVCHAR) - { - strmake(temp,dir,(uint) (end-dir)); /* Copy and remove last '\' */ - dir=temp; - } - environ=temp_env; /* Force use of dir (dir not checked) */ - temp_env[0]=0; - } - res=tempnam((char*) dir,(my_string) pfx); - environ=old_env; - return res; -#else -#ifdef __ZTC__ - if (!dir) - { /* If empty test first if TMP can be used */ - dir=getenv("TMP"); - } - return tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */ -#else -#ifdef HAVE_TEMPNAM - char temp[2],*res,**old_env,*temp_env[1]; - - if (dir && !dir[0]) - { /* Change empty string to current dir */ - temp[0]= FN_CURLIB; - temp[1]= 0; - dir=temp; - } -#ifdef OS2 - /* changing environ variable doesn't work with VACPP */ - char buffer[256]; - sprintf( buffer, "TMP=%s", dir); - /* remove ending backslash */ - if (buffer[strlen(buffer)-1] == '\\') - buffer[strlen(buffer)-1] = '\0'; - putenv( buffer); -#elif !defined(__NETWARE__) - old_env=(char**)environ; - if (dir) - { /* Don't use TMPDIR if dir is given */ - /* - The following strange cast is required because the IBM compiler on AIX - doesn't allow us to cast the value of environ. - The cast of environ is needed as some systems doesn't allow us to - update environ with a char ** pointer. (const mismatch) - */ - (*(char***) &environ)=(char**) temp_env; - temp_env[0]=0; - } -#endif - res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */ -#if !defined(OS2) && !defined(__NETWARE__) - (*(char***) &environ)=(char**) old_env; -#endif - if (!res) - DBUG_PRINT("error",("Got error: %d from tempnam",errno)); - return res; -#else - register long uniq; - register int length; - my_string pos,end_pos; - DBUG_ENTER("my_tempnam"); - /* Make a uniq nummber */ - pthread_mutex_lock(&THR_LOCK_open); - uniq= ((long) getpid() << 20) + (long) _my_tempnam_used++ ; - pthread_mutex_unlock(&THR_LOCK_open); - if (!dir && !(dir=getenv("TMPDIR"))) /* Use this if possibly */ - dir=P_tmpdir; /* Use system default */ - length=strlen(dir)+strlen(pfx)+1; - - DBUG_PRINT("test",("mallocing %d byte",length+8+sizeof(TMP_EXT)+1)); - if (!(pos=(char*) malloc(length+8+sizeof(TMP_EXT)+1))) - { - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), - length+8+sizeof(TMP_EXT)+1); - DBUG_RETURN(NullS); - } - end_pos=strmov(pos,dir); - if (end_pos != pos && end_pos[-1] != FN_LIBCHAR) - *end_pos++=FN_LIBCHAR; - end_pos=strmov(end_pos,pfx); - - for (length=0 ; length < 8 && uniq ; length++) - { - *end_pos++= _dig_vec[(int) (uniq & 31)]; - uniq >>= 5; - } - VOID(strmov(end_pos,TMP_EXT)); - DBUG_PRINT("exit",("tempnam: '%s'",pos)); - DBUG_RETURN(pos); -#endif /* HAVE_TEMPNAM */ -#endif /* __ZTC__ */ -#endif /* _MSC_VER */ -} /* my_tempnam */ diff --git a/ext/mysql/libmysql/my_thr_init.c b/ext/mysql/libmysql/my_thr_init.c deleted file mode 100644 index a5b40a2d61..0000000000 --- a/ext/mysql/libmysql/my_thr_init.c +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* -** Functions to handle initializating and allocationg of all mysys & debug -** thread variables. -*/ - -#include "mysys_priv.h" -#include <m_string.h> - -#ifdef THREAD -#ifdef USE_TLS -pthread_key(struct st_my_thread_var*, THR_KEY_mysys); -#else -pthread_key(struct st_my_thread_var, THR_KEY_mysys); -#endif /* USE_TLS */ -pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, - THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, - THR_LOCK_net, THR_LOCK_charset; -#ifndef HAVE_LOCALTIME_R -pthread_mutex_t LOCK_localtime_r; -#endif -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -pthread_mutexattr_t my_fast_mutexattr; -#endif -#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -pthread_mutexattr_t my_errchk_mutexattr; -#endif - -/* FIXME Note. TlsAlloc does not set an auto destructor, so - the function my_thread_global_free must be called from - somewhere before final exit of the library */ - -my_bool my_thread_global_init(void) -{ - if (pthread_key_create(&THR_KEY_mysys,free)) - { - fprintf(stderr,"Can't initialize threads: error %d\n",errno); - exit(1); - } -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - pthread_mutexattr_init(&my_fast_mutexattr); - pthread_mutexattr_setkind_np(&my_fast_mutexattr,PTHREAD_MUTEX_ADAPTIVE_NP); -#endif -#ifdef PPTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - pthread_mutexattr_init(&my_errchk_mutexattr); - pthread_mutexattr_setkind_np(&my_errchk_mutexattr, - PTHREAD_MUTEX_ERRORCHECK_NP); -#endif - - pthread_mutex_init(&THR_LOCK_malloc,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_open,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_keycache,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_lock,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_isam,MY_MUTEX_INIT_SLOW); - pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_SLOW); - pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); -#if defined( __WIN__) || defined(OS2) - win_pthread_init(); -#endif -#ifndef HAVE_LOCALTIME_R - pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW); -#endif - return my_thread_init(); -} - -void my_thread_global_end(void) -{ -#if defined(USE_TLS) - (void) TlsFree(THR_KEY_mysys); -#endif -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - pthread_mutexattr_destroy(&my_fast_mutexattr); -#endif -#ifdef PPTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - pthread_mutexattr_destroy(&my_errchk_mutexattr); -#endif -} - -static long thread_id=0; - -/* - We can't use mutex_locks here if we are using windows as - we may have compiled the program with SAFE_MUTEX, in which - case the checking of mutex_locks will not work until - the pthread_self thread specific variable is initialized. -*/ - -my_bool my_thread_init(void) -{ - struct st_my_thread_var *tmp; -#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) - pthread_mutex_lock(&THR_LOCK_lock); -#endif -#if !defined(__WIN__) || defined(USE_TLS) - if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys)) - { - pthread_mutex_unlock(&THR_LOCK_lock); - return 0; /* Safequard */ - } - /* We must have many calloc() here because these are freed on - pthread_exit */ - if (!(tmp=(struct st_my_thread_var *) - calloc(1,sizeof(struct st_my_thread_var)))) - { - pthread_mutex_unlock(&THR_LOCK_lock); - return 1; - } - pthread_setspecific(THR_KEY_mysys,tmp); - -#else - if (THR_KEY_mysys.id) /* Already initialized */ - { -#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) - pthread_mutex_unlock(&THR_LOCK_lock); -#endif - return 0; - } - tmp= &THR_KEY_mysys; -#endif - tmp->id= ++thread_id; - pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST); - pthread_cond_init(&tmp->suspend, NULL); -#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) - pthread_mutex_unlock(&THR_LOCK_lock); -#endif - return 0; -} - -void my_thread_end(void) -{ - struct st_my_thread_var *tmp=my_thread_var; - if (tmp) - { -#if !defined(DBUG_OFF) - if (tmp->dbug) - { - free(tmp->dbug); - tmp->dbug=0; - } -#endif -#if !defined(__bsdi__) || defined(HAVE_mit_thread) /* bsdi dumps core here */ - pthread_cond_destroy(&tmp->suspend); -#endif - pthread_mutex_destroy(&tmp->mutex); -#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) - free(tmp); -#endif - } -#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) - pthread_setspecific(THR_KEY_mysys,0); -#endif -} - -struct st_my_thread_var *_my_thread_var(void) -{ - struct st_my_thread_var *tmp= - my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); -#if defined(USE_TLS) - /* This can only happen in a .DLL */ - if (!tmp) - { - my_thread_init(); - tmp=my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); - } -#endif - return tmp; -} - -/**************************************************************************** -** Get name of current thread. -****************************************************************************/ - -#define UNKNOWN_THREAD -1 - -long my_thread_id() -{ -#if defined(HAVE_PTHREAD_GETSEQUENCE_NP) - return pthread_getsequence_np(pthread_self()); -#elif (defined(__sun) || defined(__sgi) || defined(__linux__)) && !defined(HAVE_mit_thread) - return pthread_self(); -#else - return my_thread_var->id; -#endif -} - -#ifdef DBUG_OFF -const char *my_thread_name(void) -{ - return "no_name"; -} - -#else - -const char *my_thread_name(void) -{ - char name_buff[100]; - struct st_my_thread_var *tmp=my_thread_var; - if (!tmp->name[0]) - { - long id=my_thread_id(); - sprintf(name_buff,"T@%ld", id); - strmake(tmp->name,name_buff,THREAD_NAME_SIZE); - } - return tmp->name; -} -#endif /* DBUG_OFF */ - -#endif /* THREAD */ diff --git a/ext/mysql/libmysql/my_wincond.c b/ext/mysql/libmysql/my_wincond.c deleted file mode 100644 index 555ab3bcf7..0000000000 --- a/ext/mysql/libmysql/my_wincond.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/***************************************************************************** -** The following is a simple implementation of posix conditions -*****************************************************************************/ - -#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */ -#include "mysys_priv.h" -#if defined(THREAD) && defined(__WIN__) -#include <m_string.h> -#undef getpid -#include <process.h> -#include <sys/timeb.h> - -int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) -{ - cond->waiting=0; - cond->semaphore=CreateSemaphore(NULL,0,0x7FFFFFFF,NullS); - if (!cond->semaphore) - return ENOMEM; - return 0; -} - -int pthread_cond_destroy(pthread_cond_t *cond) -{ - return CloseHandle(cond->semaphore) ? 0 : EINVAL; -} - - -int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) -{ - InterlockedIncrement(&cond->waiting); - LeaveCriticalSection(mutex); - WaitForSingleObject(cond->semaphore,INFINITE); - InterlockedDecrement(&cond->waiting); - EnterCriticalSection(mutex); - return 0 ; -} - -int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime) -{ - struct _timeb curtime; - int result; - long timeout; - _ftime(&curtime); - timeout= ((long) (abstime->tv_sec - curtime.time)*1000L + - (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L); - if (timeout < 0) /* Some safety */ - timeout = 0L; - InterlockedIncrement(&cond->waiting); - LeaveCriticalSection(mutex); - result=WaitForSingleObject(cond->semaphore,timeout); - InterlockedDecrement(&cond->waiting); - EnterCriticalSection(mutex); - - return result == WAIT_TIMEOUT ? ETIMEDOUT : 0; -} - - -int pthread_cond_signal(pthread_cond_t *cond) -{ - long prev_count; - if (cond->waiting) - ReleaseSemaphore(cond->semaphore,1,&prev_count); - return 0; -} - - -int pthread_cond_broadcast(pthread_cond_t *cond) -{ - long prev_count; - if (cond->waiting) - ReleaseSemaphore(cond->semaphore,cond->waiting,&prev_count); - return 0 ; -} - - -int pthread_attr_init(pthread_attr_t *connect_att) -{ - connect_att->dwStackSize = 0; - connect_att->dwCreatingFlag = 0; - connect_att->priority = 0; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack) -{ - connect_att->dwStackSize=stack; - return 0; -} - -int pthread_attr_setprio(pthread_attr_t *connect_att,int priority) -{ - connect_att->priority=priority; - return 0; -} - -int pthread_attr_destroy(pthread_attr_t *connect_att) -{ - bzero((gptr) connect_att,sizeof(*connect_att)); - return 0; -} - -/**************************************************************************** -** Fix localtime_r() to be a bit safer -****************************************************************************/ - -struct tm *localtime_r(const time_t *timep,struct tm *tmp) -{ - if (*timep == (time_t) -1) /* This will crash win32 */ - { - bzero(tmp,sizeof(*tmp)); - } - else - { - struct tm *res=localtime(timep); - if (!res) /* Wrong date */ - { - bzero(tmp,sizeof(*tmp)); /* Keep things safe */ - return 0; - } - *tmp= *res; - } - return tmp; -} -#endif /* __WIN__ */ diff --git a/ext/mysql/libmysql/my_winthread.c b/ext/mysql/libmysql/my_winthread.c deleted file mode 100644 index 5d06b698ee..0000000000 --- a/ext/mysql/libmysql/my_winthread.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/***************************************************************************** -** Simulation of posix threads calls for WIN95 and NT -*****************************************************************************/ - -/* SAFE_MUTEX will not work until the thread structure is up to date */ -#undef SAFE_MUTEX - -#include "mysys_priv.h" -#if defined(THREAD) && defined(__WIN__) -#include <m_string.h> -#undef getpid -#include <process.h> - -static pthread_mutex_t THR_LOCK_thread; - -struct pthread_map -{ - HANDLE pthreadself; - pthread_handler func; - void *param; -}; - -void win_pthread_init(void) -{ - pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); -} - -/* -** We have tried to use '_beginthreadex' instead of '_beginthread' here -** but in this case the program leaks about 512 characters for each -** created thread ! -** As we want to save the created thread handler for other threads to -** use and to be returned by pthread_self() (instead of the Win32 pseudo -** handler), we have to go trough pthread_start() to catch the returned handler -** in the new thread. -*/ - -static pthread_handler_decl(pthread_start,param) -{ - pthread_handler func=((struct pthread_map *) param)->func; - void *func_param=((struct pthread_map *) param)->param; - my_thread_init(); /* Will always succeed in windows */ - pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */ - win_pthread_self=((struct pthread_map *) param)->pthreadself; - pthread_mutex_unlock(&THR_LOCK_thread); - free((char*) param); /* Free param from create */ - pthread_exit((void*) (*func)(func_param)); - return 0; /* Safety */ -} - - -int pthread_create(pthread_t *thread_id, pthread_attr_t *attr, - pthread_handler func, void *param) -{ - HANDLE hThread; - struct pthread_map *map; - DBUG_ENTER("pthread_create"); - - if (!(map=malloc(sizeof(*map)))) - DBUG_RETURN(-1); - map->func=func; - map->param=param; - pthread_mutex_lock(&THR_LOCK_thread); -#ifdef __BORLANDC__ - hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#else - hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#endif - DBUG_PRINT("info", ("hThread=%lu",(long) hThread)); - *thread_id=map->pthreadself=hThread; - pthread_mutex_unlock(&THR_LOCK_thread); - - if (hThread == (HANDLE) -1) - { - int error=errno; - DBUG_PRINT("error", - ("Can't create thread to handle request (error %d)",error)); - DBUG_RETURN(error ? error : -1); - } - VOID(SetThreadPriority(hThread, attr->priority)) ; - DBUG_RETURN(0); -} - - -void pthread_exit(void *a) -{ - _endthread(); -} - -/* This is neaded to get the macro pthread_setspecific to work */ - -int win_pthread_setspecific(void *a,void *b,uint length) -{ - memcpy(a,b,length); - return 0; -} - -#endif diff --git a/ext/mysql/libmysql/my_write.c b/ext/mysql/libmysql/my_write.c deleted file mode 100644 index 0aec283acc..0000000000 --- a/ext/mysql/libmysql/my_write.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <errno.h> - - - /* Write a chunk of bytes to a file */ - -uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) -{ - uint writenbytes,errors; - ulong written; - DBUG_ENTER("my_write"); - DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %d MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); - errors=0; written=0L; - - for (;;) - { - if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == Count) - break; - if ((int) writenbytes != -1) - { /* Safeguard */ - written+=writenbytes; - Buffer+=writenbytes; - Count-=writenbytes; - } - my_errno=errno; - DBUG_PRINT("error",("Write only %d bytes, error: %d", - writenbytes,my_errno)); -#ifndef NO_BACKGROUND -#ifdef THREAD - if (my_thread_var->abort) - MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */ -#endif - if (my_errno == ENOSPC && (MyFlags & MY_WAIT_IF_FULL) && - (uint) writenbytes != (uint) -1) - { - if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE)) - my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH), - my_filename(Filedes)); - VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC)); - continue; - } - if (!writenbytes) - { - /* We may come here on an interrupt or if the file quote is exeeded */ - if (my_errno == EINTR) - continue; - if (!errors++) /* Retry once */ - { - errno=EFBIG; /* Assume this is the error */ - continue; - } - } - else if ((uint) writenbytes != (uint) -1) - continue; /* Retry */ -#endif - if (MyFlags & (MY_NABP | MY_FNABP)) - { - if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) - { - my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); - } - DBUG_RETURN(MY_FILE_ERROR); /* Error on read */ - } - else - break; /* Return bytes written */ - } - if (MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN(0); /* Want only errors */ - DBUG_RETURN(writenbytes+written); -} /* my_write */ diff --git a/ext/mysql/libmysql/mysql.h b/ext/mysql/libmysql/mysql.h deleted file mode 100644 index 11e099e531..0000000000 --- a/ext/mysql/libmysql/mysql.h +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 diff --git a/ext/mysql/libmysql/mysql.m4 b/ext/mysql/libmysql/mysql.m4 deleted file mode 100644 index 23143e36a8..0000000000 --- a/ext/mysql/libmysql/mysql.m4 +++ /dev/null @@ -1,16 +0,0 @@ -AC_DEFUN(MYSQL_CHECKS,[ - -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_PROG_LN_S]) -AC_REQUIRE([AC_PROG_RANLIB]) - -AC_DEFINE(UNDEF_THREADS_HACK,,[ ]) - -MYSQL_HEADER_CHECKS -MYSQL_TYPE_CHECKS -MYSQL_FUNCTION_CHECKS -MYSQL_CHECK_PTHREAD_GETSPECIFIC -MYSQL_CHECK_PTHREAD_MUTEX_INIT -MYSQL_CHECK_READDIR_R_ARGS -MYSQL_CHECK_SIGWAIT_STYLE -]) diff --git a/ext/mysql/libmysql/mysql_com.h b/ext/mysql/libmysql/mysql_com.h deleted file mode 100644 index 75a07202c7..0000000000 --- a/ext/mysql/libmysql/mysql_com.h +++ /dev/null @@ -1,222 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* -** 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 status variables */ -#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 - -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 diff --git a/ext/mysql/libmysql/mysql_version.h b/ext/mysql/libmysql/mysql_version.h deleted file mode 100644 index 0ebbae1191..0000000000 --- a/ext/mysql/libmysql/mysql_version.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -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.49" -#define MYSQL_SERVER_SUFFIX "" -#define FRM_VER 6 -#define MYSQL_VERSION_ID 32349 -#define MYSQL_PORT 3306 - -#ifndef MYSQL_UNIX_ADDR -#define MYSQL_UNIX_ADDR "/tmp/mysql.sock" -#endif - -/* mysqld compile time options */ -#ifndef MYSQL_CHARSET -#define MYSQL_CHARSET "latin1" -#endif -#endif diff --git a/ext/mysql/libmysql/mysqld_error.h b/ext/mysql/libmysql/mysqld_error.h deleted file mode 100644 index 81e0dd1d06..0000000000 --- a/ext/mysql/libmysql/mysqld_error.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Definefile for errormessagenumbers */ - -#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 diff --git a/ext/mysql/libmysql/mysys_err.h b/ext/mysql/libmysql/mysys_err.h deleted file mode 100644 index 650bfd4de9..0000000000 --- a/ext/mysql/libmysql/mysys_err.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#ifndef _mysys_err_h -#define _mysys_err_h - -#include <errno.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define GLOB 0 /* Error maps */ -#define GLOBERRS 27 /* Max number of error messages in map's */ -#define EE(X) globerrs[ X ] /* Defines to add error to right map */ - -extern const char * NEAR globerrs[]; /* my_error_messages is here */ - -/* Error message numbers in global map */ -#define EE_FILENOTFOUND 0 -#define EE_CANTCREATEFILE 1 -#define EE_READ 2 -#define EE_WRITE 3 -#define EE_BADCLOSE 4 -#define EE_OUTOFMEMORY 5 -#define EE_DELETE 6 -#define EE_LINK 7 -#define EE_EOFERR 9 -#define EE_CANTLOCK 10 -#define EE_CANTUNLOCK 11 -#define EE_DIR 12 -#define EE_STAT 13 -#define EE_CANT_CHSIZE 14 -#define EE_CANT_OPEN_STREAM 15 -#define EE_GETWD 16 -#define EE_SETWD 17 -#define EE_LINK_WARNING 18 -#define EE_OPEN_WARNING 19 -#define EE_DISK_FULL 20 -#define EE_CANT_MKDIR 21 -#define EE_UNKNOWN_CHARSET 22 -#define EE_OUT_OF_FILERESOURCES 23 -#define EE_CANT_READLINK 24 -#define EE_CANT_SYMLINK 25 -#define EE_REALPATH 26 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ext/mysql/libmysql/mysys_priv.h b/ext/mysql/libmysql/mysys_priv.h deleted file mode 100644 index a0131ea77e..0000000000 --- a/ext/mysql/libmysql/mysys_priv.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -#include <global.h> -#include <my_sys.h> - -#ifdef USE_SYSTEM_WRAPPERS -#include "system_wrappers.h" -#endif - -#ifdef THREAD -extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, - THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset; -extern pthread_mutex_t LOCK_bitmap; -#else /* THREAD */ -#define pthread_mutex_lock(A) -#define pthread_mutex_unlock(A) -#endif diff --git a/ext/mysql/libmysql/net.c b/ext/mysql/libmysql/net.c deleted file mode 100644 index 161fba4ace..0000000000 --- a/ext/mysql/libmysql/net.c +++ /dev/null @@ -1,671 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Write and read of logical packets to/from socket -** Writes are cached into net_buffer_length big packets. -** Read packets are reallocated dynamicly when reading big packets. -** Each logical packet has the following pre-info: -** 3 byte length & 1 byte package-number. -*/ - -#ifdef __WIN__ -#include <winsock.h> -#endif -#include <global.h> -#include <violite.h> -#include <my_sys.h> -#include <m_string.h> -#include "mysql.h" -#include "mysqld_error.h" -#include <signal.h> -#include <errno.h> -#include <sys/types.h> -#include <violite.h> - -#ifdef MYSQL_SERVER -ulong max_allowed_packet=65536; -extern ulong net_read_timeout,net_write_timeout; -extern uint test_flags; -#else -ulong max_allowed_packet=16*1024*1024L; -ulong net_read_timeout= NET_READ_TIMEOUT; -ulong net_write_timeout= NET_WRITE_TIMEOUT; -#endif -ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */ - -#if !defined(__WIN__) && !defined(MSDOS) -#include <sys/socket.h> -#else -#undef MYSQL_SERVER /* Win32 can't handle interrupts */ -#endif -#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#if !defined(alpha_linux_port) -#include <netinet/tcp.h> -#endif -#endif -#include "mysqld_error.h" -#ifdef MYSQL_SERVER -#include "my_pthread.h" -#include "thr_alarm.h" -void sql_print_error(const char *format,...); -#define RETRY_COUNT mysqld_net_retry_count -extern ulong mysqld_net_retry_count; -#else - -#ifdef OS2 /* avoid name conflict */ -#define thr_alarm_t thr_alarm_t_net -#define ALARM ALARM_net -#endif - -typedef my_bool thr_alarm_t; -typedef my_bool ALARM; -#define thr_alarm_init(A) (*(A))=0 -#define thr_alarm_in_use(A) (*(A)!= 0) -#define thr_end_alarm(A) -#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) -inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) -{ - *A=1; - return 0; -} -#define thr_got_alarm(A) 0 -#define RETRY_COUNT 1 -#endif - -#ifdef MYSQL_SERVER -extern ulong bytes_sent, bytes_received; -extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received; -#else -#undef statistic_add -#define statistic_add(A,B,C) -#endif - -/* -** Give error if a too big packet is found -** The server can change this with the -O switch, but because the client -** can't normally do this the client should have a bigger max-buffer. -*/ - -#define TEST_BLOCKING 8 -static int net_write_buff(NET *net,const char *packet,uint len); - - - /* Init with packet info */ - -int my_net_init(NET *net, Vio* vio) -{ - if (!(net->buff=(uchar*) my_malloc(net_buffer_length,MYF(MY_WME)))) - return 1; - if (net_buffer_length > max_allowed_packet) - max_allowed_packet=net_buffer_length; - net->buff_end=net->buff+(net->max_packet=net_buffer_length); - net->vio = vio; - net->no_send_ok = 0; - net->error=0; net->return_errno=0; net->return_status=0; - net->timeout=(uint) net_read_timeout; /* Timeout for read */ - net->pkt_nr=0; - net->write_pos=net->read_pos = net->buff; - net->last_error[0]=0; - net->compress=0; net->reading_or_writing=0; - net->where_b = net->remain_in_buf=0; - net->last_errno=0; - - if (vio != 0) /* If real connection */ - { - net->fd = vio_fd(vio); /* For perl DBI/DBD */ -#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) - if (!(test_flags & TEST_BLOCKING)) - vio_blocking(vio, FALSE); -#endif - vio_fastsend(vio); - } - return 0; -} - -void net_end(NET *net) -{ - my_free((gptr) net->buff,MYF(MY_ALLOW_ZERO_PTR)); - net->buff=0; -} - -/* Realloc the packet buffer */ - -static my_bool net_realloc(NET *net, ulong length) -{ - uchar *buff; - ulong pkt_length; - if (length >= max_allowed_packet) - { - DBUG_PRINT("error",("Packet too large (%lu)", length)); - net->error=1; - net->last_errno=ER_NET_PACKET_TOO_LARGE; - return 1; - } - pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1); - if (!(buff=(uchar*) my_realloc((char*) net->buff, pkt_length, MYF(MY_WME)))) - { - net->error=1; -#ifdef MYSQL_SERVER - net->last_errno=ER_OUT_OF_RESOURCES; -#endif - return 1; - } - net->buff=net->write_pos=buff; - net->buff_end=buff+(net->max_packet=pkt_length); - return 0; -} - - /* Remove unwanted characters from connection */ - -void net_clear(NET *net) -{ -#ifndef EXTRA_DEBUG - int count; - bool is_blocking=vio_is_blocking(net->vio); - if (is_blocking) - vio_blocking(net->vio, FALSE); - if (!vio_is_blocking(net->vio)) /* Safety if SSL */ - { - while ( (count = vio_read(net->vio, (char*) (net->buff), - net->max_packet)) > 0) - DBUG_PRINT("info",("skipped %d bytes from file: %s", - count,vio_description(net->vio))); - if (is_blocking) - vio_blocking(net->vio, TRUE); - } -#endif /* EXTRA_DEBUG */ - net->pkt_nr=0; /* Ready for new command */ - net->write_pos=net->buff; -} - - /* Flush write_buffer if not empty. */ - -int net_flush(NET *net) -{ - int error=0; - DBUG_ENTER("net_flush"); - if (net->buff != net->write_pos) - { - error=net_real_write(net,(char*) net->buff, - (uint) (net->write_pos - net->buff)); - net->write_pos=net->buff; - } - DBUG_RETURN(error); -} - - -/***************************************************************************** -** Write something to server/client buffer -*****************************************************************************/ - - -/* -** Write a logical packet with packet header -** Format: Packet length (3 bytes), packet number(1 byte) -** When compression is used a 3 byte compression length is added -** NOTE: If compression is used the original package is destroyed! -*/ - -int -my_net_write(NET *net,const char *packet,ulong len) -{ - uchar buff[NET_HEADER_SIZE]; - int3store(buff,len); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); - if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) - return 1; - return net_write_buff(net,packet,len); -} - -int -net_write_command(NET *net,uchar command,const char *packet,ulong len) -{ - uchar buff[NET_HEADER_SIZE+1]; - uint length=len+1; /* 1 extra byte for command */ - - int3store(buff,length); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); - buff[4]=command; - if (net_write_buff(net,(char*) buff,5)) - return 1; - return test(net_write_buff(net,packet,len) || net_flush(net)); -} - - -static int -net_write_buff(NET *net,const char *packet,uint len) -{ - uint left_length=(uint) (net->buff_end - net->write_pos); - - while (len > left_length) - { - memcpy((char*) net->write_pos,packet,left_length); - if (net_real_write(net,(char*) net->buff,net->max_packet)) - return 1; - net->write_pos=net->buff; - packet+=left_length; - len-=left_length; - left_length=net->max_packet; - } - memcpy((char*) net->write_pos,packet,len); - net->write_pos+=len; - return 0; -} - -/* Read and write using timeouts */ - -int -net_real_write(NET *net,const char *packet,ulong len) -{ - int length; - char *pos,*end; - thr_alarm_t alarmed; -#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) - ALARM alarm_buff; -#endif - uint retry_count=0; - my_bool net_blocking = vio_is_blocking(net->vio); - DBUG_ENTER("net_real_write"); - - if (net->error == 2) - DBUG_RETURN(-1); /* socket can't be used */ - - net->reading_or_writing=2; -#ifdef HAVE_COMPRESS - if (net->compress) - { - ulong complen; - uchar *b; - uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE; - if (!(b=(uchar*) my_malloc(len + NET_HEADER_SIZE + COMP_HEADER_SIZE, - MYF(MY_WME)))) - { -#ifdef MYSQL_SERVER - net->last_errno=ER_OUT_OF_RESOURCES; - net->error=2; -#endif - net->reading_or_writing=0; - DBUG_RETURN(1); - } - memcpy(b+header_length,packet,len); - - if (my_compress((byte*) b+header_length,&len,&complen)) - { - DBUG_PRINT("warning", - ("Compression error; Continuing without compression")); - complen=0; - } - int3store(&b[NET_HEADER_SIZE],complen); - int3store(b,len); - b[3]=(uchar) (net->pkt_nr++); - len+= header_length; - packet= (char*) b; - } -#endif /* HAVE_COMPRESS */ - - /* DBUG_DUMP("net",packet,len); */ -#ifdef MYSQL_SERVER - thr_alarm_init(&alarmed); - if (net_blocking) - thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff); -#else - alarmed=0; -#endif /* MYSQL_SERVER */ - - pos=(char*) packet; end=pos+len; - while (pos != end) - { - if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0) - { - my_bool interrupted = vio_should_retry(net->vio); -#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) - if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed)) - { - if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff)) - { /* Always true for client */ - if (!vio_is_blocking(net->vio)) - { - while (vio_blocking(net->vio, TRUE) < 0) - { - if (vio_should_retry(net->vio) && retry_count++ < RETRY_COUNT) - continue; -#ifdef EXTRA_DEBUG - fprintf(stderr, - "%s: my_net_write: fcntl returned error %d, aborting thread\n", - my_progname,vio_errno(net->vio)); -#endif /* EXTRA_DEBUG */ - net->error=2; /* Close socket */ - goto end; - } - } - retry_count=0; - continue; - } - } - else -#endif /* (!defined(__WIN__) && !defined(__EMX__)) */ - if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) && - interrupted) - { - if (retry_count++ < RETRY_COUNT) - continue; -#ifdef EXTRA_DEBUG - fprintf(stderr, "%s: write looped, aborting thread\n", - my_progname); -#endif /* EXTRA_DEBUG */ - } -#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) - if (vio_errno(net->vio) == SOCKET_EINTR) - { - DBUG_PRINT("warning",("Interrupted write. Retrying...")); - continue; - } -#endif /* defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) */ - net->error=2; /* Close socket */ -#ifdef MYSQL_SERVER - net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED : - ER_NET_ERROR_ON_WRITE); -#endif /* MYSQL_SERVER */ - break; - } - pos+=length; - statistic_add(bytes_sent,length,&LOCK_bytes_sent); - } -#ifndef __WIN__ - end: -#endif -#ifdef HAVE_COMPRESS - if (net->compress) - my_free((char*) packet,MYF(0)); -#endif - if (thr_alarm_in_use(&alarmed)) - { - thr_end_alarm(&alarmed); - vio_blocking(net->vio, net_blocking); - } - net->reading_or_writing=0; - DBUG_RETURN(((int) (pos != end))); -} - - -/***************************************************************************** -** Read something from server/clinet -*****************************************************************************/ - -#ifdef MYSQL_SERVER - -/* - Help function to clear the commuication buffer when we get a too - big packet -*/ - -static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) -{ - ALARM alarm_buff; - uint retry_count=0; - if (!thr_alarm_in_use(&alarmed)) - { - if (!thr_alarm(alarmed,net->timeout,&alarm_buff) || - (!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0)) - return; /* Can't setup, abort */ - } - while (remain > 0) - { - ulong length; - if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L) - { - my_bool interrupted = vio_should_retry(net->vio); - if (!thr_got_alarm(alarmed) && interrupted) - { /* Probably in MIT threads */ - if (retry_count++ < RETRY_COUNT) - continue; - } - return; - } - remain -=(ulong) length; - statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received); - } -} -#endif /* MYSQL_SERVER */ - - -static uint -my_real_read(NET *net, ulong *complen) -{ - uchar *pos; - long length; - uint i,retry_count=0; - ulong len=packet_error; - thr_alarm_t alarmed; -#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) - ALARM alarm_buff; -#endif - my_bool net_blocking=vio_is_blocking(net->vio); - ulong remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE : - NET_HEADER_SIZE); - *complen = 0; - - net->reading_or_writing=1; - thr_alarm_init(&alarmed); -#ifdef MYSQL_SERVER - if (net_blocking) - thr_alarm(&alarmed,net->timeout,&alarm_buff); -#endif /* MYSQL_SERVER */ - - pos = net->buff + net->where_b; /* net->packet -4 */ - for (i=0 ; i < 2 ; i++) - { - while (remain > 0) - { - /* First read is done with non blocking mode */ - if ((int) (length=vio_read(net->vio,(char*) pos,remain)) <= 0L) - { - my_bool interrupted = vio_should_retry(net->vio); - - DBUG_PRINT("info",("vio_read returned %d, errno: %d", - length, vio_errno(net->vio))); -#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) - /* - We got an error that there was no data on the socket. We now set up - an alarm to not 'read forever', change the socket to non blocking - mode and try again - */ - if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed)) - { - if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */ - { - if (!vio_is_blocking(net->vio)) - { - while (vio_blocking(net->vio,TRUE) < 0) - { - if (vio_should_retry(net->vio) && - retry_count++ < RETRY_COUNT) - continue; - DBUG_PRINT("error", - ("fcntl returned error %d, aborting thread", - vio_errno(net->vio))); -#ifdef EXTRA_DEBUG - fprintf(stderr, - "%s: read: fcntl returned error %d, aborting thread\n", - my_progname,vio_errno(net->vio)); -#endif /* EXTRA_DEBUG */ - len= packet_error; - net->error=2; /* Close socket */ -#ifdef MYSQL_SERVER - net->last_errno=ER_NET_FCNTL_ERROR; -#endif - goto end; - } - } - retry_count=0; - continue; - } - } -#endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */ - if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) && - interrupted) - { /* Probably in MIT threads */ - if (retry_count++ < RETRY_COUNT) - continue; -#ifdef EXTRA_DEBUG - fprintf(stderr, "%s: read looped with error %d, aborting thread\n", - my_progname,vio_errno(net->vio)); -#endif /* EXTRA_DEBUG */ - } -#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) - if (vio_should_retry(net->vio)) - { - DBUG_PRINT("warning",("Interrupted read. Retrying...")); - continue; - } -#endif - DBUG_PRINT("error",("Couldn't read packet: remain: %d errno: %d length: %d alarmed: %d", remain,vio_errno(net->vio),length,alarmed)); - len= packet_error; - net->error=2; /* Close socket */ -#ifdef MYSQL_SERVER - net->last_errno= (interrupted ? ER_NET_READ_INTERRUPTED : - ER_NET_READ_ERROR); -#endif - goto end; - } - remain -= (ulong) length; - pos+= (ulong) length; - statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received); - } - if (i == 0) - { /* First parts is packet length */ - ulong helping; - if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr) - { - if (net->buff[net->where_b] != (uchar) 255) - { - DBUG_PRINT("error", - ("Packets out of order (Found: %d, expected %d)", - (int) net->buff[net->where_b + 3], - (uint) (uchar) net->pkt_nr)); -#ifdef EXTRA_DEBUG - fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n", - (int) net->buff[net->where_b + 3], - (uint) (uchar) net->pkt_nr); -#endif - } - len= packet_error; -#ifdef MYSQL_SERVER - net->last_errno=ER_NET_PACKETS_OUT_OF_ORDER; -#endif - goto end; - } - net->pkt_nr++; -#ifdef HAVE_COMPRESS - if (net->compress) - { - /* complen is > 0 if package is really compressed */ - *complen=uint3korr(&(net->buff[net->where_b + NET_HEADER_SIZE])); - } -#endif - - len=uint3korr(net->buff+net->where_b); - helping = max(len,*complen) + net->where_b; - /* The necessary size of net->buff */ - if (helping >= net->max_packet) - { - /* We must allocate one extra byte for the end null */ - if (net_realloc(net,helping+1)) - { -#ifdef MYSQL_SERVER - if (i == 1) - my_net_skip_rest(net, len, &alarmed); -#endif - len= packet_error; /* Return error */ - goto end; - } - } - pos=net->buff + net->where_b; - remain = len; - } - } - -end: - if (thr_alarm_in_use(&alarmed)) - { - thr_end_alarm(&alarmed); - vio_blocking(net->vio, net_blocking); - } - net->reading_or_writing=0; - return(len); -} - -uint -my_net_read(NET *net) -{ - ulong len,complen; - -#ifdef HAVE_COMPRESS - if (!net->compress) - { -#endif - len = my_real_read (net,&complen); - net->read_pos = net->buff + net->where_b; - if (len != packet_error) - net->read_pos[len]=0; /* Safeguard for mysql_use_result */ - return len; -#ifdef HAVE_COMPRESS - } - if (net->remain_in_buf) - net->buff[net->buf_length - net->remain_in_buf]=net->save_char; - for (;;) - { - if (net->remain_in_buf) - { - uchar *pos = net->buff + net->buf_length - net->remain_in_buf; - if (net->remain_in_buf >= 4) - { - net->length = uint3korr(pos); - if (net->length <= net->remain_in_buf - 4) - { - /* We have a full packet */ - len=net->length; - net->remain_in_buf -= net->length + 4; - net->read_pos=pos + 4; - break; /* We have a full packet */ - } - } - /* Move data down to read next data packet after current one */ - if (net->buf_length != net->remain_in_buf) - { - memmove(net->buff,pos,net->remain_in_buf); - net->buf_length=net->remain_in_buf; - } - net->where_b=net->buf_length; - } - else - { - net->where_b=0; - net->buf_length=0; - } - - if ((len = my_real_read(net,&complen)) == packet_error) - break; - if (my_uncompress((byte*) net->buff + net->where_b, &len, &complen)) - { - len= packet_error; - net->error=2; /* caller will close socket */ -#ifdef MYSQL_SERVER - net->last_errno=ER_NET_UNCOMPRESS_ERROR; -#endif - break; - } - net->buf_length+=len; - net->remain_in_buf+=len; - } - if (len != packet_error) - { - net->save_char= net->read_pos[len]; /* Must be saved */ - net->read_pos[len]=0; /* Safeguard for mysql_use_result */ - } - return len; -#endif -} diff --git a/ext/mysql/libmysql/password.c b/ext/mysql/libmysql/password.c deleted file mode 100644 index eb40825401..0000000000 --- a/ext/mysql/libmysql/password.c +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* password checking routines */ -/***************************************************************************** - The main idea is that no password are sent between client & server on - connection and that no password are saved in mysql in a decodable form. - - On connection a random string is generated and sent to the client. - The client generates a new string with a random generator inited with - the hash values from the password and the sent string. - This 'check' string is sent to the server where it is compared with - a string generated from the stored hash_value of the password and the - random string. - - The password is saved (in user.password) by using the PASSWORD() function in - mysql. - - Example: - update user set password=PASSWORD("hello") where user="test" - This saves a hashed number as a string in the password field. -*****************************************************************************/ - -#include <global.h> -#include <my_sys.h> -#include <m_string.h> -#include "mysql.h" - - -void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2) -{ /* For mysql 3.21.# */ -#ifdef HAVE_purify - bzero((char*) rand_st,sizeof(*rand_st)); /* Avoid UMC varnings */ -#endif - rand_st->max_value= 0x3FFFFFFFL; - rand_st->max_value_dbl=(double) rand_st->max_value; - rand_st->seed1=seed1%rand_st->max_value ; - rand_st->seed2=seed2%rand_st->max_value; -} - -static void old_randominit(struct rand_struct *rand_st,ulong seed1) -{ /* For mysql 3.20.# */ - rand_st->max_value= 0x01FFFFFFL; - rand_st->max_value_dbl=(double) rand_st->max_value; - seed1%=rand_st->max_value; - rand_st->seed1=seed1 ; rand_st->seed2=seed1/2; -} - -double rnd(struct rand_struct *rand_st) -{ - rand_st->seed1=(rand_st->seed1*3+rand_st->seed2) % rand_st->max_value; - rand_st->seed2=(rand_st->seed1+rand_st->seed2+33) % rand_st->max_value; - return (((double) rand_st->seed1)/rand_st->max_value_dbl); -} - -void hash_password(ulong *result, const char *password) -{ - register ulong nr=1345345333L, add=7, nr2=0x12345671L; - ulong tmp; - for (; *password ; password++) - { - if (*password == ' ' || *password == '\t') - continue; /* skipp space in password */ - tmp= (ulong) (uchar) *password; - nr^= (((nr & 63)+add)*tmp)+ (nr << 8); - nr2+=(nr2 << 8) ^ nr; - add+=tmp; - } - result[0]=nr & (((ulong) 1L << 31) -1L); /* Don't use sign bit (str2int) */; - result[1]=nr2 & (((ulong) 1L << 31) -1L); - return; -} - -void make_scrambled_password(char *to,const char *password) -{ - ulong hash_res[2]; - hash_password(hash_res,password); - sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]); -} - -static inline uint char_val(char X) -{ - return (uint) (X >= '0' && X <= '9' ? X-'0' : - X >= 'A' && X <= 'Z' ? X-'A'+10 : - X-'a'+10); -} - -/* -** This code assumes that len(password) is divideable with 8 and that -** res is big enough (2 in mysql) -*/ - -void get_salt_from_password(ulong *res,const char *password) -{ - res[0]=res[1]=0; - if (password) - { - while (*password) - { - ulong val=0; - uint i; - for (i=0 ; i < 8 ; i++) - val=(val << 4)+char_val(*password++); - *res++=val; - } - } - return; -} - -void make_password_from_salt(char *to, ulong *hash_res) -{ - sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]); -} - - -/* - * Genererate a new message based on message and password - * The same thing is done in client and server and the results are checked. - */ - -char *scramble(char *to,const char *message,const char *password, - my_bool old_ver) -{ - struct rand_struct rand_st; - ulong hash_pass[2],hash_message[2]; - if (password && password[0]) - { - char *to_start=to; - hash_password(hash_pass,password); - hash_password(hash_message,message); - if (old_ver) - old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); - else - randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); - while (*message++) - *to++= (char) (floor(rnd(&rand_st)*31)+64); - if (!old_ver) - { /* Make it harder to break */ - char extra=(char) (floor(rnd(&rand_st)*31)); - while (to_start != to) - *(to_start++)^=extra; - } - } - *to=0; - return to; -} - - -my_bool check_scramble(const char *scrambled, const char *message, - ulong *hash_pass, my_bool old_ver) -{ - struct rand_struct rand_st; - ulong hash_message[2]; - char buff[16],*to,extra; /* Big enough for check */ - const char *pos; - - hash_password(hash_message,message); - if (old_ver) - old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); - else - randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); - to=buff; - for (pos=scrambled ; *pos ; pos++) - *to++=(char) (floor(rnd(&rand_st)*31)+64); - if (old_ver) - extra=0; - else - extra=(char) (floor(rnd(&rand_st)*31)); - to=buff; - while (*scrambled) - { - if (*scrambled++ != (char) (*to++ ^ extra)) - return 1; /* Wrong password */ - } - return 0; -} diff --git a/ext/mysql/libmysql/raid.h b/ext/mysql/libmysql/raid.h deleted file mode 100644 index caa9f743c6..0000000000 --- a/ext/mysql/libmysql/raid.h +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* 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 */ diff --git a/ext/mysql/libmysql/safemalloc.c b/ext/mysql/libmysql/safemalloc.c deleted file mode 100644 index 1918034c19..0000000000 --- a/ext/mysql/libmysql/safemalloc.c +++ /dev/null @@ -1,510 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - * [This posting refers to an article entitled "oops, corrupted memory - * again!" in net.lang.c. I am posting it here because it is source.] - * - * My tool for approaching this problem is to build another level of data - * abstraction on top of malloc() and free() that implements some checking. - * This does a number of things for you: - * - Checks for overruns and underruns on allocated data - * - Keeps track of where in the program the memory was malloc'ed - * - Reports on pieces of memory that were not free'ed - * - Records some statistics such as maximum memory used - * - Marks newly malloc'ed and newly free'ed memory with special values - * You can use this scheme to: - * - Find bugs such as overrun, underrun, etc because you know where - * a piece of data was malloc'ed and where it was free'ed - * - Find bugs where memory was not free'ed - * - Find bugs where newly malloc'ed memory is used without initializing - * - Find bugs where newly free'ed memory is still used - * - Determine how much memory your program really uses - * - and other things - */ - -/* - * To implement my scheme you must have a C compiler that has __LINE__ and - * __FILE__ macros. If your compiler doesn't have these then (a) buy another: - * compilers that do are available on UNIX 4.2bsd based systems and the PC, - * and probably on other machines; or (b) change my scheme somehow. I have - * recomendations on both these points if you would like them (e-mail please). - * - * There are 4 functions in my package: - * char *NEW( uSize ) Allocate memory of uSize bytes - * (equivalent to malloc()) - * char *REA( pPtr, uSize) Allocate memory of uSize bytes, move data and - * free pPtr. - * (equivalent to realloc()) - * FREE( pPtr ) Free memory allocated by NEW - * (equivalent to free()) - * TERMINATE(file) End system, report errors and stats on file - * I personally use two more functions, but have not included them here: - * char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory - * char *RENEW( pPtr, uSize ) - * (equivalent to realloc()) - */ - -/* - * Memory sub-system, written by Bjorn Benson - Fixed to use my_sys scheme by Michael Widenius - */ - -#ifndef SAFEMALLOC -#define SAFEMALLOC /* Get protos from my_sys */ -#endif - -#include "mysys_priv.h" -#include <m_string.h> -#include "my_static.h" -#include "mysys_err.h" - -ulonglong safemalloc_mem_limit = ~(ulonglong)0; - -#define pNext tInt._pNext -#define pPrev tInt._pPrev -#define sFileName tInt._sFileName -#define uLineNum tInt._uLineNum -#define uDataSize tInt._uDataSize -#define lSpecialValue tInt._lSpecialValue - - /* Static functions prototypes */ - -static int check_ptr(const char *where, byte *ptr, const char *sFile, - uint uLine); -static int _checkchunk(struct remember *pRec, const char *sFile, uint uLine); - -/* - * Note: both these refer to the NEW'ed - * data only. They do not include - * malloc() roundoff or the extra - * space required by the remember - * structures. - */ - -#define ALLOC_VAL (uchar) 0xA5 /* NEW'ed memory is filled with this */ - /* value so that references to it will */ - /* end up being very strange. */ -#define FREE_VAL (uchar) 0x8F /* FREE'ed memory is filled with this */ - /* value so that references to it will */ - /* also end up being strange. */ - -#define MAGICKEY 0x14235296 /* A magic value for underrun key */ -#define MAGICEND0 0x68 /* Magic values for overrun keys */ -#define MAGICEND1 0x34 /* " */ -#define MAGICEND2 0x7A /* " */ -#define MAGICEND3 0x15 /* " */ - - /* Warning: do not change the MAGICEND? values to */ - /* something with the high bit set. Various C */ - /* compilers (like the 4.2bsd one) do not do the */ - /* sign extension right later on in this code and */ - /* you will get erroneous errors. */ - - -/* - * gptr _mymalloc( uint uSize, my_string sFile, uint uLine, MyFlags ) - * Allocate some memory. - */ - -gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags) -{ - struct remember *pTmp; - DBUG_ENTER("_mymalloc"); - DBUG_PRINT("enter",("Size: %u",uSize)); - - - if (!sf_malloc_quick) - (void) _sanity (sFile, uLine); - - if(uSize + lCurMemory > safemalloc_mem_limit) - pTmp = 0; - else - /* Allocate the physical memory */ - pTmp = (struct remember *) malloc ( - sizeof (struct irem) /* remember data */ - + sf_malloc_prehunc - + uSize /* size requested */ - + 4 /* overrun mark */ - + sf_malloc_endhunc - ); - - /* Check if there isn't anymore memory avaiable */ - if (pTmp == NULL) - { - if (MyFlags & MY_FAE) - error_handler_hook=fatal_error_handler_hook; - if (MyFlags & (MY_FAE+MY_WME)) - { - char buff[SC_MAXWIDTH]; - my_errno=errno; - sprintf(buff,"Out of memory at line %d, '%s'", uLine, sFile); - my_message(EE_OUTOFMEMORY,buff,MYF(ME_BELL+ME_WAITTANG)); - sprintf(buff,"needed %d byte (%ldk), memory in use: %ld bytes (%ldk)", - uSize, (uSize + 1023L) / 1024L, - lMaxMemory, (lMaxMemory + 1023L) / 1024L); - my_message(EE_OUTOFMEMORY,buff,MYF(ME_BELL+ME_WAITTANG)); - } - DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'", - lMaxMemory,uLine, sFile)); - if (MyFlags & MY_FAE) - exit(1); - DBUG_RETURN ((gptr) NULL); - } - - /* Fill up the structure */ - *((long*) ((char*) &pTmp -> lSpecialValue+sf_malloc_prehunc)) = MAGICKEY; - pTmp -> aData[uSize + sf_malloc_prehunc+0] = MAGICEND0; - pTmp -> aData[uSize + sf_malloc_prehunc+1] = MAGICEND1; - pTmp -> aData[uSize + sf_malloc_prehunc+2] = MAGICEND2; - pTmp -> aData[uSize + sf_malloc_prehunc+3] = MAGICEND3; - pTmp -> sFileName = (my_string) sFile; - pTmp -> uLineNum = uLine; - pTmp -> uDataSize = uSize; - pTmp -> pPrev = NULL; - - /* Add this remember structure to the linked list */ - pthread_mutex_lock(&THR_LOCK_malloc); - if ((pTmp->pNext=pRememberRoot)) - { - pRememberRoot -> pPrev = pTmp; - } - pRememberRoot = pTmp; - - /* Keep the statistics */ - lCurMemory += uSize; - if (lCurMemory > lMaxMemory) { - lMaxMemory = lCurMemory; - } - cNewCount++; - pthread_mutex_unlock(&THR_LOCK_malloc); - - /* Set the memory to the aribtrary wierd value */ -#ifdef HAVE_purify - if (MyFlags & MY_ZEROFILL) -#endif - bfill(&pTmp -> aData[sf_malloc_prehunc],uSize, - (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL)); - /* Return a pointer to the real data */ - DBUG_PRINT("exit",("ptr: %lx",&(pTmp -> aData[sf_malloc_prehunc]))); - if (sf_min_adress > &(pTmp -> aData[sf_malloc_prehunc])) - sf_min_adress = &(pTmp -> aData[sf_malloc_prehunc]); - if (sf_max_adress < &(pTmp -> aData[sf_malloc_prehunc])) - sf_max_adress = &(pTmp -> aData[sf_malloc_prehunc]); - DBUG_RETURN ((gptr) &(pTmp -> aData[sf_malloc_prehunc])); -} - -/* - * Allocate some new memory and move old memoryblock there. - * Free then old memoryblock - */ - -gptr _myrealloc (register gptr pPtr, register uint uSize, - const char *sFile, uint uLine, myf MyFlags) -{ - struct remember *pRec; - gptr ptr; - DBUG_ENTER("_myrealloc"); - - if (!pPtr && (MyFlags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(_mymalloc(uSize,sFile,uLine,MyFlags)); - - if (!sf_malloc_quick) - (void) _sanity (sFile, uLine); - - if (check_ptr("Reallocating",(byte*) pPtr,sFile,uLine)) - DBUG_RETURN((gptr) NULL); - - pRec = (struct remember *) ((char*) pPtr - sizeof (struct irem)- - sf_malloc_prehunc); - if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) - != MAGICKEY) - { - fprintf (stderr, "Reallocating unallocated data at line %d, '%s'\n", - uLine, sFile); - DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'", - uLine, sFile)); - (void) fflush(stderr); - DBUG_RETURN((gptr) NULL); - } - - if ((ptr=_mymalloc(uSize,sFile,uLine,MyFlags))) /* Allocate new area */ - { - uSize=min(uSize,pRec-> uDataSize); /* Move as much as possibly */ - memcpy((byte*) ptr,pPtr,(size_t) uSize); /* Copy old data */ - _myfree(pPtr,sFile,uLine,0); /* Free not needed area */ - } - else - { - if (MyFlags & MY_HOLD_ON_ERROR) - DBUG_RETURN(pPtr); - if (MyFlags & MY_FREE_ON_ERROR) - _myfree(pPtr,sFile,uLine,0); - } - DBUG_RETURN(ptr); -} /* _myrealloc */ - - -/* - * void _myfree( my_string pPtr, my_string sFile, uint uLine, myf myflags) - * Deallocate some memory. - */ - -void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags) -{ - struct remember *pRec; - DBUG_ENTER("_myfree"); - DBUG_PRINT("enter",("ptr: %lx",pPtr)); - - if (!sf_malloc_quick) - (void) _sanity (sFile, uLine); - - if ((!pPtr && (myflags & MY_ALLOW_ZERO_PTR)) || - check_ptr("Freeing",(byte*) pPtr,sFile,uLine)) - DBUG_VOID_RETURN; - - /* Calculate the address of the remember structure */ - pRec = (struct remember *) ((byte*) pPtr-sizeof(struct irem)- - sf_malloc_prehunc); - - /* Check to make sure that we have a real remember structure */ - /* Note: this test could fail for four reasons: */ - /* (1) The memory was already free'ed */ - /* (2) The memory was never new'ed */ - /* (3) There was an underrun */ - /* (4) A stray pointer hit this location */ - - if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) - != MAGICKEY) - { - fprintf (stderr, "Freeing unallocated data at line %d, '%s'\n", - uLine, sFile); - DBUG_PRINT("safe",("Unallocated data at line %d, '%s'",uLine,sFile)); - (void) fflush(stderr); - DBUG_VOID_RETURN; - } - - /* Remove this structure from the linked list */ - pthread_mutex_lock(&THR_LOCK_malloc); - if (pRec -> pPrev) { - pRec -> pPrev -> pNext = pRec -> pNext; - } else { - pRememberRoot = pRec -> pNext; - } - if (pRec -> pNext) { - pRec -> pNext -> pPrev = pRec -> pPrev; - } - /* Handle the statistics */ - lCurMemory -= pRec -> uDataSize; - cNewCount--; - pthread_mutex_unlock(&THR_LOCK_malloc); - -#ifndef HAVE_purify - /* Mark this data as free'ed */ - bfill(&pRec->aData[sf_malloc_prehunc],pRec->uDataSize,(pchar) FREE_VAL); -#endif - *((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) = ~MAGICKEY; - - /* Actually free the memory */ - free ((my_string ) pRec); - DBUG_VOID_RETURN; -} - - /* Check if we have a wrong pointer */ - -static int check_ptr(const char *where, byte *ptr, const char *sFile, - uint uLine) -{ - if (!ptr) - { - fprintf (stderr, "%s NULL pointer at line %d, '%s'\n", - where,uLine, sFile); - DBUG_PRINT("safe",("Null pointer at line %d '%s'", uLine, sFile)); - (void) fflush(stderr); - return 1; - } -#ifndef _MSC_VER - if ((long) ptr & (MY_ALIGN(1,sizeof(char *))-1)) - { - fprintf (stderr, "%s wrong aligned pointer at line %d, '%s'\n", - where,uLine, sFile); - DBUG_PRINT("safe",("Wrong aligned pointer at line %d, '%s'", - uLine,sFile)); - (void) fflush(stderr); - return 1; - } -#endif - if (ptr < sf_min_adress || ptr > sf_max_adress) - { - fprintf (stderr, "%s pointer out of range at line %d, '%s'\n", - where,uLine, sFile); - DBUG_PRINT("safe",("Pointer out of range at line %d '%s'", - uLine,sFile)); - (void) fflush(stderr); - return 1; - } - return 0; -} - - -/* - * TERMINATE(FILE *file) - * Report on all the memory pieces that have not been - * free'ed as well as the statistics. - */ - -void TERMINATE (FILE *file) -{ - struct remember *pPtr; - DBUG_ENTER("TERMINATE"); - pthread_mutex_lock(&THR_LOCK_malloc); - - /* Report the difference between number of calls to */ - /* NEW and the number of calls to FREE. >0 means more */ - /* NEWs than FREEs. <0, etc. */ - - if (cNewCount) - { - if (file) - { - fprintf (file, "cNewCount: %d\n", cNewCount); - (void) fflush(file); - } - DBUG_PRINT("safe",("cNewCount: %d",cNewCount)); - } - - /* Report on all the memory that was allocated with NEW */ - /* but not free'ed with FREE. */ - - if ((pPtr=pRememberRoot)) - { - if (file) - { - fprintf(file, "Memory that was not free'ed (%ld bytes):\n",lCurMemory); - (void) fflush(file); - } - DBUG_PRINT("safe",("Memory that was not free'ed (%ld bytes):",lCurMemory)); - while (pPtr) - { - if (file) - { - fprintf (file, - "\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'\n", - pPtr -> uDataSize, - (ulong) &(pPtr -> aData[sf_malloc_prehunc]), - pPtr -> uLineNum, pPtr -> sFileName); - (void) fflush(file); - } - DBUG_PRINT("safe", - ("%6u bytes at 0x%09lx, allocated at line %4d in '%s'", - pPtr -> uDataSize, &(pPtr -> aData[sf_malloc_prehunc]), - pPtr -> uLineNum, pPtr -> sFileName)); - pPtr = pPtr -> pNext; - } - } - /* Report the memory usage statistics */ - if (file) - { - fprintf (file, "Maximum memory usage: %ld bytes (%ldk)\n", - lMaxMemory, (lMaxMemory + 1023L) / 1024L); - (void) fflush(file); - } - DBUG_PRINT("safe",("Maximum memory usage: %ld bytes (%ldk)", - lMaxMemory, (lMaxMemory + 1023L) / 1024L)); - pthread_mutex_unlock(&THR_LOCK_malloc); - DBUG_VOID_RETURN; -} - - - /* Returns 0 if chunk is ok */ - -static int _checkchunk (register struct remember *pRec, const char *sFile, - uint uLine) -{ - reg1 uint uSize; - reg2 my_string magicp; - reg3 int flag=0; - - /* Check for a possible underrun */ - if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) - != MAGICKEY) - { - fprintf (stderr, "Memory allocated at %s:%d was underrun,", - pRec -> sFileName, pRec -> uLineNum); - fprintf (stderr, " discovered at %s:%d\n", sFile, uLine); - (void) fflush(stderr); - DBUG_PRINT("safe",("Underrun at %lx, allocated at %s:%d", - &(pRec -> aData[sf_malloc_prehunc]), - pRec -> sFileName, - pRec -> uLineNum)); - flag=1; - } - - /* Check for a possible overrun */ - uSize = pRec -> uDataSize; - magicp = &(pRec -> aData[uSize+sf_malloc_prehunc]); - if (*magicp++ != MAGICEND0 || - *magicp++ != MAGICEND1 || - *magicp++ != MAGICEND2 || - *magicp++ != MAGICEND3) - { - fprintf (stderr, "Memory allocated at %s:%d was overrun,", - pRec -> sFileName, pRec -> uLineNum); - fprintf (stderr, " discovered at '%s:%d'\n", sFile, uLine); - (void) fflush(stderr); - DBUG_PRINT("safe",("Overrun at %lx, allocated at %s:%d", - &(pRec -> aData[sf_malloc_prehunc]), - pRec -> sFileName, - pRec -> uLineNum)); - flag=1; - } - return(flag); -} - - - /* Returns how many wrong chunks */ - -int _sanity (const char *sFile, uint uLine) -{ - reg1 struct remember *pTmp; - reg2 int flag=0; - uint count=0; - - pthread_mutex_lock(&THR_LOCK_malloc); - count=cNewCount; - for (pTmp = pRememberRoot; pTmp != NULL && count-- ; pTmp = pTmp -> pNext) - flag+=_checkchunk (pTmp, sFile, uLine); - pthread_mutex_unlock(&THR_LOCK_malloc); - if (count || pTmp) - { - const char *format="Safemalloc link list destroyed, discovered at '%s:%d'"; - fprintf (stderr, format, sFile, uLine); fputc('\n',stderr); - (void) fflush(stderr); - DBUG_PRINT("safe",(format, sFile, uLine)); - flag=1; - } - return flag; -} /* _sanity */ - - - /* malloc and copy */ - -gptr _my_memdup(const byte *from, uint length, const char *sFile, uint uLine, - myf MyFlags) -{ - gptr ptr; - if ((ptr=_mymalloc(length,sFile,uLine,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return(ptr); -} /*_my_memdup */ - - -my_string _my_strdup(const char *from, const char *sFile, uint uLine, - myf MyFlags) -{ - gptr ptr; - uint length=(uint) strlen(from)+1; - if ((ptr=_mymalloc(length,sFile,uLine,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return((my_string) ptr); -} /* _my_strdup */ diff --git a/ext/mysql/libmysql/stamp-h.in b/ext/mysql/libmysql/stamp-h.in deleted file mode 100644 index 9788f70238..0000000000 --- a/ext/mysql/libmysql/stamp-h.in +++ /dev/null @@ -1 +0,0 @@ -timestamp diff --git a/ext/mysql/libmysql/str2int.c b/ext/mysql/libmysql/str2int.c deleted file mode 100644 index a9cb9911fc..0000000000 --- a/ext/mysql/libmysql/str2int.c +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - str2int(src, radix, lower, upper, &val) - converts the string pointed to by src to an integer and stores it in - val. It skips leading spaces and tabs (but not newlines, formfeeds, - backspaces), then it accepts an optional sign and a sequence of digits - in the specified radix. The result should satisfy lower <= *val <= upper. - The result is a pointer to the first character after the number; - trailing spaces will NOT be skipped. - - If an error is detected, the result will be NullS, the value put - in val will be 0, and errno will be set to - EDOM if there are no digits - ERANGE if the result would overflow or otherwise fail to lie - within the specified bounds. - Check that the bounds are right for your machine. - This looks amazingly complicated for what you probably thought was an - easy task. Coping with integer overflow and the asymmetric range of - twos complement machines is anything but easy. - - So that users of atoi and atol can check whether an error occured, - I have taken a wholly unprecedented step: errno is CLEARED if this - call has no problems. -*/ - -#include <global.h> -#include "m_string.h" -#include "m_ctype.h" -#include "my_sys.h" /* defines errno */ -#include <errno.h> - -#define char_val(X) (X >= '0' && X <= '9' ? X-'0' :\ - X >= 'A' && X <= 'Z' ? X-'A'+10 :\ - X >= 'a' && X <= 'z' ? X-'a'+10 :\ - '\177') - -char *str2int(register const char *src, register int radix, long int lower, long int upper, long int *val) -{ - int sign; /* is number negative (+1) or positive (-1) */ - int n; /* number of digits yet to be converted */ - long limit; /* "largest" possible valid input */ - long scale; /* the amount to multiply next digit by */ - long sofar; /* the running value */ - register int d; /* (negative of) next digit */ - char *start; - int digits[32]; /* Room for numbers */ - - /* Make sure *val is sensible in case of error */ - - *val = 0; - - /* Check that the radix is in the range 2..36 */ - -#ifndef DBUG_OFF - if (radix < 2 || radix > 36) { - errno=EDOM; - return NullS; - } -#endif - - /* The basic problem is: how do we handle the conversion of - a number without resorting to machine-specific code to - check for overflow? Obviously, we have to ensure that - no calculation can overflow. We are guaranteed that the - "lower" and "upper" arguments are valid machine integers. - On sign-and-magnitude, twos-complement, and ones-complement - machines all, if +|n| is representable, so is -|n|, but on - twos complement machines the converse is not true. So the - "maximum" representable number has a negative representative. - Limit is set to min(-|lower|,-|upper|); this is the "largest" - number we are concerned with. */ - - /* Calculate Limit using Scale as a scratch variable */ - - if ((limit = lower) > 0) limit = -limit; - if ((scale = upper) > 0) scale = -scale; - if (scale < limit) limit = scale; - - /* Skip leading spaces and check for a sign. - Note: because on a 2s complement machine MinLong is a valid - integer but |MinLong| is not, we have to keep the current - converted value (and the scale!) as *negative* numbers, - so the sign is the opposite of what you might expect. - */ - while (isspace(*src)) src++; - sign = -1; - if (*src == '+') src++; else - if (*src == '-') src++, sign = 1; - - /* Skip leading zeros so that we never compute a power of radix - in scale that we won't have a need for. Otherwise sticking - enough 0s in front of a number could cause the multiplication - to overflow when it neededn't. - */ - start=(char*) src; - while (*src == '0') src++; - - /* Move over the remaining digits. We have to convert from left - to left in order to avoid overflow. Answer is after last digit. - */ - - for (n = 0; (digits[n]=char_val(*src)) < radix && n < 20; n++,src++) ; - - /* Check that there is at least one digit */ - - if (start == src) { - errno=EDOM; - return NullS; - } - - /* The invariant we want to maintain is that src is just - to the right of n digits, we've converted k digits to - sofar, scale = -radix**k, and scale < sofar < 0. Now - if the final number is to be within the original - Limit, we must have (to the left)*scale+sofar >= Limit, - or (to the left)*scale >= Limit-sofar, i.e. the digits - to the left of src must form an integer <= (Limit-sofar)/(scale). - In particular, this is true of the next digit. In our - incremental calculation of Limit, - - IT IS VITAL that (-|N|)/(-|D|) = |N|/|D| - */ - - for (sofar = 0, scale = -1; --n >= 1;) - { - if ((long) -(d=digits[n]) < limit) { - errno=ERANGE; - return NullS; - } - limit = (limit+d)/radix, sofar += d*scale; scale *= radix; - } - if (n == 0) - { - if ((long) -(d=digits[n]) < limit) /* get last digit */ - { - errno=ERANGE; - return NullS; - } - sofar+=d*scale; - } - - /* Now it might still happen that sofar = -32768 or its equivalent, - so we can't just multiply by the sign and check that the result - is in the range lower..upper. All of this caution is a right - pain in the neck. If only there were a standard routine which - says generate thus and such a signal on integer overflow... - But not enough machines can do it *SIGH*. - */ - if (sign < 0) - { - if (sofar < -LONG_MAX || (sofar= -sofar) > upper) - { - errno=ERANGE; - return NullS; - } - } - else if (sofar < lower) - { - errno=ERANGE; - return NullS; - } - *val = sofar; - errno=0; /* indicate that all went well */ - return (char*) src; -} - - /* Theese are so slow compared with ordinary, optimized atoi */ - -#ifdef WANT_OUR_ATOI - -int atoi(const char *src) -{ - long val; - str2int(src, 10, (long) INT_MIN, (long) INT_MAX, &val); - return (int) val; -} - - -long atol(const char *src) -{ - long val; - str2int(src, 10, LONG_MIN, LONG_MAX, &val); - return val; -} - -#endif /* WANT_OUR_ATOI */ diff --git a/ext/mysql/libmysql/strcend.c b/ext/mysql/libmysql/strcend.c deleted file mode 100644 index ef4fb95d5c..0000000000 --- a/ext/mysql/libmysql/strcend.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : strcend.c - Author : Michael Widenius: ifdef MC68000 - Updated: 20 April 1984 - Defines: strcend() - - strcend(s, c) returns a pointer to the first place in s where c - occurs, or a pointer to the end-null of s if c does not occur in s. -*/ - -#include <global.h> -#include "m_string.h" - -#if defined(MC68000) && defined(DS90) - -char *strcend(const char *s, pchar c) -{ -asm(" movl 4(a7),a0 "); -asm(" movl 8(a7),d1 "); -asm(".L2: movb (a0)+,d0 "); -asm(" cmpb d0,d1 "); -asm(" beq .L1 "); -asm(" tstb d0 "); -asm(" bne .L2 "); -asm(".L1: movl a0,d0 "); -asm(" subql #1,d0 "); -} - -#else - -char *strcend(register const char *s, register pchar c) -{ - for (;;) - { - if (*s == (char) c) return (char*) s; - if (!*s++) return (char*) s-1; - } -} - -#endif diff --git a/ext/mysql/libmysql/strcont.c b/ext/mysql/libmysql/strcont.c deleted file mode 100644 index cc75ec450e..0000000000 --- a/ext/mysql/libmysql/strcont.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : strcont.c - Author : Monty - Updated: 1988.07.27 - Defines: strcont() - - strcont(str, set) if str contanies any character in the string set. - The result is the position of the first found character in str, or NullS - if there isn't anything found. - -*/ - -#include <global.h> -#include "m_string.h" - -my_string strcont(reg1 const char *str,reg2 const char *set) -{ - reg3 my_string start = (my_string) set; - - while (*str) - { - while (*set) - { - if (*set++ == *str) - return ((char*) str); - } - set=start; str++; - } - return (NullS); -} /* strcont */ diff --git a/ext/mysql/libmysql/strend.c b/ext/mysql/libmysql/strend.c deleted file mode 100644 index 18b9d1fbd0..0000000000 --- a/ext/mysql/libmysql/strend.c +++ /dev/null @@ -1,33 +0,0 @@ -/* File : strend.c - Author : Richard A. O'Keefe. - Updated: 23 April 1984 - Defines: strend() - - strend(s) returns a character pointer to the NUL which ends s. That - is, strend(s)-s == strlen(s). This is useful for adding things at - the end of strings. It is redundant, because strchr(s,'\0') could - be used instead, but this is clearer and faster. - Beware: the asm version works only if strlen(s) < 65535. -*/ - -#include <global.h> -#include "m_string.h" - -#if VaxAsm - -char *strend(s) -const char *s; -{ - asm("locc $0,$65535,*4(ap)"); - asm("movl r1,r0"); -} - -#else /* ~VaxAsm */ - -char *strend(register const char *s) -{ - while (*s++); - return (char*) (s-1); -} - -#endif /* VaxAsm */ diff --git a/ext/mysql/libmysql/strfill.c b/ext/mysql/libmysql/strfill.c deleted file mode 100644 index 2a8496b8b1..0000000000 --- a/ext/mysql/libmysql/strfill.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : strfill.c - Author : Monty - Updated: 1987.04.16 - Defines: strfill() - - strfill(dest, len, fill) makes a string of fill-characters. The result - string is of length == len. The des+len character is allways set to NULL. - strfill() returns pointer to dest+len; -*/ - -#include <global.h> -#include "m_string.h" - -my_string strfill(my_string s,uint len,pchar fill) -{ - while (len--) *s++ = fill; - *(s) = '\0'; - return(s); -} /* strfill */ diff --git a/ext/mysql/libmysql/string.c b/ext/mysql/libmysql/string.c deleted file mode 100644 index 5de6428242..0000000000 --- a/ext/mysql/libmysql/string.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Code for handling strings with can grow dynamicly. - Copyright Monty Program KB. - By monty. -*/ - -#include "mysys_priv.h" -#include <m_string.h> - -my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, - uint init_alloc, uint alloc_increment) -{ - uint length; - DBUG_ENTER("init_dynamic_string"); - - if (!alloc_increment) - alloc_increment=128; - length=1; - if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc) - init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment; - if (!init_alloc) - init_alloc=alloc_increment; - - if (!(str->str=(char*) my_malloc(init_alloc,MYF(MY_WME)))) - DBUG_RETURN(TRUE); - str->length=length-1; - if (init_str) - memcpy(str->str,init_str,length); - str->max_length=init_alloc; - str->alloc_increment=alloc_increment; - DBUG_RETURN(FALSE); -} - - -my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str) -{ - uint length=0; - DBUG_ENTER("dynstr_set"); - - if (init_str && (length= (uint) strlen(init_str)+1) > str->max_length) - { - str->max_length=((length+str->alloc_increment-1)/str->alloc_increment)* - str->alloc_increment; - if (!str->max_length) - str->max_length=str->alloc_increment; - if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME)))) - DBUG_RETURN(TRUE); - } - if (init_str) - { - str->length=length-1; - memcpy(str->str,init_str,length); - } - else - str->length=0; - DBUG_RETURN(FALSE); -} - - -my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size) -{ - DBUG_ENTER("dynstr_realloc"); - - if (!additional_size) DBUG_RETURN(FALSE); - if (str->length + additional_size > str->max_length) - { - str->max_length=((str->length + additional_size+str->alloc_increment-1)/ - str->alloc_increment)*str->alloc_increment; - if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME)))) - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} - - -my_bool dynstr_append(DYNAMIC_STRING *str, const char *append) -{ - return dynstr_append_mem(str,append,strlen(append)); -} - - -my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, - uint length) -{ - char *new_ptr; - if (str->length+length >= str->max_length) - { - uint new_length=(str->length+length+str->alloc_increment)/ - str->alloc_increment; - new_length*=str->alloc_increment; - if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME)))) - return TRUE; - str->str=new_ptr; - str->max_length=new_length; - } - memcpy(str->str + str->length,append,length); - str->length+=length; - str->str[str->length]=0; /* Safety for C programs */ - return FALSE; -} - - -void dynstr_free(DYNAMIC_STRING *str) -{ - if (str->str) - { - my_free(str->str,MYF(MY_WME)); - str->str=0; - } -} diff --git a/ext/mysql/libmysql/strinstr.c b/ext/mysql/libmysql/strinstr.c deleted file mode 100644 index ed165b9ce9..0000000000 --- a/ext/mysql/libmysql/strinstr.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : strinstr.c - Author : Monty & David - Updated: 1986.12.08 - Defines: strinstr() - - strinstr(src, pat) looks for an instance of pat in src. pat is not a - regex(3) pattern, it is a literal string which must be matched exactly. - The result 0 if the pattern was not found else it is the start char of - the pattern counted from the beginning of the string, where the first - char is 1. -*/ - -#include <global.h> -#include "m_string.h" - -uint strinstr(reg1 const char *str,reg4 const char *search) -{ - reg2 my_string i,j; - my_string start = (my_string) str; - - skipp: - while (*str != '\0') - { - if (*str++ == *search) - { - i=(my_string) str; j= (my_string) search+1; - while (*j) - if (*i++ != *j++) goto skipp; - return ((uint) (str - start)); - } - } - return (0); -} diff --git a/ext/mysql/libmysql/strmake.c b/ext/mysql/libmysql/strmake.c deleted file mode 100644 index 8bfe104aa5..0000000000 --- a/ext/mysql/libmysql/strmake.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* File : strmake.c - Author : Michael Widenius - Updated: 20 Jul 1984 - Defines: strmake() - - strmake(dst,src,length) moves length characters, or until end, of src to - dst and appends a closing NUL to dst. - Note that is strlen(src) >= length then dst[length] will be set to \0 - strmake() returns pointer to closing null -*/ - -#include <global.h> -#include "m_string.h" - -#ifdef BAD_STRING_COMPILER - -char *strmake(char *dst,const char *src,uint length) -{ - reg1 char *res; - - if ((res=memccpy(dst,src,0,length))) - return res-1; - dst[length]=0; - return dst+length; -} - -#define strmake strmake_overlapp /* Use orginal for overlapping str */ -#endif - -char *strmake(register char *dst, register const char *src, uint length) -{ - while (length--) - if (! (*dst++ = *src++)) - return dst-1; - *dst=0; - return dst; -} diff --git a/ext/mysql/libmysql/strmov.c b/ext/mysql/libmysql/strmov.c deleted file mode 100644 index 66e90a8d6c..0000000000 --- a/ext/mysql/libmysql/strmov.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - strmov(dst, src) moves all the characters of src (including the - closing NUL) to dst, and returns a pointer to the new closing NUL in - dst. The similar UNIX routine strcpy returns the old value of dst, - which I have never found useful. strmov(strmov(dst,a),b) moves a//b - into dst, which seems useful. -*/ - -#include <global.h> -#include "m_string.h" - -#ifdef BAD_STRING_COMPILER -#undef strmov -#define strmov strmov_overlapp -#endif - -#ifndef strmov - -#if !defined(MC68000) && !defined(DS90) - -char *strmov(register char *dst, register const char *src) -{ - while ((*dst++ = *src++)) ; - return dst-1; -} - -#else - -char *strmov(dst, src) - char *dst, *src; -{ - asm(" movl 4(a7),a1 "); - asm(" movl 8(a7),a0 "); - asm(".L4: movb (a0)+,(a1)+ "); - asm(" jne .L4 "); - asm(" movl a1,d0 "); - asm(" subql #1,d0 "); -} - -#endif - -#endif /* strmov */ diff --git a/ext/mysql/libmysql/strnmov.c b/ext/mysql/libmysql/strnmov.c deleted file mode 100644 index fd521fedea..0000000000 --- a/ext/mysql/libmysql/strnmov.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - strnmov(dst,src,length) moves length characters, or until end, of src to - dst and appends a closing NUL to dst if src is shorter than length. - The result is a pointer to the first NUL in dst, or is dst+n if dst was - truncated. -*/ - -#include <global.h> -#include "m_string.h" - -char *strnmov(register char *dst, register const char *src, uint n) -{ - while (n-- != 0) { - if (!(*dst++ = *src++)) { - return (char*) dst-1; - } - } - return dst; -} diff --git a/ext/mysql/libmysql/strto.c b/ext/mysql/libmysql/strto.c deleted file mode 100644 index b858ef19ea..0000000000 --- a/ext/mysql/libmysql/strto.c +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - strtol,strtoul,strtoll,strtoull - convert string to long, unsigned long, long long or unsigned long long. - strtoxx(char *src,char **ptr,int base) - converts the string pointed to by src to an long of appropriate long and - returnes it. It skips leading spaces and tabs (but not newlines, formfeeds, - backspaces), then it accepts an optional sign and a sequence of digits - in the specified radix. - If the value of ptr is not (char **)NULL, a pointer to the character - terminating the scan is returned in the location pointed to by ptr. - Trailing spaces will NOT be skipped. - - If an error is detected, the result will be LONG_MIN, 0 or LONG_MAX, - (or LONGLONG..) and errno will be set to - EDOM if there are no digits - ERANGE if the result would overflow. - the ptr will be set to src. - This file is based on the strtol from the the GNU C Library. - it can be compiled with the UNSIGNED and/or LONGLONG flag set -*/ - -#include <global.h> -#include "m_string.h" -#include "m_ctype.h" -#include "my_sys.h" /* defines errno */ -#include <errno.h> - -#undef strtoull -#undef strtoll -#undef strtoul -#undef strtol -#ifdef USE_LONGLONG -#define UTYPE_MAX (~(ulonglong) 0) -#define TYPE_MIN LONGLONG_MIN -#define TYPE_MAX LONGLONG_MAX -#define longtype longlong -#define ulongtype ulonglong -#ifdef USE_UNSIGNED -#define function ulongtype strtoull -#else -#define function longtype strtoll -#endif -#else -#define UTYPE_MAX (ulong) ~0L -#define TYPE_MIN LONG_MIN -#define TYPE_MAX LONG_MAX -#define longtype long -#define ulongtype unsigned long -#ifdef USE_UNSIGNED -#define function ulongtype strtoul -#else -#define function longtype strtol -#endif -#endif - - -/* Convert NPTR to an `unsigned long int' or `long int' in base BASE. - If BASE is 0 the base is determined by the presence of a leading - zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. - If BASE is < 2 or > 36, it is reset to 10. - If ENDPTR is not NULL, a pointer to the character after the last - one converted is stored in *ENDPTR. */ - - -function (const char *nptr,char **endptr,int base) -{ - int negative; - register ulongtype cutoff; - register unsigned int cutlim; - register ulongtype i; - register const char *s; - register unsigned char c; - const char *save; - int overflow; - - if (base < 0 || base == 1 || base > 36) - base = 10; - - s = nptr; - - /* Skip white space. */ - while (isspace (*s)) - ++s; - if (*s == '\0') - { - goto noconv; - } - - /* Check for a sign. */ - if (*s == '-') - { - negative = 1; - ++s; - } - else if (*s == '+') - { - negative = 0; - ++s; - } - else - negative = 0; - - if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X') - s += 2; - - /* If BASE is zero, figure it out ourselves. */ - if (base == 0) - { - if (*s == '0') - { - if (toupper (s[1]) == 'X') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - } - - /* Save the pointer so we can check later if anything happened. */ - save = s; - - cutoff = UTYPE_MAX / (unsigned long int) base; - cutlim = (uint) (UTYPE_MAX % (unsigned long int) base); - - overflow = 0; - i = 0; - for (c = *s; c != '\0'; c = *++s) - { - if (isdigit (c)) - c -= '0'; - else if (isalpha (c)) - c = toupper (c) - 'A' + 10; - else - break; - if (c >= base) - break; - /* Check for overflow. */ - if (i > cutoff || (i == cutoff && c > cutlim)) - overflow = 1; - else - { - i *= (ulongtype) base; - i += c; - } - } - - /* Check if anything actually happened. */ - if (s == save) - goto noconv; - - /* Store in ENDPTR the address of one character - past the last character we converted. */ - if (endptr != NULL) - *endptr = (char *) s; - -#ifndef USE_UNSIGNED - /* Check for a value that is within the range of - `unsigned long int', but outside the range of `long int'. */ - if (negative) - { - if (i > (ulongtype) TYPE_MIN) - overflow = 1; - } - else if (i > (ulongtype) TYPE_MAX) - overflow = 1; -#endif - - if (overflow) - { - my_errno=ERANGE; -#ifdef USE_UNSIGNED - return UTYPE_MAX; -#else - return negative ? TYPE_MIN : TYPE_MAX; -#endif - } - - /* Return the result of the appropriate sign. */ - return (negative ? -((longtype) i) : (longtype) i); - -noconv: - /* There was no number to convert. */ - my_errno=EDOM; - if (endptr != NULL) - *endptr = (char *) nptr; - return 0L; -} diff --git a/ext/mysql/libmysql/strtoll.c b/ext/mysql/libmysql/strtoll.c deleted file mode 100644 index d1d1e1e8b6..0000000000 --- a/ext/mysql/libmysql/strtoll.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* This is defines strtoll() if neaded */ - -#include <global.h> -#include <m_string.h> -#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG) -#define USE_LONGLONG -#include "strto.c" -#endif diff --git a/ext/mysql/libmysql/strtoull.c b/ext/mysql/libmysql/strtoull.c deleted file mode 100644 index 9dea75fd28..0000000000 --- a/ext/mysql/libmysql/strtoull.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* This is defines strtoull() */ - -#include <global.h> -#include <m_string.h> -#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG) -#define USE_UNSIGNED -#define USE_LONGLONG -#include "strto.c" -#endif diff --git a/ext/mysql/libmysql/strxmov.c b/ext/mysql/libmysql/strxmov.c deleted file mode 100644 index 7ee1d303ee..0000000000 --- a/ext/mysql/libmysql/strxmov.c +++ /dev/null @@ -1,33 +0,0 @@ -/* File : strxmov.c - Author : Richard A. O'Keefe. - Updated: 25 may 1984 - Defines: strxmov() - - strxmov(dst, src1, ..., srcn, NullS) - moves the concatenation of src1,...,srcn to dst, terminates it - with a NUL character, and returns a pointer to the terminating NUL. - It is just like strmov except that it concatenates multiple sources. - Beware: the last argument should be the null character pointer. - Take VERY great care not to omit it! Also be careful to use NullS - and NOT to use 0, as on some machines 0 is not the same size as a - character pointer, or not the same bit pattern as NullS. -*/ - -#include <global.h> -#include "m_string.h" -#include <stdarg.h> - -char *strxmov(char *dst,const char *src, ...) -{ - va_list pvar; - - va_start(pvar,src); - while (src != NullS) { - while ((*dst++ = *src++)) ; - dst--; - src = va_arg(pvar, char *); - } - va_end(pvar); - *dst = 0; /* there might have been no sources! */ - return dst; -} diff --git a/ext/mysql/libmysql/thr_alarm.h b/ext/mysql/libmysql/thr_alarm.h deleted file mode 100644 index c6d70029c5..0000000000 --- a/ext/mysql/libmysql/thr_alarm.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Prototypes when using thr_alarm library functions */ - -#ifndef _thr_alarm_h -#define _thr_alarm_h -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef USE_ALARM_THREAD -#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */ -#endif -#ifdef HAVE_LINUXTHREADS -#define THR_CLIENT_ALARM SIGALRM -#else -#define THR_CLIENT_ALARM SIGUSR1 -#endif -#ifdef HAVE_rts_threads -#undef USE_ONE_SIGNAL_HAND -#define USE_ALARM_THREAD -#define THR_SERVER_ALARM SIGUSR1 -#else -#define THR_SERVER_ALARM SIGALRM -#endif - -#if defined(DONT_USE_THR_ALARM) - -#define USE_ALARM_THREAD -#undef USE_ONE_SIGNAL_HAND - -typedef struct st_thr_alarm_entry -{ - uint crono; -} thr_alarm_entry; - -#define thr_alarm_init(A) (A)->crono=0 -#define thr_alarm_in_use(A) (A)->crono -#define init_thr_alarm(A) -#define thr_alarm_kill(A) -#define end_thr_alarm() -#define thr_alarm(A,B) (((A)->crono=1)-1) -#define thr_got_alarm(A) (A)->crono -#define thr_end_alarm(A) - -#else -#if defined(__WIN__) -typedef struct st_thr_alarm_entry -{ - rf_SetTimer crono; -} thr_alarm_entry; - -#elif defined(__EMX__) || defined(OS2) - -typedef struct st_thr_alarm_entry -{ - uint crono; - uint event; -} thr_alarm_entry; - -#else /* System with posix threads */ - -typedef int thr_alarm_entry; - -#define thr_got_alarm(thr_alarm) (**(thr_alarm)) - -#endif /* __WIN__ */ - -typedef thr_alarm_entry* thr_alarm_t; - -typedef struct st_alarm { - ulong expire_time; - thr_alarm_entry alarmed; /* set when alarm is due */ - pthread_t thread; - my_bool malloced; -} ALARM; - -#define thr_alarm_init(A) (*(A))=0 -#define thr_alarm_in_use(A) (*(A)!= 0) -void init_thr_alarm(uint max_alarm); -bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff); -void thr_alarm_kill(pthread_t thread_id); -void thr_end_alarm(thr_alarm_t *alarmed); -void end_thr_alarm(void); -sig_handler process_alarm(int); -#ifndef thr_got_alarm -bool thr_got_alarm(thr_alarm_t *alrm); -#endif - - -#endif /* DONT_USE_THR_ALARM */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* _thr_alarm_h */ - diff --git a/ext/mysql/libmysql/thr_mutex.c b/ext/mysql/libmysql/thr_mutex.c deleted file mode 100644 index 7ec8bfb59a..0000000000 --- a/ext/mysql/libmysql/thr_mutex.c +++ /dev/null @@ -1,217 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* This makes a wrapper for mutex handling to make it easier to debug mutex */ - -#include <global.h> -#if defined(HAVE_LINUXTHREADS) && !defined (__USE_UNIX98) -#define __USE_UNIX98 /* To get rw locks under Linux */ -#endif -#include <m_string.h> -#if defined(THREAD) && defined(SAFE_MUTEX) -#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */ -#include <my_pthread.h> - -#ifndef DO_NOT_REMOVE_THREAD_WRAPPERS -/* Remove wrappers */ -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_unlock -#undef pthread_mutex_destroy -#undef pthread_cond_wait -#undef pthread_cond_timedwait -#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT -#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b)) -#endif -#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */ - -int safe_mutex_init(safe_mutex_t *mp, - const pthread_mutexattr_t *attr __attribute__((unused))) -{ - bzero((char*) mp,sizeof(*mp)); - pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK); - pthread_mutex_init(&mp->mutex,attr); - return 0; -} - -int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) -{ - int error; - pthread_mutex_lock(&mp->global); - if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) - { - fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d\n", - file,line,mp->file,mp->line); - fflush(stderr); - abort(); - } - pthread_mutex_unlock(&mp->global); - error=pthread_mutex_lock(&mp->mutex); - if (error || (error=pthread_mutex_lock(&mp->global))) - { - fprintf(stderr,"Got error %d when trying to lock mutex at %s, line %d\n", - error, file, line); - fflush(stderr); - abort(); - } - if (mp->count++) - { - fprintf(stderr,"safe_mutex: Error in thread libray: Got mutex at %s, line %d more than 1 time\n", file,line); - fflush(stderr); - abort(); - } - mp->thread=pthread_self(); - mp->file= (char*) file; - mp->line=line; - pthread_mutex_unlock(&mp->global); - return error; -} - - -int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) -{ - int error; - pthread_mutex_lock(&mp->global); - if (mp->count == 0) - { - fprintf(stderr,"safe_mutex: Trying to unlock mutex that wasn't locked at %s, line %d\n Last used at %s, line: %d\n", - file,line,mp->file ? mp->file : "",mp->line); - fflush(stderr); - abort(); - } - if (!pthread_equal(pthread_self(),mp->thread)) - { - fprintf(stderr,"safe_mutex: Trying to unlock mutex at %s, line %d that was locked by another thread at: %s, line: %d\n", - file,line,mp->file,mp->line); - fflush(stderr); - abort(); - } - mp->count--; -#ifdef __WIN__ - pthread_mutex_unlock(&mp->mutex); - error=0; -#else - error=pthread_mutex_unlock(&mp->mutex); - if (error) - { - fprintf(stderr,"safe_mutex: Got error: %d when trying to unlock mutex at %s, line %d\n", error, file, line); - fflush(stderr); - abort(); - } -#endif /* __WIN__ */ - pthread_mutex_unlock(&mp->global); - return error; -} - - -int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, - uint line) -{ - int error; - pthread_mutex_lock(&mp->global); - if (mp->count == 0) - { - fprintf(stderr,"safe_mutex: Trying to cond_wait on a unlocked mutex at %s, line %d\n",file,line); - fflush(stderr); - abort(); - } - if (!pthread_equal(pthread_self(),mp->thread)) - { - fprintf(stderr,"safe_mutex: Trying to cond_wait on a mutex at %s, line %d that was locked by another thread at: %s, line: %d\n", - file,line,mp->file,mp->line); - fflush(stderr); - abort(); - } - - if (mp->count-- != 1) - { - fprintf(stderr,"safe_mutex: Count was %d on locked mutex at %s, line %d\n", - mp->count+1, file, line); - fflush(stderr); - abort(); - } - pthread_mutex_unlock(&mp->global); - error=pthread_cond_wait(cond,&mp->mutex); - pthread_mutex_lock(&mp->global); - if (error) - { - fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_wait at %s, line %d\n", error, file, line); - fflush(stderr); - abort(); - } - if (mp->count++) - { - fprintf(stderr, - "safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d\n", - mp->count-1, my_thread_id(), file, line); - fflush(stderr); - abort(); - } - mp->thread=pthread_self(); - mp->file= (char*) file; - mp->line=line; - pthread_mutex_unlock(&mp->global); - return error; -} - - -int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, - struct timespec *abstime, - const char *file, uint line) -{ - int error; - pthread_mutex_lock(&mp->global); - if (mp->count != 1 || !pthread_equal(pthread_self(),mp->thread)) - { - fprintf(stderr,"safe_mutex: Trying to cond_wait at %s, line %d on a not hold mutex\n",file,line); - fflush(stderr); - abort(); - } - mp->count--; /* Mutex will be released */ - pthread_mutex_unlock(&mp->global); - error=pthread_cond_timedwait(cond,&mp->mutex,abstime); -#ifdef EXTRA_DEBUG - if (error && (error != EINTR && error != ETIMEDOUT)) - { - fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_timedwait at %s, line %d\n", error, file, line); - } -#endif - pthread_mutex_lock(&mp->global); - if (mp->count++) - { - fprintf(stderr, - "safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d)\n", - mp->count-1, my_thread_id(), file, line, error); - fflush(stderr); - abort(); - } - mp->thread=pthread_self(); - mp->file= (char*) file; - mp->line=line; - pthread_mutex_unlock(&mp->global); - return error; -} - -int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) -{ - int error=0; - if (mp->count != 0) - { - fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n", - mp->file,mp->line, file, line); - fflush(stderr); - abort(); - } -#ifdef __WIN__ - pthread_mutex_destroy(&mp->global); - pthread_mutex_destroy(&mp->mutex); -#else - if (pthread_mutex_destroy(&mp->global)) - error=1; - if (pthread_mutex_destroy(&mp->mutex)) - error=1; -#endif - return error; -} - -#endif /* THREAD && SAFE_MUTEX */ diff --git a/ext/mysql/libmysql/typelib.c b/ext/mysql/libmysql/typelib.c deleted file mode 100644 index 0fd4415b2c..0000000000 --- a/ext/mysql/libmysql/typelib.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* Functions to handle typelib */ - -#include "mysys_priv.h" -#include <m_string.h> -#include <m_ctype.h> - -/*************************************************************************** -** Search after a fieldtype. Endspace in x is not compared. -** If part, uniq field is found and full_name == 0 then x is expanded -** to full field. -** full_name has the following bit values: -** If & 1 accept only whole names -** If & 2 don't expand if half field -** If & 4 allow #number# as type -****************************************************************************/ - -int find_type(my_string x, TYPELIB *typelib, uint full_name) -{ - int find,pos,findpos; - reg1 my_string i; - reg2 const char *j; - DBUG_ENTER("find_type"); - DBUG_PRINT("enter",("x: '%s' lib: %lx",x,typelib)); - - if (!typelib->count) - { - DBUG_PRINT("exit",("no count")); - DBUG_RETURN(0); - } - LINT_INIT(findpos); - find=0; - for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) - { - for (i=x ; *i && toupper(*i) == toupper(*j) ; i++, j++) ; - if (! *j) - { - while (*i == ' ') - i++; /* skipp_end_space */ - if (! *i) - DBUG_RETURN(pos+1); - } - if (! *i && (!*j || !(full_name & 1))) - { - find++; - findpos=pos; - } - } - if (find == 0 && (full_name & 4) && x[0] == '#' && strend(x)[-1] == '#' && - (findpos=atoi(x+1)-1) >= 0 && (uint) findpos < typelib->count) - find=1; - else if (find == 0 || ! x[0]) - { - DBUG_PRINT("exit",("Couldn't find type")); - DBUG_RETURN(0); - } - else if (find != 1 || (full_name & 1)) - { - DBUG_PRINT("exit",("Too many possybilities")); - DBUG_RETURN(-1); - } - if (!(full_name & 2)) - (void) strmov(x,typelib->type_names[findpos]); - DBUG_RETURN(findpos+1); -} /* find_type */ - - - /* Get name of type nr 'nr' */ - /* Warning first type is 1, 0 = empty field */ - -void make_type(register my_string to, register uint nr, register TYPELIB *typelib) -{ - DBUG_ENTER("make_type"); - if (!nr) - to[0]=0; - else - (void) strmov(to,get_type(typelib,nr-1)); - DBUG_VOID_RETURN; -} /* make_type */ - - - /* Get type */ - /* Warning first type is 0 */ - -const char *get_type(TYPELIB *typelib, uint nr) -{ - if (nr < (uint) typelib->count && typelib->type_names) - return(typelib->type_names[nr]); - return "?"; -} diff --git a/ext/mysql/libmysql/update_sources b/ext/mysql/libmysql/update_sources deleted file mode 100755 index 87547e483e..0000000000 --- a/ext/mysql/libmysql/update_sources +++ /dev/null @@ -1,103 +0,0 @@ -#! /usr/bin/perl -w - -# Maybe I should have used PHP instead? ;) - -use strict; -$| = 1; - --f "libmysql.c" or die "$0 must be run from the libmysql directory\n"; - -my $command = shift || usage(); -$command =~ /^--(?:update|huh|restore)$/ or usage(); - -my $from = shift || '/my/mysql'; -my @source_dirs = qw/dbug strings mysys libmysql include/; -my $source_re = qr/\.(?:cc?|h)$/; -my %skip = ( - 'ctype_autoconf.c' => 1, # PHP uses a pre-made one - 'ctype_extra_sources.c' => 1, # same here - 'my_config.h' => 1, # we use php_config.h -); - -opendir D, "." - or die "can't opendir .: $!\n"; -my @files = grep { /$source_re/ and !$skip{$_} } readdir D; -closedir D; - -if ($command eq '--restore') -{ - foreach (@files) - { - -f "$_.orig" and - system("mv -f $_.orig $_") and die "can't restore $_: $!\n"; - } - exit 0; -} - -if ($command eq '--huh') -{ - diff_files(); - exit 0; -} - -my %sources; -foreach my $d (@source_dirs) -{ - opendir D, "$from/$d" or die "opendir $from/$d: $!\n"; - foreach (grep { /$source_re/ } readdir D) - { - $sources{$_} ||= "$d/$_"; - } - closedir D; -} - -foreach my $f (@files) -{ - my $s = $sources{$f} or die "can't find source file for $f\n"; - unlink "$f.orig"; - system("mv $f $f.orig") and die "can't move $f: $!\n"; - #print ">> ", scalar(`ls -l $from/$s`), "\n"; - print ">> $s\n"; - system("cp $from/$s $f") and die "can't copy $from/$s: $!\n"; - #print "]] ", scalar(`ls -l $f`), "\n"; -} - -system("chmod u+w @files") and die "can't set perms on files: $!\n"; -system("./fix_copyright @files") and die "can't fix copyright: $!\n"; -diff_files(); - -exit 0; - - -sub usage -{ - die <<"EOF"; -usage: $0 --update [mysql-source-dir] - $0 --huh - $0 --restore - - Typical use is: - \$ $0 --update 2>&1 > /tmp/php-update.diff - \$ @{[$ENV{EDITOR}||'vi']} /tmp/php-update.diff #does it look okay? - \$ Monkey around a bit - \$ cvs diff -u | less # does this look okay? - \$ rm *.orig -EOF -} - -sub diff_files { - foreach my $f (@files) - { - if (!-f "$f.orig" or !system("diff -u $f.orig $f")) - { - print STDERR "SAME: $f\n"; - unlink "$f.orig"; - } - else - { - print STDERR "DIFF: $f\n"; - $f eq 'config-win.h' and - print STDERR "/n/nDon't forget to undefine HAVE_COMPRESS in $f/n/n/n"; - } - } -} diff --git a/ext/mysql/libmysql/violite.c b/ext/mysql/libmysql/violite.c deleted file mode 100644 index 957f8400ac..0000000000 --- a/ext/mysql/libmysql/violite.c +++ /dev/null @@ -1,429 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - Note that we can't have assertion on file descriptors; The reason for - this is that during mysql shutdown, another thread can close a file - we are working on. In this case we should just return read errors from - the file descriptior. -*/ - -#include <global.h> - -#ifndef HAVE_VIO /* is Vio suppored by the Vio lib ? */ - -#include <errno.h> -#include <assert.h> -#include <violite.h> -#include <my_sys.h> -#include <my_net.h> -#include <m_string.h> -#ifdef HAVE_POLL -#include <sys/poll.h> -#endif -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif - -#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__FreeBSD__) -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#if !defined(alpha_linux_port) -#include <netinet/tcp.h> -#endif -#endif - -#if defined(__EMX__) || defined(OS2) -#define ioctlsocket ioctl -#endif /* defined(__EMX__) */ - -#if defined(MSDOS) || defined(__WIN__) -#define O_NONBLOCK 1 /* For emulation of fcntl() */ -#endif -#ifndef EWOULDBLOCK -#define SOCKET_EWOULDBLOCK SOCKET_EAGAIN -#endif - -#ifndef __WIN__ -#define HANDLE void * -#endif - -struct st_vio -{ - my_socket sd; /* my_socket - real or imaginary */ - HANDLE hPipe; - my_bool localhost; /* Are we from localhost? */ - int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */ - struct sockaddr_in local; /* Local internet address */ - struct sockaddr_in remote; /* Remote internet address */ - enum enum_vio_type type; /* Type of connection */ - char desc[30]; /* String description */ -}; - -typedef void *vio_ptr; -typedef char *vio_cstring; - -/* - * Helper to fill most of the Vio* with defaults. - */ - -static void vio_reset(Vio* vio, enum enum_vio_type type, - my_socket sd, HANDLE hPipe, - my_bool localhost) -{ - bzero((char*) vio, sizeof(*vio)); - vio->type = type; - vio->sd = sd; - vio->hPipe = hPipe; - vio->localhost= localhost; -} - -/* Open the socket or TCP/IP connection and read the fnctl() status */ - -Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) -{ - Vio *vio; - DBUG_ENTER("vio_new"); - DBUG_PRINT("enter", ("sd=%d", sd)); - if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME)))) - { - vio_reset(vio, type, sd, 0, localhost); - sprintf(vio->desc, - (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"), - vio->sd); -#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) -#if !defined(NO_FCNTL_NONBLOCK) - vio->fcntl_mode = fcntl(sd, F_GETFL); -#elif defined(HAVE_SYS_IOCTL_H) /* hpux */ - /* Non blocking sockets doesn't work good on HPUX 11.0 */ - (void) ioctl(sd,FIOSNBIO,0); -#endif -#else /* !defined(__WIN__) && !defined(__EMX__) */ - { - /* set to blocking mode by default */ - ulong arg=0, r; - r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg)); - } -#endif - } - DBUG_RETURN(vio); -} - - -#ifdef __WIN__ - -Vio *vio_new_win32pipe(HANDLE hPipe) -{ - Vio *vio; - DBUG_ENTER("vio_new_handle"); - if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME)))) - { - vio_reset(vio, VIO_TYPE_NAMEDPIPE, 0, hPipe, TRUE); - strmov(vio->desc, "named pipe"); - } - DBUG_RETURN(vio); -} - -#endif - -void vio_delete(Vio * vio) -{ - /* It must be safe to delete null pointers. */ - /* This matches the semantics of C++'s delete operator. */ - if (vio) - { - if (vio->type != VIO_CLOSED) - vio_close(vio); - my_free((gptr) vio,MYF(0)); - } -} - -int vio_errno(Vio *vio __attribute__((unused))) -{ - return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ -} - - -int vio_read(Vio * vio, gptr buf, int size) -{ - int r; - DBUG_ENTER("vio_read"); - DBUG_PRINT("enter", ("sd=%d size=%d", vio->sd, size)); -#if defined( __WIN__) || defined(OS2) - if (vio->type == VIO_TYPE_NAMEDPIPE) - { - DWORD length; -#ifdef OS2 - if (!DosRead((HFILE)vio->hPipe, buf, size, &length)) - DBUG_RETURN(-1); -#else - if (!ReadFile(vio->hPipe, buf, size, &length, NULL)) - DBUG_RETURN(-1); -#endif - DBUG_RETURN(length); - } - r = recv(vio->sd, buf, size,0); -#else - errno=0; /* For linux */ - r = read(vio->sd, buf, size); -#endif /* __WIN__ */ -#ifndef DBUG_OFF - if (r < 0) - { - DBUG_PRINT("vio_error", ("Got error %d during read",socket_errno)); - } -#endif /* DBUG_OFF */ - DBUG_PRINT("exit", ("%d", r)); - DBUG_RETURN(r); -} - - -int vio_write(Vio * vio, const gptr buf, int size) -{ - int r; - DBUG_ENTER("vio_write"); - DBUG_PRINT("enter", ("sd=%d size=%d", vio->sd, size)); -#if defined( __WIN__) || defined(OS2) - if ( vio->type == VIO_TYPE_NAMEDPIPE) - { - DWORD length; -#ifdef OS2 - if (!DosWrite((HFILE)vio->hPipe, (char*) buf, size, &length)) - DBUG_RETURN(-1); -#else - if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL)) - DBUG_RETURN(-1); -#endif - DBUG_RETURN(length); - } - r = send(vio->sd, buf, size,0); -#else - r = write(vio->sd, buf, size); -#endif /* __WIN__ */ -#ifndef DBUG_OFF - if (r < 0) - { - DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno)); - } -#endif /* DBUG_OFF */ - DBUG_PRINT("exit", ("%d", r)); - DBUG_RETURN(r); -} - - -int vio_blocking(Vio * vio, my_bool set_blocking_mode) -{ - int r=0; - DBUG_ENTER("vio_blocking"); - DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode)); - -#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) -#if !defined(NO_FCNTL_NONBLOCK) - - if (vio->sd >= 0) - { - int old_fcntl=vio->fcntl_mode; - if (set_blocking_mode) - vio->fcntl_mode &= ~O_NONBLOCK; /* clear bit */ - else - vio->fcntl_mode |= O_NONBLOCK; /* set bit */ - if (old_fcntl != vio->fcntl_mode) - r = fcntl(vio->sd, F_SETFL, vio->fcntl_mode); - } -#endif /* !defined(NO_FCNTL_NONBLOCK) */ -#else /* !defined(__WIN__) && !defined(__EMX__) */ -#ifndef __EMX__ - if (vio->type != VIO_TYPE_NAMEDPIPE) -#endif - { - ulong arg; - int old_fcntl=vio->fcntl_mode; - if (set_blocking_mode) - { - arg = 0; - vio->fcntl_mode &= ~O_NONBLOCK; /* clear bit */ - } - else - { - arg = 1; - vio->fcntl_mode |= O_NONBLOCK; /* set bit */ - } - if (old_fcntl != vio->fcntl_mode) - r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg)); - } -#endif /* !defined(__WIN__) && !defined(__EMX__) */ - DBUG_RETURN(r); -} - -my_bool -vio_is_blocking(Vio * vio) -{ - my_bool r; - DBUG_ENTER("vio_is_blocking"); - r = !(vio->fcntl_mode & O_NONBLOCK); - DBUG_PRINT("exit", ("%d", (int) r)); - DBUG_RETURN(r); -} - - -int vio_fastsend(Vio * vio __attribute__((unused))) -{ - int r=0; - DBUG_ENTER("vio_fastsend"); - -#ifdef IPTOS_THROUGHPUT - { -#ifndef __EMX__ - int tos = IPTOS_THROUGHPUT; - if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) -#endif /* !__EMX__ */ - { - int nodelay = 1; - if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, - sizeof(nodelay))) { - DBUG_PRINT("warning", - ("Couldn't set socket option for fast send")); - r= -1; - } - } - } -#endif /* IPTOS_THROUGHPUT */ - DBUG_PRINT("exit", ("%d", r)); - DBUG_RETURN(r); -} - -int vio_keepalive(Vio* vio, my_bool set_keep_alive) -{ - int r=0; - uint opt = 0; - DBUG_ENTER("vio_keepalive"); - DBUG_PRINT("enter", ("sd=%d set_keep_alive=%d", vio->sd, (int) - set_keep_alive)); - if (vio->type != VIO_TYPE_NAMEDPIPE) - { - if (set_keep_alive) - opt = 1; - r = setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt, - sizeof(opt)); - } - DBUG_RETURN(r); -} - - -my_bool -vio_should_retry(Vio * vio __attribute__((unused))) -{ - int en = socket_errno; - return en == SOCKET_EAGAIN || en == SOCKET_EINTR || en == SOCKET_EWOULDBLOCK; -} - - -int vio_close(Vio * vio) -{ - int r; - DBUG_ENTER("vio_close"); -#ifdef __WIN__ - if (vio->type == VIO_TYPE_NAMEDPIPE) - { -#if defined(__NT__) && defined(MYSQL_SERVER) - CancelIo(vio->hPipe); - DisconnectNamedPipe(vio->hPipe); -#endif - r=CloseHandle(vio->hPipe); - } - else if (vio->type != VIO_CLOSED) -#endif /* __WIN__ */ - { - r=0; - if (shutdown(vio->sd,2)) - r= -1; - if (closesocket(vio->sd)) - r= -1; - } - if (r) - { - DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno)); - /* FIXME: error handling (not critical for MySQL) */ - } - vio->type= VIO_CLOSED; - vio->sd= -1; - DBUG_RETURN(r); -} - - -const char *vio_description(Vio * vio) -{ - return vio->desc; -} - -enum enum_vio_type vio_type(Vio* vio) -{ - return vio->type; -} - -my_socket vio_fd(Vio* vio) -{ - return vio->sd; -} - - -my_bool vio_peer_addr(Vio * vio, char *buf) -{ - DBUG_ENTER("vio_peer_addr"); - DBUG_PRINT("enter", ("sd=%d", vio->sd)); - if (vio->localhost) - { - strmov(buf,"127.0.0.1"); - } - else - { - size_socket addrLen = sizeof(struct sockaddr); - if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), - &addrLen) != 0) - { - DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno)); - DBUG_RETURN(1); - } - my_inet_ntoa(vio->remote.sin_addr,buf); - } - DBUG_PRINT("exit", ("addr=%s", buf)); - DBUG_RETURN(0); -} - - -void vio_in_addr(Vio *vio, struct in_addr *in) -{ - DBUG_ENTER("vio_in_addr"); - if (vio->localhost) - bzero((char*) in, sizeof(*in)); /* This should never be executed */ - else - *in=vio->remote.sin_addr; - DBUG_VOID_RETURN; -} - - -/* Return 0 if there is data to be read */ - -my_bool vio_poll_read(Vio *vio,uint timeout) -{ -#ifndef HAVE_POLL - return 0; -#else - struct pollfd fds; - int res; - DBUG_ENTER("vio_poll"); - fds.fd=vio->sd; - fds.events=POLLIN; - fds.revents=0; - if ((res=poll(&fds,1,(int) timeout*1000)) <= 0) - { - DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */ - } - DBUG_RETURN(fds.revents & POLLIN ? 0 : 1); -#endif -} - -#endif /* HAVE_VIO */ diff --git a/ext/mysql/libmysql/violite.h b/ext/mysql/libmysql/violite.h deleted file mode 100644 index e764ca02bd..0000000000 --- a/ext/mysql/libmysql/violite.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* - * Vio Lite. - * Purpose: include file for Vio that will work with C and C++ - */ - -#ifndef vio_violite_h_ -#define vio_violite_h_ - -#include "my_net.h" /* needed because of struct in_addr */ - -#ifdef HAVE_VIO -#include <Vio.h> /* Full VIO interface */ -#else - -/* Simple vio interface in C; The functions are implemented in violite.c */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef Vio_defined -#define Vio_defined -struct st_vio; /* Only C */ -typedef struct st_vio Vio; -#endif - -enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, - VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL}; - -Vio* vio_new(my_socket sd, - enum enum_vio_type type, - my_bool localhost); -#ifdef __WIN__ -Vio* vio_new_win32pipe(HANDLE hPipe); -#endif -void vio_delete(Vio* vio); - -/* - * vio_read and vio_write should have the same semantics - * as read(2) and write(2). - */ -int vio_read( Vio* vio, - gptr buf, int size); -int vio_write( Vio* vio, - const gptr buf, - int size); -/* - * Whenever the socket is set to blocking mode or not. - */ -int vio_blocking( Vio* vio, - my_bool onoff); -my_bool vio_is_blocking( Vio* vio); -/* - * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. - */ - int vio_fastsend( Vio* vio); -/* - * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. - */ -int vio_keepalive( Vio* vio, - my_bool onoff); -/* - * Whenever we should retry the last read/write operation. - */ -my_bool vio_should_retry( Vio* vio); -/* - * When the workday is over... - */ -int vio_close( Vio* vio); -/* - * Short text description of the socket for those, who are curious.. - */ -const char* vio_description( Vio* vio); - -/* Return the type of the connection */ - enum enum_vio_type vio_type(Vio* vio); - -/* Return last error number */ -int vio_errno(Vio *vio); - -/* Get socket number */ -my_socket vio_fd(Vio *vio); - -/* - * Remote peer's address and name in text form. - */ -my_bool vio_peer_addr(Vio * vio, char *buf); - -/* Remotes in_addr */ - -void vio_in_addr(Vio *vio, struct in_addr *in); - - /* Return 1 if there is data to be read */ -my_bool vio_poll_read(Vio *vio,uint timeout); - -#ifdef __cplusplus -} -#endif -#endif /* HAVE_VIO */ -#endif /* vio_violite_h_ */ |