GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
c_priv.c
Go to the documentation of this file.
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 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 
18 /*!
19  \brief Grant privileges on table
20 
21  \param driver db driver
22  \param tableName table name
23  \param priv privileges DB_PRIV_SELECT
24  \param to grant to DB_GROUP | DB_PUBLIC
25 
26  \return DB_OK on success
27  \return DB_FAILED on failure
28  */
29 int db_grant_on_table(dbDriver *driver, const char *tableName, int priv, int to)
30 {
31  int ret_code;
32  dbString name;
33 
35  db_set_string(&name, tableName);
36 
37  /* start the procedure call */
38  db__set_protocol_fds(driver->send, driver->recv);
40 
41  /* send the argument(s) to the procedure */
43  DB_SEND_INT(priv);
44  DB_SEND_INT(to);
45 
47 
48  /* get the return code for the procedure call */
49  DB_RECV_RETURN_CODE(&ret_code);
50 
51  if (ret_code != DB_OK)
52  return ret_code; /* ret_code SHOULD == DB_FAILED */
53 
54  /* no results */
55  return DB_OK;
56 }
int db_grant_on_table(dbDriver *driver, const char *tableName, int priv, int to)
Grant privileges on table.
Definition: c_priv.c:29
#define DB_PROC_GRANT_ON_TABLE
Definition: dbmi.h:59
#define DB_OK
Definition: dbmi.h:71
void db_free_string(dbString *)
Free allocated space for dbString.
Definition: string.c:150
int db_set_string(dbString *, const char *)
Inserts string to dbString (enlarge string)
Definition: string.c:41
void db__set_protocol_fds(FILE *, FILE *)
?
void db_init_string(dbString *)
Initialize dbString.
Definition: string.c:25
#define DB_SEND_STRING(x)
Definition: macros.h:24
#define DB_SEND_INT(x)
Definition: macros.h:82
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:7
const char * name
Definition: named_colr.c:6
Definition: driver.h:21