d_finddb.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*!
  2. * \file db/dbmi_driver/d_finddb.c
  3. *
  4. * \brief DBMI Library (driver) - find database
  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 <stdlib.h>
  15. #include <grass/dbmi.h>
  16. #include "macros.h"
  17. #include "dbstubs.h"
  18. /*!
  19. \brief Find database
  20. \return DB_OK on success
  21. \return DB_FAILED on failure
  22. */
  23. int db_d_find_database(void)
  24. {
  25. dbHandle handle;
  26. int found;
  27. int stat;
  28. /* get the arg(s) */
  29. db_init_handle(&handle);
  30. DB_RECV_HANDLE(&handle);
  31. /* call the procedure */
  32. stat = db_driver_find_database(&handle, &found);
  33. /* send the return code */
  34. if (stat != DB_OK) {
  35. db_free_handle(&handle);
  36. DB_SEND_FAILURE();
  37. return DB_OK;
  38. }
  39. DB_SEND_SUCCESS();
  40. /* send results */
  41. DB_SEND_INT(found);
  42. if (found) {
  43. DB_SEND_HANDLE(&handle);
  44. }
  45. db_free_handle(&handle);
  46. return DB_OK;
  47. }