handle.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <grass/dbmi.h>
00003 
00010 void
00011 db_init_handle  (dbHandle *handle)
00012 
00013 {
00014     db_init_string (&handle->dbName);
00015     db_init_string (&handle->dbSchema);
00016 }
00017 
00024 db_set_handle  (dbHandle *handle, char *dbName, char *dbSchema)
00025 
00026 {
00027     int stat;
00028 
00029     stat = db_set_string (&handle->dbName, dbName);
00030     if (stat != DB_OK)
00031         return stat;
00032     stat = db_set_string (&handle->dbSchema, dbSchema);
00033     return stat;
00034 }
00035 
00042 char *
00043 db_get_handle_dbname (dbHandle *handle)
00044 
00045 {
00046     return db_get_string (&handle->dbName);
00047 }
00048 
00055 char *
00056 db_get_handle_dbschema (dbHandle *handle)
00057 
00058 {
00059     return db_get_string (&handle->dbSchema);
00060 }
00061 
00068 void
00069 db_free_handle (dbHandle *handle)
00070 
00071 {
00072     db_free_string (&handle->dbName);
00073     db_free_string (&handle->dbSchema);
00074 }
00075 
00082 void
00083 db_free_handle_array  (dbHandle *handle, int count)
00084 
00085 {
00086     int i;
00087 
00088     if (handle)
00089     {
00090         for (i = 0; i < count; i++)
00091             db_free_handle(&handle[i]);
00092         free(handle);
00093     }
00094 }
00095 
00102 dbHandle *
00103 db_alloc_handle_array  (int count)
00104 
00105 {
00106     int i;
00107     dbHandle *handle;
00108 
00109     handle = (dbHandle *) db_calloc (count, sizeof(dbHandle));
00110     if (handle)
00111         for (i = 0; i < count; i++)
00112             db_init_handle (&handle[i]);
00113     return handle;
00114 }

Generated on Sun Apr 6 17:31:38 2008 for GRASS by  doxygen 1.5.5