handle.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <grass/dbmi.h>
00003 
00010 void db_init_handle(dbHandle * handle)
00011 {
00012     db_init_string(&handle->dbName);
00013     db_init_string(&handle->dbSchema);
00014 }
00015 
00022 int db_set_handle(dbHandle * handle, const char *dbName, const char *dbSchema)
00023 {
00024     int stat;
00025 
00026     stat = db_set_string(&handle->dbName, dbName);
00027     if (stat != DB_OK)
00028         return stat;
00029     stat = db_set_string(&handle->dbSchema, dbSchema);
00030     return stat;
00031 }
00032 
00039 const char *db_get_handle_dbname(dbHandle * handle)
00040 {
00041     return db_get_string(&handle->dbName);
00042 }
00043 
00050 const char *db_get_handle_dbschema(dbHandle * handle)
00051 {
00052     return db_get_string(&handle->dbSchema);
00053 }
00054 
00061 void db_free_handle(dbHandle * handle)
00062 {
00063     db_free_string(&handle->dbName);
00064     db_free_string(&handle->dbSchema);
00065 }
00066 
00073 void db_free_handle_array(dbHandle * handle, int count)
00074 {
00075     int i;
00076 
00077     if (handle) {
00078         for (i = 0; i < count; i++)
00079             db_free_handle(&handle[i]);
00080         free(handle);
00081     }
00082 }
00083 
00090 dbHandle *db_alloc_handle_array(int count)
00091 {
00092     int i;
00093     dbHandle *handle;
00094 
00095     handle = (dbHandle *) db_calloc(count, sizeof(dbHandle));
00096     if (handle)
00097         for (i = 0; i < count; i++)
00098             db_init_handle(&handle[i]);
00099     return handle;
00100 }
Generated on Tue Apr 6 13:27:21 2010 for GRASS Programmer's Manual by  doxygen 1.6.3