Changeset: e059e4d2edd5 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e059e4d2edd5 Modified Files: clients/src/mapiclient/Makefile.ag clients/src/mapiclient/MapiClient.mx clients/src/mapiclient/mclient.mx Branch: default Log Message:
Rename MapiClient.mx into mclient now that we retain history over moves diffs (truncated from 5274 to 300 lines): diff -r c96ec91aee07 -r e059e4d2edd5 clients/src/mapiclient/Makefile.ag --- a/clients/src/mapiclient/Makefile.ag Sat May 08 20:52:49 2010 +0200 +++ b/clients/src/mapiclient/Makefile.ag Sun May 09 09:58:06 2010 +0200 @@ -27,7 +27,7 @@ #Name alignment of tools in M5 context. bin_mclient = { - SOURCES = MapiClient.mx ReadlineTools.mx + SOURCES = mclient.mx ReadlineTools.mx LIBS = libmcutil ../mapilib/libMapi $(MAPI_LIBS) $(READLINE_LIBS) \ $(MONETDB_LIBS) -lmutils -lstream \ $(ICONV_LIBS) diff -r c96ec91aee07 -r e059e4d2edd5 clients/src/mapiclient/MapiClient.mx --- a/clients/src/mapiclient/MapiClient.mx Sat May 08 20:52:49 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2627 +0,0 @@ -@' The contents of this file are subject to the MonetDB Public License -@' Version 1.1 (the "License"); you may not use this file except in -@' compliance with the License. You may obtain a copy of the License at -@' http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html -@' -@' Software distributed under the License is distributed on an "AS IS" -@' basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -@' License for the specific language governing rights and limitations -@' under the License. -@' -@' The Original Code is the MonetDB Database System. -@' -@' The Initial Developer of the Original Code is CWI. -@' Portions created by CWI are Copyright (C) 1997-July 2008 CWI. -@' Copyright August 2008-2010 MonetDB B.V. -@' All Rights Reserved. - -...@a Sjoerd Mullender, Martin Kersten, Peter Boncz, Niels Nes, Fabian Groffen -...@v 6 -...@f MapiClient -...@* The Mapi Client Interface -A textual interface to the Monet server using the Mapi library, -providing command-line access for its users. It is the preferred -interface for non-DBAs. - -...@+ Manual Page -The @code{mclient} program provides a textual -interface to the MonetDB server. Unlike the Mserver console, the -...@code{mclient} program is intended not only for the database -administrator, but for all users. It is more comfortable than the -console, since it provides a command history and automatic file name -completion. - -...@verbatim -mclient [options] [inputfile+] -...@end verbatim - -The following options are supported: - -...@multitable @columnfractions .25 .25 .25 -...@item -h hostname -...@tab --host=hostname -...@tab host to connect to -...@item -l language -...@tab --language=lang -...@tab @{mal,sql,m...@} -...@item -P[passwd] -...@tab --passwd[=passwd] -...@tab password -...@item -p portnr -...@tab --port=portnr -...@tab port to connect to -...@item -s stmt -...@tab --statement=stmt -...@tab run single statement -...@item -X -...@tab --Xdebug -...@tab trace mapi network interaction -...@item -t -...@tab --time -...@tab time commands -...@item -u[user] -...@tab --user[=user] -...@tab user id -...@item -H -...@tab --history -...@tab load/save cmdline history (default off) -...@item -? -...@tab --help -...@tab show this usage message -...@end multitable - -Calling "mclient -lsql" establishes a SQL connection with a -MonetDB server running on the local machine. - -In the SQL mode, a few more convenient commands are available. -...@multitable @columnfractions .25 .75 -...@item --rows -...@tab to control the pagination behavior -...@item --width -...@tab to control the maximum column width (default=80) -...@end multitable -...@{ -...@+ Implementation -...@c -#include "clients_config.h" -#include "monet_utils.h" -#ifndef HAVE_GETOPT_LONG -# include "monet_getopt.h" -#else -# ifdef HAVE_GETOPT_H -# include "getopt.h" -# endif -#endif -#include "mapilib/Mapi.h" -#include <unistd.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/stat.h> -#include <errno.h> -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#ifdef HAVE_LIBREADLINE -#include <readline/readline.h> -#include <readline/history.h> -#include "ReadlineTools.h" -#endif -#include "stream.h" -#include "msqldump.h" -#include "mprompt.h" -#ifdef HAVE_LOCALE_H -#include <locale.h> -#endif -#ifdef HAVE_ICONV -#ifdef HAVE_ICONV_H -#include <iconv.h> -#endif -#ifdef HAVE_NL_LANGINFO -#ifdef HAVE_LANGINFO_H -#include <langinfo.h> -#endif -#else -#ifdef NATIVE_WIN32 -#include <Windows.h> -#endif -#endif -#endif - -#ifndef S_ISCHR -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#endif - -#ifdef NATIVE_WIN32 -#define strdup _strdup -#endif - -enum modes { - NOLANGUAGE, - MAL, - SQL, - XQUERY, - MIL -}; - -static enum modes mode = NOLANGUAGE; -static stream *toConsole; -static stream *toConsole_raw; /* toConsole without iconv conversion */ -static stream *stdout_stream; -static stream *stderr_stream; -static FILE *fromConsole = NULL; -static char *language = NULL; -static char *logfile = NULL; -static char promptbuf[16]; -static int echoquery = 0; -#ifdef HAVE_ICONV -static char *encoding; -static iconv_t cd_in; -#endif -static int errseen = 0; - -#define setPrompt() sprintf(promptbuf, "%.*s>", (int) sizeof(promptbuf) - 2, language) -#define debugMode() (strncmp(promptbuf, "mdb", 3) == 0) - -/* the internal formatters */ -enum formatters { - NOformatter, - RAWformatter, - TABLEformatter, - CSVformatter, - TABformatter, - XMLformatter, - TESTformatter -}; -static enum formatters formatter = NOformatter; -char *output = NULL; /* output format as string */ - -#define DEFWIDTH 80 - -/* try to use a 64 bit integer for the timer, but fall back to plain long */ -#ifdef HAVE_LONG_LONG -typedef long long timertype; -#else -#ifdef HAVE___INT64 -typedef __int64 timertype; -#else -typedef long timertype; -#endif -#endif - -static timertype t0, t1; /* used for timing */ -static char *mark, *mark2; - -#define UTF8BOM "\xEF\xBB\xBF" /* UTF-8 encoding of Unicode BOM */ -#define UTF8BOMLENGTH 3 /* length of above */ - -/* Pagination and simple ASCII-based rendering is provided for SQL - * sessions. The result set size is limited by the cache size of the - * Mapi Library. It is sufficiently large to accommodate most result - * to be browsed manually. - * - * The pagewidth determines the maximum space allocated for a single - * row. If the total space required is larger, then a heuristic - * routine is called to distribute the available space. Attribute - * values may then span multiple lines. Setting the pagewidth to 0 - * turns off row size control. */ - -#ifdef HAVE_POPEN -static char *pager = 0; /* use external pager */ -#include <signal.h> /* to block SIGPIPE */ -#endif -static int rowsperpage = 0; /* for SQL pagination */ -static int pagewidth = -1; /* use raw mode for file input, tabular format in stdin */ -static int pagewidthset = 0; /* whether the user set the width explicitly */ -static int interactive_stdin = 0; - -enum modifiers { - NOmodifier, - DEBUGmodifier -}; -static enum modifiers specials = NOmodifier; -/* set when we see DEBUG (only if mode == SQL). Also retain these - * modes until after you have received the answer. */ - -/* keep these aligned, the MINCOLSIZE should ensure you can always - * write the NULLSTRING */ -#define MINCOLSIZE 4 -static char default_nullstring[] = "null"; -static char *nullstring = default_nullstring; - -/* stolen piece */ -#ifdef HAVE_FTIME -#include <sys/timeb.h> -#endif - -#ifdef TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# ifdef HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif -#ifdef HAVE_STROPTS_H -#include <stropts.h> /* ioctl */ -#endif -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif -#ifdef HAVE_TERMIOS_H -#include <termios.h> /* TIOCGWINSZ/TIOCSWINSZ */ -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#define fileno _fileno -#endif - -static timertype -gettime(void) -{ - /* Return the time in milliseconds since an epoch. The epoch - is roughly the time this program started. */ -#ifdef HAVE_QUERYPERFORMANCECOUNTER - static LARGE_INTEGER freq, start; /* automatically initialized to 0 */ - LARGE_INTEGER ctr; - - if (start.QuadPart == 0 && - (!QueryPerformanceFrequency(&freq) || - !QueryPerformanceCounter(&start))) - start.QuadPart = -1; - if (start.QuadPart > 0) { - QueryPerformanceCounter(&ctr); - return (timertype) (((ctr.QuadPart - start.QuadPart) * 1000000) / freq.QuadPart); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list