aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq++/pgenv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq++/pgenv.cc')
-rw-r--r--src/interfaces/libpq++/pgenv.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/interfaces/libpq++/pgenv.cc b/src/interfaces/libpq++/pgenv.cc
index 451a4f3fde3..b7edbd12fe0 100644
--- a/src/interfaces/libpq++/pgenv.cc
+++ b/src/interfaces/libpq++/pgenv.cc
@@ -14,7 +14,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgenv.cc,v 1.3 1997/02/13 10:00:33 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgenv.cc,v 1.4 1999/05/10 15:27:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,3 +66,19 @@ string PgEnv::getenv(const char* name)
char* env = ::getenv(name);
return (env ? env : "");
}
+
+
+// Extract the PgEnv contents into a form suitable for PQconnectdb
+// which happens to be readable, hence choice of <<
+ostream& operator << (ostream &s, const PgEnv& a)
+{
+ s<<' '; // surround with whitespace, just in case
+ if(a.pgHost.length() !=0)s<<" host=" <<a.pgHost;
+ if(a.pgPort.length() !=0)s<<" port=" <<a.pgPort;
+ // deprecated: if(a.pgAuth.length()!=0)s<<" authtype="<<a.pgAuth;
+ if(a.pgOption.length()!=0)s<<" options="<<a.pgOption;
+ if(a.pgTty.length() !=0)s<<" tty=" <<a.pgTty;
+ s<<' ';
+
+ return s;
+}