GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
db/dbmi_client/handler.c
Go to the documentation of this file.
1 /*!
2  \file lib/db/dbmi_client/handler.c
3 
4  \brief DBMI Library (client) - standard error handlers
5 
6  (C) 2013 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Martin Landa <landa.martin gmail.com>
12 */
13 
14 #include <grass/gis.h>
15 #include <grass/dbmi.h>
16 
17 static void error_handler_driver(void *p)
18 {
20 
21  driver = (dbDriver *) p;
22  db_close_database(driver);
23  db_shutdown_driver(driver);
24 }
25 
26 /*!
27  \brief Define standard error handler for open database connection
28 
29  This handler:
30  - close database connection
31  - shutdown db driver
32 
33  Note: It's recommended to call this routine after
34  db_start_driver_open_database().
35 
36  \param driver DB driver
37 */
39 {
40  G_add_error_handler(error_handler_driver, driver);
41 }
42 
43 /*!
44  \brief Remove error handler before closing the driver
45 
46  \param driver DB driver
47 */
49 {
50  G_remove_error_handler(error_handler_driver, driver);
51 }
void db_set_error_handler_driver(dbDriver *driver)
Define standard error handler for open database connection.
void db_unset_error_handler_driver(dbDriver *driver)
Remove error handler before closing the driver.
int db_close_database(dbDriver *)
Close database connection.
Definition: c_closedb.c:26
const struct driver * driver
Definition: driver/init.c:25
int db_shutdown_driver(dbDriver *)
Closedown the driver, and free the driver structure.
Definition: shutdown.c:36
void G_remove_error_handler(void(*)(void *), void *)
Remove existing error handler.
Definition: gis/handler.c:84
Definition: driver.h:22
void G_add_error_handler(void(*)(void *), void *)
Add new error handler.
Definition: gis/handler.c:70