1 /*
2  *  R : A Computer Language for Statistical Data Analysis
3  *  Copyright (C) 2092--2012     The R Core Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, a copy is available at
17  *  https://www.R-project.org/Licenses/
18  *
19  */
20 
21 #include <Rinternals.h>
22 #include "tools.h"
23 
24 
25 extern int extR_HTTPDCreate(const char *ip, int port);
26 extern void extR_HTTPDStop(void);
27 
startHTTPD(SEXP sIP,SEXP sPort)28 SEXP startHTTPD(SEXP sIP, SEXP sPort)
29 {
30     const char *ip = 0;
31     if (sIP != R_NilValue && (TYPEOF(sIP) != STRSXP || LENGTH(sIP) != 1))
32 	error(_("invalid bind address specification"));
33     if (sIP != R_NilValue) ip = CHAR(STRING_ELT(sIP, 0));
34     return ScalarInteger(extR_HTTPDCreate(ip, asInteger(sPort)));
35 }
36 
stopHTTPD(void)37 SEXP stopHTTPD(void)
38 {
39     extR_HTTPDStop();
40     return R_NilValue;
41 }
42