WL#5498: Remove dead and unused source code

Remove unused source code and associated paraphernalia.
This commit is contained in:
Davi Arnaut 2010-07-23 17:14:35 -03:00
commit 7a221fc9a3
33 changed files with 28 additions and 1703 deletions

View file

@ -17,23 +17,23 @@
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c
errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_bit.c my_bitmap.c my_chsize.c
my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
thr_rwlock.c tree.c typelib.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c
my_rdtsc.c)

View file

@ -24,31 +24,29 @@ LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug
noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_open.c my_create.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \
mf_keycaches.c my_crc32.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_once.c mulalloc.c \
my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \
my_alloc.c my_new.cc my_atomic.c lf_hash.c \
lf_dynarray.c lf_alloc-pin.c \
my_fopen.c my_fstream.c my_getsystime.c \
my_error.c errors.c my_div.c my_mess.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
mf_pack.c mf_unixpath.c mf_arr_appstr.c \
mf_wcomp.c mf_wfile.c my_gethwaddr.c \
mf_wcomp.c my_gethwaddr.c \
mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c my_getncpus.c \
tree.c trie.c list.c hash.c array.c string.c typelib.c \
my_copy.c my_append.c my_lib.c \
tree.c list.c hash.c array.c string.c typelib.c \
my_copy.c my_lib.c \
my_delete.c my_rename.c my_redel.c \
my_chsize.c my_clock.c \
my_quick.c my_lockmem.c my_static.c \
my_chsize.c my_quick.c my_lockmem.c my_static.c \
my_sync.c my_getopt.c my_mkdir.c \
default_modify.c default.c \
my_compress.c checksum.c \
my_net.c my_port.c my_sleep.c \
default.c my_compress.c checksum.c \
my_port.c my_sleep.c \
charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_largepage.c \

View file

@ -1,252 +0,0 @@
/* Copyright (C) 2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "my_global.h"
#include "mysys_priv.h"
#include "m_string.h"
#include <my_dir.h>
#define BUFF_SIZE 1024
#define RESERVE 1024 /* Extend buffer with this extent */
#ifdef _WIN32
#define NEWLINE "\r\n"
#define NEWLINE_LEN 2
#else
#define NEWLINE "\n"
#define NEWLINE_LEN 1
#endif
static char *add_option(char *dst, const char *option_value,
const char *option, int remove_option);
/*
Add/remove option to the option file section.
SYNOPSYS
modify_defaults_file()
file_location The location of configuration file to edit
option The name of the option to look for (can be NULL)
option value The value of the option we would like to set (can be NULL)
section_name The name of the section (must be NOT NULL)
remove_option This defines what we want to remove:
- MY_REMOVE_NONE -- nothing to remove;
- MY_REMOVE_OPTION -- remove the specified option;
- MY_REMOVE_SECTION -- remove the specified section;
IMPLEMENTATION
We open the option file first, then read the file line-by-line,
looking for the section we need. At the same time we put these lines
into a buffer. Then we look for the option within this section and
change/remove it. In the end we get a buffer with modified version of the
file. Then we write it to the file, truncate it if needed and close it.
Note that there is a small time gap, when the file is incomplete,
and this theoretically might introduce a problem.
RETURN
0 - ok
1 - some error has occured. Probably due to the lack of resourses
2 - cannot open the file
*/
int modify_defaults_file(const char *file_location, const char *option,
const char *option_value,
const char *section_name, int remove_option)
{
FILE *cnf_file;
MY_STAT file_stat;
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended;
uint nr_newlines= 0, buffer_size;
my_bool in_section= FALSE, opt_applied= 0;
int reserve_occupied= 0;
DBUG_ENTER("modify_defaults_file");
if (!(cnf_file= my_fopen(file_location, O_RDWR | O_BINARY, MYF(0))))
DBUG_RETURN(2);
/* my_fstat doesn't use the flag parameter */
if (my_fstat(my_fileno(cnf_file), &file_stat, MYF(0)))
goto malloc_err;
if (option && option_value)
{
opt_len= strlen(option);
optval_len= strlen(option_value);
}
new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN;
/* calculate the size of the buffer we need */
reserve_extended= (opt_len +
1 + /* For '=' char */
optval_len + /* Option value len */
NEWLINE_LEN + /* Space for newline */
RESERVE); /* Some additional space */
buffer_size= (file_stat.st_size +
1); /* The ending zero */
/*
Reserve space to read the contents of the file and some more
for the option we want to add.
*/
if (!(file_buffer= (char*) my_malloc(buffer_size + reserve_extended,
MYF(MY_WME))))
goto malloc_err;
sect_len= strlen(section_name);
for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); )
{
/* Skip over whitespaces */
for (src_ptr= linebuff; my_isspace(&my_charset_latin1, *src_ptr);
src_ptr++)
{}
if (!*src_ptr) /* Empty line */
{
nr_newlines++;
continue;
}
/* correct the option (if requested) */
if (option && in_section && !strncmp(src_ptr, option, opt_len) &&
(*(src_ptr + opt_len) == '=' ||
my_isspace(&my_charset_latin1, *(src_ptr + opt_len)) ||
*(src_ptr + opt_len) == '\0'))
{
char *old_src_ptr= src_ptr;
src_ptr= strend(src_ptr+ opt_len); /* Find the end of the line */
/* could be negative */
reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr);
if (reserve_occupied >= (int) reserve_extended)
{
reserve_extended= (uint) reserve_occupied + RESERVE;
if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size +
reserve_extended,
MYF(MY_WME|MY_FREE_ON_ERROR))))
goto malloc_err;
}
opt_applied= 1;
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
}
else
{
/*
If we are going to the new group and have an option to apply, do
it now. If we are removing a single option or the whole section
this will only trigger opt_applied flag.
*/
if (in_section && !opt_applied && *src_ptr == '[')
{
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
opt_applied= 1; /* set the flag to do write() later */
reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN;
}
for (; nr_newlines; nr_newlines--)
dst_ptr= strmov(dst_ptr, NEWLINE);
/* Skip the section if MY_REMOVE_SECTION was given */
if (!in_section || remove_option != MY_REMOVE_SECTION)
dst_ptr= strmov(dst_ptr, linebuff);
}
/* Look for a section */
if (*src_ptr == '[')
{
/* Copy the line to the buffer */
if (!strncmp(++src_ptr, section_name, sect_len))
{
src_ptr+= sect_len;
/* Skip over whitespaces. They are allowed after section name */
for (; my_isspace(&my_charset_latin1, *src_ptr); src_ptr++)
{}
if (*src_ptr != ']')
{
in_section= FALSE;
continue; /* Missing closing parenthesis. Assume this was no group */
}
if (remove_option == MY_REMOVE_SECTION)
dst_ptr= dst_ptr - strlen(linebuff);
in_section= TRUE;
}
else
in_section= FALSE; /* mark that this section is of no interest to us */
}
}
/*
File ended. Apply an option or set opt_applied flag (in case of
MY_REMOVE_SECTION) so that the changes are saved. Do not do anything
if we are removing non-existent option.
*/
if (!opt_applied && in_section && (remove_option != MY_REMOVE_OPTION))
{
/* New option still remains to apply at the end */
if (!remove_option && *(dst_ptr - 1) != '\n')
dst_ptr= strmov(dst_ptr, NEWLINE);
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
opt_applied= 1;
}
for (; nr_newlines; nr_newlines--)
dst_ptr= strmov(dst_ptr, NEWLINE);
if (opt_applied)
{
/* Don't write the file if there are no changes to be made */
if (my_chsize(my_fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
MYF(MY_WME)) ||
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer),
MYF(MY_NABP)))
goto err;
}
if (my_fclose(cnf_file, MYF(MY_WME)))
DBUG_RETURN(1);
my_free(file_buffer);
DBUG_RETURN(0);
err:
my_free(file_buffer);
malloc_err:
my_fclose(cnf_file, MYF(0));
DBUG_RETURN(1); /* out of resources */
}
static char *add_option(char *dst, const char *option_value,
const char *option, int remove_option)
{
if (!remove_option)
{
dst= strmov(dst, option);
if (*option_value)
{
*dst++= '=';
dst= strmov(dst, option_value);
}
/* add a newline */
dst= strmov(dst, NEWLINE);
}
return dst;
}

View file

@ -1,71 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* make-conf.c
* make a charset .conf file out of a ctype-charset.c file.
*/
#ifndef CHARSET
#error You must define the charset, e.g.: -DCHARSET=latin1
#endif
/* some pre-processor tricks to get us going */
#define _STRINGIZE_HELPER(x) #x
#define STRINGIZE(x) _STRINGIZE_HELPER(x)
#define _JOIN_WORDS_HELPER(a, b) a ## b
#define JOIN_WORDS(a, b) _JOIN_WORDS_HELPER(a, b)
#define CH_SRC ctype- ## CHARSET ## .c
#define CH_INCLUDE STRINGIZE(CH_SRC)
/* aaaah, that's better */
#include <my_my_global.h>
#include CH_INCLUDE
#include <stdio.h>
#include <stdlib.h>
#define ROW_LEN 16
void print_array(const char *name, const uchar *array, uint size);
int main(void)
{
printf("# Configuration file for the "
STRINGIZE(CHARSET)
" character set.\n");
print_array("ctype", JOIN_WORDS(ctype_, CHARSET), 257);
print_array("to_lower", JOIN_WORDS(to_lower_, CHARSET), 256);
print_array("to_upper", JOIN_WORDS(to_upper_, CHARSET), 256);
print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256);
exit(EXIT_SUCCESS);
}
void print_array(const char *name, const uchar *array, uint size)
{
uint i;
printf("\n# The %s array must have %d elements.\n", name, size);
for (i = 0; i < size; ++i) {
printf(" %02X", array[i]);
if ((i+1) % ROW_LEN == size % ROW_LEN)
printf("\n");
}
}

View file

@ -1,123 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Functions for finding files with wildcards */
/*
The following file-name-test is supported:
- "name [[,] name...] ; Matches any of used filenames.
Each name can have "*" and/or "?"
wild-cards.
- [wildspec [,]] !wildspec2 ; File that matches wildspec and not
wildspec2.
*/
#include "mysys_priv.h"
#include <m_string.h>
/* Store wildcard-string in a easyer format */
WF_PACK *wf_comp(char * str)
{
uint ant;
int not_pos;
register char * pos;
char * buffer;
WF_PACK *ret;
DBUG_ENTER("wf_comp");
not_pos= -1; /* Skip space and '!' in front */
while (*str == ' ')
str++;
if (*str == '!')
{
not_pos=0;
while (*++str == ' ') {};
}
if (*str == 0) /* Empty == everything */
DBUG_RETURN((WF_PACK *) NULL);
ant=1; /* Count filespecs */
for (pos=str ; *pos ; pos++)
ant+= test(*pos == ' ' || *pos == ',');
if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+
sizeof(WF_PACK)+ (uint) strlen(str)+1,
MYF(MY_WME)))
== 0)
DBUG_RETURN((WF_PACK *) NULL);
ret->wild= (char **) (ret+1);
buffer= (char *) (ret->wild+ant);
ant=0;
for (pos=str ; *pos ; str= pos)
{
ret->wild[ant++]=buffer;
while (*pos != ' ' && *pos != ',' && *pos != '!' && *pos)
*buffer++ = *pos++;
*buffer++ = '\0';
while (*pos == ' ' || *pos == ',' || *pos == '!' )
if (*pos++ == '!' && not_pos <0)
not_pos=(int) ant;
}
ret->wilds=ant;
if (not_pos <0)
ret->not_pos=ant;
else
ret->not_pos=(uint) not_pos;
DBUG_PRINT("exit",("antal: %d not_pos: %d",ret->wilds,ret->not_pos));
DBUG_RETURN(ret);
} /* wf_comp */
/* Test if a given filename is matched */
int wf_test(register WF_PACK *wf_pack, register const char *name)
{
reg2 uint i;
reg3 uint not_pos;
DBUG_ENTER("wf_test");
if (! wf_pack || wf_pack->wilds == 0)
DBUG_RETURN(0); /* Everything goes */
not_pos=wf_pack->not_pos;
for (i=0 ; i < not_pos; i++)
if (wild_compare(name,wf_pack->wild[i],0) == 0)
goto found;
if (i)
DBUG_RETURN(1); /* No-match */
found:
/* Test that it isn't in not-list */
for (i=not_pos ; i < wf_pack->wilds; i++)
if (wild_compare(name,wf_pack->wild[i],0) == 0)
DBUG_RETURN(1);
DBUG_RETURN(0);
} /* wf_test */
/* We need this because program don't know with malloc we used */
void wf_end(WF_PACK *buffer)
{
DBUG_ENTER("wf_end");
my_free(buffer);
DBUG_VOID_RETURN;
} /* wf_end */

View file

@ -1,64 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysys_priv.h"
#include <sys/stat.h>
#include <m_string.h>
#if defined(HAVE_UTIME_H)
#include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
#include <sys/utime.h>
#elif !defined(HPUX10)
struct utimbuf {
time_t actime;
time_t modtime;
};
#endif
/*
Append a file to another
NOTES
Don't set MY_FNABP or MY_NABP bits on when calling this function
*/
int my_append(const char *from, const char *to, myf MyFlags)
{
size_t Count;
File from_file,to_file;
uchar buff[IO_SIZE];
DBUG_ENTER("my_append");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
from_file= to_file= -1;
if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0)
{
if ((to_file=my_open(to,O_APPEND | O_WRONLY,MyFlags)) >= 0)
{
while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0)
if (Count == (uint) -1 ||
my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
goto err;
if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
DBUG_RETURN(-1); /* Error on close */
DBUG_RETURN(0);
}
}
err:
if (from_file >= 0) (void) my_close(from_file,MyFlags);
if (to_file >= 0) (void) my_close(to_file,MyFlags);
DBUG_RETURN(-1);
}

View file

@ -1,32 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "my_global.h"
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
#include "mysys_priv.h"
#include <sys/times.h>
#endif
long my_clock(void)
{
#if !defined(__WIN__)
struct tms tmsbuf;
(void) times(&tmsbuf);
return (tmsbuf.tms_utime + tmsbuf.tms_stime);
#else
return clock();
#endif
}

View file

@ -1,41 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysys_priv.h"
#include "mysys_err.h"
#include <my_dir.h>
#include <errno.h>
#if defined(__WIN__)
#include <share.h>
#endif
/* Open a file */
File my_dup(File file, myf MyFlags)
{
File fd;
const char *filename;
DBUG_ENTER("my_dup");
DBUG_PRINT("my",("file: %d MyFlags: %d", file, MyFlags));
#ifdef _WIN32
fd= my_win_dup(file);
#else
fd= dup(file);
#endif
filename= (((uint) file < my_file_limit) ?
my_file_info[(int) file].name : "Unknown");
DBUG_RETURN(my_register_filename(fd, filename, FILE_BY_DUP,
EE_FILENOTFOUND, MyFlags));
} /* my_open */

View file

@ -138,9 +138,6 @@ my_bool my_init(void)
#ifdef THREAD
if (my_thread_global_init())
return 1;
#if !defined(__WIN__)
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
{
DBUG_ENTER("my_init");

View file

@ -1,42 +0,0 @@
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* thread safe version of some common functions */
#include "mysys_priv.h"
#include <m_string.h>
/* for thread safe my_inet_ntoa */
#if !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(__WIN__) */
void my_inet_ntoa(struct in_addr in, char *buf)
{
char *ptr;
mysql_mutex_lock(&THR_LOCK_net);
ptr=inet_ntoa(in);
strmov(buf,ptr);
mysql_mutex_unlock(&THR_LOCK_net);
}

View file

@ -43,9 +43,6 @@ struct st_my_file_info *my_file_info= my_file_info_default;
int 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_reccache.c */
ulong my_default_record_cache_size=RECORD_CACHE_SIZE;

View file

@ -25,9 +25,6 @@ C_MODE_START
#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;
@ -48,9 +45,6 @@ extern struct st_my_file_info my_file_info_default[MY_NFILE];
extern ulonglong query_performance_frequency, query_performance_offset;
#if defined(THREAD) && !defined(__WIN__)
extern sigset_t my_signals; /* signals blocked by mf_brkhant */
#endif
C_MODE_END
#endif /* MYSYS_MY_STATIC_INCLUDED */

View file

@ -1,109 +0,0 @@
/* Copyright (C) 2005 MySQL AB
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Variable length encoding.
A method to store an arbitrary-size non-negative integer. We let the
most significant bit of the number indicate that the next byte
should be contatenated to form the real number.
*/
#include "my_vle.h"
/*
Function to encode an unsigned long as VLE. The bytes for the VLE
will be written to the location pointed to by 'out'. The maximum
number of bytes written will be 'max'.
PARAMETERS
out Pointer to beginning of where to store VLE bytes.
max Maximum number of bytes to write.
n Number to encode.
RETURN VALUE
On success, one past the end of the array containing the VLE
bytes. On failure, the 'out' pointer is returned.
*/
uchar*
my_vle_encode(uchar* out, size_t max, ulong n)
{
uchar buf[my_vle_sizeof(n)];
uchar *ptr= buf;
size_t len;
do
{
*ptr++= (uchar) (n & 0x7F);
n>>= 7;
}
while (n > 0);
len= ptr - buf;
if (len <= max)
{
/*
The bytes are stored in reverse order in 'buf'. Let's write them
in correct order to the output buffer and set the MSB at the
same time.
*/
while (ptr-- > buf)
{
uchar v= *ptr;
if (ptr > buf)
v|= 0x80;
*out++= v;
}
}
return out;
}
/*
Function to decode a VLE representation of an integral value.
PARAMETERS
result_ptr Pointer to an unsigned long where the value will be written.
vle Pointer to the VLE bytes.
RETURN VALUE
One-past the end of the VLE bytes. The routine will never read
more than sizeof(*result_ptr) + 1 bytes.
*/
uchar const*
my_vle_decode(ulong *result_ptr, uchar const *vle)
{
ulong result= 0;
size_t cnt= 1;
do
{
result<<= 7;
result|= (*vle & 0x7F);
}
while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1);
if (cnt <= sizeof(*result_ptr) + 1)
*result_ptr= result;
return vle;
}

View file

@ -1,69 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysys_priv.h"
const char *test_names[]=
{
"/usr/my/include/srclib/myfunc/dbug/test",
"test",
"dbug/test",
"/usr/my/srclib/myfunc/dbug/test",
"/usr/monty/oldcopy/jazz/setupp.frm",
"~/monty.tst",
"~/dbug/monty.tst",
"./hejsan",
"./dbug/test",
"../dbug/test",
"../myfunc/test",
"../../monty/rutedit",
"/usr/monty//usr/monty/rutedit",
"/usr/./monty/rutedit",
"/usr/my/../monty/rutedit",
"/usr/my/~/rutedit",
"~/../my",
"~/../my/srclib/myfunc/test",
"~/../my/srclib/myfunc/./dbug/test",
"/../usr/my/srclib/dbug",
"c/../my",
"/c/../my",
NullS,
};
int main(int argc __attribute__((unused)), char **argv)
{
const char **pos;
char buff[FN_REFLEN],buff2[FN_REFLEN];
DBUG_ENTER ("main");
DBUG_PROCESS (argv[0]);
MY_INIT(argv[0]);
if (argv[1] && argv[1][1] == '#')
DBUG_PUSH(argv[1]+2);
for (pos=test_names; *pos ; pos++)
{
printf("org : '%s'\n",*pos);
printf("pack: '%s'\n",fn_format(buff,*pos,"","",8));
printf("unpack: '%s'\n",fn_format(buff2,*pos,"","",4));
unpack_filename(buff,buff);
if (strcmp(buff,buff2) != 0)
{
printf("error on cmp: '%s' != '%s'\n",buff,buff2);
}
puts("");
}
DBUG_RETURN(0);
}

View file

@ -1,236 +0,0 @@
/* Copyright (C) 2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Implementation of trie and Aho-Corasick automaton.
Supports only charsets that can be compared byte-wise.
TODO:
Add character frequencies. Can increase lookup speed
up to 30%.
Implement character-wise comparision.
*/
#include "mysys_priv.h"
#include <m_string.h>
#include <my_trie.h>
#include <my_base.h>
/*
SYNOPSIS
TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset);
DESCRIPTION
Allocates or initializes a `TRIE' object. If `trie' is a `NULL'
pointer, the function allocates, initializes, and returns a new
object. Otherwise, the object is initialized and the address of
the object is returned. If `trie_init()' allocates a new object,
it will be freed when `trie_free()' is called.
RETURN VALUE
An initialized `TRIE*' object. `NULL' if there was insufficient
memory to allocate a new object.
*/
TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset)
{
MEM_ROOT mem_root;
DBUG_ENTER("trie_init");
DBUG_ASSERT(charset);
init_alloc_root(&mem_root,
(sizeof(TRIE_NODE) * 128) + ALLOC_ROOT_MIN_BLOCK_SIZE,
sizeof(TRIE_NODE) * 128);
if (! trie)
{
if (! (trie= (TRIE *)alloc_root(&mem_root, sizeof(TRIE))))
{
free_root(&mem_root, MYF(0));
DBUG_RETURN(NULL);
}
}
memcpy(&trie->mem_root, &mem_root, sizeof(MEM_ROOT));
trie->root.leaf= 0;
trie->root.c= 0;
trie->root.next= NULL;
trie->root.links= NULL;
trie->root.fail= NULL;
trie->charset= charset;
trie->nnodes= 0;
trie->nwords= 0;
DBUG_RETURN(trie);
}
/*
SYNOPSIS
void trie_free (TRIE *trie);
trie - valid pointer to `TRIE'
DESCRIPTION
Frees the memory allocated for a `trie'.
RETURN VALUE
None.
*/
void trie_free (TRIE *trie)
{
MEM_ROOT mem_root;
DBUG_ENTER("trie_free");
DBUG_ASSERT(trie);
memcpy(&mem_root, &trie->mem_root, sizeof(MEM_ROOT));
free_root(&mem_root, MYF(0));
DBUG_VOID_RETURN;
}
/*
SYNOPSIS
my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen);
trie - valid pointer to `TRIE'
key - valid pointer to key to insert
keylen - non-0 key length
DESCRIPTION
Inserts new key into trie.
RETURN VALUE
Upon successful completion, `trie_insert' returns `FALSE'. Otherwise
`TRUE' is returned.
NOTES
If this function fails you must assume `trie' is broken.
However it can be freed with trie_free().
*/
my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen)
{
TRIE_NODE *node;
TRIE_NODE *next;
uchar p;
uint k;
DBUG_ENTER("trie_insert");
DBUG_ASSERT(trie && key && keylen);
node= &trie->root;
trie->root.fail= NULL;
for (k= 0; k < keylen; k++)
{
p= key[k];
for (next= node->links; next; next= next->next)
if (next->c == p)
break;
if (! next)
{
TRIE_NODE *tmp= (TRIE_NODE *)alloc_root(&trie->mem_root,
sizeof(TRIE_NODE));
if (! tmp)
DBUG_RETURN(TRUE);
tmp->leaf= 0;
tmp->c= p;
tmp->links= tmp->fail= tmp->next= NULL;
trie->nnodes++;
if (! node->links)
{
node->links= tmp;
}
else
{
for (next= node->links; next->next; next= next->next) /* no-op */;
next->next= tmp;
}
node= tmp;
}
else
{
node= next;
}
}
node->leaf= keylen;
trie->nwords++;
DBUG_RETURN(FALSE);
}
/*
SYNOPSIS
my_bool trie_prepare (TRIE *trie);
trie - valid pointer to `TRIE'
DESCRIPTION
Constructs Aho-Corasick automaton.
RETURN VALUE
Upon successful completion, `trie_prepare' returns `FALSE'. Otherwise
`TRUE' is returned.
*/
my_bool ac_trie_prepare (TRIE *trie)
{
TRIE_NODE **tmp_nodes;
TRIE_NODE *node;
uint32 fnode= 0;
uint32 lnode= 0;
DBUG_ENTER("trie_prepare");
DBUG_ASSERT(trie);
tmp_nodes= (TRIE_NODE **)my_malloc(trie->nnodes * sizeof(TRIE_NODE *), MYF(0));
if (! tmp_nodes)
DBUG_RETURN(TRUE);
trie->root.fail= &trie->root;
for (node= trie->root.links; node; node= node->next)
{
node->fail= &trie->root;
tmp_nodes[lnode++]= node;
}
while (fnode < lnode)
{
TRIE_NODE *current= (TRIE_NODE *)tmp_nodes[fnode++];
for (node= current->links; node; node= node->next)
{
TRIE_NODE *fail= current->fail;
tmp_nodes[lnode++]= node;
while (! (node->fail= trie_goto(&trie->root, fail, node->c)))
fail= fail->fail;
}
}
my_free(tmp_nodes);
DBUG_RETURN(FALSE);
}
/*
SYNOPSIS
void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state);
trie - valid pointer to `TRIE'
state - value pointer to `AC_TRIE_STATE'
DESCRIPTION
Initializes `AC_TRIE_STATE' object.
*/
void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state)
{
DBUG_ENTER("ac_trie_init");
DBUG_ASSERT(trie && state);
state->trie= trie;
state->node= &trie->root;
DBUG_VOID_RETURN;
}