Commit 1a17447b authored by Peter Eisentraut's avatar Peter Eisentraut

NLS for libpq. Clean up the message formats and change the documentation

accordingly.
parent 9e5ec3b0
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.56 2001/06/10 03:46:31 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.57 2001/07/15 13:45:03 petere Exp $
Postgres documentation
-->
......@@ -2349,7 +2349,7 @@ Field separator is "oo",
<para>
Pressing Control-C during a <quote>copy in</quote> (data sent to the
server) doesn't show the most ideal of behaviors. If you get a message
such as <quote>PQexec: you gotta get out of a COPY state yourself</quote>,
such as <quote>COPY state must be terminated first</quote>,
simply reset the connection by entering <literal>\c - -</literal>.
</para>
</listitem>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.72 2001/06/30 22:03:25 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.73 2001/07/15 13:45:03 petere Exp $
-->
<Chapter Id="runtime">
......@@ -392,9 +392,9 @@ IpcSemaphoreCreate: semget(key=5440026, num=16, 01600) failed: No space left on
<para>
<screen>
PQconnectPoll() -- connect() failed: Connection refused
Is the postmaster running (with -i) at 'server.joe.com'
and accepting connections on TCP/IP port 5432?
psql: could not connect to server: Connection refused
Is the server running on host server.joe.com and accepting
TCP/IP connections on port 5432?
</screen>
This is the generic <quote>I couldn't find a server to talk
to</quote> failure. It looks like the above when TCP/IP
......@@ -407,9 +407,9 @@ PQconnectPoll() -- connect() failed: Connection refused
Alternatively, you'll get this when attempting
Unix-socket communication to a local postmaster:
<screen>
connectDBstart() -- connect() failed: No such file or directory
Is the postmaster running locally
and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
</screen>
</para>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.15 2000/11/30 23:20:50 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.16 2001/07/15 13:45:03 petere Exp $
-->
<chapter id="start">
......@@ -154,18 +154,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.15 2000/11/30 23:20:50 tgl E
<programlisting>
% psql template1
psql: connectDBStart() -- connect() failed: No such file or directory
Is the postmaster running locally
and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
</programlisting>
or
<programlisting>
% psql -h localhost template1
psql: PQconnectPoll() -- connect() failed: Connection refused
Is the postmaster running (with -i) at 'localhost'
and accepting connections on TCP/IP port 5432?
psql: could not connect to server: Connection refused
Is the server running on host localhost and accepting
TCP/IP connections on port 5432?
</programlisting>
it is usually because
......
......@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.52 2001/05/11 01:46:33 momjian Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.53 2001/07/15 13:45:04 petere Exp $
#
#-------------------------------------------------------------------------
......@@ -30,7 +30,7 @@ endif
# Add libraries that libpq depends (or might depend) on into the
# shared library link. (The order in which you list them here doesn't
# matter.)
SHLIB_LINK += $(filter -L%, $(LDFLAGS)) $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv, $(LIBS))
SHLIB_LINK += $(filter -L%, $(LDFLAGS)) $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS))
all: all-lib
......
This diff is collapsed.
......@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.47 2001/03/22 04:01:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.48 2001/07/15 13:45:04 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -160,7 +160,7 @@ pg_krb4_authname(char *PQerrormsg)
status = krb_get_tf_fullname(tkt_string(), name, instance, realm);
if (status != KSUCCESS)
{
(void) sprintf(PQerrormsg,
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb4_authname: krb_get_tf_fullname: %s\n",
krb_err_txt[status]);
return (char *) NULL;
......@@ -218,8 +218,8 @@ pg_krb4_sendauth(char *PQerrormsg, int sock,
PG_KRB4_VERSION);
if (status != KSUCCESS)
{
(void) sprintf(PQerrormsg,
"pg_krb4_sendauth: kerberos error: %s\n",
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 4 error: %s\n"),
krb_err_txt[status]);
return STATUS_ERROR;
}
......@@ -384,7 +384,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb5_sendauth: fcntl: %s", strerror(errno));
libpq_gettext("could not set socket to blocking mode: %s"), strerror(errno));
krb5_free_principal(pg_krb5_context, server);
return STATUS_ERROR;
}
......@@ -400,13 +400,13 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (retval == KRB5_SENDAUTH_REJECTED && err_ret)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb5_sendauth: authentication rejected: \"%*s\"",
libpq_gettext("Kerberos 5 authentication rejected: %*s"),
err_ret->text.length, err_ret->text.data);
}
else
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb5_sendauth: krb5_sendauth: %s",
"krb5_sendauth: %s",
error_message(retval));
}
......@@ -421,7 +421,8 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (fcntl(sock, F_SETFL, (long) flags))
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb5_sendauth: fcntl: %s", strerror(errno));
libpq_gettext("could not restore non-blocking mode on socket: %s"),
strerror(errno));
ret = STATUS_ERROR;
}
......@@ -463,14 +464,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
&conn->raddr.in,
hostname) != STATUS_OK)
{
(void) sprintf(PQerrormsg,
"fe_sendauth: krb4 authentication failed\n");
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 4 authentication failed\n"));
return STATUS_ERROR;
}
break;
#else
(void) sprintf(PQerrormsg,
"fe_sendauth: krb4 authentication not supported\n");
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 4 authentication not supported\n"));
return STATUS_ERROR;
#endif
......@@ -480,14 +481,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
&conn->raddr.in,
hostname) != STATUS_OK)
{
(void) sprintf(PQerrormsg,
"fe_sendauth: krb5 authentication failed\n");
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 5 authentication failed\n"));
return STATUS_ERROR;
}
break;
#else
(void) sprintf(PQerrormsg,
"fe_sendauth: krb5 authentication not supported\n");
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("Kerberos 5 authentication not supported\n"));
return STATUS_ERROR;
#endif
......@@ -509,8 +510,8 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
break;
default:
(void) sprintf(PQerrormsg,
"fe_sendauth: authentication type %u not supported\n", areq);
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("authentication method %u not supported\n"), areq);
return STATUS_ERROR;
}
......@@ -546,8 +547,8 @@ fe_setauthsvc(const char *name, char *PQerrormsg)
}
if (i == n_authsvcs)
{
(void) sprintf(PQerrormsg,
"fe_setauthsvc: invalid name: %s, ignoring...\n",
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("invalid authentication service name \"%s\", ignored"),
name);
}
return;
......@@ -603,7 +604,9 @@ fe_getauthname(char *PQerrormsg)
}
if (authsvc != STARTUP_MSG && authsvc != STARTUP_KRB4_MSG && authsvc != STARTUP_KRB5_MSG)
sprintf(PQerrormsg, "fe_getauthname: invalid authentication system: %d\n", authsvc);
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
libpq_gettext("fe_getauthname: invalid authentication system: %d\n"),
authsvc);
if (name && (authn = (char *) malloc(strlen(name) + 1)))
strcpy(authn, name);
......
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.34 2001/03/22 06:16:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.35 2001/07/15 13:45:04 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -16,6 +16,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include "libpq-fe.h"
#include "libpq-int.h"
......@@ -395,8 +396,8 @@ lo_import(PGconn *conn, const char *filename)
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
"lo_import: can't open unix file\"%s\"\n",
filename);
libpq_gettext("could not open file \"%s\": %s\n"),
filename, strerror(errno));
return InvalidOid;
}
......@@ -407,7 +408,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobjOid == InvalidOid)
{
printfPQExpBuffer(&conn->errorMessage,
"lo_import: can't create inv object for \"%s\"",
libpq_gettext("could not create large object for file \"%s\"\n"),
filename);
return InvalidOid;
}
......@@ -416,7 +417,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
"lo_import: could not open inv object oid %u",
libpq_gettext("could not open large object %u\n"),
lobjOid);
return InvalidOid;
}
......@@ -430,7 +431,7 @@ lo_import(PGconn *conn, const char *filename)
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
"lo_import: error while reading \"%s\"",
libpq_gettext("error while reading file \"%s\"\n"),
filename);
return InvalidOid;
}
......@@ -463,7 +464,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
"lo_export: can't open inv object %u", lobjId);
libpq_gettext("could not open large object %u\n"), lobjId);
return -1;
}
......@@ -474,8 +475,8 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (fd < 0)
{ /* error */
printfPQExpBuffer(&conn->errorMessage,
"lo_export: can't open unix file\"%s\"",
filename);
libpq_gettext("could not open file \"%s\": %s\n"),
filename, strerror(errno));
return 0;
}
......@@ -488,7 +489,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
"lo_export: error while writing \"%s\"",
libpq_gettext("error while writing to file \"%s\"\n"),
filename);
return -1;
}
......@@ -525,7 +526,7 @@ lo_initialize(PGconn *conn)
if (lobjfuncs == (PGlobjfuncs *) NULL)
{
printfPQExpBuffer(&conn->errorMessage,
"FATAL: malloc() failed in lo_initialize()\n");
libpq_gettext("out of memory\n"));
return -1;
}
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
......@@ -553,7 +554,7 @@ lo_initialize(PGconn *conn)
free(lobjfuncs);
PQclear(res);
printfPQExpBuffer(&conn->errorMessage,
"ERROR: SELECT didn't return data in lo_initialize()\n");
libpq_gettext("query to initialize large object functions did not return data\n"));
return -1;
}
......@@ -591,56 +592,56 @@ lo_initialize(PGconn *conn)
if (lobjfuncs->fn_lo_open == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_open\n");
libpq_gettext("cannot determine OID of function lo_open\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_close == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_close\n");
libpq_gettext("cannot determine OID of function lo_close\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_creat == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_creat\n");
libpq_gettext("cannot determine OID of function lo_creat\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_unlink == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_unlink\n");
libpq_gettext("cannot determine OID of function lo_unlink\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_lseek == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_lseek\n");
libpq_gettext("cannot determine OID of function lo_lseek\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_tell == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_tell\n");
libpq_gettext("cannot determine OID of function lo_tell\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_read == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function loread\n");
libpq_gettext("cannot determine OID of function loread\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_write == 0)
{
printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lowrite\n");
libpq_gettext("cannot determine OID of function lowrite\n"));
free(lobjfuncs);
return -1;
}
......
......@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.50 2001/07/06 17:58:53 petere Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.51 2001/07/15 13:45:04 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -128,8 +128,7 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
if (nbytes > Max(conn->outBufSize - conn->outCount, 0))
{
printfPQExpBuffer(&conn->errorMessage,
"pqPutBytes -- pqFlush couldn't flush enough"
" data: space available: %d, space needed %d\n",
libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"),
Max(conn->outBufSize - conn->outCount, 0), nbytes);
return EOF;
}
......@@ -276,8 +275,9 @@ pqGetInt(int *result, size_t bytes, PGconn *conn)
*result = (int) ntohl(tmp4);
break;
default:
sprintf(noticeBuf,
"pqGetInt: int size %lu not supported\n", (unsigned long) bytes);
snprintf(noticeBuf, sizeof(noticeBuf),
libpq_gettext("integer of size %lu not supported by pqGetInt\n"),
(unsigned long) bytes);
DONOTICE(conn, noticeBuf);
return EOF;
}
......@@ -313,8 +313,9 @@ pqPutInt(int value, size_t bytes, PGconn *conn)
return EOF;
break;
default:
sprintf(noticeBuf,
"pqPutInt: int size %lu not supported\n", (unsigned long) bytes);
snprintf(noticeBuf, sizeof(noticeBuf),
libpq_gettext("integer of size %lu not supported by pqPutInt\n"),
(unsigned long) bytes);
DONOTICE(conn, noticeBuf);
return EOF;
}
......@@ -351,8 +352,8 @@ retry:
goto retry;
printfPQExpBuffer(&conn->errorMessage,
"pqReadReady() -- select() failed: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("select() failed: %s\n"),
strerror(errno));
return -1;
}
......@@ -385,8 +386,8 @@ retry:
goto retry;
printfPQExpBuffer(&conn->errorMessage,
"pqWriteReady() -- select() failed: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("select() failed: %s\n"),
strerror(errno));
return -1;
}
return FD_ISSET(conn->sock, &input_mask) ? 1 : 0;
......@@ -411,7 +412,7 @@ pqReadData(PGconn *conn)
if (conn->sock < 0)
{
printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- connection not open\n");
libpq_gettext("connection not open\n"));
return -1;
}
......@@ -482,8 +483,8 @@ tryAgain:
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- read() failed: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("could not receive data from server: %s\n"),
strerror(errno));
return -1;
}
if (nread > 0)
......@@ -568,8 +569,8 @@ tryAgain2:
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- read() failed: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("could not receive data from server: %s\n"),
strerror(errno));
return -1;
}
if (nread > 0)
......@@ -584,9 +585,10 @@ tryAgain2:
*/
definitelyFailed:
printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- backend closed the channel unexpectedly.\n"
"\tThis probably means the backend terminated abnormally\n"
"\tbefore or while processing the request.\n");
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
conn->status = CONNECTION_BAD; /* No more connection to backend */
#ifdef WIN32
closesocket(conn->sock);
......@@ -610,7 +612,7 @@ pqFlush(PGconn *conn)
if (conn->sock < 0)
{
printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- connection not open\n");
libpq_gettext("connection not open\n"));
return EOF;
}
......@@ -627,7 +629,6 @@ pqFlush(PGconn *conn)
/* Prevent being SIGPIPEd if backend has closed the connection. */
#ifndef WIN32
pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
#endif
int sent;
......@@ -669,9 +670,10 @@ pqFlush(PGconn *conn)
case ECONNRESET:
#endif
printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- backend closed the channel unexpectedly.\n"
"\tThis probably means the backend terminated abnormally"
" before or while processing the request.\n");
libpq_gettext(
"server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
/*
* We used to close the socket here, but that's a bad
......@@ -685,8 +687,8 @@ pqFlush(PGconn *conn)
default:
printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- couldn't send data: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("could not send data to server: %s\n"),
strerror(errno));
/* We don't assume it's a fatal error... */
return EOF;
}
......@@ -751,7 +753,7 @@ pqWait(int forRead, int forWrite, PGconn *conn)
if (conn->sock < 0)
{
printfPQExpBuffer(&conn->errorMessage,
"pqWait() -- connection not open\n");
libpq_gettext("connection not open\n"));
return EOF;
}
......@@ -772,8 +774,8 @@ retry:
if (errno == EINTR)
goto retry;
printfPQExpBuffer(&conn->errorMessage,
"pqWait() -- select() failed: errno=%d\n%s\n",
errno, strerror(errno));
libpq_gettext("select() failed: %s\n"),
strerror(errno));
return EOF;
}
}
......@@ -831,3 +833,20 @@ PQenv2encoding(void)
}
#endif /* MULTIBYTE */
#ifdef ENABLE_NLS
char *
libpq_gettext(const char *msgid)
{
static int already_bound = 0;
if (!already_bound)
{
already_bound = 1;
bindtextdomain("libpq", LOCALEDIR);
}
return dgettext("libpq", msgid);
}
#endif /* ENABLE_NLS */
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.35 2001/07/06 19:04:23 petere Exp $
* $Id: libpq-int.h,v 1.36 2001/07/15 13:45:04 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -343,4 +343,14 @@ extern int pqWriteReady(PGconn *conn);
*/
#define pqIsnonblocking(conn) ((conn)->nonblocking)
#ifdef ENABLE_NLS
extern char * libpq_gettext(const char *msgid)
#ifdef __GNUC__
__attribute__((format_arg(1)))
#endif
;
#else
#define libpq_gettext(x) (x)
#endif
#endif /* LIBPQ_INT_H */
# $Header: /cvsroot/pgsql/src/interfaces/libpq/nls.mk,v 1.1 2001/07/15 13:45:04 petere Exp $
CATALOG_NAME := libpq
AVAIL_LANGUAGES := de
GETTEXT_FILES := fe-auth.c fe-connect.c fe-exec.c fe-lobj.c fe-misc.c
GETTEXT_TRIGGERS:= libpq_gettext
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment