CXXR (C++ R)
Rinternet.h
1 /*CXXR $Id: Rinternet.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 #ifndef R_INTERNET_MODULE_H
18 #define R_INTERNET_MODULE_H
19 
20 
21 #include <Rinternals.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef SEXP (*R_DownloadRoutine)(SEXP call, SEXP op, SEXP args, SEXP env);
28 typedef Rconnection (*R_NewUrlRoutine)(const char *description, const char * const mode);
29 typedef Rconnection (*R_NewSockRoutine)(const char *host, int port, int server, const char *const mode, int timeout);
30 
31 typedef void * (*R_HTTPOpenRoutine)(const char *url, const char *headers, const int cacheOK);
32 typedef int (*R_HTTPReadRoutine)(void *ctx, char *dest, int len);
33 typedef void (*R_HTTPCloseRoutine)(void *ctx);
34 
35 typedef void * (*R_FTPOpenRoutine)(const char *url);
36 typedef int (*R_FTPReadRoutine)(void *ctx, char *dest, int len);
37 typedef void (*R_FTPCloseRoutine)(void *ctx);
38 
39 typedef void (*R_SockOpenRoutine)(int *port);
40 typedef void (*R_SockListenRoutine)(int *sockp, char **buf, int *len);
41 typedef void (*R_SockConnectRoutine)(int *port, char **host);
42 typedef void (*R_SockCloseRoutine)(int *sockp);
43 
44 typedef void (*R_SockReadRoutine)(int *sockp, char **buf, int *maxlen);
45 typedef void (*R_SockWriteRoutine)(int *sockp, char **buf, int *start, int *end, int *len);
46 typedef int (*R_SockSelectRoutine)(int nsock, int *insockfd, int *ready, int *write, double timeout);
47 
48 typedef int (*R_HTTPDCreateRoutine)(const char *ip, int port);
49 typedef void (*R_HTTPDStopRoutine)();
50 
51 typedef struct {
52  R_DownloadRoutine download;
53  R_NewUrlRoutine newurl;
54  R_NewSockRoutine newsock;
55 
56  R_HTTPOpenRoutine HTTPOpen;
57  R_HTTPReadRoutine HTTPRead;
58  R_HTTPCloseRoutine HTTPClose;
59 
60  R_FTPOpenRoutine FTPOpen;
61  R_FTPReadRoutine FTPRead;
62  R_FTPCloseRoutine FTPClose;
63 
64  R_SockOpenRoutine sockopen;
65  R_SockListenRoutine socklisten;
66  R_SockConnectRoutine sockconnect;
67  R_SockCloseRoutine sockclose;
68 
69  R_SockReadRoutine sockread;
70  R_SockWriteRoutine sockwrite;
71  R_SockSelectRoutine sockselect;
72 
73  R_HTTPDCreateRoutine HTTPDCreate;
74  R_HTTPDStopRoutine HTTPDStop;
75 } R_InternetRoutines;
76 
77 R_InternetRoutines *R_setInternetRoutines(R_InternetRoutines *routines);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif /* ifndef R_INTERNET_MODULE_H */