d_close_cur.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. * \file db/dbmi_driver/d_close_cur.c
  3. *
  4. * \brief DBMI Library (driver) - close cursor
  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 Close cursor
  20. \return DB_OK on success
  21. \return DB_FAILED on failure
  22. */
  23. int db_d_close_cursor(void)
  24. {
  25. dbCursor *cursor;
  26. dbToken token;
  27. int stat;
  28. /* get the arg(s) */
  29. DB_RECV_TOKEN(&token);
  30. cursor = (dbCursor *) db_find_token(token);
  31. if (cursor == NULL) {
  32. db_error("** invalid cursor **");
  33. return DB_FAILED;
  34. }
  35. /* call the procedure */
  36. stat = db_driver_close_cursor(cursor);
  37. /* get rid of the cursor */
  38. db_drop_token(token);
  39. db_free_cursor(cursor);
  40. db__drop_cursor_from_driver_state(cursor);
  41. db_free(cursor); /* ?? */
  42. /* send the return code */
  43. if (stat != DB_OK) {
  44. DB_SEND_FAILURE();
  45. return DB_OK;
  46. }
  47. DB_SEND_SUCCESS();
  48. /* no results */
  49. return DB_OK;
  50. }