diff options
Diffstat (limited to 'extra')
-rw-r--r-- | extra/Makefile.am | 4 | ||||
-rw-r--r-- | extra/comp_err.c | 37 | ||||
-rw-r--r-- | extra/my_print_defaults.c | 13 | ||||
-rw-r--r-- | extra/mysql_install.c | 258 | ||||
-rw-r--r-- | extra/perror.c | 4 | ||||
-rw-r--r-- | extra/replace.c | 2 | ||||
-rw-r--r-- | extra/resolve_stack_dump.c | 13 | ||||
-rw-r--r-- | extra/resolveip.c | 4 |
8 files changed, 56 insertions, 279 deletions
diff --git a/extra/Makefile.am b/extra/Makefile.am index 8e4491969b5..0276355ef65 100644 --- a/extra/Makefile.am +++ b/extra/Makefile.am @@ -14,11 +14,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include -I.. +INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \ ../dbug/libdbug.a ../strings/libmystrings.a bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \ - resolve_stack_dump mysql_install mysql_waitpid + resolve_stack_dump mysql_waitpid # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/extra/comp_err.c b/extra/comp_err.c index bd7e6231908..6c7fad6a270 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -24,11 +24,13 @@ #define MAXLENGTH 1000 #define MAX_ROWS 1000 #define MAX_FILES 10 +#define MAX_CHARSET_NAME 64 int row_count; uint file_pos[MAX_ROWS],file_row_pos[MAX_FILES]; my_string saved_row[MAX_ROWS]; uchar file_head[]= { 254,254,2,1 }; +char charset_name[MAX_CHARSET_NAME]; static void get_options(int *argc,char **argv[]); static int count_rows(FILE *from,pchar c, pchar c2); @@ -40,11 +42,12 @@ static int copy_rows(FILE *to); int main(int argc,char *argv[]) { + uint csnum= 0; int i,error,files,length; uchar head[32]; FILE *from,*to; MY_INIT(argv[0]); - + get_options(&argc,&argv); error=1; row_count=files=0; @@ -61,6 +64,20 @@ int main(int argc,char *argv[]) } VOID(count_rows(from,'"','{')); /* Calculate start-info */ + if (!charset_name[0]) + { + fprintf(stderr,"Character set is not specified in '%s'\n",*argv); + fclose(from); + goto end; + } + + if (!(csnum= get_charset_number(charset_name, MY_CS_PRIMARY))) + { + fprintf(stderr,"Unknown character '%s' in '%s'\n",charset_name, *argv); + fclose(from); + goto end; + } + if (remember_rows(from,'}') < 0) /* Remember rows */ { fprintf(stderr,"Can't find textrows in '%s'\n",*argv); @@ -91,7 +108,8 @@ int main(int argc,char *argv[]) { int2store(head+10+i+i,file_row_pos[i]); } - + head[30]= csnum; + fseek(to,0l,0); if (fwrite(head,1,32,to) != 32) goto end; @@ -134,6 +152,10 @@ static void get_options(register int *argc,register char **argv[]) case 'V': printf("%s (Compile errormessage) Ver 1.3\n",progname); break; + case 'C': + charsets_dir= pos+1; + *(pos--)= '\0'; + break; case 'I': case '?': printf(" %s (Compile errormessage) Ver 1.3\n",progname); @@ -168,8 +190,19 @@ static int count_rows(FILE *from, pchar c, pchar c2) DBUG_ENTER("count_rows"); pos=ftell(from); count=0; + + charset_name[0]= '\0'; while (fgets(rad,MAXLENGTH,from) != NULL) { + if (!strncmp(rad,"character-set=",14)) + { + char *b= rad+14, *e; + for (e=b ; e[0] && e-b < MAX_CHARSET_NAME && + e[0] != ' ' && e[0] != '\r' && + e[0] != '\n' && e[0] != '\t' ; e++); + e[0]= '\0'; + strcpy(charset_name, b); + } if (rad[0] == c || rad[0] == c2) break; count++; diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 07d6c0ca555..e580603bcb8 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -30,21 +30,21 @@ uint verbose= 0, opt_defaults_file_used= 0; static struct my_option my_long_options[] = { - {"config-file", 'c', "The config file to be used", + {"config-file", 'c', "The config file to be used.", (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"defaults-file", 'c', "Synonym for --config-file", + {"defaults-file", 'c', "Synonym for --config-file.", (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"defaults-extra-file", 'e', + {"defaults-extra-file", 'e', "Read this file after the global /etc config file and before the config file in the users home directory.", (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"extra-file", 'e', - "Synonym for --defaults-extra-file", + {"extra-file", 'e', + "Synonym for --defaults-extra-file.", (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"no-defaults", 'n', "Return an empty string (useful for scripts)", + {"no-defaults", 'n', "Return an empty string (useful for scripts).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -55,7 +55,6 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - static void usage(my_bool version) { printf("%s Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE, diff --git a/extra/mysql_install.c b/extra/mysql_install.c deleted file mode 100644 index e2783f906b9..00000000000 --- a/extra/mysql_install.c +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -/* Install or upgrade MySQL server. By Sasha Pachev <sasha@mysql.com> - */ - -#define INSTALL_VERSION "1.2" - -#define DONT_USE_RAID -#include <my_global.h> -#include <m_ctype.h> -#include <my_sys.h> -#include <m_string.h> -#include <mysql_version.h> -#include <errno.h> -#include <my_getopt.h> - -#define ANSWERS_CHUNCK 32 - -int have_gui=0; - -static struct my_option my_long_options[] = -{ - {"help", '?', "Display this help and exit.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Output version information and exit.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} -}; - -/* For now, not much exciting here, but we'll add more once - we add GUI support - */ -typedef struct -{ - FILE* out; - FILE* in; - const char* question; - int default_ind; - DYNAMIC_ARRAY answers; -} QUESTION_WIDGET; - -static void usage(); -static void die(const char* fmt, ...); -static void print_version(void); -static char get_answer_char(int ans_ind); -static int ask_user(const char* question,int default_ind, ...); -static void add_answer(QUESTION_WIDGET* w, const char* ans); -static void display_question(QUESTION_WIDGET* w); -static int init_question_widget(QUESTION_WIDGET* w, const char* question, - int default_ind); -static void end_question_widget(QUESTION_WIDGET* w); -static int get_answer(QUESTION_WIDGET* w); -static char answer_from_char(char c); -static void invalid_answer(QUESTION_WIDGET* w); - -enum {IMODE_STANDARD=0,IMODE_CUSTOM,IMODE_UPGRAGE} install_mode - = IMODE_STANDARD; - -static char get_answer_char(int ans_ind) -{ - return 'a' + ans_ind; -} - -static void invalid_answer(QUESTION_WIDGET* w) -{ - if (!have_gui) - { - fprintf(w->out, "ERROR: invalid answer, try again...\a\n"); - } -} - -static char answer_from_char(char c) -{ - return c - 'a'; -} - -static void die(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - fprintf(stderr, "%s: ", my_progname); - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); - va_end(args); - exit(1); -} - -static void display_question(QUESTION_WIDGET* w) -{ - if (!have_gui) - { - uint i,num_answers=w->answers.elements; - DYNAMIC_ARRAY* answers = &w->answers; - fprintf(w->out,"\n%s\n\n",w->question); - - for (i=0; i<num_answers; i++) - { - char* ans; - get_dynamic(answers,(gptr)&ans,i); - fprintf(w->out,"%c - %s\n",get_answer_char(i),ans); - } - fprintf(w->out,"q - Abort Install/Upgrade\n\n"); - } -} - -static void add_answer(QUESTION_WIDGET* w, const char* ans) -{ - insert_dynamic(&w->answers,(gptr)&ans); -} - -static int init_question_widget(QUESTION_WIDGET* w, const char* question, - int default_ind) -{ - if (have_gui) - { - w->in = w->out = 0; - } - else - { - w->out = stdout; - w->in = stdin; - } - w->question = question; - w->default_ind = default_ind; - if (my_init_dynamic_array(&w->answers,sizeof(char*), - ANSWERS_CHUNCK,ANSWERS_CHUNCK)) - die("Out of memory"); - return 0; -} - -static void end_question_widget(QUESTION_WIDGET* w) -{ - delete_dynamic(&w->answers); -} - -static int get_answer(QUESTION_WIDGET* w) -{ - if (!have_gui) - { - char buf[32]; - int ind; - char c; - if (!fgets(buf,sizeof(buf),w->in)) - die("Failed fgets on input stream"); - switch ((c=tolower(*buf))) - { - case '\n': - return w->default_ind; - case 'q': - die("Install/Upgrade aborted"); - default: - ind = answer_from_char(c); - if (ind >= 0 && ind < (int)w->answers.elements) - return ind; - } - } - return -1; -} - -static int ask_user(const char* question,int default_ind, ...) -{ - va_list args; - char* opt; - QUESTION_WIDGET w; - int ans; - - va_start(args,default_ind); - init_question_widget(&w,question,default_ind); - for (;(opt=va_arg(args,char*));) - { - add_answer(&w,opt); - } - for (;;) - { - display_question(&w); - if ((ans = get_answer(&w)) >= 0) - break; - invalid_answer(&w); - } - end_question_widget(&w); - va_end(args); - return ans; -} - - -static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) -{ - switch(optid) { - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; -} - - -static int parse_args(int argc, char **argv) -{ - int ho_error; - - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) - exit(ho_error); - - return 0; -} - -static void print_version(void) -{ - printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,INSTALL_VERSION, - MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} - -static void usage() -{ - print_version(); - printf("MySQL AB, by Sasha Pachev\n"); - printf("This software comes with ABSOLUTELY NO WARRANTY\n\n"); - printf("Install or upgrade MySQL server.\n\n"); - printf("Usage: %s [OPTIONS] \n", my_progname); - my_print_help(my_long_options); - my_print_variables(my_long_options); -} - -int main(int argc, char** argv) -{ - MY_INIT(argv[0]); - parse_args(argc,argv); - install_mode = ask_user("Please select install/upgrade mode", - install_mode, "Standard Install", - "Custom Install", "Upgrade",0); - printf("mode=%d\n", install_mode); - return 0; -} - - - - - diff --git a/extra/perror.c b/extra/perror.c index ca6bbfb54f9..d05fa2492de 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -30,14 +30,14 @@ static struct my_option my_long_options[] = { {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"info", 'I', "Synonym for --help", 0, 0, 0, GET_NO_ARG, + {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SYS_ERRLIST {"all", 'a', "Print all the error messages and the number.", (gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"silent", 's', "Only print the error message", 0, 0, 0, GET_NO_ARG, NO_ARG, + {"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, diff --git a/extra/replace.c b/extra/replace.c index 41312f5e3d4..8e007e3a971 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -113,7 +113,7 @@ char *argv[]; exit(1); for (i=1,pos=word_end_chars ; i < 256 ; i++) - if (isspace(i)) + if (my_isspace(&my_charset_latin1,i)) *pos++=i; *pos=0; if (!(replace=init_replace((char**) from.typelib.type_names, diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index c54f17a186e..06a670b935d 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -175,9 +175,9 @@ trace dump and specify the path to it with -s or --symbols-file"); static uchar hex_val(char c) { uchar l; - if (isdigit(c)) + if (my_isdigit(&my_charset_latin1,c)) return c - '0'; - l = tolower(c); + l = my_tolower(&my_charset_latin1,c); if (l < 'a' || l > 'f') return HEX_INVALID; return (uchar)10 + ((uchar)c - (uchar)'a'); @@ -203,9 +203,11 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf) if (!se->addr) return -1; - while (isspace(*buf++)) ; + while (my_isspace(&my_charset_latin1,*buf++)) + /* empty */; - while (isspace(*buf++)) ; /* skip more space */ + while (my_isspace(&my_charset_latin1,*buf++)) + /* empty - skip more space */; --buf; /* now we are on the symbol */ for (p = se->symbol, p_end = se->symbol + sizeof(se->symbol) - 1; @@ -285,7 +287,8 @@ static void do_resolve() while (fgets(buf, sizeof(buf), fp_dump)) { p = buf; - while(isspace(*p)) + /* skip space */ + while (my_isspace(&my_charset_latin1,*p)) ++p; if (*p++ == '0' && *p++ == 'x') diff --git a/extra/resolveip.c b/extra/resolveip.c index d3caa9e1d45..f8cff2a976c 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -42,7 +42,7 @@ static struct my_option my_long_options[] = { {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"info", 'I', "Synonym for --help", + {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -119,7 +119,7 @@ int main(int argc, char **argv) { ip = *argv++; - if (isdigit(ip[0])) + if (my_isdigit(&my_charset_latin1,ip[0])) { taddr = inet_addr(ip); if (taddr == htonl(INADDR_BROADCAST)) |