GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
d_closedb.c
Go to the documentation of this file.
1 /*!
2  * \file db/dbmi_driver/d_closedb.c
3  *
4  * \brief DBMI Library (driver) - close database connection
5  *
6  * (C) 1999-2008 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public
9  * License (>=v2). Read the file COPYING that comes with GRASS
10  * for details.
11  *
12  * \author Joel Jones (CERL/UIUC), Radim Blazek
13  */
14 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 #include "dbstubs.h"
18 
19 /*!
20  \brief Close database connection
21 
22  \return DB_OK on success
23  \return DB_FAILED on failure
24 */
26 {
27  int stat;
28 
29  /* no arg(s) */
30 
31  /* see if a database is open */
32  if (!db__test_database_open()) {
33  db_error("no database is open");
35  return DB_OK;
36  };
37  /* make sure all cursors are closed */
39 
40  /* call the procedure */
41  stat = db_driver_close_database();
42 
43  /* send the return code */
44  if (stat != DB_OK) {
46  return DB_OK;
47  }
49 
50  /* clear the driver state */
53 
54  /* no results */
55  return DB_OK;
56 }
int(* db_driver_close_database)(void)
int db__test_database_open(void)
Test database connection.
Definition: driver_state.c:46
#define DB_SEND_FAILURE()
Definition: macros.h:9
void db_error(const char *)
Report error message.
void db__init_driver_state(void)
Initialize driver state.
Definition: driver_state.c:25
#define DB_SEND_SUCCESS()
Definition: macros.h:7
void db__mark_database_closed(void)
Mark database as closed.
Definition: driver_state.c:67
int db_d_close_database(void)
Close database connection.
Definition: d_closedb.c:25
void db__close_all_cursors(void)
Close all cursors.
Definition: driver_state.c:122
#define DB_OK
Definition: dbmi.h:71