R->c c->R code
This commit is contained in:
54
src/R_modb_user_groups.c
Normal file
54
src/R_modb_user_groups.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "modb_database.h"
|
||||
#include "modb_ref.h"
|
||||
#include "R_modb_users.h"
|
||||
#include "R_helpers_p.h"
|
||||
#include "R_modb_user_groups.h"
|
||||
|
||||
SEXP rmodb_userAddGroup(SEXP r_conn_ref, SEXP r_user_id, SEXP r_group_id)
|
||||
{
|
||||
stored_conn *sconn;
|
||||
modb_ref modb;
|
||||
unsigned int user_id, group_id;
|
||||
|
||||
if ((sconn = getConnectionByRef(r_conn_ref)) == 0) {
|
||||
Rf_error("invalid connection reference\n");
|
||||
}
|
||||
|
||||
if (!modbFindUse(sconn, &modb)) {
|
||||
Rf_error("invalid modb reference\n");
|
||||
}
|
||||
|
||||
user_id = (unsigned int)Rf_asInteger(r_user_id);
|
||||
group_id = (unsigned int)Rf_asInteger(r_group_id);
|
||||
if (modbLink_User_Group(sconn, &modb, user_id, group_id) <= 0) {
|
||||
return Rf_ScalarLogical(FALSE);
|
||||
}
|
||||
|
||||
return Rf_ScalarLogical(TRUE);
|
||||
}
|
||||
|
||||
SEXP rmodb_userRemoveGroup(SEXP r_conn_ref, SEXP r_user_id, SEXP r_group_id)
|
||||
{
|
||||
stored_conn *sconn;
|
||||
modb_ref modb;
|
||||
unsigned int user_id, group_id;
|
||||
|
||||
if ((sconn = getConnectionByRef(r_conn_ref)) == 0) {
|
||||
Rf_error("invalid connection reference\n");
|
||||
}
|
||||
|
||||
if (!modbFindUse(sconn, &modb)) {
|
||||
Rf_error("invalid modb reference\n");
|
||||
}
|
||||
|
||||
user_id = (unsigned int)Rf_asInteger(r_user_id);
|
||||
group_id = (unsigned int)Rf_asInteger(r_group_id);
|
||||
if (modbUnlink_User_Group(sconn, &modb, user_id, group_id) <= 0) {
|
||||
return Rf_ScalarLogical(FALSE);
|
||||
}
|
||||
|
||||
return Rf_ScalarLogical(TRUE);
|
||||
}
|
||||
Reference in New Issue
Block a user