GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
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_d_close_database(void)
Close database connection.
Definition: d_closedb.c:25
#define DB_OK
Definition: dbmi.h:71
int(* db_driver_close_database)(void)
void db__close_all_cursors(void)
Close all cursors.
Definition: driver_state.c:120
int db__test_database_open(void)
Test database connection.
Definition: driver_state.c:45
void db__init_driver_state(void)
Initialize driver state.
Definition: driver_state.c:24
void db__mark_database_closed(void)
Mark database as closed.
Definition: driver_state.c:66
void db_error(const char *)
Report error message.
#define DB_SEND_SUCCESS()
Definition: macros.h:13
#define DB_SEND_FAILURE()
Definition: macros.h:18