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