c_priv.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*!
  2. * \file db/dbmi_client/c_priv.c
  3. *
  4. * \brief DBMI Library (client) - privileges management
  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. #include "macros.h"
  16. /*!
  17. \brief Grant privileges on table
  18. \param driver db driver
  19. \param tableName table name
  20. \param priv privileges DB_PRIV_SELECT
  21. \param to grant to DB_GROUP | DB_PUBLIC
  22. \return DB_OK on success
  23. \return DB_FAILED on failure
  24. */
  25. int db_grant_on_table(dbDriver * driver, const char *tableName, int priv, int to)
  26. {
  27. int ret_code;
  28. dbString name;
  29. db_init_string(&name);
  30. db_set_string(&name, tableName);
  31. /* start the procedure call */
  32. db__set_protocol_fds(driver->send, driver->recv);
  33. DB_START_PROCEDURE_CALL(DB_PROC_GRANT_ON_TABLE);
  34. /* send the argument(s) to the procedure */
  35. DB_SEND_STRING(&name);
  36. DB_SEND_INT(priv);
  37. DB_SEND_INT(to);
  38. db_free_string(&name);
  39. /* get the return code for the procedure call */
  40. DB_RECV_RETURN_CODE(&ret_code);
  41. if (ret_code != DB_OK)
  42. return ret_code; /* ret_code SHOULD == DB_FAILED */
  43. /* no results */
  44. return DB_OK;
  45. }