[GRASS-SVN] r56199 - grass/trunk/db/db.connect
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 11 06:37:39 PDT 2013
Author: martinl
Date: 2013-05-11 06:37:39 -0700 (Sat, 11 May 2013)
New Revision: 56199
Modified:
grass/trunk/db/db.connect/main.c
Log:
db.connect -p: substitute variables in database settings
Modified: grass/trunk/db/db.connect/main.c
===================================================================
--- grass/trunk/db/db.connect/main.c 2013-05-11 13:23:40 UTC (rev 56198)
+++ grass/trunk/db/db.connect/main.c 2013-05-11 13:37:39 UTC (rev 56199)
@@ -49,7 +49,8 @@
print = G_define_flag();
print->key = 'p';
- print->description = _("Print current connection parameters and exit");
+ print->label = _("Print current connection parameters and exit");
+ print->description = _("Substitute variables in database settings");
print->guisection = _("Print");
shell = G_define_flag();
@@ -124,10 +125,42 @@
fprintf(stdout, "group=%s\n", conn.group ? conn.group : "");
}
else {
+ char database[GPATH_MAX];
+
+ if (conn.databaseName) {
+ char *c, buf[GPATH_MAX];
+
+ strcpy(database, conn.databaseName);
+
+ strcpy(buf, database);
+ c = (char *)strstr(buf, "$GISDBASE");
+ if (c != NULL) {
+ *c = '\0';
+ sprintf(database, "%s%s%s", buf, G_gisdbase(), c + 9);
+ }
+
+ strcpy(buf, database);
+ c = (char *)strstr(buf, "$LOCATION_NAME");
+ if (c != NULL) {
+ *c = '\0';
+ sprintf(database, "%s%s%s", buf, G_location(), c + 14);
+ }
+
+ strcpy(buf, database);
+ c = (char *)strstr(buf, "$MAPSET");
+ if (c != NULL) {
+ *c = '\0';
+ sprintf(database, "%s%s%s", buf, G_mapset(), c + 7);
+ }
+ }
+ else {
+ database[0] = '\0';
+ }
+
fprintf(stdout, "driver: %s\n",
conn.driverName ? conn.driverName : "");
- fprintf(stdout, "database: %s\n",
- conn.databaseName ? conn.databaseName : "");
+ /* substitute variables */
+ fprintf(stdout, "database: %s\n", database);
fprintf(stdout, "schema: %s\n",
conn.schemaName ? conn.schemaName : "");
fprintf(stdout, "group: %s\n", conn.group ? conn.group : "");
More information about the grass-commit
mailing list