GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
c_listdb.c
Go to the documentation of this file.
1 /*!
2  * \file db/dbmi_client/c_listdb.c
3  *
4  * \brief DBMI Library (client) - list databases
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 
18 /*!
19  \brief List databases
20 
21  \param driver db driver
22  \param path db path
23  \param npaths number of given paths
24  \param[out] handles handle infos
25  \param[out] count number of handle infos
26 
27  \return DB_OK on success
28  \return DB_FAILED on failure
29 */
31  dbHandle ** handles, int *count)
32 {
33  int ret_code;
34  int i;
35  dbHandle *h;
36 
37  /* start the procedure call */
38  db__set_protocol_fds(driver->send, driver->recv);
40 
41  /* arguments */
42  DB_SEND_STRING_ARRAY(path, npaths);
43 
44  /* get the return code for the procedure call */
45  DB_RECV_RETURN_CODE(&ret_code);
46 
47  if (ret_code != DB_OK)
48  return ret_code; /* ret_code SHOULD == DB_FAILED */
49 
50  /* results */
51  DB_RECV_INT(count);
52  h = db_alloc_handle_array(*count);
53  for (i = 0; i < *count; i++) {
54  DB_RECV_HANDLE(&h[i]);
55  }
56  *handles = h;
57 
58  return DB_OK;
59 }
int db_list_databases(dbDriver *driver, dbString *path, int npaths, dbHandle **handles, int *count)
List databases.
Definition: c_listdb.c:30
#define DB_RECV_INT(x)
Definition: macros.h:39
#define DB_RECV_HANDLE(x)
Definition: macros.h:59
int count
dbHandle * db_alloc_handle_array(int)
Allocate array of handles.
Definition: handle.c:109
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
Definition: driver.h:22
Definition: path.h:16
FILE * recv
Definition: dbmi.h:171
void db__set_protocol_fds(FILE *, FILE *)
?
#define DB_PROC_LIST_DATABASES
Definition: dbmi.h:33
FILE * send
Definition: dbmi.h:171
#define DB_SEND_STRING_ARRAY(x, n)
Definition: macros.h:14
#define DB_OK
Definition: dbmi.h:71