GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-f241532c70
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 */
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_OK
Definition: dbmi.h:71
#define DB_PROC_LIST_DATABASES
Definition: dbmi.h:33
dbHandle * db_alloc_handle_array(int)
Allocate array of handles.
Definition: handle.c:109
void db__set_protocol_fds(FILE *, FILE *)
?
int count
#define DB_SEND_STRING_ARRAY(x, n)
Definition: macros.h:29
#define DB_RECV_INT(x)
Definition: macros.h:87
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_HANDLE(x)
Definition: macros.h:131
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:7
Definition: driver.h:21
Definition: path.h:15