|
@@ -1,3 +1,17 @@
|
|
|
+/*!
|
|
|
+ * \file db/dbmi_driver/driver_state.c
|
|
|
+ *
|
|
|
+ * \brief DBMI Library (driver) - drivers state
|
|
|
+ *
|
|
|
+ * (C) 1999-2008 by the GRASS Development Team
|
|
|
+ *
|
|
|
+ * This program is free software under the GNU General Public
|
|
|
+ * License (>=v2). Read the file COPYING that comes with GRASS
|
|
|
+ * for details.
|
|
|
+ *
|
|
|
+ * \author Joel Jones (CERL/UIUC), Radim Blazek
|
|
|
+ */
|
|
|
+
|
|
|
#include <stdlib.h>
|
|
|
#include <grass/dbmi.h>
|
|
|
#include "dbstubs.h"
|
|
@@ -5,25 +19,41 @@
|
|
|
|
|
|
static dbDriverState state;
|
|
|
|
|
|
-
|
|
|
+/*!
|
|
|
+ \brief Initialize driver state
|
|
|
+*/
|
|
|
void db__init_driver_state(void)
|
|
|
{
|
|
|
db_zero((void *)&state, sizeof(state));
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Get driver state
|
|
|
|
|
|
+ \return pointer to dbDriverState
|
|
|
+*/
|
|
|
dbDriverState *db__get_driver_state(void)
|
|
|
{
|
|
|
return &state;
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Test database connection
|
|
|
|
|
|
+ \return 1 opened
|
|
|
+ \return 0 closed
|
|
|
+*/
|
|
|
int db__test_database_open(void)
|
|
|
{
|
|
|
return state.open ? 1 : 0;
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Mark database as opened
|
|
|
|
|
|
+ \param dbname database name
|
|
|
+ \param dbschema database schema name
|
|
|
+*/
|
|
|
void db__mark_database_open(const char *dbname, const char *dbschema)
|
|
|
{
|
|
|
state.dbname = db_store(dbname);
|
|
@@ -31,7 +61,9 @@ void db__mark_database_open(const char *dbname, const char *dbschema)
|
|
|
state.open = 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+/*!
|
|
|
+ \brief Mark database as closed
|
|
|
+*/
|
|
|
void db__mark_database_closed(void)
|
|
|
{
|
|
|
free(state.dbname);
|
|
@@ -39,7 +71,11 @@ void db__mark_database_closed(void)
|
|
|
state.open = 0;
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Add cursor do driver state
|
|
|
|
|
|
+ \param cursor db cursor to be added
|
|
|
+*/
|
|
|
void db__add_cursor_to_driver_state(dbCursor * cursor)
|
|
|
{
|
|
|
dbCursor **list;
|
|
@@ -66,7 +102,11 @@ void db__add_cursor_to_driver_state(dbCursor * cursor)
|
|
|
list[i] = cursor;
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Drop cursor from driver state
|
|
|
|
|
|
+ \param cursor db cursor to be dropped
|
|
|
+*/
|
|
|
void db__drop_cursor_from_driver_state(dbCursor * cursor)
|
|
|
{
|
|
|
int i;
|
|
@@ -76,7 +116,9 @@ void db__drop_cursor_from_driver_state(dbCursor * cursor)
|
|
|
state.cursor_list[i] = NULL;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+/*!
|
|
|
+ \brief Close all cursors
|
|
|
+*/
|
|
|
void db__close_all_cursors(void)
|
|
|
{
|
|
|
int i;
|