Added modb_use to R and the c handler + moved the connection referencing to a helpers file

This commit is contained in:
2020-10-05 17:30:27 +01:00
parent cbbda5378f
commit ca594a2c0b
5 changed files with 83 additions and 36 deletions

21
src/R_helpers_p.c Normal file
View File

@@ -0,0 +1,21 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "R_helpers_p.h"
#include "strext.h"
struct stored_conn_t *getConnectionByRef(SEXP r_conn_ref)
{
struct stored_conn_t *sconn = 0;
if (Rf_isString(r_conn_ref)) {
sconn = connectionByName(Rf_translateCharUTF8(STRING_ELT(r_conn_ref, 0)));
} else if (Rf_isInteger(r_conn_ref)) {
sconn = connectionById(Rf_asInteger(r_conn_ref));
} else {
Rf_error("Neither name or id provided");
}
return sconn;
}