mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
removed editline and replaced with mysql readline
created new facade object for CommandInterpreter removed CPC #if 0 code removed editline from mgmtsrver, no replace with readline since interface is obsolete anyways BitKeeper/deleted/.del-MANIFEST~e8c948c4a4413f8d: Delete: ndb/src/common/editline/MANIFEST BitKeeper/deleted/.del-Makefile.am~dfbe493d6e2d25f4: Delete: ndb/src/common/editline/Makefile.am BitKeeper/deleted/.del-Makefile_old~90ac19a1668ecdd5: Delete: ndb/src/common/editline/Makefile_old BitKeeper/deleted/.del-README~3f39f9b8294466e8: Delete: ndb/src/common/editline/README BitKeeper/deleted/.del-complete.c~a1bc3055fd90e27f: Delete: ndb/src/common/editline/complete.c BitKeeper/deleted/.del-editline.3~1f9bb4274cf4381: Delete: ndb/src/common/editline/editline.3 BitKeeper/deleted/.del-editline.c~5b759f3e5fd3c196: Delete: ndb/src/common/editline/editline.c BitKeeper/deleted/.del-editline_internal.h~96ca8d53fb758586: Delete: ndb/src/common/editline/editline_internal.h BitKeeper/deleted/.del-editline_win32.c~45b257bec279826e: Delete: ndb/src/common/editline/editline_win32.c BitKeeper/deleted/.del-sysunix.c~8e7a6901783efd17: Delete: ndb/src/common/editline/sysunix.c BitKeeper/deleted/.del-unix.h~1c244c1d4ba6c6fb: Delete: ndb/src/common/editline/unix.h BitKeeper/deleted/.del-Makefile~46cecfa6cd1a4e6b: Delete: ndb/src/common/editline/test/Makefile BitKeeper/deleted/.del-testit.c~82837111b1876e44: Delete: ndb/src/common/editline/test/testit.c BitKeeper/deleted/.del-Makefile_old~59409aa4debaeb90: Delete: ndb/src/common/Makefile_old BitKeeper/deleted/.del-Makefile_old~92af3f5a7f24caf: Delete: ndb/src/mgmclient/Makefile_old ndb/test/src/CpcClient.cpp: Rename: ndb/src/mgmclient/CpcClient.cpp -> ndb/test/src/CpcClient.cpp ndb/test/include/CpcClient.hpp: Rename: ndb/src/mgmclient/CpcClient.hpp -> ndb/test/include/CpcClient.hpp configure.in: removed editline ndb/src/common/Makefile.am: removed editline ndb/src/mgmclient/CommandInterpreter.cpp: removed editline and replaced with mysql readline created new facade object for CommandInterpreter removed CPC #if 0 code ndb/src/mgmclient/Makefile.am: removed editline and replaced with mysql readline created new facade object for CommandInterpreter removed CPC #if 0 code ndb/src/mgmclient/main.cpp: removed editline and replaced with mysql readline created new facade object for CommandInterpreter removed CPC #if 0 code ndb/src/mgmclient/ndb_mgmclient.hpp: new facade object for CommandInterpreter ndb/src/mgmsrv/CommandInterpreter.hpp: removed editline from mgmtsrver, no replace with readline since interface is obsolete anyways ndb/src/mgmsrv/Makefile.am: removed editline from mgmtsrver, no replace with readline since interface is obsolete anyways ndb/test/run-test/Makefile.am: moved cpc code to test ndb/test/src/Makefile.am: moved cpc code to test ndb/test/tools/Makefile.am: moved cpc code to test
This commit is contained in:
@ -3093,7 +3093,6 @@ AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl
|
||||
ndb/src/common/logger/Makefile dnl
|
||||
ndb/src/common/transporter/Makefile dnl
|
||||
ndb/src/common/mgmcommon/Makefile dnl
|
||||
ndb/src/common/editline/Makefile dnl
|
||||
ndb/src/kernel/Makefile dnl
|
||||
ndb/src/kernel/error/Makefile dnl
|
||||
ndb/src/kernel/blocks/Makefile dnl
|
||||
|
@ -1,4 +1,4 @@
|
||||
SUBDIRS = portlib debugger util logger transporter mgmcommon editline
|
||||
SUBDIRS = portlib debugger util logger transporter mgmcommon
|
||||
|
||||
noinst_LTLIBRARIES = libcommon.la
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
include .defs.mk
|
||||
|
||||
LIB_DIRS := \
|
||||
portlib \
|
||||
debugger \
|
||||
util \
|
||||
logger
|
||||
|
||||
ifneq ($(USE_EDITLINE), N)
|
||||
LIB_DIRS += editline
|
||||
endif
|
||||
|
||||
DIRS := transporter mgmcommon
|
||||
|
||||
include $(NDB_TOP)/Epilogue.mk
|
@ -1,15 +0,0 @@
|
||||
File Name Description
|
||||
--------------------------------------------------------
|
||||
README Release notes and copyright
|
||||
MANIFEST This shipping list
|
||||
Make.os9 OS-9 makefile
|
||||
Makefile Unix makefile
|
||||
complete.c Filename completion routines
|
||||
editline.3 Manual page for editline library
|
||||
editline.c Line-editing routines
|
||||
editline_internal.h Internal library header file
|
||||
os9.h OS-9-specific declarations
|
||||
sysos9.c OS-9-specific routines
|
||||
sysunix.c Unix-specific routines
|
||||
testit.c Test driver
|
||||
unix.h Unix-specific declarations
|
@ -1,10 +0,0 @@
|
||||
|
||||
noinst_LIBRARIES = libeditline.a
|
||||
|
||||
libeditline_a_SOURCES = complete.c editline.c sysunix.c
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include
|
||||
DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
@ -1,18 +0,0 @@
|
||||
include .defs.mk
|
||||
|
||||
TYPE :=
|
||||
|
||||
ARCHIVE_TARGET := editline
|
||||
|
||||
CFLAGS += -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX
|
||||
|
||||
ifeq ($(NDB_OS), WIN32)
|
||||
SOURCES = editline_win32.c
|
||||
else
|
||||
SOURCES = complete.c editline.c sysunix.c
|
||||
endif
|
||||
|
||||
DIRS := test
|
||||
|
||||
include $(NDB_TOP)/Epilogue.mk
|
||||
|
@ -1,53 +0,0 @@
|
||||
--
|
||||
NOTE: This version has been modified by Ericsson/Alzato. Please
|
||||
see the cvs changelog for more details.
|
||||
--
|
||||
|
||||
$Revision: 1.2 $
|
||||
|
||||
This is a line-editing library. It can be linked into almost any
|
||||
program to provide command-line editing and recall.
|
||||
|
||||
It is call-compatible with the FSF readline library, but it is a
|
||||
fraction of the size (and offers fewer features). It does not use
|
||||
standard I/O. It is distributed under a "C News-like" copyright.
|
||||
|
||||
Configuration is done in the Makefile. Type "make testit" to get
|
||||
a small slow shell for testing.
|
||||
|
||||
This contains some changes since the posting to comp.sources.misc:
|
||||
- Bugfix for completion on absolute pathnames.
|
||||
- Better handling of M-n versus showing raw 8bit chars.
|
||||
- Better signal handling.
|
||||
- Now supports termios/termio/sgttyb ioctl's.
|
||||
- Add M-m command to toggle how 8bit data is displayed.
|
||||
The following changes, made since the last public release, come from
|
||||
J.G. Vons <vons@cesar.crbca1.sinet.slb.com>:
|
||||
- History-searching no longer redraws the line wrong
|
||||
- Added ESC-ESC as synonym for ESC-?
|
||||
- SIGQUIT (normally ^\) now sends a signal, not indicating EOF.
|
||||
- Fixed some typo's and unclear wording in the manpage.
|
||||
- Fixed completion when all entries shared a common prefix.
|
||||
- Fixed some meta-char line-redrawing bugs.
|
||||
|
||||
Enjoy,
|
||||
Rich $alz
|
||||
<rsalz@osf.org>
|
||||
|
||||
Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
|
||||
|
||||
This software is not subject to any license of the American Telephone
|
||||
and Telegraph Company or of the Regents of the University of California.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose on
|
||||
any computer system, and to alter it and redistribute it freely, subject
|
||||
to the following restrictions:
|
||||
1. The authors are not responsible for the consequences of use of this
|
||||
software, no matter how awful, even if they arise from flaws in it.
|
||||
2. The origin of this software must not be misrepresented, either by
|
||||
explicit claim or by omission. Since few users ever read sources,
|
||||
credits must appear in the documentation.
|
||||
3. Altered versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software. Since few users
|
||||
ever read sources, credits must appear in the documentation.
|
||||
4. This notice may not be removed or altered.
|
@ -1,195 +0,0 @@
|
||||
/* -*- c-basic-offset: 4; -*-
|
||||
** $Revision: 1.8 $
|
||||
**
|
||||
** History and file completion functions for editline library.
|
||||
*/
|
||||
#include "editline_internal.h"
|
||||
|
||||
|
||||
/*
|
||||
** strcmp-like sorting predicate for qsort.
|
||||
*/
|
||||
static int
|
||||
compare(const void *p1, const void *p2)
|
||||
{
|
||||
const char **v1;
|
||||
const char **v2;
|
||||
|
||||
v1 = (const char **)p1;
|
||||
v2 = (const char **)p2;
|
||||
return strcmp(*v1, *v2);
|
||||
}
|
||||
|
||||
/*
|
||||
** Fill in *avp with an array of names that match file, up to its length.
|
||||
** Ignore . and .. .
|
||||
*/
|
||||
static int
|
||||
FindMatches(char *dir, char *file, char ***avp)
|
||||
{
|
||||
char **av;
|
||||
char **new;
|
||||
char *p;
|
||||
DIR *dp;
|
||||
struct dirent *ep;
|
||||
size_t ac;
|
||||
size_t len;
|
||||
|
||||
if ((dp = opendir(dir)) == NULL)
|
||||
return 0;
|
||||
|
||||
av = NULL;
|
||||
ac = 0;
|
||||
len = strlen(file);
|
||||
while ((ep = readdir(dp)) != NULL) {
|
||||
p = ep->d_name;
|
||||
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
|
||||
continue;
|
||||
if (len && strncmp(p, file, len) != 0)
|
||||
continue;
|
||||
|
||||
if ((ac % MEM_INC) == 0) {
|
||||
if ((new = malloc(sizeof(char*) * (ac + MEM_INC))) == NULL)
|
||||
break;
|
||||
if (ac) {
|
||||
memcpy(new, av, ac * sizeof (char **));
|
||||
free(av);
|
||||
}
|
||||
*avp = av = new;
|
||||
}
|
||||
|
||||
if ((av[ac] = strdup(p)) == NULL) {
|
||||
if (ac == 0)
|
||||
free(av);
|
||||
break;
|
||||
}
|
||||
ac++;
|
||||
}
|
||||
|
||||
/* Clean up and return. */
|
||||
(void)closedir(dp);
|
||||
if (ac)
|
||||
qsort(av, ac, sizeof (char **), compare);
|
||||
return ac;
|
||||
}
|
||||
|
||||
/*
|
||||
** Split a pathname into allocated directory and trailing filename parts.
|
||||
*/
|
||||
static int
|
||||
SplitPath(char *path, char **dirpart, char ** filepart)
|
||||
{
|
||||
static char DOT[] = ".";
|
||||
char *dpart;
|
||||
char *fpart;
|
||||
|
||||
if ((fpart = strrchr(path, '/')) == NULL) {
|
||||
if ((dpart = strdup(DOT)) == NULL)
|
||||
return -1;
|
||||
if ((fpart = strdup(path)) == NULL) {
|
||||
free(dpart);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((dpart = strdup(path)) == NULL)
|
||||
return -1;
|
||||
dpart[fpart - path + 1] = '\0';
|
||||
if ((fpart = strdup(++fpart)) == NULL) {
|
||||
free(dpart);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*dirpart = dpart;
|
||||
*filepart = fpart;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Attempt to complete the pathname, returning an allocated copy.
|
||||
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
|
||||
*/
|
||||
char *
|
||||
rl_complete(char *pathname,int *unique)
|
||||
{
|
||||
char **av;
|
||||
char *dir;
|
||||
char *file;
|
||||
char *new;
|
||||
char *p;
|
||||
size_t ac;
|
||||
size_t end;
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t len;
|
||||
size_t new_len;
|
||||
size_t p_len;
|
||||
|
||||
if (SplitPath(pathname, &dir, &file) < 0)
|
||||
return NULL;
|
||||
if ((ac = FindMatches(dir, file, &av)) == 0) {
|
||||
free(dir);
|
||||
free(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = NULL;
|
||||
len = strlen(file);
|
||||
if (ac == 1) {
|
||||
/* Exactly one match -- finish it off. */
|
||||
*unique = 1;
|
||||
j = strlen(av[0]) - len + 2;
|
||||
p_len = sizeof(char) * (j + 1);
|
||||
if ((p = malloc(p_len)) != NULL) {
|
||||
memcpy(p, av[0] + len, j);
|
||||
new_len = sizeof(char) * (strlen(dir) + strlen(av[0]) + 2);
|
||||
new = malloc(new_len);
|
||||
if(new != NULL) {
|
||||
snprintf(new, new_len, "%s/%s", dir, av[0]);
|
||||
rl_add_slash(new, p, p_len);
|
||||
free(new);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Find largest matching substring. */
|
||||
for (*unique = 0, i = len, end = strlen(av[0]); i < end; i++)
|
||||
for (j = 1; j < ac; j++)
|
||||
if (av[0][i] != av[j][i])
|
||||
goto breakout;
|
||||
breakout:
|
||||
if (i > len) {
|
||||
j = i - len + 1;
|
||||
if ((p = malloc(sizeof(char) * j)) != NULL) {
|
||||
memcpy(p, av[0] + len, j);
|
||||
p[j - 1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up and return. */
|
||||
free(dir);
|
||||
free(file);
|
||||
for (i = 0; i < ac; i++)
|
||||
free(av[i]);
|
||||
free(av);
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return all possible completions.
|
||||
*/
|
||||
int
|
||||
rl_list_possib(char *pathname, char ***avp)
|
||||
{
|
||||
char *dir;
|
||||
char *file;
|
||||
int ac;
|
||||
|
||||
if (SplitPath(pathname, &dir, &file) < 0)
|
||||
return 0;
|
||||
ac = FindMatches(dir, file, avp);
|
||||
free(dir);
|
||||
free(file);
|
||||
return ac;
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
.\" $Revision: 1.1 $
|
||||
.TH EDITLINE 3
|
||||
.SH NAME
|
||||
editline \- command-line editing library with history
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B "char *"
|
||||
.B "readline(prompt)"
|
||||
.B " char *prompt;"
|
||||
|
||||
.B "void"
|
||||
.B "add_history(line)"
|
||||
.B " char *line;"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.I Editline
|
||||
is a library that provides an line-editing interface with text recall.
|
||||
It is intended to be compatible with the
|
||||
.I readline
|
||||
library provided by the Free Software Foundation, but much smaller.
|
||||
The bulk of this manual page describes the user interface.
|
||||
.PP
|
||||
The
|
||||
.I readline
|
||||
routine returns a line of text with the trailing newline removed.
|
||||
The data is returned in a buffer allocated with
|
||||
.IR malloc (3),
|
||||
so the space should be released with
|
||||
.IR free (3)
|
||||
when the calling program is done with it.
|
||||
Before accepting input from the user, the specified
|
||||
.I prompt
|
||||
is displayed on the terminal.
|
||||
.PP
|
||||
The
|
||||
.I add_history
|
||||
routine makes a copy of the specified
|
||||
.I line
|
||||
and adds it to the internal history list.
|
||||
.SS "User Interface"
|
||||
A program that uses this library provides a simple emacs-like editing
|
||||
interface to its users.
|
||||
A line may be edited before it is sent to the calling program by typing either
|
||||
control characters or escape sequences.
|
||||
A control character, shown as a caret followed by a letter, is typed by
|
||||
holding down the ``control'' key while the letter is typed.
|
||||
For example, ``^A'' is a control-A.
|
||||
An escape sequence is entered by typing the ``escape'' key followed by one or
|
||||
more characters.
|
||||
The escape key is abbreviated as ``ESC''.
|
||||
Note that unlike control keys, case matters in escape sequences; ``ESC\ F''
|
||||
is not the same as ``ESC\ f''.
|
||||
.PP
|
||||
An editing command may be typed anywhere on the line, not just at the
|
||||
beginning.
|
||||
In addition, a return may also be typed anywhere on the line, not just at
|
||||
the end.
|
||||
.PP
|
||||
Most editing commands may be given a repeat count,
|
||||
.IR n ,
|
||||
where
|
||||
.I n
|
||||
is a number.
|
||||
To enter a repeat count, type the escape key, the number, and then
|
||||
the command to execute.
|
||||
For example, ``ESC\ 4\ ^f'' moves forward four characters.
|
||||
If a command may be given a repeat count then the text ``[n]'' is given at the
|
||||
end of its description.
|
||||
.PP
|
||||
The following control characters are accepted:
|
||||
.RS
|
||||
.nf
|
||||
.ta \w'ESC DEL 'u
|
||||
^A Move to the beginning of the line
|
||||
^B Move left (backwards) [n]
|
||||
^D Delete character [n]
|
||||
^E Move to end of line
|
||||
^F Move right (forwards) [n]
|
||||
^G Ring the bell
|
||||
^H Delete character before cursor (backspace key) [n]
|
||||
^I Complete filename (tab key); see below
|
||||
^J Done with line (return key)
|
||||
^K Kill to end of line (or column [n])
|
||||
^L Redisplay line
|
||||
^M Done with line (alternate return key)
|
||||
^N Get next line from history [n]
|
||||
^P Get previous line from history [n]
|
||||
^R Search backward (forward if [n]) through history for text;
|
||||
\& prefixing the string with a caret (^) forces it to
|
||||
\& match only at the beginning of a history line
|
||||
^T Transpose characters
|
||||
^V Insert next character, even if it is an edit command
|
||||
^W Wipe to the mark
|
||||
^X^X Exchange current location and mark
|
||||
^Y Yank back last killed text
|
||||
^[ Start an escape sequence (escape key)
|
||||
^]c Move forward to next character ``c''
|
||||
^? Delete character before cursor (delete key) [n]
|
||||
.fi
|
||||
.RE
|
||||
.PP
|
||||
The following escape sequences are provided.
|
||||
.RS
|
||||
.nf
|
||||
.ta \w'ESC DEL 'u
|
||||
ESC\ ^H Delete previous word (backspace key) [n]
|
||||
ESC\ DEL Delete previous word (delete key) [n]
|
||||
ESC\ ESC Show possible completions; see below
|
||||
ESC\ SP Set the mark (space key); see ^X^X and ^Y above
|
||||
ESC\ . Get the last (or [n]'th) word from previous line
|
||||
ESC\ ? Show possible completions; see below
|
||||
ESC\ < Move to start of history
|
||||
ESC\ > Move to end of history
|
||||
ESC\ b Move backward a word [n]
|
||||
ESC\ d Delete word under cursor [n]
|
||||
ESC\ f Move forward a word [n]
|
||||
ESC\ l Make word lowercase [n]
|
||||
ESC\ m Toggle if 8bit chars display as themselves or with
|
||||
\& an ``M\-'' prefix
|
||||
ESC\ u Make word uppercase [n]
|
||||
ESC\ y Yank back last killed text
|
||||
ESC\ w Make area up to mark yankable
|
||||
ESC\ nn Set repeat count to the number nn
|
||||
ESC\ C Read from environment variable ``_C_'', where C is
|
||||
\& an uppercase letter
|
||||
.fi
|
||||
.RE
|
||||
.PP
|
||||
The
|
||||
.I editline
|
||||
library has a small macro facility.
|
||||
If you type the escape key followed by an uppercase letter,
|
||||
.IR C ,
|
||||
then the contents of the environment variable
|
||||
.I _C_
|
||||
are read in as if you had typed them at the keyboard.
|
||||
For example, if the variable
|
||||
.I _L_
|
||||
contains the following:
|
||||
.RS
|
||||
^A^Kecho '^V^[[H^V^[[2J'^M
|
||||
.RE
|
||||
Then typing ``ESC L'' will move to the beginning of the line, kill the
|
||||
entire line, enter the echo command needed to clear the terminal (if your
|
||||
terminal is like a VT-100), and send the line back to the shell.
|
||||
.PP
|
||||
The
|
||||
.I editline
|
||||
library also does filename completion.
|
||||
Suppose the root directory has the following files in it:
|
||||
.RS
|
||||
.nf
|
||||
.ta \w'core 'u
|
||||
bin vmunix
|
||||
core vmunix.old
|
||||
.fi
|
||||
.RE
|
||||
If you type ``rm\ /v'' and then the tab key.
|
||||
.I Editline
|
||||
will then finish off as much of the name as possible by adding ``munix''.
|
||||
Because the name is not unique, it will then beep.
|
||||
If you type the escape key followed by either a question mark or another
|
||||
escape, it will display the two choices.
|
||||
If you then type a period and a tab, the library will finish off the filename
|
||||
for you:
|
||||
.RS
|
||||
.nf
|
||||
.RI "rm /v[TAB]" munix ".[TAB]" old
|
||||
.fi
|
||||
.RE
|
||||
The tab key is shown by ``[TAB]'' and the automatically-entered text
|
||||
is shown in italics.
|
||||
.SH "BUGS AND LIMITATIONS"
|
||||
Cannot handle lines more than 80 columns.
|
||||
.SH AUTHORS
|
||||
Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy>
|
||||
and Rich $alz <rsalz@osf.org>.
|
||||
Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
/* $Revision: 1.2 $
|
||||
**
|
||||
** Internal header file for editline library.
|
||||
*/
|
||||
|
||||
#include <ndb_global.h>
|
||||
|
||||
#if defined(SYS_UNIX)
|
||||
#include "unix.h"
|
||||
#endif /* defined(SYS_UNIX) */
|
||||
|
||||
#define MEM_INC 64
|
||||
#define SCREEN_INC 256
|
||||
|
||||
/*
|
||||
** Variables and routines internal to this package.
|
||||
*/
|
||||
extern int rl_eof;
|
||||
extern int rl_erase;
|
||||
extern int rl_intr;
|
||||
extern int rl_kill;
|
||||
extern int rl_quit;
|
||||
#if defined(DO_SIGTSTP)
|
||||
extern int rl_susp;
|
||||
#endif /* defined(DO_SIGTSTP) */
|
||||
extern char *rl_complete();
|
||||
extern int rl_list_possib();
|
||||
extern void rl_ttyset();
|
||||
extern void rl_add_slash();
|
||||
|
@ -1,132 +0,0 @@
|
||||
/* $Revision: 1.4 $
|
||||
**
|
||||
** Unix system-dependant routines for editline library.
|
||||
*/
|
||||
#include "editline_internal.h"
|
||||
|
||||
#if defined(HAVE_TCGETATTR)
|
||||
#include <termios.h>
|
||||
|
||||
void
|
||||
rl_ttyset(int Reset)
|
||||
{
|
||||
static struct termios old;
|
||||
struct termios new;
|
||||
|
||||
if (Reset == 0) {
|
||||
if (tcgetattr(0, &old) < 0) perror("tcgetattr");
|
||||
rl_erase = old.c_cc[VERASE];
|
||||
rl_kill = old.c_cc[VKILL];
|
||||
rl_eof = old.c_cc[VEOF];
|
||||
rl_intr = old.c_cc[VINTR];
|
||||
rl_quit = old.c_cc[VQUIT];
|
||||
#if defined(DO_SIGTSTP)
|
||||
rl_susp = old.c_cc[VSUSP];
|
||||
#endif /* defined(DO_SIGTSTP) */
|
||||
|
||||
new = old;
|
||||
new.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||
new.c_iflag &= ~(ISTRIP | INPCK);
|
||||
new.c_cc[VMIN] = 1;
|
||||
new.c_cc[VTIME] = 0;
|
||||
if (tcsetattr(0, TCSADRAIN, &new) < 0) perror("tcsetattr");
|
||||
}
|
||||
else
|
||||
(void)tcsetattr(0, TCSADRAIN, &old);
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(HAVE_TERMIO)
|
||||
#include <termio.h>
|
||||
|
||||
void
|
||||
rl_ttyset(int Reset)
|
||||
{
|
||||
static struct termio old;
|
||||
struct termio new;
|
||||
|
||||
if (Reset == 0) {
|
||||
(void)ioctl(0, TCGETA, &old);
|
||||
rl_erase = old.c_cc[VERASE];
|
||||
rl_kill = old.c_cc[VKILL];
|
||||
rl_eof = old.c_cc[VEOF];
|
||||
rl_intr = old.c_cc[VINTR];
|
||||
rl_quit = old.c_cc[VQUIT];
|
||||
#if defined(DO_SIGTSTP)
|
||||
rl_susp = old.c_cc[VSUSP];
|
||||
#endif /* defined(DO_SIGTSTP) */
|
||||
|
||||
new = old;
|
||||
new.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||
new.c_iflag &= ~(ISTRIP | INPCK);
|
||||
new.c_cc[VMIN] = 1;
|
||||
new.c_cc[VTIME] = 0;
|
||||
(void)ioctl(0, TCSETAW, &new);
|
||||
}
|
||||
else
|
||||
(void)ioctl(0, TCSETAW, &old);
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sgtty.h>
|
||||
|
||||
void
|
||||
rl_ttyset(int Reset)
|
||||
{
|
||||
static struct sgttyb old_sgttyb;
|
||||
static struct tchars old_tchars;
|
||||
struct sgttyb new_sgttyb;
|
||||
struct tchars new_tchars;
|
||||
#if defined(DO_SIGTSTP)
|
||||
struct ltchars old_ltchars;
|
||||
#endif /* defined(DO_SIGTSTP) */
|
||||
|
||||
if (Reset == 0) {
|
||||
(void)ioctl(0, TIOCGETP, &old_sgttyb);
|
||||
rl_erase = old_sgttyb.sg_erase;
|
||||
rl_kill = old_sgttyb.sg_kill;
|
||||
|
||||
(void)ioctl(0, TIOCGETC, &old_tchars);
|
||||
rl_eof = old_tchars.t_eofc;
|
||||
rl_intr = old_tchars.t_intrc;
|
||||
rl_quit = old_tchars.t_quitc;
|
||||
|
||||
#if defined(DO_SIGTSTP)
|
||||
(void)ioctl(0, TIOCGLTC, &old_ltchars);
|
||||
rl_susp = old_ltchars.t_suspc;
|
||||
#endif /* defined(DO_SIGTSTP) */
|
||||
|
||||
new_sgttyb = old_sgttyb;
|
||||
new_sgttyb.sg_flags &= ~ECHO;
|
||||
new_sgttyb.sg_flags |= RAW;
|
||||
#if defined(PASS8)
|
||||
new_sgttyb.sg_flags |= PASS8;
|
||||
#endif /* defined(PASS8) */
|
||||
(void)ioctl(0, TIOCSETP, &new_sgttyb);
|
||||
|
||||
new_tchars = old_tchars;
|
||||
new_tchars.t_intrc = -1;
|
||||
new_tchars.t_quitc = -1;
|
||||
(void)ioctl(0, TIOCSETC, &new_tchars);
|
||||
}
|
||||
else {
|
||||
(void)ioctl(0, TIOCSETP, &old_sgttyb);
|
||||
(void)ioctl(0, TIOCSETC, &old_tchars);
|
||||
}
|
||||
}
|
||||
#endif /* defined(HAVE_TERMIO) */
|
||||
#endif /* defined(HAVE_TCGETATTR) */
|
||||
|
||||
void
|
||||
rl_add_slash(char *path, char *p, size_t p_len)
|
||||
{
|
||||
struct stat Sb;
|
||||
|
||||
if (stat(path, &Sb) >= 0) {
|
||||
size_t len= strlen(p);
|
||||
if (len+1 < p_len) {
|
||||
p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' ';
|
||||
p[len+1]= 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
include .defs.mk
|
||||
|
||||
TYPE := util
|
||||
|
||||
BIN_TARGET := editline_test
|
||||
BIN_TARGET_ARCHIVES := editline
|
||||
|
||||
SOURCES = testit.c
|
||||
|
||||
include $(NDB_TOP)/Epilogue.mk
|
@ -1,55 +0,0 @@
|
||||
/* Copyright (C) 2003 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* -*- c-basic-offset: 4; -*-
|
||||
** $Revision: 1.5 $
|
||||
**
|
||||
** A "micro-shell" to test editline library.
|
||||
** If given any arguments, commands aren't executed.
|
||||
*/
|
||||
#include <ndb_global.h>
|
||||
#include <editline/editline.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *prompt;
|
||||
char *p;
|
||||
int doit;
|
||||
|
||||
(void)argv; /* Suppress warning */
|
||||
|
||||
doit = argc == 1;
|
||||
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
||||
prompt = "testit> ";
|
||||
|
||||
while ((p = readline(prompt)) != NULL) {
|
||||
(void)printf("\t\t\t|%s|\n", p);
|
||||
if (doit) {
|
||||
if (strncmp(p, "cd ", 3) == 0) {
|
||||
if (chdir(&p[3]) < 0)
|
||||
perror(&p[3]);
|
||||
} else {
|
||||
if (system(p) != 0)
|
||||
perror(p);
|
||||
}
|
||||
}
|
||||
add_history(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* $Revision: 1.3 $
|
||||
**
|
||||
** Editline system header file for Unix.
|
||||
*/
|
||||
|
||||
#define CRLF "\r\n"
|
||||
|
||||
#include <ndb_global.h>
|
||||
#include <dirent.h>
|
@ -17,7 +17,195 @@
|
||||
#include <ndb_global.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
#include "CommandInterpreter.hpp"
|
||||
// copied from mysql.cc to get readline
|
||||
extern "C" {
|
||||
#if defined( __WIN__) || defined(OS2)
|
||||
#include <conio.h>
|
||||
#elif !defined(__NETWARE__)
|
||||
#include <readline/readline.h>
|
||||
extern "C" int add_history(const char *command); /* From readline directory */
|
||||
#define HAVE_READLINE
|
||||
#endif
|
||||
}
|
||||
|
||||
//#define HAVE_GLOBAL_REPLICATION
|
||||
|
||||
#include <Vector.hpp>
|
||||
#ifdef HAVE_GLOBAL_REPLICATION
|
||||
#include "../rep/repapi/repapi.h"
|
||||
#endif
|
||||
|
||||
#include <mgmapi.h>
|
||||
|
||||
class MgmtSrvr;
|
||||
|
||||
/**
|
||||
* @class CommandInterpreter
|
||||
* @brief Reads command line in management client
|
||||
*
|
||||
* This class has one public method which reads a command line
|
||||
* from a stream. It then interpret that commmand line and calls a suitable
|
||||
* method in the MgmtSrvr class which executes the command.
|
||||
*
|
||||
* For command syntax, see the HELP command.
|
||||
*/
|
||||
class CommandInterpreter {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param mgmtSrvr: Management server to use when executing commands
|
||||
*/
|
||||
CommandInterpreter(const char *);
|
||||
~CommandInterpreter();
|
||||
|
||||
/**
|
||||
* Reads one line from the stream, parse the line to find
|
||||
* a command and then calls a suitable method which executes
|
||||
* the command.
|
||||
*
|
||||
* @return true until quit/bye/exit has been typed
|
||||
*/
|
||||
int readAndExecute(int _try_reconnect=-1);
|
||||
int execute(const char *_line, int _try_reconnect=-1);
|
||||
|
||||
private:
|
||||
void printError();
|
||||
|
||||
/**
|
||||
* Analyse the command line, after the first token.
|
||||
*
|
||||
* @param processId: DB process id to send command to or -1 if
|
||||
* command will be sent to all DB processes.
|
||||
* @param allAfterFirstToken: What the client gave after the
|
||||
* first token on the command line
|
||||
*/
|
||||
void analyseAfterFirstToken(int processId, char* allAfterFirstTokenCstr);
|
||||
|
||||
/**
|
||||
* Parse the block specification part of the LOG* commands,
|
||||
* things after LOG*: [BLOCK = {ALL|<blockName>+}]
|
||||
*
|
||||
* @param allAfterLog: What the client gave after the second token
|
||||
* (LOG*) on the command line
|
||||
* @param blocks, OUT: ALL or name of all the blocks
|
||||
* @return: true if correct syntax, otherwise false
|
||||
*/
|
||||
bool parseBlockSpecification(const char* allAfterLog,
|
||||
Vector<const char*>& blocks);
|
||||
|
||||
/**
|
||||
* A bunch of execute functions: Executes one of the commands
|
||||
*
|
||||
* @param processId: DB process id to send command to
|
||||
* @param parameters: What the client gave after the command name
|
||||
* on the command line.
|
||||
* For example if complete input from user is: "1 LOGLEVEL 22" then the
|
||||
* parameters argument is the string with everything after LOGLEVEL, in
|
||||
* this case "22". Each function is responsible to check the parameters
|
||||
* argument.
|
||||
*/
|
||||
void executeHelp(char* parameters);
|
||||
void executeShow(char* parameters);
|
||||
void executeShutdown(char* parameters);
|
||||
void executeRun(char* parameters);
|
||||
void executeInfo(char* parameters);
|
||||
void executeClusterLog(char* parameters);
|
||||
|
||||
public:
|
||||
void executeStop(int processId, const char* parameters, bool all);
|
||||
void executeEnterSingleUser(char* parameters);
|
||||
void executeExitSingleUser(char* parameters);
|
||||
void executeStart(int processId, const char* parameters, bool all);
|
||||
void executeRestart(int processId, const char* parameters, bool all);
|
||||
void executeLogLevel(int processId, const char* parameters, bool all);
|
||||
void executeError(int processId, const char* parameters, bool all);
|
||||
void executeTrace(int processId, const char* parameters, bool all);
|
||||
void executeLog(int processId, const char* parameters, bool all);
|
||||
void executeLogIn(int processId, const char* parameters, bool all);
|
||||
void executeLogOut(int processId, const char* parameters, bool all);
|
||||
void executeLogOff(int processId, const char* parameters, bool all);
|
||||
void executeTestOn(int processId, const char* parameters, bool all);
|
||||
void executeTestOff(int processId, const char* parameters, bool all);
|
||||
void executeSet(int processId, const char* parameters, bool all);
|
||||
void executeGetStat(int processId, const char* parameters, bool all);
|
||||
void executeStatus(int processId, const char* parameters, bool all);
|
||||
void executeEventReporting(int processId, const char* parameters, bool all);
|
||||
void executeDumpState(int processId, const char* parameters, bool all);
|
||||
void executeStartBackup(char * parameters);
|
||||
void executeAbortBackup(char * parameters);
|
||||
|
||||
void executeRep(char* parameters);
|
||||
|
||||
void executeCpc(char * parameters);
|
||||
|
||||
public:
|
||||
bool connect();
|
||||
bool disconnect();
|
||||
|
||||
/**
|
||||
* A execute function definition
|
||||
*/
|
||||
public:
|
||||
typedef void (CommandInterpreter::* ExecuteFunction)(int processId,
|
||||
const char * param,
|
||||
bool all);
|
||||
|
||||
struct CommandFunctionPair {
|
||||
const char * command;
|
||||
ExecuteFunction executeFunction;
|
||||
};
|
||||
private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void executeForAll(const char * cmd,
|
||||
ExecuteFunction fun,
|
||||
const char * param);
|
||||
|
||||
NdbMgmHandle m_mgmsrv;
|
||||
bool connected;
|
||||
const char *host;
|
||||
int try_reconnect;
|
||||
#ifdef HAVE_GLOBAL_REPLICATION
|
||||
NdbRepHandle m_repserver;
|
||||
const char *rep_host;
|
||||
bool rep_connected;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Facade object for CommandInterpreter
|
||||
*/
|
||||
|
||||
#include "ndb_mgmclient.hpp"
|
||||
|
||||
Ndb_mgmclient::Ndb_mgmclient(const char *host)
|
||||
{
|
||||
m_cmd= new CommandInterpreter(host);
|
||||
}
|
||||
Ndb_mgmclient::~Ndb_mgmclient()
|
||||
{
|
||||
delete m_cmd;
|
||||
}
|
||||
int Ndb_mgmclient::read_and_execute(int _try_reconnect)
|
||||
{
|
||||
return m_cmd->readAndExecute(_try_reconnect);
|
||||
}
|
||||
int Ndb_mgmclient::execute(const char *_line, int _try_reconnect)
|
||||
{
|
||||
return m_cmd->execute(_line,_try_reconnect);
|
||||
}
|
||||
int
|
||||
Ndb_mgmclient::disconnect()
|
||||
{
|
||||
return m_cmd->disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The CommandInterpreter
|
||||
*/
|
||||
|
||||
#include <mgmapi.h>
|
||||
#include <mgmapi_debug.h>
|
||||
@ -33,7 +221,10 @@
|
||||
|
||||
#endif // HAVE_GLOBAL_REPLICATION
|
||||
#include "MgmtErrorReporter.hpp"
|
||||
#include "CpcClient.hpp"
|
||||
#include <Parser.hpp>
|
||||
#include <SocketServer.hpp>
|
||||
#include <util/InputStream.hpp>
|
||||
#include <util/OutputStream.hpp>
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -201,7 +392,7 @@ CommandInterpreter::~CommandInterpreter()
|
||||
host = NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
static bool
|
||||
emptyString(const char* s)
|
||||
{
|
||||
if (s == NULL) {
|
||||
@ -265,17 +456,47 @@ CommandInterpreter::disconnect()
|
||||
|
||||
int
|
||||
CommandInterpreter::readAndExecute(int _try_reconnect)
|
||||
{
|
||||
static char *line_read = (char *)NULL;
|
||||
|
||||
/* If the buffer has already been allocated, return the memory
|
||||
to the free pool. */
|
||||
if (line_read)
|
||||
{
|
||||
free (line_read);
|
||||
line_read = (char *)NULL;
|
||||
}
|
||||
#ifdef HAVE_READLINE
|
||||
/* Get a line from the user. */
|
||||
line_read = readline ("ndb_mgm> ");
|
||||
/* If the line has any text in it, save it on the history. */
|
||||
if (line_read && *line_read)
|
||||
add_history (line_read);
|
||||
#else
|
||||
static char linebuffer[254];
|
||||
fputs("ndb_mgm> ", stdout);
|
||||
linebuffer[sizeof(linebuffer)-1]=0;
|
||||
line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin);
|
||||
if (line_read == linebuffer) {
|
||||
char *q=linebuffer;
|
||||
while (*q > 31) q++;
|
||||
*q=0;
|
||||
line_read= strdup(linebuffer);
|
||||
}
|
||||
#endif
|
||||
return execute(line_read,_try_reconnect);
|
||||
}
|
||||
|
||||
int
|
||||
CommandInterpreter::execute(const char *_line, int _try_reconnect)
|
||||
{
|
||||
if (_try_reconnect >= 0)
|
||||
try_reconnect=_try_reconnect;
|
||||
|
||||
char* _line = readline_gets();
|
||||
char * line;
|
||||
if(_line == NULL) {
|
||||
// ndbout << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
line = my_strdup(_line,MYF(MY_WME));
|
||||
My_auto_ptr<char> ptr(line);
|
||||
|
||||
@ -349,10 +570,6 @@ CommandInterpreter::readAndExecute(int _try_reconnect)
|
||||
strcmp(firstToken, "BYE") == 0) &&
|
||||
allAfterFirstToken == NULL){
|
||||
return false;
|
||||
#if 0
|
||||
} else if(strcmp(firstToken, "CPC") == 0) {
|
||||
executeCpc(allAfterFirstToken);
|
||||
#endif
|
||||
} else {
|
||||
/**
|
||||
* First token should be a digit, node ID
|
||||
@ -1903,169 +2120,4 @@ CommandInterpreter::executeRep(char* parameters)
|
||||
}
|
||||
#endif // HAVE_GLOBAL_REPLICATION
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* CPC
|
||||
*****************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
#if 0
|
||||
//#ifdef NDB_SOLARIS // XXX fix me
|
||||
static char* strsep(char** x, const char* y) { return 0; }
|
||||
#endif
|
||||
|
||||
// Note this code has not been verified
|
||||
#if 0
|
||||
static char * my_strsep(char **stringp, const char *delim)
|
||||
{
|
||||
char *tmp= *stringp;
|
||||
if (tmp == 0)
|
||||
return 0;
|
||||
*stringp = strtok(tmp, delim);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
CommandInterpreter::executeCpc(char *parameters)
|
||||
{
|
||||
char *host_str = NULL, *port_str = NULL, *end;
|
||||
long port = 1234; /* XXX */
|
||||
|
||||
while((host_str = my_strsep(¶meters, " \t:")) != NULL &&
|
||||
host_str[0] == '\0');
|
||||
|
||||
if(parameters && parameters[0] != '\0') {
|
||||
while((port_str = my_strsep(¶meters, " \t:")) != NULL &&
|
||||
port_str[0] == '\0');
|
||||
|
||||
errno = 0;
|
||||
port = strtol(port_str, &end, 0);
|
||||
if(end[0] != '\0')
|
||||
goto error;
|
||||
if((port == LONG_MAX || port == LONG_MIN) &&
|
||||
errno == ERANGE)
|
||||
goto error;
|
||||
}
|
||||
|
||||
{
|
||||
SimpleCpcClient cpc(host_str, port);
|
||||
bool done = false;
|
||||
|
||||
if(cpc.connect() < 0) {
|
||||
ndbout_c("Cannot connect to %s:%d.", cpc.getHost(), cpc.getPort());
|
||||
switch(errno) {
|
||||
case ENOENT:
|
||||
ndbout << ": " << "No such host" << endl;
|
||||
break;
|
||||
default:
|
||||
ndbout << ": " << strerror(errno) << endl;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
while(!done) {
|
||||
char *line = readline("CPC> ");
|
||||
if(line != NULL) {
|
||||
add_history(line);
|
||||
|
||||
char *cmd = strtok(line, " ");
|
||||
char *arg = strtok(NULL, "");
|
||||
|
||||
if(arg != NULL) {
|
||||
while(arg[0] == ' ')
|
||||
arg++;
|
||||
if(strlen(arg) == 0)
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
if(cmd != NULL) {
|
||||
if(strcmp(cmd, "exit") == 0)
|
||||
done = true;
|
||||
else if(strcmp(cmd, "list") == 0)
|
||||
cpc.cmd_list(arg);
|
||||
else if(strcmp(cmd, "start") == 0)
|
||||
cpc.cmd_start(arg);
|
||||
else if(strcmp(cmd, "stop") == 0)
|
||||
cpc.cmd_stop(arg);
|
||||
else if(strcmp(cmd, "help") == 0)
|
||||
cpc.cmd_help(arg);
|
||||
}
|
||||
} else {
|
||||
done = true;
|
||||
ndbout << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
ndbout << "Error: expected a tcp port number, got '" << port_str << "'."
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static
|
||||
void
|
||||
CmdBackupCallback(const MgmtSrvr::BackupEvent & event){
|
||||
char str[255];
|
||||
|
||||
ndbout << endl;
|
||||
|
||||
bool ok = false;
|
||||
switch(event.Event){
|
||||
case MgmtSrvr::BackupEvent::BackupStarted:
|
||||
ok = true;
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
"Backup %d started", event.Started.BackupId);
|
||||
break;
|
||||
case MgmtSrvr::BackupEvent::BackupFailedToStart:
|
||||
ok = true;
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
"Backup failed to start (Error %d)",
|
||||
event.FailedToStart.ErrorCode);
|
||||
break;
|
||||
case MgmtSrvr::BackupEvent::BackupCompleted:
|
||||
ok = true;
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
"Backup %d completed",
|
||||
event.Completed.BackupId);
|
||||
ndbout << str << endl;
|
||||
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
" StartGCP: %d StopGCP: %d",
|
||||
event.Completed.startGCP, event.Completed.stopGCP);
|
||||
ndbout << str << endl;
|
||||
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
" #Records: %d #LogRecords: %d",
|
||||
event.Completed.NoOfRecords, event.Completed.NoOfLogRecords);
|
||||
ndbout << str << endl;
|
||||
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
" Data: %d bytes Log: %d bytes",
|
||||
event.Completed.NoOfBytes, event.Completed.NoOfLogBytes);
|
||||
break;
|
||||
case MgmtSrvr::BackupEvent::BackupAborted:
|
||||
ok = true;
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
"Backup %d has been aborted reason %d",
|
||||
event.Aborted.BackupId,
|
||||
event.Aborted.Reason);
|
||||
break;
|
||||
}
|
||||
if(!ok){
|
||||
BaseString::snprintf(str, sizeof(str),
|
||||
"Unknown backup event: %d",
|
||||
event.Event);
|
||||
|
||||
}
|
||||
ndbout << str << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
template class Vector<char const*>;
|
||||
|
@ -1,197 +0,0 @@
|
||||
/* Copyright (C) 2003 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef CommandInterpreter_H
|
||||
#define CommandInterpreter_H
|
||||
|
||||
//#define HAVE_GLOBAL_REPLICATION
|
||||
//*****************************************************************************
|
||||
// Author: Peter Lind
|
||||
//*****************************************************************************
|
||||
|
||||
#include <ndb_global.h>
|
||||
#include <Vector.hpp>
|
||||
#include <editline/editline.h>
|
||||
|
||||
#ifdef HAVE_GLOBAL_REPLICATION
|
||||
#include "../rep/repapi/repapi.h"
|
||||
#endif
|
||||
|
||||
#include <mgmapi.h>
|
||||
|
||||
class MgmtSrvr;
|
||||
|
||||
/**
|
||||
* @class CommandInterpreter
|
||||
* @brief Reads command line in management client
|
||||
*
|
||||
* This class has one public method which reads a command line
|
||||
* from a stream. It then interpret that commmand line and calls a suitable
|
||||
* method in the MgmtSrvr class which executes the command.
|
||||
*
|
||||
* For command syntax, see the HELP command.
|
||||
*/
|
||||
class CommandInterpreter {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param mgmtSrvr: Management server to use when executing commands
|
||||
*/
|
||||
CommandInterpreter(const char *);
|
||||
~CommandInterpreter();
|
||||
|
||||
/**
|
||||
* Reads one line from the stream, parse the line to find
|
||||
* a command and then calls a suitable method which executes
|
||||
* the command.
|
||||
*
|
||||
* @return true until quit/bye/exit has been typed
|
||||
*/
|
||||
int readAndExecute(int _try_reconnect=-1);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Read a string, and return a pointer to it.
|
||||
*
|
||||
* @return NULL on EOF.
|
||||
*/
|
||||
char *readline_gets ()
|
||||
{
|
||||
static char *line_read = (char *)NULL;
|
||||
|
||||
/* If the buffer has already been allocated, return the memory
|
||||
to the free pool. */
|
||||
if (line_read)
|
||||
{
|
||||
free (line_read);
|
||||
line_read = (char *)NULL;
|
||||
}
|
||||
|
||||
/* Get a line from the user. */
|
||||
line_read = readline ("NDB> ");
|
||||
|
||||
/* If the line has any text in it, save it on the history. */
|
||||
if (line_read && *line_read)
|
||||
add_history (line_read);
|
||||
|
||||
return (line_read);
|
||||
}
|
||||
|
||||
void printError();
|
||||
|
||||
/**
|
||||
* Analyse the command line, after the first token.
|
||||
*
|
||||
* @param processId: DB process id to send command to or -1 if
|
||||
* command will be sent to all DB processes.
|
||||
* @param allAfterFirstToken: What the client gave after the
|
||||
* first token on the command line
|
||||
*/
|
||||
void analyseAfterFirstToken(int processId, char* allAfterFirstTokenCstr);
|
||||
|
||||
/**
|
||||
* Parse the block specification part of the LOG* commands,
|
||||
* things after LOG*: [BLOCK = {ALL|<blockName>+}]
|
||||
*
|
||||
* @param allAfterLog: What the client gave after the second token
|
||||
* (LOG*) on the command line
|
||||
* @param blocks, OUT: ALL or name of all the blocks
|
||||
* @return: true if correct syntax, otherwise false
|
||||
*/
|
||||
bool parseBlockSpecification(const char* allAfterLog,
|
||||
Vector<const char*>& blocks);
|
||||
|
||||
/**
|
||||
* A bunch of execute functions: Executes one of the commands
|
||||
*
|
||||
* @param processId: DB process id to send command to
|
||||
* @param parameters: What the client gave after the command name
|
||||
* on the command line.
|
||||
* For example if complete input from user is: "1 LOGLEVEL 22" then the
|
||||
* parameters argument is the string with everything after LOGLEVEL, in
|
||||
* this case "22". Each function is responsible to check the parameters
|
||||
* argument.
|
||||
*/
|
||||
void executeHelp(char* parameters);
|
||||
void executeShow(char* parameters);
|
||||
void executeShutdown(char* parameters);
|
||||
void executeRun(char* parameters);
|
||||
void executeInfo(char* parameters);
|
||||
void executeClusterLog(char* parameters);
|
||||
|
||||
public:
|
||||
void executeStop(int processId, const char* parameters, bool all);
|
||||
void executeEnterSingleUser(char* parameters);
|
||||
void executeExitSingleUser(char* parameters);
|
||||
void executeStart(int processId, const char* parameters, bool all);
|
||||
void executeRestart(int processId, const char* parameters, bool all);
|
||||
void executeLogLevel(int processId, const char* parameters, bool all);
|
||||
void executeError(int processId, const char* parameters, bool all);
|
||||
void executeTrace(int processId, const char* parameters, bool all);
|
||||
void executeLog(int processId, const char* parameters, bool all);
|
||||
void executeLogIn(int processId, const char* parameters, bool all);
|
||||
void executeLogOut(int processId, const char* parameters, bool all);
|
||||
void executeLogOff(int processId, const char* parameters, bool all);
|
||||
void executeTestOn(int processId, const char* parameters, bool all);
|
||||
void executeTestOff(int processId, const char* parameters, bool all);
|
||||
void executeSet(int processId, const char* parameters, bool all);
|
||||
void executeGetStat(int processId, const char* parameters, bool all);
|
||||
void executeStatus(int processId, const char* parameters, bool all);
|
||||
void executeEventReporting(int processId, const char* parameters, bool all);
|
||||
void executeDumpState(int processId, const char* parameters, bool all);
|
||||
void executeStartBackup(char * parameters);
|
||||
void executeAbortBackup(char * parameters);
|
||||
|
||||
void executeRep(char* parameters);
|
||||
|
||||
void executeCpc(char * parameters);
|
||||
|
||||
public:
|
||||
bool connect();
|
||||
bool disconnect();
|
||||
|
||||
/**
|
||||
* A execute function definition
|
||||
*/
|
||||
public:
|
||||
typedef void (CommandInterpreter::* ExecuteFunction)(int processId,
|
||||
const char * param,
|
||||
bool all);
|
||||
|
||||
struct CommandFunctionPair {
|
||||
const char * command;
|
||||
ExecuteFunction executeFunction;
|
||||
};
|
||||
private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void executeForAll(const char * cmd,
|
||||
ExecuteFunction fun,
|
||||
const char * param);
|
||||
|
||||
NdbMgmHandle m_mgmsrv;
|
||||
bool connected;
|
||||
const char *host;
|
||||
int try_reconnect;
|
||||
#ifdef HAVE_GLOBAL_REPLICATION
|
||||
NdbRepHandle m_repserver;
|
||||
const char *rep_host;
|
||||
bool rep_connected;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // CommandInterpreter_H
|
@ -1,18 +1,19 @@
|
||||
|
||||
ndbtools_PROGRAMS = ndb_mgm
|
||||
noinst_LTLIBRARIES = libndbmgmclient.la
|
||||
|
||||
ndb_mgm_SOURCES = \
|
||||
main.cpp \
|
||||
CommandInterpreter.cpp \
|
||||
CpcClient.cpp
|
||||
libndbmgmclient_la_SOURCES = CommandInterpreter.cpp
|
||||
|
||||
ndb_mgm_SOURCES = main.cpp
|
||||
|
||||
include $(top_srcdir)/ndb/config/common.mk.am
|
||||
include $(top_srcdir)/ndb/config/type_ndbapi.mk.am
|
||||
|
||||
INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon
|
||||
|
||||
LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \
|
||||
$(top_builddir)/ndb/src/common/editline/libeditline.a \
|
||||
LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/libndbmgmclient.la \
|
||||
@readline_link@ \
|
||||
$(top_builddir)/ndb/src/libndbclient.la \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
$(top_builddir)/strings/libmystrings.a \
|
||||
|
@ -1,25 +0,0 @@
|
||||
include .defs.mk
|
||||
|
||||
TYPE := ndbapi
|
||||
|
||||
BIN_TARGET := mgmtclient
|
||||
BIN_TARGET_LIBS :=
|
||||
BIN_TARGET_ARCHIVES := trace logger mgmapi general mgmsrvcommon portlib repapi
|
||||
|
||||
BIN_TARGET_ARCHIVES += editline
|
||||
|
||||
DIRS = test_cpcd
|
||||
|
||||
# Source files of non-templated classes (.cpp files)
|
||||
SOURCES = \
|
||||
main.cpp \
|
||||
CommandInterpreter.cpp \
|
||||
CpcClient.cpp
|
||||
|
||||
CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/mgmapi) \
|
||||
-I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon)
|
||||
|
||||
include $(NDB_TOP)/Epilogue.mk
|
||||
|
||||
_bins_mkconfig : $(NDB_TOP)/bin/$(BIN_TARGET)
|
||||
|
@ -23,12 +23,12 @@
|
||||
#include <ndb_version.h>
|
||||
#include <LocalConfig.hpp>
|
||||
|
||||
#include "CommandInterpreter.hpp"
|
||||
#include "ndb_mgmclient.hpp"
|
||||
|
||||
const char *progname = "ndb_mgm";
|
||||
|
||||
|
||||
static CommandInterpreter* com;
|
||||
static Ndb_mgmclient* com;
|
||||
|
||||
extern "C"
|
||||
void
|
||||
@ -127,8 +127,8 @@ int main(int argc, char** argv){
|
||||
|
||||
signal(SIGPIPE, handler);
|
||||
|
||||
com = new CommandInterpreter(buf);
|
||||
while(com->readAndExecute(_try_reconnect));
|
||||
com = new Ndb_mgmclient(buf);
|
||||
while(com->read_and_execute(_try_reconnect));
|
||||
delete com;
|
||||
|
||||
return 0;
|
||||
|
@ -14,19 +14,20 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef Ndb_mgmclient_h
|
||||
#define Ndb_mgmclient_h
|
||||
|
||||
#include <ndb_global.h>
|
||||
|
||||
|
||||
char* readline(const char* prompt)
|
||||
class CommandInterpreter;
|
||||
class Ndb_mgmclient
|
||||
{
|
||||
char* szBuf;
|
||||
printf(prompt);
|
||||
szBuf = (char*)malloc(256);
|
||||
return gets(szBuf);
|
||||
}
|
||||
|
||||
void add_history(char* pch)
|
||||
{
|
||||
}
|
||||
public:
|
||||
Ndb_mgmclient(const char*);
|
||||
~Ndb_mgmclient();
|
||||
int read_and_execute(int _try_reconnect=-1);
|
||||
int execute(const char *_line, int _try_reconnect=-1);
|
||||
int disconnect();
|
||||
private:
|
||||
CommandInterpreter *m_cmd;
|
||||
};
|
||||
|
||||
#endif // Ndb_mgmclient_h
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include <ndb_global.h>
|
||||
#include <Vector.hpp>
|
||||
#include <editline/editline.h>
|
||||
#include <BaseString.hpp>
|
||||
|
||||
class MgmtSrvr;
|
||||
@ -63,26 +62,27 @@ private:
|
||||
*/
|
||||
char *readline_gets ()
|
||||
{
|
||||
static char linebuffer[254];
|
||||
static char *line_read = (char *)NULL;
|
||||
|
||||
// Disable the default file-name completion action of TAB
|
||||
// rl_bind_key ('\t', rl_insert);
|
||||
|
||||
/* If the buffer has already been allocated, return the memory
|
||||
to the free pool. */
|
||||
if (line_read)
|
||||
{
|
||||
free (line_read);
|
||||
line_read = (char *)NULL;
|
||||
}
|
||||
{
|
||||
free (line_read);
|
||||
line_read = (char *)NULL;
|
||||
}
|
||||
|
||||
/* Get a line from the user. */
|
||||
line_read = readline ("NDB> ");
|
||||
|
||||
/* If the line has any text in it, save it on the history. */
|
||||
if (line_read && *line_read)
|
||||
add_history (line_read);
|
||||
|
||||
fputs("ndb_mgmd> ", stdout);
|
||||
linebuffer[sizeof(linebuffer)-1]=0;
|
||||
line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin);
|
||||
if (line_read == linebuffer) {
|
||||
char *q=linebuffer;
|
||||
while (*q > 31) q++;
|
||||
*q=0;
|
||||
line_read= strdup(linebuffer);
|
||||
}
|
||||
return (line_read);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ INCLUDES_LOC = -I$(top_srcdir)/ndb/src/ndbapi \
|
||||
-I$(top_srcdir)/ndb/src/common/mgmcommon
|
||||
|
||||
LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \
|
||||
$(top_builddir)/ndb/src/common/editline/libeditline.a \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
|
||||
|
@ -11,9 +11,8 @@ test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \
|
||||
atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh
|
||||
|
||||
atrt_SOURCES = main.cpp
|
||||
INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/ndb/src/mgmclient
|
||||
LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \
|
||||
$(top_builddir)/ndb/test/src/libNDBT.a \
|
||||
INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include
|
||||
LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \
|
||||
$(top_builddir)/ndb/src/libndbclient.la \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
|
@ -9,7 +9,8 @@ libNDBT_a_SOURCES = \
|
||||
HugoAsynchTransactions.cpp UtilTransactions.cpp \
|
||||
NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \
|
||||
NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \
|
||||
NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c
|
||||
NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c \
|
||||
CpcClient.cpp
|
||||
|
||||
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/common/mgmcommon -I$(top_srcdir)/ndb/include/mgmcommon -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/src/mgmapi
|
||||
|
||||
|
@ -20,12 +20,10 @@ copy_tab_SOURCES = copy_tab.cpp
|
||||
create_index_SOURCES = create_index.cpp
|
||||
ndb_cpcc_SOURCES = cpcc.cpp
|
||||
|
||||
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmclient
|
||||
|
||||
include $(top_srcdir)/ndb/config/common.mk.am
|
||||
include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am
|
||||
|
||||
ndb_cpcc_LDADD = $(LDADD) $(top_builddir)/ndb/src/mgmclient/CpcClient.o
|
||||
ndb_cpcc_LDADD = $(LDADD)
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
|
Reference in New Issue
Block a user