GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
34  db_init_string(&name);
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 */
42  DB_SEND_STRING(&name);
43  DB_SEND_INT(priv);
44  DB_SEND_INT(to);
45 
46  db_free_string(&name);
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 }
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_PROC_GRANT_ON_TABLE
Definition: dbmi.h:59
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_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
#define DB_SEND_STRING(x)
Definition: macros.h:12
Definition: driver.h:22
int db_set_string(dbString *x, const char *s)
Inserts string to dbString (enlarge string)
Definition: string.c:41
void db__set_protocol_fds(FILE *send, FILE *recv)
?
FILE * recv
Definition: dbmi.h:171
const char * name
Definition: named_colr.c:7
void db_free_string(dbString *x)
Free allocated space for dbString.
Definition: string.c:150
FILE * send
Definition: dbmi.h:171
void db_init_string(dbString *x)
Initialize dbString.
Definition: string.c:25
#define DB_OK
Definition: dbmi.h:71