From 1a17447be1186fdd36391c58a2a0209f613d89c4 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 15 Jul 2001 13:45:04 +0000 Subject: [PATCH] NLS for libpq. Clean up the message formats and change the documentation accordingly. --- doc/src/sgml/ref/psql-ref.sgml | 4 +- doc/src/sgml/runtime.sgml | 14 +- doc/src/sgml/start.sgml | 14 +- src/interfaces/libpq/Makefile | 4 +- src/interfaces/libpq/de.po | 427 ++++++++++++++++++++++++++++++ src/interfaces/libpq/fe-auth.c | 53 ++-- src/interfaces/libpq/fe-connect.c | 147 +++++----- src/interfaces/libpq/fe-exec.c | 96 ++++--- src/interfaces/libpq/fe-lobj.c | 41 +-- src/interfaces/libpq/fe-misc.c | 79 +++--- src/interfaces/libpq/libpq-int.h | 12 +- src/interfaces/libpq/nls.mk | 5 + 12 files changed, 686 insertions(+), 210 deletions(-) create mode 100644 src/interfaces/libpq/de.po create mode 100644 src/interfaces/libpq/nls.mk diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 2a4fe71220..ef14a9fdd4 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1,5 +1,5 @@ @@ -2349,7 +2349,7 @@ Field separator is "oo", Pressing Control-C during a copy in (data sent to the server) doesn't show the most ideal of behaviors. If you get a message - such as PQexec: you gotta get out of a COPY state yourself, + such as COPY state must be terminated first, simply reset the connection by entering \c - -. diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index f73bddf354..8a7923b957 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,5 +1,5 @@ @@ -392,9 +392,9 @@ IpcSemaphoreCreate: semget(key=5440026, num=16, 01600) failed: No space left on -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? This is the generic I couldn't find a server to talk to 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: -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"? diff --git a/doc/src/sgml/start.sgml b/doc/src/sgml/start.sgml index 12a413d7ec..ebbccfd042 100644 --- a/doc/src/sgml/start.sgml +++ b/doc/src/sgml/start.sgml @@ -1,5 +1,5 @@ @@ -154,18 +154,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.15 2000/11/30 23:20:50 tgl E % 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"? or % 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? it is usually because diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile index d29f8be2aa..91759e9786 100644 --- a/src/interfaces/libpq/Makefile +++ b/src/interfaces/libpq/Makefile @@ -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 diff --git a/src/interfaces/libpq/de.po b/src/interfaces/libpq/de.po new file mode 100644 index 0000000000..c9c3976f4e --- /dev/null +++ b/src/interfaces/libpq/de.po @@ -0,0 +1,427 @@ +# German message translation file for libpq +# Peter Eisentraut , 2001. +# +# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/de.po,v 1.1 2001/07/15 13:45:04 petere Exp $ +# +# Use these quotes: »%s« +# +msgid "" +msgstr "" +"Project-Id-Version: PostgreSQL 7.2\n" +"POT-Creation-Date: 2001-07-15 14:41+0200\n" +"PO-Revision-Date: 2001-07-15 14:41+0200\n" +"Last-Translator: Peter Eisentraut \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#: fe-auth.c:222 +#, c-format +msgid "Kerberos 4 error: %s\n" +msgstr "Kerberos-4-Fehler: %s\n" + +#: fe-auth.c:387 +#, c-format +msgid "could not set socket to blocking mode: %s" +msgstr "konnte Socket nicht auf blockierenden Modus umstellen: %s" + +#: fe-auth.c:403 +#, c-format +msgid "Kerberos 5 authentication rejected: %*s" +msgstr "Authentifizierung mit Kerberos 5 abgelehnt: %*s" + +#: fe-auth.c:424 +#, c-format +msgid "could not restore non-blocking mode on socket: %s" +msgstr "" +"konnte den nicht blockierenden Modus auf dem Socket nicht wieder herstellen: " +"%s" + +#: fe-auth.c:468 +msgid "Kerberos 4 authentication failed\n" +msgstr "Authentifizierung mit Kerberos 4 schlug fehl\n" + +#: fe-auth.c:474 +msgid "Kerberos 4 authentication not supported\n" +msgstr "Authentifizierung mit Kerberos 4 nicht unterstützt\n" + +#: fe-auth.c:485 +msgid "Kerberos 5 authentication failed\n" +msgstr "Authentifizierung mit Kerberos 5 schlug fehl\n" + +#: fe-auth.c:491 +msgid "Kerberos 5 authentication not supported\n" +msgstr "Authentifizierung mit Kerberos 5 nicht unterstützt\n" + +#: fe-auth.c:514 +#, c-format +msgid "authentication method %u not supported\n" +msgstr "Authentifizierungsmethode %u nicht unterstützt\n" + +#: fe-auth.c:551 +#, c-format +msgid "invalid authentication service name \"%s\", ignored" +msgstr "ungültiger Authentifizierungsdienstname »%s«, ignoriert" + +#: fe-auth.c:608 +#, c-format +msgid "fe_getauthname: invalid authentication system: %d\n" +msgstr "fe_getauthname: ungültiges Authentifizierungssystem: %d\n" + +#: fe-connect.c:491 +msgid "could not determine the PostgreSQL user name to use\n" +msgstr "konnte den zu verwendenden PostgreSQL-Benutzernamen nicht bestimmen\n" + +#: fe-connect.c:713 +#, c-format +msgid "could not socket to non-blocking mode: %s\n" +msgstr "konnte Socket nicht auf nicht-blockierenden Modus umstellen: %s\n" + +#: fe-connect.c:737 +#, c-format +msgid "could not set socket to TCP no delay mode: %s\n" +msgstr "konnte Socket nicht auf TCP »No Delay«-Modus umstellen: %s\n" + +#: fe-connect.c:760 +#, c-format +msgid "" +"could not connect to server: %s\n" +"\tIs the server running locally and accepting\n" +"\tconnections on Unix domain socket \"%s\"?\n" +msgstr "" +"konnte nicht mit dem Server verbinden: %s\n" +"\tLäuft der Server lokal und akzeptiert er Verbindungen\n" +"\tauf dem Unix-Domain-Socket »%s«?\n" + +#: fe-connect.c:769 +#, c-format +msgid "" +"could not connect to server: %s\n" +"\tIs the server running on host %s and accepting\n" +"\tTCP/IP connections on port %s?\n" +msgstr "" +"konnte nicht mit dem Server verbinden: %s\n" +"\tLäuft der Server auf dem Host %s und akzeptiert er\n" +"\tTCP/IP-Verbindungen auf Port %s?\n" + +#: fe-connect.c:834 +#, c-format +msgid "invalid host address: %s\n" +msgstr "ungültige Hostadresse: %s\n" + +#: fe-connect.c:853 +#, c-format +msgid "unknown host name: %s\n" +msgstr "unbekannter Hostname: %s\n" + +#: fe-connect.c:895 +#, c-format +msgid "could not create socket: %s\n" +msgstr "konnte Socket nicht erzeugen: %s\n" + +#: fe-connect.c:975 +#, c-format +msgid "could not send SSL negotiation packet: %s\n" +msgstr "konnte Paket zur SSL-Verhandlung nicht senden: %s\n" + +#: fe-connect.c:983 +#, c-format +msgid "could not receive server response to SSL negotiation packet: %s\n" +msgstr "konnte Serverantwort auf SSL-Verhandlungspaket nicht empfangen: %s\n" + +#: fe-connect.c:997 +#, c-format +msgid "could not create SSL context: %s\n" +msgstr "konnte SSL-Kontext nicht erzeugen: %s\n" + +#: fe-connect.c:1007 +#, c-format +msgid "could not establish SSL connection: %s\n" +msgstr "konnte SSL-Verbindung nicht aufbauen: %s\n" + +#: fe-connect.c:1025 +#, c-format +msgid "received invalid response to SSL negotiation: %c\n" +msgstr "ungültige Antwort auf SSL-Verhandlungspaket empfangen: %c\n" + +#: fe-connect.c:1034 +msgid "server does not support SSL, but SSL was required\n" +msgstr "Server unterstützt kein SSL, aber SSL wurde verlangt\n" + +#: fe-connect.c:1203 +msgid "invalid connection state, probably indicative of memory corruption\n" +msgstr "ungültiger Verbindungszustand, möglicherweise ein Speicherproblem\n" + +#: fe-connect.c:1241 +#, c-format +msgid "could not get socket error status: %s\n" +msgstr "konnte Socket-Fehlerstatus nicht ermitteln: %s\n" + +#: fe-connect.c:1262 +#, c-format +msgid "could not get client address from socket: %s\n" +msgstr "konnte Client-Adresse vom Socket nicht ermitteln: %s\n" + +#: fe-connect.c:1301 +#, c-format +msgid "could not send startup packet: %s\n" +msgstr "konnte Startpaket nicht senden: %s\n" + +#: fe-connect.c:1357 +#, c-format +msgid "expected authentication request from server, but received %c\n" +msgstr "" +"Authentifizierungsanfrage wurde vom Server erwartet, aber %c wurde " +"empfangen\n" + +#: fe-connect.c:1460 +msgid "unexpected message from server during startup\n" +msgstr "unerwartete Nachricht vom Server beim Start\n" + +#: fe-connect.c:1519 +#, c-format +msgid "invalid connection state %c, probably indicative of memory corruption\n" +msgstr "ungültiger Verbindungszustand %c, möglicherweise ein Speicherproblem\n" + +#: fe-connect.c:1623 +#, c-format +msgid "invalid setenv state %c, probably indicative of memory corruption\n" +msgstr "ungültiger »setenv«-Zustand %c, möglicherweise ein Speicherproblem\n" + +#: fe-connect.c:1664 +#, c-format +msgid "invalid encoding name in PGCLIENTENCODING: %s\n" +msgstr "ungültiger Kodierungsname in PGCLIENTENCODING: %s\n" + +#: fe-connect.c:1789 +#, c-format +msgid "invalid state %c, probably indicative of memory corruption\n" +msgstr "ungültiger Zustand %c, möglicherweise ein Speicherproblem\n" + +#: fe-connect.c:2402 fe-connect.c:2411 fe-exec.c:1070 fe-lobj.c:529 +msgid "out of memory\n" +msgstr "Speicher aufgebraucht\n" + +#: fe-connect.c:2450 +#, c-format +msgid "missing \"=\" after \"%s\" in connection info string\n" +msgstr "fehlendes »=« nach »%s« in der Zeichenkette der Verbindungsdaten\n" + +#: fe-connect.c:2499 +msgid "unterminated quoted string in connection info string\n" +msgstr "" +"fehlendes schließendes Anführungszeichen (\") in der Zeichenkette der " +"Verbindugsdaten\n" + +#: fe-connect.c:2533 +#, c-format +msgid "invalid connection option \"%s\"\n" +msgstr "ungültige Verbindungsoption »%s«\n" + +#: fe-connect.c:2718 +msgid "connection pointer is NULL\n" +msgstr "Verbindung ist ein NULL-Zeiger\n" + +#: fe-exec.c:512 +msgid "command string is a null pointer\n" +msgstr "Kommandozeichenkette ist ein NULL-Zeiger\n" + +#: fe-exec.c:520 +msgid "no connection to the server\n" +msgstr "keine Verbindung mit dem Server\n" + +#: fe-exec.c:527 +msgid "another command is already in progress\n" +msgstr "ein anderes Kommando ist bereits in Ausführung\n" + +#: fe-exec.c:730 +#, c-format +msgid "message type 0x%02x arrived from server while idle\n" +msgstr "Nachricht vom Typ 0x%02x kam im Leerlaufzustand vom Server\n" + +#: fe-exec.c:773 +#, c-format +msgid "" +"unexpected character %c following empty query response (\"I\" message)\n" +msgstr "" +"unerwartetes Zeichen %c nach Antwort auf leere Anweisung (»I«-Nachricht)\n" + +#: fe-exec.c:831 +msgid "" +"server sent data (\"D\" message) without prior row description (\"T\" " +"message)\n" +msgstr "" +"Server sendete Daten (»D«-Nachricht) ohne vorherige Zeilenbeschreibung (»T«-" +"Nachricht)\n" + +#: fe-exec.c:848 +msgid "" +"server sent binary data (\"B\" message) without prior row description (\"T\" " +"message)\n" +msgstr "" +"Server sendete binäre Daten (»B«-Nachricht) ohne vorherige " +"Zeilenbeschreibung (»T«-Nachricht)\n" + +#: fe-exec.c:864 +#, c-format +msgid "unexpected response from server; first received character was \"%c\"\n" +msgstr "unerwartete Antwort vom Server; erstes empfangenes Zeichen war »%c«\n" + +#: fe-exec.c:1158 +#, c-format +msgid "unexpected asyncStatus: %d\n" +msgstr "unerwarteter asyncStatus: %d\n" + +#: fe-exec.c:1208 +msgid "COPY state must be terminated first\n" +msgstr "COPY-Zustand muß erst beendet werden\n" + +#: fe-exec.c:1546 +msgid "no COPY in progress\n" +msgstr "keine COPY in Ausführung\n" + +#: fe-exec.c:1585 +msgid "lost synchronization with server, resetting connection\n" +msgstr "" +"Synchronisation mit dem Server verloren, Verbindung wird zurückgesetzt\n" + +#: fe-exec.c:1650 +msgid "connection in wrong state\n" +msgstr "Verbindung im falschen Zustand\n" + +#: fe-exec.c:1752 fe-exec.c:1786 +#, c-format +msgid "protocol error: id=0x%x\n" +msgstr "Protokollfehler: id=0x%x\n" + +#: fe-exec.c:1821 +msgid "invalid ExecStatusType code" +msgstr "ungültiger ExecStatusType-Kode" + +#: fe-exec.c:1874 fe-exec.c:1907 +#, c-format +msgid "column number %d is out of range 0..%d\n" +msgstr "Spaltennummer %d außerhalb des zulässigem Bereichs 0..%d\n" + +#: fe-exec.c:1896 +#, c-format +msgid "row number %d is out of range 0..%d\n" +msgstr "Zeilennummer %d außerhalb des zulässigem Bereichs 0..%d\n" + +#: fe-exec.c:2087 +#, c-format +msgid "could not interpret result from server: %s\n" +msgstr "konnte Ergebnis vom Server nicht interpretieren: %s\n" + +#: fe-exec.c:2103 +msgid "no row count available\n" +msgstr "keine Zeilenzahl verfügbar\n" + +#: fe-lobj.c:399 fe-lobj.c:478 +#, c-format +msgid "could not open file \"%s\": %s\n" +msgstr "konnte Datei »%s« nicht öffnen: %s\n" + +#: fe-lobj.c:411 +#, c-format +msgid "could not create large object for file \"%s\"\n" +msgstr "konnte Large Object für Datei »%s« nicht erzeugen\n" + +#: fe-lobj.c:420 fe-lobj.c:467 +#, c-format +msgid "could not open large object %u\n" +msgstr "konnte Large Object %u nicht öffnen\n" + +#: fe-lobj.c:434 +#, c-format +msgid "error while reading file \"%s\"\n" +msgstr "Fehler beim Lesen der Datei »%s«\n" + +#: fe-lobj.c:492 +#, c-format +msgid "error while writing to file \"%s\"\n" +msgstr "Fehler beim Schreiben der Datei »%s«\n" + +#: fe-lobj.c:557 +msgid "query to initialize large object functions did not return data\n" +msgstr "" +"Abfrage zur Initialisierung der Large-Object-Funktionen ergab keine Daten\n" + +#: fe-lobj.c:595 +msgid "cannot determine OID of function lo_open\n" +msgstr "kann OID der Funktion lo_open nicht ermitteln\n" + +#: fe-lobj.c:602 +msgid "cannot determine OID of function lo_close\n" +msgstr "kann OID der Funktion lo_close nicht ermitteln\n" + +#: fe-lobj.c:609 +msgid "cannot determine OID of function lo_creat\n" +msgstr "kann OID der Funktion lo_open nicht ermitteln\n" + +#: fe-lobj.c:616 +msgid "cannot determine OID of function lo_unlink\n" +msgstr "kann OID der Funktion lo_unlink nicht ermitteln\n" + +#: fe-lobj.c:623 +msgid "cannot determine OID of function lo_lseek\n" +msgstr "kann OID der Funktion lo_lseek nicht ermitteln\n" + +#: fe-lobj.c:630 +msgid "cannot determine OID of function lo_tell\n" +msgstr "kann OID der Funktion lo_tell nicht ermitteln\n" + +#: fe-lobj.c:637 +msgid "cannot determine OID of function loread\n" +msgstr "kann OID der Funktion loread nicht ermitteln\n" + +#: fe-lobj.c:644 +msgid "cannot determine OID of function lowrite\n" +msgstr "kann OID der Funktion lowrite nicht ermitteln\n" + +#: fe-misc.c:131 +#, c-format +msgid "could not flush enough data (space available: %d, space needed %d)\n" +msgstr "" +"konnte nicht genug Daten flushen (verfügbarer Platz: %d, benötigter Platz: %" +"d)\n" + +#: fe-misc.c:279 +#, c-format +msgid "integer of size %lu not supported by pqGetInt\n" +msgstr "Integer der Größe %lu wird nicht von pqGetInt unterstützt\n" + +#: fe-misc.c:317 +#, c-format +msgid "integer of size %lu not supported by pqPutInt\n" +msgstr "Integer der Größe %lu wird nicht von pqPutInt unterstützt\n" + +#: fe-misc.c:355 fe-misc.c:389 fe-misc.c:777 +#, c-format +msgid "select() failed: %s\n" +msgstr "select() fehlgeschlagen: %s\n" + +#: fe-misc.c:415 fe-misc.c:615 fe-misc.c:756 +msgid "connection not open\n" +msgstr "Verbindung nicht offen\n" + +#: fe-misc.c:486 fe-misc.c:572 +#, c-format +msgid "could not receive data from server: %s\n" +msgstr "konnte keine Daten vom Server empfangen: %s\n" + +#: fe-misc.c:589 fe-misc.c:674 +msgid "" +"server closed the connection unexpectedly\n" +"\tThis probably means the server terminated abnormally\n" +"\tbefore or while processing the request.\n" +msgstr "" +"Server beendete die Verbindung unerwartet\n" +"\tDas heißt wahrscheinlich, daß der Server abnormal beendete\n" +"\tbevor oder während die Anweisung bearbeitet wurde.\n" + +#: fe-misc.c:690 +#, c-format +msgid "could not send data to server: %s\n" +msgstr "konnte keine Daten an den Server senden: %s\n" diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 0e158d984f..d8b27c3772 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -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,9 +160,9 @@ pg_krb4_authname(char *PQerrormsg) status = krb_get_tf_fullname(tkt_string(), name, instance, realm); if (status != KSUCCESS) { - (void) sprintf(PQerrormsg, - "pg_krb4_authname: krb_get_tf_fullname: %s\n", - krb_err_txt[status]); + snprintf(PQerrormsg, PQERRORMSG_LENGTH, + "pg_krb4_authname: krb_get_tf_fullname: %s\n", + krb_err_txt[status]); return (char *) NULL; } return name; @@ -218,9 +218,9 @@ pg_krb4_sendauth(char *PQerrormsg, int sock, PG_KRB4_VERSION); if (status != KSUCCESS) { - (void) sprintf(PQerrormsg, - "pg_krb4_sendauth: kerberos error: %s\n", - krb_err_txt[status]); + snprintf(PQerrormsg, PQERRORMSG_LENGTH, + libpq_gettext("Kerberos 4 error: %s\n"), + krb_err_txt[status]); return STATUS_ERROR; } return STATUS_OK; @@ -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,9 +547,9 @@ fe_setauthsvc(const char *name, char *PQerrormsg) } if (i == n_authsvcs) { - (void) sprintf(PQerrormsg, - "fe_setauthsvc: invalid name: %s, ignoring...\n", - name); + 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); diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index e215eb87e9..71096e9cf1 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.166 2001/07/06 19:04:23 petere Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.167 2001/07/15 13:45:04 petere Exp $ * *------------------------------------------------------------------------- */ @@ -488,7 +488,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, { error = TRUE; printfPQExpBuffer(&conn->errorMessage, - "FATAL: PQsetdbLogin(): Unable to determine a Postgres username!\n"); + libpq_gettext("could not determine the PostgreSQL user name to use\n")); } if (pwd) @@ -710,8 +710,8 @@ connectMakeNonblocking(PGconn *conn) #endif { printfPQExpBuffer(&conn->errorMessage, - "connectMakeNonblocking -- fcntl() failed: errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not socket to non-blocking mode: %s\n"), + strerror(errno)); return 0; } @@ -734,8 +734,8 @@ connectNoDelay(PGconn *conn) sizeof(on)) < 0) { printfPQExpBuffer(&conn->errorMessage, - "connectNoDelay() -- setsockopt failed: errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not set socket to TCP no delay mode: %s\n"), + strerror(errno)); #ifdef WIN32 printf("Winsock error: %i\n", WSAGetLastError()); #endif @@ -752,26 +752,30 @@ connectNoDelay(PGconn *conn) * ---------- */ static void -connectFailureMessage(PGconn *conn, const char *caller, int errorno) +connectFailureMessage(PGconn *conn, int errorno) { -#ifdef HAVE_UNIX_SOCKETS if (conn->raddr.sa.sa_family == AF_UNIX) printfPQExpBuffer(&conn->errorMessage, - "%s -- connect() failed: %s\n" - "\tIs the postmaster running locally\n" - "\tand accepting connections on Unix socket '%s'?\n", - caller, + libpq_gettext( + "could not connect to server: %s\n" + "\tIs the server running locally and accepting\n" + "\tconnections on Unix domain socket \"%s\"?\n" + ), strerror(errorno), conn->raddr.un.sun_path); else -#endif printfPQExpBuffer(&conn->errorMessage, - "%s -- connect() failed: %s\n" - "\tIs the postmaster running (with -i) at '%s'\n" - "\tand accepting connections on TCP/IP port %s?\n", - caller, + libpq_gettext( + "could not connect to server: %s\n" + "\tIs the server running on host %s and accepting\n" + "\tTCP/IP connections on port %s?\n" + ), strerror(errorno), - conn->pghost ? conn->pghost : "localhost", + conn->pghost + ? conn->pghost + : (conn->pghostaddr + ? conn->pghostaddr + : "???"), conn->pgport); } @@ -827,8 +831,8 @@ connectDBStart(PGconn *conn) if (!inet_aton(conn->pghostaddr, &addr)) { printfPQExpBuffer(&conn->errorMessage, - "connectDBStart() -- " - "invalid host address: %s\n", conn->pghostaddr); + libpq_gettext("invalid host address: %s\n"), + conn->pghostaddr); goto connect_errReturn; } @@ -846,7 +850,7 @@ connectDBStart(PGconn *conn) if ((hp == NULL) || (hp->h_addrtype != AF_INET)) { printfPQExpBuffer(&conn->errorMessage, - "connectDBStart() -- unknown hostname: %s\n", + libpq_gettext("unknown host name: %s\n"), conn->pghost); goto connect_errReturn; } @@ -858,7 +862,7 @@ connectDBStart(PGconn *conn) } else { - /* pghostaddr and pghost are NULL, so use UDP */ + /* pghostaddr and pghost are NULL, so use Unix domain socket */ family = AF_UNIX; } @@ -888,9 +892,8 @@ connectDBStart(PGconn *conn) if ((conn->sock = socket(family, SOCK_STREAM, 0)) < 0) { printfPQExpBuffer(&conn->errorMessage, - "connectDBStart() -- " - "socket() failed: errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not create socket: %s\n"), + strerror(errno)); goto connect_errReturn; } @@ -950,7 +953,7 @@ connectDBStart(PGconn *conn) else { /* Something's gone wrong */ - connectFailureMessage(conn, "connectDBStart()", errno); + connectFailureMessage(conn, errno); goto connect_errReturn; } } @@ -969,15 +972,16 @@ connectDBStart(PGconn *conn) if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - "connectDB() -- couldn't send SSL negotiation packet: errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not send SSL negotiation packet: %s\n"), + strerror(errno)); goto connect_errReturn; } /* Now receive the postmasters response */ if (recv(conn->sock, &SSLok, 1, 0) != 1) { - printfPQExpBuffer(&conn->errorMessage, "PQconnectDB() -- couldn't read postmaster response: errno=%d\n%s\n", - errno, strerror(errno)); + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not receive server response to SSL negotiation packet: %s\n"), + strerror(errno)); goto connect_errReturn; } if (SSLok == 'S') @@ -990,8 +994,8 @@ connectDBStart(PGconn *conn) if (!SSL_context) { printfPQExpBuffer(&conn->errorMessage, - "connectDB() -- couldn't create SSL context: %s\n", - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not create SSL context: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } } @@ -1000,8 +1004,8 @@ connectDBStart(PGconn *conn) SSL_connect(conn->ssl) <= 0) { printfPQExpBuffer(&conn->errorMessage, - "connectDB() -- couldn't establish SSL connection: %s\n", - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not establish SSL connection: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } /* SSL connection finished. Continue to send startup packet */ @@ -1018,7 +1022,8 @@ connectDBStart(PGconn *conn) else if (SSLok != 'N') { printfPQExpBuffer(&conn->errorMessage, - "Received invalid negotiation response.\n"); + libpq_gettext("received invalid response to SSL negotiation: %c\n"), + SSLok); goto connect_errReturn; } } @@ -1026,7 +1031,7 @@ connectDBStart(PGconn *conn) { /* Require SSL, but server does not support/want it */ printfPQExpBuffer(&conn->errorMessage, - "Server does not support SSL when SSL was required.\n"); + libpq_gettext("server does not support SSL, but SSL was required\n")); goto connect_errReturn; } #endif @@ -1194,8 +1199,10 @@ PQconnectPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- unknown connection state - " - "probably indicative of memory corruption!\n"); + libpq_gettext( + "invalid connection state, " + "probably indicative of memory corruption\n" + )); goto error_return; } @@ -1231,9 +1238,8 @@ keep_going: /* We will come back to here until there (char *) &optval, &optlen) == -1) { printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- getsockopt() failed: " - "errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not get socket error status: %s\n"), + strerror(errno)); goto error_return; } else if (optval != 0) @@ -1244,7 +1250,7 @@ keep_going: /* We will come back to here until there * see connect failures at this point, so provide a * friendly error message. */ - connectFailureMessage(conn, "PQconnectPoll()", optval); + connectFailureMessage(conn, optval); goto error_return; } @@ -1253,9 +1259,8 @@ keep_going: /* We will come back to here until there if (getsockname(conn->sock, &conn->laddr.sa, &laddrlen) < 0) { printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- getsockname() failed: " - "errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not get client address from socket: %s\n"), + strerror(errno)); goto error_return; } @@ -1293,10 +1298,8 @@ keep_going: /* We will come back to here until there sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- " - "couldn't send startup packet: " - "errno=%d\n%s\n", - errno, strerror(errno)); + libpq_gettext("could not send startup packet: %s\n"), + strerror(errno)); goto error_return; } @@ -1350,8 +1353,11 @@ keep_going: /* We will come back to here until there if (beresp != 'R') { printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- expected " - "authentication request\n"); + libpq_gettext( + "expected authentication request from " + "server, but received %c\n" + ), + beresp); goto error_return; } @@ -1451,8 +1457,7 @@ keep_going: /* We will come back to here until there { if (res->resultStatus != PGRES_FATAL_ERROR) printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- unexpected message " - "during startup\n"); + libpq_gettext("unexpected message from server during startup\n")); /* * if the resultStatus is FATAL, then @@ -1510,8 +1515,11 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, - "PQconnectPoll() -- unknown connection state - " - "probably indicative of memory corruption!\n"); + libpq_gettext( + "invalid connection state %c, " + "probably indicative of memory corruption\n" + ), + conn->status); goto error_return; } @@ -1611,8 +1619,11 @@ PQsetenvPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - "PQsetenvPoll() -- unknown state - " - "probably indicative of memory corruption!\n"); + libpq_gettext( + "invalid setenv state %c, " + "probably indicative of memory corruption\n" + ), + conn->setenv_state); goto error_return; } @@ -1649,8 +1660,9 @@ keep_going: /* We will come back to here until there if (encoding < 0) { - strcpy(conn->errorMessage.data, - "PGCLIENTENCODING has no valid encoding name.\n"); + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("invalid encoding name in PGCLIENTENCODING: %s\n"), + env); goto error_return; } conn->client_encoding = encoding; @@ -1774,8 +1786,9 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, - "PQsetenvPoll() -- unknown state - " - "probably indicative of memory corruption!\n"); + libpq_gettext("invalid state %c, " + "probably indicative of memory corruption\n"), + conn->setenv_state); goto error_return; } @@ -2386,7 +2399,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (options == NULL) { printfPQExpBuffer(errorMessage, - "FATAL: cannot allocate memory for copy of PQconninfoOptions\n"); + libpq_gettext("out of memory\n")); return NULL; } memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); @@ -2395,7 +2408,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if ((buf = strdup(conninfo)) == NULL) { printfPQExpBuffer(errorMessage, - "FATAL: cannot allocate memory for copy of conninfo string\n"); + libpq_gettext("out of memory\n")); PQconninfoFree(options); return NULL; } @@ -2434,7 +2447,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (*cp != '=') { printfPQExpBuffer(errorMessage, - "ERROR: Missing '=' after '%s' in conninfo\n", + libpq_gettext("missing \"=\" after \"%s\" in connection info string\n"), pname); PQconninfoFree(options); free(buf); @@ -2483,7 +2496,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (*cp == '\0') { printfPQExpBuffer(errorMessage, - "ERROR: PQconnectdb() - unterminated quoted string in conninfo\n"); + libpq_gettext("unterminated quoted string in connection info string\n")); PQconninfoFree(options); free(buf); return NULL; @@ -2517,7 +2530,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (option->keyword == NULL) { printfPQExpBuffer(errorMessage, - "ERROR: Unknown conninfo option '%s'\n", + libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); free(buf); @@ -2702,7 +2715,7 @@ char * PQerrorMessage(const PGconn *conn) { if (!conn) - return "PQerrorMessage: conn pointer is NULL\n"; + return libpq_gettext("connection pointer is NULL\n"); return conn->errorMessage.data; } diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 78d5736908..fcd2724b8e 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.102 2001/07/06 17:58:53 petere Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.103 2001/07/15 13:45:04 petere Exp $ * *------------------------------------------------------------------------- */ @@ -509,7 +509,7 @@ PQsendQuery(PGconn *conn, const char *query) if (!query) { printfPQExpBuffer(&conn->errorMessage, - "PQsendQuery() -- query pointer is null.\n"); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -517,15 +517,14 @@ PQsendQuery(PGconn *conn, const char *query) if (conn->status != CONNECTION_OK) { printfPQExpBuffer(&conn->errorMessage, - "PQsendQuery() -- There is no connection " - "to the backend.\n"); + libpq_gettext("no connection to the server\n")); return 0; } /* Can't send while already busy, either. */ if (conn->asyncStatus != PGASYNC_IDLE) { printfPQExpBuffer(&conn->errorMessage, - "PQsendQuery() -- another query already in progress.\n"); + libpq_gettext("another command is already in progress\n")); return 0; } @@ -727,9 +726,9 @@ parseInput(PGconn *conn) } else { - sprintf(noticeWorkspace, - "Backend message type 0x%02x arrived while idle\n", - id); + snprintf(noticeWorkspace, sizeof(noticeWorkspace), + libpq_gettext("message type 0x%02x arrived from server while idle\n"), + id); DONOTICE(conn, noticeWorkspace); /* Discard the unexpected message; good idea?? */ conn->inStart = conn->inEnd; @@ -770,9 +769,9 @@ parseInput(PGconn *conn) return; if (id != '\0') { - sprintf(noticeWorkspace, - "unexpected character %c following 'I'\n", - id); + snprintf(noticeWorkspace, sizeof(noticeWorkspace), + libpq_gettext("unexpected character %c following empty query response (\"I\" message)\n"), + id); DONOTICE(conn, noticeWorkspace); } if (conn->result == NULL) @@ -828,8 +827,8 @@ parseInput(PGconn *conn) } else { - sprintf(noticeWorkspace, - "Backend sent D message without prior T\n"); + snprintf(noticeWorkspace, sizeof(noticeWorkspace), + libpq_gettext("server sent data (\"D\" message) without prior row description (\"T\" message)\n")); DONOTICE(conn, noticeWorkspace); /* Discard the unexpected message; good idea?? */ conn->inStart = conn->inEnd; @@ -845,8 +844,8 @@ parseInput(PGconn *conn) } else { - sprintf(noticeWorkspace, - "Backend sent B message without prior T\n"); + snprintf(noticeWorkspace, sizeof(noticeWorkspace), + libpq_gettext("server sent binary data (\"B\" message) without prior row description (\"T\" message)\n")); DONOTICE(conn, noticeWorkspace); /* Discard the unexpected message; good idea?? */ conn->inStart = conn->inEnd; @@ -861,9 +860,8 @@ parseInput(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - "Unknown protocol character '%c' read from backend. " - "(The protocol character is the first character the " - "backend sends in response to a query it receives).\n", + libpq_gettext( + "unexpected response from server; first received character was \"%c\"\n"), id); /* build an error result holding the error message */ saveErrorResult(conn); @@ -1069,7 +1067,7 @@ outOfMemory: */ pqClearAsyncResult(conn); printfPQExpBuffer(&conn->errorMessage, - "getAnotherTuple() -- out of memory for result\n"); + libpq_gettext("out of memory\n")); conn->result = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); conn->asyncStatus = PGASYNC_READY; /* Discard the failed message --- good idea? */ @@ -1157,7 +1155,7 @@ PQgetResult(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - "PQgetResult: Unexpected asyncStatus %d\n", + libpq_gettext("unexpected asyncStatus: %d\n"), (int) conn->asyncStatus); res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); break; @@ -1207,7 +1205,7 @@ PQexec(PGconn *conn, const char *query) { PQclear(result); printfPQExpBuffer(&conn->errorMessage, - "PQexec: you gotta get out of a COPY state yourself.\n"); + libpq_gettext("COPY state must be terminated first\n")); /* restore blocking status */ goto errout; } @@ -1545,7 +1543,7 @@ PQendcopy(PGconn *conn) conn->asyncStatus != PGASYNC_COPY_OUT) { printfPQExpBuffer(&conn->errorMessage, - "PQendcopy() -- I don't think there's a copy in progress.\n"); + libpq_gettext("no COPY in progress\n")); return 1; } @@ -1584,7 +1582,7 @@ PQendcopy(PGconn *conn) if (conn->errorMessage.len > 0) DONOTICE(conn, conn->errorMessage.data); - DONOTICE(conn, "PQendcopy: resetting connection\n"); + DONOTICE(conn, libpq_gettext("lost synchronization with server, resetting connection\n")); /* * Users doing non-blocking connections need to handle the reset @@ -1649,7 +1647,7 @@ PQfn(PGconn *conn, conn->result != NULL) { printfPQExpBuffer(&conn->errorMessage, - "PQfn() -- connection in wrong state\n"); + libpq_gettext("connection in wrong state\n")); return NULL; } @@ -1751,7 +1749,7 @@ PQfn(PGconn *conn, { /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - "FATAL: PQfn: protocol error: id=0x%x\n", + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1785,7 +1783,7 @@ PQfn(PGconn *conn, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - "FATAL: PQfn: protocol error: id=0x%x\n", + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1820,7 +1818,7 @@ char * PQresStatus(ExecStatusType status) { if (status < 0 || status >= sizeof pgresStatus / sizeof pgresStatus[0]) - return "Invalid ExecStatusType code"; + return libpq_gettext("invalid ExecStatusType code"); return pgresStatus[status]; } @@ -1862,7 +1860,7 @@ PQbinaryTuples(const PGresult *res) */ static int -check_field_number(const char *routineName, const PGresult *res, int field_num) +check_field_number(const PGresult *res, int field_num) { char noticeBuf[128]; @@ -1872,9 +1870,9 @@ check_field_number(const char *routineName, const PGresult *res, int field_num) { if (res->noticeHook) { - sprintf(noticeBuf, - "%s: ERROR! field number %d is out of range 0..%d\n", - routineName, field_num, res->numAttributes - 1); + snprintf(noticeBuf, sizeof(noticeBuf), + libpq_gettext("column number %d is out of range 0..%d\n"), + field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -1883,7 +1881,7 @@ check_field_number(const char *routineName, const PGresult *res, int field_num) } static int -check_tuple_field_number(const char *routineName, const PGresult *res, +check_tuple_field_number(const PGresult *res, int tup_num, int field_num) { char noticeBuf[128]; @@ -1894,9 +1892,9 @@ check_tuple_field_number(const char *routineName, const PGresult *res, { if (res->noticeHook) { - sprintf(noticeBuf, - "%s: ERROR! tuple number %d is out of range 0..%d\n", - routineName, tup_num, res->ntups - 1); + snprintf(noticeBuf, sizeof(noticeBuf), + libpq_gettext("row number %d is out of range 0..%d\n"), + tup_num, res->ntups - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -1905,9 +1903,9 @@ check_tuple_field_number(const char *routineName, const PGresult *res, { if (res->noticeHook) { - sprintf(noticeBuf, - "%s: ERROR! field number %d is out of range 0..%d\n", - routineName, field_num, res->numAttributes - 1); + snprintf(noticeBuf, sizeof(noticeBuf), + libpq_gettext("column number %d is out of range 0..%d\n"), + field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -1921,7 +1919,7 @@ check_tuple_field_number(const char *routineName, const PGresult *res, char * PQfname(const PGresult *res, int field_num) { - if (!check_field_number("PQfname", res, field_num)) + if (!check_field_number(res, field_num)) return NULL; if (res->attDescs) return res->attDescs[field_num].name; @@ -1972,7 +1970,7 @@ PQfnumber(const PGresult *res, const char *field_name) Oid PQftype(const PGresult *res, int field_num) { - if (!check_field_number("PQftype", res, field_num)) + if (!check_field_number(res, field_num)) return InvalidOid; if (res->attDescs) return res->attDescs[field_num].typid; @@ -1983,7 +1981,7 @@ PQftype(const PGresult *res, int field_num) int PQfsize(const PGresult *res, int field_num) { - if (!check_field_number("PQfsize", res, field_num)) + if (!check_field_number(res, field_num)) return 0; if (res->attDescs) return res->attDescs[field_num].typlen; @@ -1994,7 +1992,7 @@ PQfsize(const PGresult *res, int field_num) int PQfmod(const PGresult *res, int field_num) { - if (!check_field_number("PQfmod", res, field_num)) + if (!check_field_number(res, field_num)) return 0; if (res->attDescs) return res->attDescs[field_num].atttypmod; @@ -2085,8 +2083,8 @@ PQcmdTuples(PGresult *res) { if (res->noticeHook) { - sprintf(noticeBuf, - "PQcmdTuples (%s) -- bad input from server\n", + snprintf(noticeBuf, sizeof(noticeBuf), + libpq_gettext("could not interpret result from server: %s\n"), res->cmdStatus); DONOTICE(res, noticeBuf); } @@ -2101,8 +2099,8 @@ PQcmdTuples(PGresult *res) { if (res->noticeHook) { - sprintf(noticeBuf, - "PQcmdTuples (INSERT) -- there's no # of tuples\n"); + snprintf(noticeBuf, sizeof(noticeBuf), + libpq_gettext("no row count available\n")); DONOTICE(res, noticeBuf); } return ""; @@ -2126,7 +2124,7 @@ PQcmdTuples(PGresult *res) char * PQgetvalue(const PGresult *res, int tup_num, int field_num) { - if (!check_tuple_field_number("PQgetvalue", res, tup_num, field_num)) + if (!check_tuple_field_number(res, tup_num, field_num)) return NULL; return res->tuples[tup_num][field_num].value; } @@ -2140,7 +2138,7 @@ PQgetvalue(const PGresult *res, int tup_num, int field_num) int PQgetlength(const PGresult *res, int tup_num, int field_num) { - if (!check_tuple_field_number("PQgetlength", res, tup_num, field_num)) + if (!check_tuple_field_number(res, tup_num, field_num)) return 0; if (res->tuples[tup_num][field_num].len != NULL_LEN) return res->tuples[tup_num][field_num].len; @@ -2154,7 +2152,7 @@ PQgetlength(const PGresult *res, int tup_num, int field_num) int PQgetisnull(const PGresult *res, int tup_num, int field_num) { - if (!check_tuple_field_number("PQgetisnull", res, tup_num, field_num)) + if (!check_tuple_field_number(res, tup_num, field_num)) return 1; /* pretend it is null */ if (res->tuples[tup_num][field_num].len == NULL_LEN) return 1; diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 0759f053a5..078184ceb0 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -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 #include +#include #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; } diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index bcc3bdc9c8..af7998ce97 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -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,9 +128,8 @@ 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", - Max(conn->outBufSize - conn->outCount, 0), nbytes); + libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"), + Max(conn->outBufSize - conn->outCount, 0), nbytes); return EOF; } /* fixup avail for while loop */ @@ -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 */ diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 7d8848e3e9..5e90e492f1 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -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 */ diff --git a/src/interfaces/libpq/nls.mk b/src/interfaces/libpq/nls.mk new file mode 100644 index 0000000000..e9d4fdc77a --- /dev/null +++ b/src/interfaces/libpq/nls.mk @@ -0,0 +1,5 @@ +# $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