connect.c

Go to the documentation of this file.
00001 #include <grass/gis.h>
00002 #include <grass/dbmi.h>
00003 
00010 int db_set_connection(dbConnection * connection)
00011 {
00012     /* TODO: add checks and return DB_* error code if needed */
00013 
00014     if (connection->driverName)
00015         G_setenv2("DB_DRIVER", connection->driverName, G_VAR_MAPSET);
00016 
00017     if (connection->databaseName)
00018         G_setenv2("DB_DATABASE", connection->databaseName, G_VAR_MAPSET);
00019 
00020     if (connection->schemaName)
00021         G_setenv2("DB_SCHEMA", connection->schemaName, G_VAR_MAPSET);
00022 
00023     if (connection->group)
00024         G_setenv2("DB_GROUP", connection->group, G_VAR_MAPSET);
00025 
00026     /* below commented due to new mechanism:
00027        if ( connection->hostName )
00028        G_setenv("DB_HOST", connection->hostName);
00029 
00030        if ( connection->location )
00031        G_setenv("DB_LOCATION", connection->location);
00032 
00033        if ( connection->user )
00034        G_setenv("DB_USER", connection->user);
00035 
00036        if ( connection->password )
00037        G_setenv("DB_PASSWORD", connection->password);
00038      */
00039 
00040     return DB_OK;
00041 }
00042 
00049 int db_get_connection(dbConnection * connection)
00050 {
00051     /* TODO: add checks and return DB_* error code if needed */
00052 
00053     connection->driverName = G__getenv2("DB_DRIVER", G_VAR_MAPSET);
00054     connection->databaseName = G__getenv2("DB_DATABASE", G_VAR_MAPSET);
00055     connection->schemaName = G__getenv2("DB_SCHEMA", G_VAR_MAPSET);
00056     connection->group = G__getenv2("DB_GROUP", G_VAR_MAPSET);
00057 
00058     /* below commented due to new mechanism:
00059        connection->hostName = G__getenv("DB_HOST");
00060        connection->location = G__getenv("DB_LOCATION");
00061        connection->user = G__getenv("DB_USER");
00062        connection->password = G__getenv("DB_PASSWORD");
00063      */
00064 
00065     return DB_OK;
00066 }

Generated on Sat Oct 24 03:24:24 2009 for GRASS Programmer's Manual by  doxygen 1.6.1