From jon.clayden at gmail.com  Fri Feb 19 15:21:21 2016
From: jon.clayden at gmail.com (Jon Clayden)
Date: Fri, 19 Feb 2016 14:21:21 +0000
Subject: [Rd] Reading from an existing connection in compiled code
Message-ID: <CAM9CR=3mEWU-d4eOieo7OXoadHpCPgLWnFsAiFd_kM81C0CgQA@mail.gmail.com>

Dear all,

I'd like to be able to read from an arbitrary R connection (in the
sense of ?connections), which would be passed to an R function by the
user and then down into some C code via .Call.

The R API, in file R_ext/Connections.h, specifies a function,
R_ReadConnection, which takes a pointer to an Rconn struct as its
first argument, and does what I want. The struct itself is also
defined in that header, but I see no way of retrieving a struct of
that type, aside from getConnection (the C function), which is not
part of the API. As far as I can tell, the external pointer associated
with the connection also does not point to the struct directly.

So, could anyone please tell me whether there is a supported way to
convert a suitable SEXP to a pointer to the associated Rconn struct?

Thanks in advance.

Jon

(This question was also posted yesterday to StackOverflow
<http://stackoverflow.com/questions/35483523/r-reading-from-an-existing-connection-in-compiled-code>,
but no definitive answer has been posted.)



[Rd] Reading from an existing connection in compiled code
Jon Clayden