GRASS 8 Programmer's Manual 8.6.0dev(2026)-55de52a352
Loading...
Searching...
No Matches
d_opendb.c
Go to the documentation of this file.
1/*!
2 * \file db/dbmi_driver/d_opendb.c
3 *
4 * \brief DBMI Library (driver) - open database connection
5 *
6 * SPDX-FileCopyrightText: 1999-2008 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Joel Jones (CERL/UIUC), Radim Blazek
10 */
11
12#include <stdlib.h>
13#include <grass/dbmi.h>
14#include "macros.h"
15#include "dbstubs.h"
16
17/*!
18 \brief Open database connection
19
20 \return DB_OK on success
21 \return DB_FAILED on failure
22 */
24{
25 dbHandle handle;
26 int stat;
27
28 /* get the arg(s) */
29 db_init_handle(&handle);
30 DB_RECV_HANDLE(&handle);
31
32 /* see if there is a database already open */
34 db_error("Multiple open databases not allowed");
36 return DB_OK;
37 }
38
39 /* call the procedure */
41
42 /* send the return code */
43 if (stat != DB_OK) {
44 db_free_handle(&handle);
46 return DB_OK;
47 }
49
50 /* record the open in the driver state */
52 db_get_handle_dbschema(&handle));
53 /* DO NOT free the handle since we saved the pointers to the name,path */
54
55 /* no results */
56 return DB_OK;
57}
int db_d_open_database(void)
Open database connection.
Definition d_opendb.c:23
Main header of GRASS DataBase Management Interface.
#define DB_OK
Definition dbmi.h:69
int(* db_driver_open_database)(dbHandle *)
const char * db_get_handle_dbname(dbHandle *)
Get handle database name.
Definition handle.c:54
int db__test_database_open(void)
Test database connection.
void db__mark_database_open(const char *, const char *)
Mark database as opened.
void db_init_handle(dbHandle *)
Initialize handle (i.e database/schema)
Definition handle.c:20
void db_free_handle(dbHandle *)
Free dbHandle structure.
Definition handle.c:76
const char * db_get_handle_dbschema(dbHandle *)
Get handle schema name.
Definition handle.c:66
void db_error(const char *)
Report error message.
#define DB_SEND_SUCCESS()
Definition macros.h:13
#define DB_RECV_HANDLE(x)
Definition macros.h:131
#define DB_SEND_FAILURE()
Definition macros.h:18