summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authormonty@mysql.com <>2004-05-25 22:01:50 +0300
committermonty@mysql.com <>2004-05-25 22:01:50 +0300
commitca8dbc24eef40f78464400ad4492b0d9b39c29ff (patch)
treef5abb32f436bbc05db102bf322757f4a03aaa850 /client
parent7ee9540976dd3130d575a1bb677ad13a4bb1b572 (diff)
parentf2e1e3ce4c72d383f16fd8c525b28c4912e8f2de (diff)
downloadmariadb-git-ca8dbc24eef40f78464400ad4492b0d9b39c29ff.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/tmp/skr99/mysql-4.0
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc25
-rw-r--r--client/mysqladmin.c4
-rw-r--r--client/mysqlbinlog.cc5
-rw-r--r--client/mysqlcheck.c4
-rw-r--r--client/mysqldump.c8
-rw-r--r--client/mysqlimport.c5
-rw-r--r--client/mysqlshow.c6
-rw-r--r--client/mysqltest.c112
8 files changed, 161 insertions, 8 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 46ade3aef26..1fd909a397e 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -590,6 +590,10 @@ static struct my_option my_long_options[] =
static void usage(int version)
{
+ /* Divert all help information on NetWare to logger screen. */
+#ifdef __NETWARE__
+#define printf consoleprintf
+#endif
printf("%s Ver %s Distrib %s, for %s (%s)\n",
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version)
@@ -602,8 +606,13 @@ and you are welcome to modify and redistribute it under the GPL license\n");
my_print_help(my_long_options);
print_defaults("my", load_default_groups);
my_print_variables(my_long_options);
+ NETWARE_SET_SCREEN_MODE(1);
+#ifdef __NETWARE__
+#undef printf
+#endif
}
+
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
@@ -812,6 +821,7 @@ static int read_lines(bool execute_commands)
#ifdef __NETWARE__
line=fgets(linebuffer, sizeof(linebuffer)-1, stdin);
/* Remove the '\n' */
+ if (line)
{
char *p = strrchr(line, '\n');
if (p != NULL)
@@ -827,7 +837,11 @@ static int read_lines(bool execute_commands)
line= readline(prompt);
#endif /* defined( __WIN__) || defined(OS2) || defined(__NETWARE__) */
- if (opt_outfile)
+ /*
+ When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
+ which may cause coredump.
+ */
+ if (opt_outfile && line)
fprintf(OUTFILE, "%s\n", line);
}
if (!line) // End of file
@@ -2018,10 +2032,8 @@ static int
com_quit(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
-#ifdef __NETWARE__
- // let the screen auto close on a normal shutdown
- setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
-#endif
+ /* let the screen auto close on a normal shutdown */
+ NETWARE_SET_SCREEN_MODE(SCR_AUTOCLOSE_ON_EXIT);
status.exit_status=0;
return 1;
}
@@ -2489,6 +2501,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
{
va_list args;
+ NETWARE_YIELD;
va_start(args, fmt);
(void) vfprintf(file, fmt, args);
#ifdef OS2
@@ -2502,6 +2515,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
void tee_fputs(const char *s, FILE *file)
{
+ NETWARE_YIELD;
fputs(s, file);
#ifdef OS2
fflush( file);
@@ -2513,6 +2527,7 @@ void tee_fputs(const char *s, FILE *file)
void tee_puts(const char *s, FILE *file)
{
+ NETWARE_YIELD;
fputs(s, file);
fputs("\n", file);
#ifdef OS2
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 9fbf7e2d64d..3bc11ec0fb0 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -815,11 +815,13 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return 0;
}
+#include <help_start.h>
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s on %s\n",my_progname,ADMIN_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
}
@@ -861,6 +863,8 @@ static void usage(void)
version Get version info from server");
}
+#include <help_end.h>
+
static int drop_db(MYSQL *mysql, const char *db)
{
char name_buff[FN_REFLEN+20], buf[10];
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 6c6acb750d3..7bceedea4fe 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -479,9 +479,12 @@ static void die(const char* fmt, ...)
exit(1);
}
+#include <help_start.h>
+
static void print_version()
{
printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
}
@@ -500,6 +503,8 @@ the mysql command line client\n\n");
my_print_variables(my_long_options);
}
+#include <help_end.h>
+
extern "C" my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 3261ec1577d..1c5638f3c52 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -159,10 +159,13 @@ static void print_result();
static char *fix_table_name(char *dest, char *src);
int what_to_do = 0;
+#include <help_start.h>
+
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, CHECK_VERSION,
MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
} /* print_version */
@@ -193,6 +196,7 @@ static void usage(void)
my_print_variables(my_long_options);
} /* usage */
+#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
diff --git a/client/mysqldump.c b/client/mysqldump.c
index f264b9b61c6..3f3746f2963 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -267,11 +267,13 @@ static char *quote_name(const char *name, char *buff, my_bool force);
static void print_quoted_xml(FILE *output, char *fname, char *str, uint len);
static const char *check_if_ignore_table(const char *table_name);
+#include <help_start.h>
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION,
- MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+ MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
} /* print_version */
@@ -281,8 +283,10 @@ static void short_usage_sub(void)
printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
my_progname);
printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname);
+ NETWARE_SET_SCREEN_MODE(1);
}
+
static void usage(void)
{
print_version();
@@ -302,6 +306,8 @@ static void short_usage(void)
printf("For more options, use %s --help\n", my_progname);
}
+#include <help_end.h>
+
static void write_header(FILE *sql_file, char *db_name)
{
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index c72e32dd2a7..ca53b74c119 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -134,14 +134,16 @@ static struct my_option my_long_options[] =
static const char *load_default_groups[]= { "mysqlimport","client",0 };
+#include <help_start.h>
+
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n" ,my_progname,
IMPORT_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
}
-
static void usage(void)
{
print_version();
@@ -160,6 +162,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n");
my_print_variables(my_long_options);
}
+#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index ccae43e4e27..1a9aec02955 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -182,12 +182,16 @@ static struct my_option my_long_options[] =
};
+#include <help_start.h>
+
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,SHOW_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+ NETWARE_SET_SCREEN_MODE(1);
}
+
static void usage(void)
{
print_version();
@@ -207,6 +211,8 @@ are shown");
my_print_variables(my_long_options);
}
+#include <help_end.h>
+
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 7dae99efde3..cdf1648769b 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -178,6 +178,17 @@ typedef struct
int alloced;
} VAR;
+#ifdef __NETWARE__
+/*
+ Netware doesn't proved environment variable substitution that is done
+ by the shell in unix environments. We do this in the following function:
+*/
+
+static char *subst_env_var(const char *cmd);
+static int my_popen(const char *cmd, const char *mode);
+#define popen(A,B) my_popen((A),(B))
+#endif /* __NETWARE__ */
+
VAR var_reg[10];
/*Perl/shell-like variable registers */
HASH var_hash;
@@ -890,7 +901,7 @@ int do_exec(struct st_query* q)
while (fgets(buf, sizeof(buf), res_file))
replace_dynstr_append_mem(ds, buf, strlen(buf));
-
+
if (glob_replace)
free_replace();
@@ -913,6 +924,7 @@ int do_exec(struct st_query* q)
DBUG_RETURN(error);
}
+
int var_query_set(VAR* v, const char* p, const char** p_end)
{
char* end = (char*)((p_end && *p_end) ? *p_end : p + strlen(p));
@@ -3473,3 +3485,101 @@ static void get_replace_column(struct st_query *q)
}
my_free(start, MYF(0));
}
+
+#ifdef __NETWARE__
+
+/*
+ Substitute environment variables with text.
+
+ SYNOPSIS
+ subst_env_var()
+ arg String that should be substitute
+
+ DESCRIPTION
+ This function takes a string as an input and replaces the
+ environment variables, that starts with '$' character, with it value.
+
+ NOTES
+ Return string must be freed with my_free()
+
+ RETURN
+ String with environment variables replaced.
+*/
+
+static char *subst_env_var(const char *str)
+{
+ char *result;
+
+ result= pos= my_malloc(MAX_QUERY, MYF(MY_FAE));
+ while (*str)
+ {
+ /*
+ need this only when we want to provide the functionality of
+ escaping through \ 'backslash'
+ if ((result == pos && *str=='$') ||
+ (result != pos && *str=='$' && str[-1] !='\\'))
+ */
+ if (*str == '$')
+ {
+ char env_var[256], *env_pos= env_var, *subst;
+
+ /* Search for end of environment variable */
+ for (str++;
+ *str && !isspace(*str) && *str != '\\' && *str != '/' &&
+ *str != '$';
+ str++)
+ *env_pos++ *str;
+ *env_pos= 0;
+
+ if (!(subst= getenv(env_var)))
+ {
+ my_free(result, MYF(0));
+ die("MYSQLTEST.NLM: Environment variable %s is not defined\n",
+ env_var);
+ }
+
+ /* get the string to be substitued for env_var */
+ pos= strmov(pos, subst);
+ /* Process delimiter in *str again */
+ }
+ else
+ *pos++= *str++;
+ }
+ *pos= 0;
+ return result;
+}
+
+
+/*
+ popen replacement for Netware
+
+ SYNPOSIS
+ my_popen()
+ name Command to execute (with possible env variables)
+ mode Mode for popen.
+
+ NOTES
+ Environment variable expansion does not take place for popen function
+ on NetWare, so we use this function to wrap around popen to do this.
+
+ For the moment we ignore 'mode' and always use 'r0'
+
+ RETURN
+ # >= 0 File handle
+ -1 Error
+*/
+
+#undef popen /* Remove wrapper */
+
+int my_popen(const char *cmd, const char *mode __attribute__((unused)) t)
+{
+ char *subst_cmd;
+ int res_file;
+
+ subst_cmd= subst_env_var(cmd);
+ res_file= popen(subst_cmd, "r0");
+ my_free(subst_cmd, MYF(0));
+ return res_file;
+}
+
+#endif /* __NETWARE__ */