diff options
Diffstat (limited to 'mysql-client/mysql/downstream')
-rw-r--r-- | mysql-client/mysql/downstream/mysql_version.h | 5 | ||||
-rw-r--r-- | mysql-client/mysql/downstream/readline.c | 87 | ||||
-rw-r--r-- | mysql-client/mysql/downstream/readline.h | 59 |
3 files changed, 151 insertions, 0 deletions
diff --git a/mysql-client/mysql/downstream/mysql_version.h b/mysql-client/mysql/downstream/mysql_version.h new file mode 100644 index 0000000..fd4471b --- /dev/null +++ b/mysql-client/mysql/downstream/mysql_version.h @@ -0,0 +1,5 @@ +/* file : mysql/downstream/mysql_version.h + * license : GPLv2 with Universal FOSS Exception; see accompanying LICENSE file + */ + +#include <mysql/mysql_version.h> diff --git a/mysql-client/mysql/downstream/readline.c b/mysql-client/mysql/downstream/readline.c new file mode 100644 index 0000000..7522be5 --- /dev/null +++ b/mysql-client/mysql/downstream/readline.c @@ -0,0 +1,87 @@ +/* file : mysql/downstream/readline.h + * license : GPLv2 with Universal FOSS Exception; see accompanying LICENSE file + */ + +#include <downstream/readline.h> + +#include <isocline.h> + +char* rl_readline_name = NULL; +rl_completion_func_t* rl_attempted_completion_function = NULL; +rl_compentry_func_t* rl_completion_entry_function = NULL; + +int history_length = 0; + +/* Perform some basic libisocline initialization on the first readline() call. + */ +static int init = 1; + +#define UNUSED(x) (void)(x) + +char* +readline (const char* prompt) +{ + if (init) + { + init = 0; + + ic_set_prompt_marker("" /* prompt_marker */, + NULL /* continuation_prompt_marker */); + + } + + return ic_readline (prompt); +} + +int +add_history (const char* command) +{ + UNUSED (command); + return 1; /* Unsupported */ +} + +int +read_history (const char* file) +{ + UNUSED (file); + return 1; /* Unsupported */ +} + +int +write_history (const char* command) +{ + UNUSED (command); + return 1; /* Unsupported */ +} + +HIST_ENTRY* +history_get (int offset) +{ + UNUSED (offset); + return NULL; +} + +int +rl_insert (int count, int chr) +{ + UNUSED (count); + UNUSED (chr); + return 1; /* Unsupported */ +} + +int +rl_add_defun (const char* name, rl_command_func_t* f, int chr) +{ + UNUSED (name); + UNUSED (f); + UNUSED (chr); + return 1; /* Unsupported */ +} + +char** +rl_completion_matches (const char* str, rl_compentry_func_t* f) +{ + UNUSED (str); + UNUSED (f); + return NULL; +} diff --git a/mysql-client/mysql/downstream/readline.h b/mysql-client/mysql/downstream/readline.h new file mode 100644 index 0000000..1540200 --- /dev/null +++ b/mysql-client/mysql/downstream/readline.h @@ -0,0 +1,59 @@ +/* file : mysql/downstream/readline.h + * license : GPLv2 with Universal FOSS Exception; see accompanying LICENSE file + */ + +#ifndef MYSQL_DOWNSTREAM_READLINE_H +#define MYSQL_DOWNSTREAM_READLINE_H + +/* + * Reduced implementation of the libedit library based on libisocline. + * + * Specially, only the basic line editing functionality is supported (no + * completion, history, etc). + */ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Thin wrapper around libisocline's ic_readline(). + */ +char* +readline (const char* prompt); + +/* + * Reading function stubs. + */ +typedef char** rl_completion_func_t (const char*, int, int); +typedef char* rl_compentry_func_t (const char*, int); +typedef int rl_command_func_t (int, int); +typedef char* rl_compentry_func_t (const char*, int); + +int rl_insert (int, int); +int rl_add_defun (const char*, rl_command_func_t*, int); +char** rl_completion_matches (const char*, rl_compentry_func_t*); + +extern char* rl_readline_name; +extern rl_completion_func_t* rl_attempted_completion_function; +extern rl_compentry_func_t* rl_completion_entry_function; + +/* + * Hstory function stubs. + */ +typedef struct _hist_entry { + const char *line; + const char *data; +} HIST_ENTRY; + +int add_history (const char*); +int read_history (const char*); +int write_history (const char*); +HIST_ENTRY* history_get (int); + +extern int history_length; + +#ifdef __cplusplus +} +#endif + +#endif /* MYSQL_DOWNSTREAM_READLINE_H */ |