<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.91 2003/07/23 15:05:42 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.92 2003/07/27 03:32:26 momjian Exp $
PostgreSQL documentation
-->
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>WIN32_CONSOLE</varname></term>
+ <listitem>
+ <para>
+ This variable is only useful when working under the Win32 command
+ console. As the Win32 command console uses a different encoding than
+ the rest of the Windows system. Eight-bit characters (e.g. German Umlauts)
+ are corrupted. When this variable is set the command console encoding will
+ be translated into ASCII encoding for input and output.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect3>
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.80 2003/07/25 21:42:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.81 2003/07/27 03:32:26 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
#include <ctype.h>
+#ifdef WIN32
+/*
+ * mbvalidate() is used in function describeOneTableDetails() to make sure
+ * all characters of the cells will be printed to the DOS console in a
+ * correct way
+ */
+#include "mbprint.h"
+#endif
+
+
#define _(x) gettext((x))
static bool describeOneTableDetails(const char *schemaname,
for (i = 0; i < numrows; i++)
{
/* Name */
+#ifdef WIN32
+ cells[i * cols + 0] = mbvalidate(PQgetvalue(res, i, 0));
+#else
cells[i * cols + 0] = PQgetvalue(res, i, 0); /* don't free this
* afterwards */
+#endif
+
/* Type */
+#ifdef WIN32
+ cells[i * cols + 1] = mbvalidate(PQgetvalue(res, i, 1));
+#else
cells[i * cols + 1] = PQgetvalue(res, i, 1); /* don't free this
* either */
+#endif
/* Extra: not null and default */
if (show_modifiers)
PQgetvalue(res, i, 2));
}
+#ifdef WIN32
+ cells[i * cols + 2] = xstrdup(mbvalidate(tmpbuf.data));
+#else
cells[i * cols + 2] = xstrdup(tmpbuf.data);
+#endif
}
/* Description */
if (verbose)
+#ifdef WIN32
+ cells[i * cols + cols - 1] = mbvalidate(PQgetvalue(res, i, 5));
+#else
cells[i * cols + cols - 1] = PQgetvalue(res, i, 5);
+#endif
}
/* Make title */
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.25 2003/07/25 19:27:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.26 2003/07/27 03:32:26 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
#include <errno.h>
+#ifdef WIN32
+#include <windows.h>
+#endif
+
#include "pqexpbuffer.h"
#include "settings.h"
#include "tab-complete.h"
#define PSQLHISTORY ".psql_history"
+#ifdef WIN32
+ /*
+ * translate DOS console character set into ANSI, needed e.g. for
+ * German umlauts
+ */
+ if (GetVariableBool(pset.vars, "WIN32_CONSOLE"))
+ OemToChar(s, s);
+#endif
+
#ifdef USE_READLINE
static enum histcontrol
GetHistControlConfig(void)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.6 2003/03/18 22:15:44 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.7 2003/07/27 03:32:26 momjian Exp $
*/
#include "postgres_fe.h"
#include "mb/pg_wchar.h"
+#ifdef WIN32
+#include <windows.h>
+#endif
+
/*
* This is an implementation of wcwidth() and wcswidth() as defined in
* "The Single UNIX Specification, Version 2, The Open Group, 1997"
return mb_utf_validate(pwcs);
else
{
+#ifdef WIN32
+ /*
+ * translate characters to DOS console encoding, e.g. needed
+ * for German umlauts
+ */
+ if (GetVariableBool(pset.vars, "WIN32_CONSOLE"))
+ CharToOem(pwcs, pwcs);
+#endif
/*
* other encodings needing validation should add their own
* routines here
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.4 2003/03/18 22:09:37 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/sprompt.c,v 1.5 2003/07/27 03:32:26 momjian Exp $
*/
#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#else
+#ifdef WIN32
+#include <windows.h>
+#endif
#endif
bool prompt_state = false;
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
t;
+#else
+#ifdef WIN32
+ HANDLE t;
+ LPDWORD t_orig;
+#endif
#endif
destination = (char *) malloc(maxlen + 1);
t.c_lflag &= ~ECHO;
tcsetattr(fileno(termin), TCSAFLUSH, &t);
}
+#else
+#ifdef WIN32
+ if (!echo)
+ {
+ /* get a new handle to turn echo off */
+ t_orig=(LPDWORD)malloc(sizeof(DWORD));
+ t=GetStdHandle(STD_INPUT_HANDLE);
+
+ /* save the old configuration first */
+ GetConsoleMode(t, t_orig);
+
+ /* set to the new mode */
+ SetConsoleMode(t, ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT);
+ }
+#endif
#endif
if (prompt)
fputs("\n", termout);
fflush(termout);
}
+#else
+#ifdef WIN32
+ if (!echo)
+ {
+ /* reset to the original console mode */
+ SetConsoleMode(t, *t_orig);
+ fputs("\n", termout);
+ fflush(termout);
+ free(t_orig);
+ }
+#endif
#endif
if (termin != stdin)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.254 2003/07/26 13:50:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.255 2003/07/27 03:32:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
PGconn *conn = (PGconn *) malloc(sizeof(PGconn));
+/* needed to use the static libpq under windows as well */
+#ifdef WIN32
+ WSADATA wsaData;
+#endif
+
if (conn == NULL)
return conn;
+#ifdef WIN32
+ if (WSAStartup(MAKEWORD(1, 1), &wsaData))
+ {
+ free(conn);
+ return (PGconn*) NULL;
+ }
+
+ WSASetLastError(0);
+
+#endif
+
/* Zero all pointers and booleans */
MemSet((char *) conn, 0, sizeof(PGconn));