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 Postgres documentation
--> -->
...@@ -2349,7 +2349,7 @@ Field separator is "oo", ...@@ -2349,7 +2349,7 @@ Field separator is "oo",
<para> <para>
Pressing Control-C during a <quote>copy in</quote> (data sent to the 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 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>. simply reset the connection by entering <literal>\c - -</literal>.
</para> </para>
</listitem> </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"> <Chapter Id="runtime">
...@@ -392,9 +392,9 @@ IpcSemaphoreCreate: semget(key=5440026, num=16, 01600) failed: No space left on ...@@ -392,9 +392,9 @@ IpcSemaphoreCreate: semget(key=5440026, num=16, 01600) failed: No space left on
<para> <para>
<screen> <screen>
PQconnectPoll() -- connect() failed: Connection refused psql: could not connect to server: Connection refused
Is the postmaster running (with -i) at 'server.joe.com' Is the server running on host server.joe.com and accepting
and accepting connections on TCP/IP port 5432? TCP/IP connections on port 5432?
</screen> </screen>
This is the generic <quote>I couldn't find a server to talk This is the generic <quote>I couldn't find a server to talk
to</quote> failure. It looks like the above when TCP/IP to</quote> failure. It looks like the above when TCP/IP
...@@ -407,9 +407,9 @@ PQconnectPoll() -- connect() failed: Connection refused ...@@ -407,9 +407,9 @@ PQconnectPoll() -- connect() failed: Connection refused
Alternatively, you'll get this when attempting Alternatively, you'll get this when attempting
Unix-socket communication to a local postmaster: Unix-socket communication to a local postmaster:
<screen> <screen>
connectDBstart() -- connect() failed: No such file or directory psql: could not connect to server: Connection refused
Is the postmaster running locally Is the server running locally and accepting
and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'? connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
</screen> </screen>
</para> </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"> <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 ...@@ -154,18 +154,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.15 2000/11/30 23:20:50 tgl E
<programlisting> <programlisting>
% psql template1 % psql template1
psql: connectDBStart() -- connect() failed: No such file or directory psql: could not connect to server: Connection refused
Is the postmaster running locally Is the server running locally and accepting
and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'? connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
</programlisting> </programlisting>
or or
<programlisting> <programlisting>
% psql -h localhost template1 % psql -h localhost template1
psql: PQconnectPoll() -- connect() failed: Connection refused psql: could not connect to server: Connection refused
Is the postmaster running (with -i) at 'localhost' Is the server running on host localhost and accepting
and accepting connections on TCP/IP port 5432? TCP/IP connections on port 5432?
</programlisting> </programlisting>
it is usually because it is usually because
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # 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 ...@@ -30,7 +30,7 @@ endif
# Add libraries that libpq depends (or might depend) on into the # Add libraries that libpq depends (or might depend) on into the
# shared library link. (The order in which you list them here doesn't # shared library link. (The order in which you list them here doesn't
# matter.) # 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 all: all-lib
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * 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,9 +160,9 @@ pg_krb4_authname(char *PQerrormsg) ...@@ -160,9 +160,9 @@ pg_krb4_authname(char *PQerrormsg)
status = krb_get_tf_fullname(tkt_string(), name, instance, realm); status = krb_get_tf_fullname(tkt_string(), name, instance, realm);
if (status != KSUCCESS) if (status != KSUCCESS)
{ {
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb4_authname: krb_get_tf_fullname: %s\n", "pg_krb4_authname: krb_get_tf_fullname: %s\n",
krb_err_txt[status]); krb_err_txt[status]);
return (char *) NULL; return (char *) NULL;
} }
return name; return name;
...@@ -218,9 +218,9 @@ pg_krb4_sendauth(char *PQerrormsg, int sock, ...@@ -218,9 +218,9 @@ pg_krb4_sendauth(char *PQerrormsg, int sock,
PG_KRB4_VERSION); PG_KRB4_VERSION);
if (status != KSUCCESS) if (status != KSUCCESS)
{ {
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb4_sendauth: kerberos error: %s\n", libpq_gettext("Kerberos 4 error: %s\n"),
krb_err_txt[status]); krb_err_txt[status]);
return STATUS_ERROR; return STATUS_ERROR;
} }
return STATUS_OK; return STATUS_OK;
...@@ -384,7 +384,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, ...@@ -384,7 +384,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK))) if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
{ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, 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); krb5_free_principal(pg_krb5_context, server);
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -400,13 +400,13 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, ...@@ -400,13 +400,13 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (retval == KRB5_SENDAUTH_REJECTED && err_ret) if (retval == KRB5_SENDAUTH_REJECTED && err_ret)
{ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, 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); err_ret->text.length, err_ret->text.data);
} }
else else
{ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb5_sendauth: krb5_sendauth: %s", "krb5_sendauth: %s",
error_message(retval)); error_message(retval));
} }
...@@ -421,7 +421,8 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, ...@@ -421,7 +421,8 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
if (fcntl(sock, F_SETFL, (long) flags)) if (fcntl(sock, F_SETFL, (long) flags))
{ {
snprintf(PQerrormsg, PQERRORMSG_LENGTH, 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; ret = STATUS_ERROR;
} }
...@@ -463,14 +464,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, ...@@ -463,14 +464,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
&conn->raddr.in, &conn->raddr.in,
hostname) != STATUS_OK) hostname) != STATUS_OK)
{ {
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: krb4 authentication failed\n"); libpq_gettext("Kerberos 4 authentication failed\n"));
return STATUS_ERROR; return STATUS_ERROR;
} }
break; break;
#else #else
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: krb4 authentication not supported\n"); libpq_gettext("Kerberos 4 authentication not supported\n"));
return STATUS_ERROR; return STATUS_ERROR;
#endif #endif
...@@ -480,14 +481,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, ...@@ -480,14 +481,14 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
&conn->raddr.in, &conn->raddr.in,
hostname) != STATUS_OK) hostname) != STATUS_OK)
{ {
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: krb5 authentication failed\n"); libpq_gettext("Kerberos 5 authentication failed\n"));
return STATUS_ERROR; return STATUS_ERROR;
} }
break; break;
#else #else
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: krb5 authentication not supported\n"); libpq_gettext("Kerberos 5 authentication not supported\n"));
return STATUS_ERROR; return STATUS_ERROR;
#endif #endif
...@@ -509,8 +510,8 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, ...@@ -509,8 +510,8 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
break; break;
default: default:
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: authentication type %u not supported\n", areq); libpq_gettext("authentication method %u not supported\n"), areq);
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -546,9 +547,9 @@ fe_setauthsvc(const char *name, char *PQerrormsg) ...@@ -546,9 +547,9 @@ fe_setauthsvc(const char *name, char *PQerrormsg)
} }
if (i == n_authsvcs) if (i == n_authsvcs)
{ {
(void) sprintf(PQerrormsg, snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_setauthsvc: invalid name: %s, ignoring...\n", libpq_gettext("invalid authentication service name \"%s\", ignored"),
name); name);
} }
return; return;
} }
...@@ -603,7 +604,9 @@ fe_getauthname(char *PQerrormsg) ...@@ -603,7 +604,9 @@ fe_getauthname(char *PQerrormsg)
} }
if (authsvc != STARTUP_MSG && authsvc != STARTUP_KRB4_MSG && authsvc != STARTUP_KRB5_MSG) 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))) if (name && (authn = (char *) malloc(strlen(name) + 1)))
strcpy(authn, name); strcpy(authn, name);
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 @@ ...@@ -16,6 +16,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#include "libpq-fe.h" #include "libpq-fe.h"
#include "libpq-int.h" #include "libpq-int.h"
...@@ -395,8 +396,8 @@ lo_import(PGconn *conn, const char *filename) ...@@ -395,8 +396,8 @@ lo_import(PGconn *conn, const char *filename)
if (fd < 0) if (fd < 0)
{ /* error */ { /* error */
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_import: can't open unix file\"%s\"\n", libpq_gettext("could not open file \"%s\": %s\n"),
filename); filename, strerror(errno));
return InvalidOid; return InvalidOid;
} }
...@@ -407,7 +408,7 @@ lo_import(PGconn *conn, const char *filename) ...@@ -407,7 +408,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobjOid == InvalidOid) if (lobjOid == InvalidOid)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_import: can't create inv object for \"%s\"", libpq_gettext("could not create large object for file \"%s\"\n"),
filename); filename);
return InvalidOid; return InvalidOid;
} }
...@@ -416,7 +417,7 @@ lo_import(PGconn *conn, const char *filename) ...@@ -416,7 +417,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobj == -1) if (lobj == -1)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_import: could not open inv object oid %u", libpq_gettext("could not open large object %u\n"),
lobjOid); lobjOid);
return InvalidOid; return InvalidOid;
} }
...@@ -430,7 +431,7 @@ lo_import(PGconn *conn, const char *filename) ...@@ -430,7 +431,7 @@ lo_import(PGconn *conn, const char *filename)
if (tmp < nbytes) if (tmp < nbytes)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_import: error while reading \"%s\"", libpq_gettext("error while reading file \"%s\"\n"),
filename); filename);
return InvalidOid; return InvalidOid;
} }
...@@ -463,7 +464,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) ...@@ -463,7 +464,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (lobj == -1) if (lobj == -1)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_export: can't open inv object %u", lobjId); libpq_gettext("could not open large object %u\n"), lobjId);
return -1; return -1;
} }
...@@ -474,8 +475,8 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) ...@@ -474,8 +475,8 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (fd < 0) if (fd < 0)
{ /* error */ { /* error */
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_export: can't open unix file\"%s\"", libpq_gettext("could not open file \"%s\": %s\n"),
filename); filename, strerror(errno));
return 0; return 0;
} }
...@@ -488,7 +489,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) ...@@ -488,7 +489,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (tmp < nbytes) if (tmp < nbytes)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"lo_export: error while writing \"%s\"", libpq_gettext("error while writing to file \"%s\"\n"),
filename); filename);
return -1; return -1;
} }
...@@ -525,7 +526,7 @@ lo_initialize(PGconn *conn) ...@@ -525,7 +526,7 @@ lo_initialize(PGconn *conn)
if (lobjfuncs == (PGlobjfuncs *) NULL) if (lobjfuncs == (PGlobjfuncs *) NULL)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"FATAL: malloc() failed in lo_initialize()\n"); libpq_gettext("out of memory\n"));
return -1; return -1;
} }
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs)); MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
...@@ -553,7 +554,7 @@ lo_initialize(PGconn *conn) ...@@ -553,7 +554,7 @@ lo_initialize(PGconn *conn)
free(lobjfuncs); free(lobjfuncs);
PQclear(res); PQclear(res);
printfPQExpBuffer(&conn->errorMessage, 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; return -1;
} }
...@@ -591,56 +592,56 @@ lo_initialize(PGconn *conn) ...@@ -591,56 +592,56 @@ lo_initialize(PGconn *conn)
if (lobjfuncs->fn_lo_open == 0) if (lobjfuncs->fn_lo_open == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_open\n"); libpq_gettext("cannot determine OID of function lo_open\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_close == 0) if (lobjfuncs->fn_lo_close == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_close\n"); libpq_gettext("cannot determine OID of function lo_close\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_creat == 0) if (lobjfuncs->fn_lo_creat == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_creat\n"); libpq_gettext("cannot determine OID of function lo_creat\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_unlink == 0) if (lobjfuncs->fn_lo_unlink == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_unlink\n"); libpq_gettext("cannot determine OID of function lo_unlink\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_lseek == 0) if (lobjfuncs->fn_lo_lseek == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_lseek\n"); libpq_gettext("cannot determine OID of function lo_lseek\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_tell == 0) if (lobjfuncs->fn_lo_tell == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lo_tell\n"); libpq_gettext("cannot determine OID of function lo_tell\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_read == 0) if (lobjfuncs->fn_lo_read == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function loread\n"); libpq_gettext("cannot determine OID of function loread\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
if (lobjfuncs->fn_lo_write == 0) if (lobjfuncs->fn_lo_write == 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"ERROR: Cannot determine OID for function lowrite\n"); libpq_gettext("cannot determine OID of function lowrite\n"));
free(lobjfuncs); free(lobjfuncs);
return -1; return -1;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* *
* *
* IDENTIFICATION * 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,9 +128,8 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) ...@@ -128,9 +128,8 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
if (nbytes > Max(conn->outBufSize - conn->outCount, 0)) if (nbytes > Max(conn->outBufSize - conn->outCount, 0))
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqPutBytes -- pqFlush couldn't flush enough" libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"),
" data: space available: %d, space needed %d\n", Max(conn->outBufSize - conn->outCount, 0), nbytes);
Max(conn->outBufSize - conn->outCount, 0), nbytes);
return EOF; return EOF;
} }
/* fixup avail for while loop */ /* fixup avail for while loop */
...@@ -276,8 +275,9 @@ pqGetInt(int *result, size_t bytes, PGconn *conn) ...@@ -276,8 +275,9 @@ pqGetInt(int *result, size_t bytes, PGconn *conn)
*result = (int) ntohl(tmp4); *result = (int) ntohl(tmp4);
break; break;
default: default:
sprintf(noticeBuf, snprintf(noticeBuf, sizeof(noticeBuf),
"pqGetInt: int size %lu not supported\n", (unsigned long) bytes); libpq_gettext("integer of size %lu not supported by pqGetInt\n"),
(unsigned long) bytes);
DONOTICE(conn, noticeBuf); DONOTICE(conn, noticeBuf);
return EOF; return EOF;
} }
...@@ -313,8 +313,9 @@ pqPutInt(int value, size_t bytes, PGconn *conn) ...@@ -313,8 +313,9 @@ pqPutInt(int value, size_t bytes, PGconn *conn)
return EOF; return EOF;
break; break;
default: default:
sprintf(noticeBuf, snprintf(noticeBuf, sizeof(noticeBuf),
"pqPutInt: int size %lu not supported\n", (unsigned long) bytes); libpq_gettext("integer of size %lu not supported by pqPutInt\n"),
(unsigned long) bytes);
DONOTICE(conn, noticeBuf); DONOTICE(conn, noticeBuf);
return EOF; return EOF;
} }
...@@ -351,8 +352,8 @@ retry: ...@@ -351,8 +352,8 @@ retry:
goto retry; goto retry;
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqReadReady() -- select() failed: errno=%d\n%s\n", libpq_gettext("select() failed: %s\n"),
errno, strerror(errno)); strerror(errno));
return -1; return -1;
} }
...@@ -385,8 +386,8 @@ retry: ...@@ -385,8 +386,8 @@ retry:
goto retry; goto retry;
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqWriteReady() -- select() failed: errno=%d\n%s\n", libpq_gettext("select() failed: %s\n"),
errno, strerror(errno)); strerror(errno));
return -1; return -1;
} }
return FD_ISSET(conn->sock, &input_mask) ? 1 : 0; return FD_ISSET(conn->sock, &input_mask) ? 1 : 0;
...@@ -411,7 +412,7 @@ pqReadData(PGconn *conn) ...@@ -411,7 +412,7 @@ pqReadData(PGconn *conn)
if (conn->sock < 0) if (conn->sock < 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- connection not open\n"); libpq_gettext("connection not open\n"));
return -1; return -1;
} }
...@@ -482,8 +483,8 @@ tryAgain: ...@@ -482,8 +483,8 @@ tryAgain:
goto definitelyFailed; goto definitelyFailed;
#endif #endif
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- read() failed: errno=%d\n%s\n", libpq_gettext("could not receive data from server: %s\n"),
errno, strerror(errno)); strerror(errno));
return -1; return -1;
} }
if (nread > 0) if (nread > 0)
...@@ -568,8 +569,8 @@ tryAgain2: ...@@ -568,8 +569,8 @@ tryAgain2:
goto definitelyFailed; goto definitelyFailed;
#endif #endif
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- read() failed: errno=%d\n%s\n", libpq_gettext("could not receive data from server: %s\n"),
errno, strerror(errno)); strerror(errno));
return -1; return -1;
} }
if (nread > 0) if (nread > 0)
...@@ -584,9 +585,10 @@ tryAgain2: ...@@ -584,9 +585,10 @@ tryAgain2:
*/ */
definitelyFailed: definitelyFailed:
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqReadData() -- backend closed the channel unexpectedly.\n" libpq_gettext(
"\tThis probably means the backend terminated abnormally\n" "server closed the connection unexpectedly\n"
"\tbefore or while processing the request.\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 */ conn->status = CONNECTION_BAD; /* No more connection to backend */
#ifdef WIN32 #ifdef WIN32
closesocket(conn->sock); closesocket(conn->sock);
...@@ -610,7 +612,7 @@ pqFlush(PGconn *conn) ...@@ -610,7 +612,7 @@ pqFlush(PGconn *conn)
if (conn->sock < 0) if (conn->sock < 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- connection not open\n"); libpq_gettext("connection not open\n"));
return EOF; return EOF;
} }
...@@ -627,7 +629,6 @@ pqFlush(PGconn *conn) ...@@ -627,7 +629,6 @@ pqFlush(PGconn *conn)
/* Prevent being SIGPIPEd if backend has closed the connection. */ /* Prevent being SIGPIPEd if backend has closed the connection. */
#ifndef WIN32 #ifndef WIN32
pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
#endif #endif
int sent; int sent;
...@@ -669,9 +670,10 @@ pqFlush(PGconn *conn) ...@@ -669,9 +670,10 @@ pqFlush(PGconn *conn)
case ECONNRESET: case ECONNRESET:
#endif #endif
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- backend closed the channel unexpectedly.\n" libpq_gettext(
"\tThis probably means the backend terminated abnormally" "server closed the connection unexpectedly\n"
" before or while processing the request.\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 * We used to close the socket here, but that's a bad
...@@ -685,8 +687,8 @@ pqFlush(PGconn *conn) ...@@ -685,8 +687,8 @@ pqFlush(PGconn *conn)
default: default:
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqFlush() -- couldn't send data: errno=%d\n%s\n", libpq_gettext("could not send data to server: %s\n"),
errno, strerror(errno)); strerror(errno));
/* We don't assume it's a fatal error... */ /* We don't assume it's a fatal error... */
return EOF; return EOF;
} }
...@@ -751,7 +753,7 @@ pqWait(int forRead, int forWrite, PGconn *conn) ...@@ -751,7 +753,7 @@ pqWait(int forRead, int forWrite, PGconn *conn)
if (conn->sock < 0) if (conn->sock < 0)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqWait() -- connection not open\n"); libpq_gettext("connection not open\n"));
return EOF; return EOF;
} }
...@@ -772,8 +774,8 @@ retry: ...@@ -772,8 +774,8 @@ retry:
if (errno == EINTR) if (errno == EINTR)
goto retry; goto retry;
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
"pqWait() -- select() failed: errno=%d\n%s\n", libpq_gettext("select() failed: %s\n"),
errno, strerror(errno)); strerror(errno));
return EOF; return EOF;
} }
} }
...@@ -831,3 +833,20 @@ PQenv2encoding(void) ...@@ -831,3 +833,20 @@ PQenv2encoding(void)
} }
#endif /* MULTIBYTE */ #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 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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); ...@@ -343,4 +343,14 @@ extern int pqWriteReady(PGconn *conn);
*/ */
#define pqIsnonblocking(conn) ((conn)->nonblocking) #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 */ #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