The R Project SVN R

Rev

Rev 72855 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4394 ripley 1
/*
2
 *  A simple 'reading' pipe (and a command executor)
3
 *  Copyright (C) 1999  Guido Masarotto
75992 kalibera 4
 *            (C) 2004-2019  The R Core Team
4394 ripley 5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
42300 ripley 17
 *  along with this program; if not, a copy is available at
68956 ripley 18
 *  https://www.R-project.org/Licenses/
4394 ripley 19
 */
20
 
21
 
36901 ripley 22
#define WIN32_LEAN_AND_MEAN 1
4394 ripley 23
#include <windows.h>
24
 
75992 kalibera 25
typedef struct {
26
    PROCESS_INFORMATION pi;
27
    HANDLE job;
28
    HANDLE port;
29
} pinfo;
30
 
4394 ripley 31
struct structRPIPE {
75992 kalibera 32
    pinfo pi;
51030 murdoch 33
    HANDLE thread;
12256 pd 34
    HANDLE read, write;
72855 kalibera 35
    int exitcode, active, timedout;
36
    DWORD timeoutMillis;
4394 ripley 37
};
38
 
39
typedef struct structRPIPE rpipe;
40
 
41
/*
42
 * runcmd and rpipeClose return the exit code of the process
52802 ripley 43
 * if runcmd return NOLAUNCH, problems in process start
4394 ripley 44
*/
32210 ripley 45
#define runcmd Rf_runcmd
72855 kalibera 46
int runcmd(const char *cmd, cetype_t enc, int wait, int visible, 
47
           const char *fin, const char *fout, const char *ferr);
4394 ripley 48
 
72855 kalibera 49
int runcmd_timeout(const char *cmd, cetype_t enc, int wait, int visible, 
50
                   const char *fin, const char *fout, const char *ferr,
51
                   int timeout, int *timedout);
52
 
52814 ripley 53
rpipe *rpipeOpen(const char *cmd, cetype_t enc, int visible, 
53572 ripley 54
		 const char *finput, int io,
72855 kalibera 55
		 const char *fout, const char *ferr,
56
		 int timeout);
12256 pd 57
char  *rpipeGets(rpipe *r, char *buf, int len);
58
int rpipeGetc(rpipe *r);
72855 kalibera 59
int rpipeClose(rpipe *r, int *timedout);
4394 ripley 60
 
44201 ripley 61
char *runerror(void);
4394 ripley 62
 
52802 ripley 63
/* Changed in R 2.12.0 to be the conventional Unix value -- previously -1 */
64
#define NOLAUNCH 127