c_list_drivers.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include <grass/dbmi.h>
  15. /*!
  16. \brief Return comma separated list of existing DB drivers, used for driver parameter options
  17. \return list of db drivers
  18. */
  19. const char *db_list_drivers(void)
  20. {
  21. dbDbmscap *list, *cur;
  22. dbString drivernames;
  23. db_init_string(&drivernames);
  24. /* read the dbmscap info */
  25. if (NULL == (list = db_read_dbmscap()))
  26. return NULL;
  27. else {
  28. /* build the comma separated string of existing drivers */
  29. for (cur = list; cur; cur = cur->next) {
  30. if (cur->driverName[0] == '\0')
  31. break;
  32. else {
  33. if (cur != list)
  34. db_append_string(&drivernames, ",");
  35. db_append_string(&drivernames, cur->driverName);
  36. }
  37. }
  38. }
  39. return db_get_string(&drivernames);
  40. }