GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
c_list_drivers.c
Go to the documentation of this file.
1 /*!
2  * \file db/dbmi_client/c_list_drivers.c
3  *
4  * \brief DBMI Library (client) - list drivers
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 
17 /*!
18  \brief Return comma separated list of existing DB drivers, used for driver parameter options
19 
20  \return list of db drivers
21  */
22 const char *db_list_drivers(void)
23 {
24  dbDbmscap *list, *cur;
25  dbString drivernames;
26 
27  db_init_string(&drivernames);
28 
29  /* read the dbmscap info */
30  if (NULL == (list = db_read_dbmscap()))
31  return NULL;
32  else {
33  /* build the comma separated string of existing drivers */
34  for (cur = list; cur; cur = cur->next) {
35  if (cur->driverName[0] == '\0')
36  break;
37  else {
38  if (cur != list)
39  db_append_string(&drivernames, ",");
40  db_append_string(&drivernames, cur->driverName);
41  }
42  }
43  }
44 
45  return db_get_string(&drivernames);
46 }
struct _dbmscap * next
Definition: dbmi.h:158
Definition: dbmi.h:153
void db_init_string(dbString *)
Initialize dbString.
Definition: string.c:25
char * db_get_string(const dbString *)
Get string.
Definition: string.c:140
#define NULL
Definition: ccmath.h:32
int db_append_string(dbString *, const char *)
Append string to dbString.
Definition: string.c:205
struct list * list
Definition: read_list.c:24
char driverName[256]
Definition: dbmi.h:155
const char * db_list_drivers(void)
Return comma separated list of existing DB drivers, used for driver parameter options.
dbDbmscap * db_read_dbmscap(void)
Read dbmscap.
Definition: dbmscap.c:100