diff options
author | Bruce Momjian <bruce@momjian.us> | 2004-06-03 00:07:38 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2004-06-03 00:07:38 +0000 |
commit | 687084333977dfc4318c470b405c55babd056710 (patch) | |
tree | 7d9155832550182368a492915bbf4552352e4f58 /src/interfaces/libpq | |
parent | 70f5a87ecc4cfa8810fb27ad55fa4904dcb40a6a (diff) | |
download | postgresql-687084333977dfc4318c470b405c55babd056710.tar.gz postgresql-687084333977dfc4318c470b405c55babd056710.zip |
Add PGETC (for pg_service.conf) and PGLOCALE (for locale dir)
environment variable processing to libpq.
The patch also adds code to our client apps so we set the environment
variable directly based on our binary location, unless it is already
set. This will allow our applications to emit proper locale messages
that are generated in libpq.
Diffstat (limited to 'src/interfaces/libpq')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 15 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 1cfc6808c5d..1e3379ef651 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.271 2004/05/26 18:35:51 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.272 2004/06/03 00:07:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2363,17 +2363,13 @@ pqPacketSend(PGconn *conn, char pack_type, -#ifndef SYSCONFDIR -#error "You must compile this file with SYSCONFDIR defined." -#endif - #define MAXBUFSIZE 256 static int parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) { char *service = conninfo_getval(options, "service"); - char *serviceFile = SYSCONFDIR "/pg_service.conf"; + char serviceFile[MAXPGPATH]; bool group_found = false; int linenr = 0, i; @@ -2386,6 +2382,13 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) if (service == NULL) service = getenv("PGSERVICE"); + /* + * This could be used by any application so we can't use the binary + * location to find our config files. + */ + snprintf(serviceFile, MAXPGPATH, "%s/pg_service.conf", + getenv("PGETC") ? getenv("PGETC") : SYSCONFDIR); + if (service != NULL) { FILE *f; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index abf2111a508..1d1a2795601 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.106 2004/05/25 01:00:29 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.107 2004/06/03 00:07:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1132,7 +1132,7 @@ libpq_gettext(const char *msgid) { already_bound = 1; /* No relocatable lookup here because the binary could be anywhere */ - bindtextdomain("libpq", LOCALEDIR); + bindtextdomain("libpq", getenv("PGLOCALE") ? getenv("PGLOCALE") : LOCALEDIR); } return dgettext("libpq", msgid); |