[GRASS-SVN] r59626 - grass/trunk/lib/db/dbmi_base
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 7 03:44:45 PDT 2014
Author: martinl
Date: 2014-04-07 03:44:44 -0700 (Mon, 07 Apr 2014)
New Revision: 59626
Modified:
grass/trunk/lib/db/dbmi_base/connect.c
Log:
dbmi: fix db_get_connection() to get info about user/passwd
Modified: grass/trunk/lib/db/dbmi_base/connect.c
===================================================================
--- grass/trunk/lib/db/dbmi_base/connect.c 2014-04-07 09:45:27 UTC (rev 59625)
+++ grass/trunk/lib/db/dbmi_base/connect.c 2014-04-07 10:44:44 UTC (rev 59626)
@@ -64,24 +64,33 @@
\param[out] connection pointer to dbConnection to be modified
\return DB_OK
+ \return DB_FAILED
*/
int db_get_connection(dbConnection * connection)
{
- /* TODO: add checks and return DB_* error code if needed */
-
G_zero(connection, sizeof(dbConnection));
connection->driverName = (char *)G__getenv2("DB_DRIVER", G_VAR_MAPSET);
connection->databaseName = (char *)G__getenv2("DB_DATABASE", G_VAR_MAPSET);
+
+ if (connection->driverName == NULL ||
+ connection->databaseName == NULL)
+ return DB_FAILED;
+
connection->schemaName = (char *)G__getenv2("DB_SCHEMA", G_VAR_MAPSET);
connection->group = (char *)G__getenv2("DB_GROUP", G_VAR_MAPSET);
- /* below commented due to new mechanism:
+ /* below commented due to new mechanism: see db_get_login()
connection->hostName = G__getenv("DB_HOST");
connection->location = G__getenv("DB_LOCATION");
connection->user = G__getenv("DB_USER");
connection->password = G__getenv("DB_PASSWORD");
*/
+
+ /* try to get user/password */
+ db_get_login(connection->driverName, connection->databaseName,
+ (const char **) &(connection->user),
+ (const char **) &(connection->password));
return DB_OK;
}
More information about the grass-commit
mailing list