| 12778 |
pd |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
| 89942 |
luke |
3 |
* Copyright (C) 2000-2026 The R Core Team.
|
| 12778 |
pd |
4 |
*
|
| 71657 |
plummer |
5 |
* This header file is free software; you can redistribute it and/or modify
|
| 12778 |
pd |
6 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
7 |
* the Free Software Foundation; either version 2.1 of the License, or
|
|
|
8 |
* (at your option) any later version.
|
|
|
9 |
*
|
| 71657 |
plummer |
10 |
* This file is part of R. R is distributed under the terms of the
|
|
|
11 |
* GNU General Public License, either Version 2, June 1991 or Version 3,
|
|
|
12 |
* June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
|
|
|
13 |
*
|
| 12778 |
pd |
14 |
* This program is distributed in the hope that it will be useful,
|
|
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
17 |
* GNU Lesser General Public License for more details.
|
|
|
18 |
*
|
|
|
19 |
* You should have received a copy of the GNU Lesser General Public License
|
| 42308 |
ripley |
20 |
* along with this program; if not, a copy is available at
|
| 68949 |
ripley |
21 |
* https://www.R-project.org/Licenses/
|
| 12778 |
pd |
22 |
*/
|
|
|
23 |
|
| 60255 |
ripley |
24 |
/*
|
|
|
25 |
For use by alternative front-ends and packages which need to share
|
| 71071 |
ripley |
26 |
the R event loop (on Unix-alikes).
|
| 60255 |
ripley |
27 |
|
| 89942 |
luke |
28 |
Part of the embedding API and subject to change without notice.
|
| 71071 |
ripley |
29 |
|
|
|
30 |
NB: HAVE_SYS_SELECT_H should be checked and defined before this is
|
| 71371 |
ripley |
31 |
included.
|
| 60255 |
ripley |
32 |
*/
|
|
|
33 |
|
| 11211 |
ripley |
34 |
#ifndef R_EXT_EVENTLOOP_H
|
|
|
35 |
#define R_EXT_EVENTLOOP_H
|
| 8902 |
duncan |
36 |
|
| 71371 |
ripley |
37 |
#ifdef HAVE_SYS_SELECT_H
|
|
|
38 |
# include <sys/select.h> /* for fd_set, select according to POSIX 2004 */
|
|
|
39 |
#endif
|
|
|
40 |
#ifdef HAVE_SYS_TIME_H
|
|
|
41 |
# include <sys/time.h> /* ... according to earlier POSIX and perhaps HP-UX */
|
|
|
42 |
#endif
|
| 71071 |
ripley |
43 |
/* NOTE: At one time needed on FreeBSD so that fd_set is defined. */
|
| 71371 |
ripley |
44 |
#include <sys/types.h>
|
| 19423 |
hornik |
45 |
|
| 11211 |
ripley |
46 |
#ifdef __cplusplus
|
|
|
47 |
extern "C" {
|
|
|
48 |
#endif
|
| 8902 |
duncan |
49 |
|
|
|
50 |
#define XActivity 1
|
|
|
51 |
#define StdinActivity 2
|
|
|
52 |
|
|
|
53 |
typedef void (*InputHandlerProc)(void *userData);
|
|
|
54 |
|
|
|
55 |
typedef struct _InputHandler {
|
|
|
56 |
|
|
|
57 |
int activity;
|
|
|
58 |
int fileDescriptor;
|
|
|
59 |
InputHandlerProc handler;
|
|
|
60 |
|
|
|
61 |
struct _InputHandler *next;
|
|
|
62 |
|
|
|
63 |
/* Whether we should be listening to this file descriptor or not. */
|
|
|
64 |
int active;
|
|
|
65 |
|
|
|
66 |
/* Data that can be passed to the routine as its only argument.
|
|
|
67 |
This might be a user-level function or closure when we implement
|
|
|
68 |
a callback to R mechanism.
|
|
|
69 |
*/
|
|
|
70 |
void *userData;
|
|
|
71 |
|
|
|
72 |
} InputHandler;
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
extern InputHandler *addInputHandler(InputHandler *handlers, int fd, InputHandlerProc handler, int activity);
|
|
|
76 |
extern InputHandler *getInputHandler(InputHandler *handlers, int fd);
|
|
|
77 |
extern int removeInputHandler(InputHandler **handlers, InputHandler *it);
|
| 89135 |
luke |
78 |
|
|
|
79 |
#ifdef USE_BASE_R_SUPPORT
|
| 8902 |
duncan |
80 |
extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
|
| 89158 |
luke |
81 |
#endif
|
| 21006 |
pd |
82 |
extern fd_set *R_checkActivity(int usec, int ignore_stdin);
|
|
|
83 |
extern void R_runHandlers(InputHandler *handlers, fd_set *mask);
|
| 8902 |
duncan |
84 |
|
| 89158 |
luke |
85 |
#ifdef USE_BASE_R_SUPPORT
|
| 25220 |
luke |
86 |
extern int R_SelectEx(int n, fd_set *readfds, fd_set *writefds,
|
|
|
87 |
fd_set *exceptfds, struct timeval *timeout,
|
|
|
88 |
void (*intr)(void));
|
| 89135 |
luke |
89 |
#endif
|
| 25220 |
luke |
90 |
|
| 8973 |
ripley |
91 |
#ifdef __SYSTEM__
|
| 39864 |
duncan |
92 |
#ifndef __cplusplus /* Would get duplicate conflicting symbols*/
|
| 8973 |
ripley |
93 |
InputHandler *R_InputHandlers;
|
| 39864 |
duncan |
94 |
#endif
|
| 8973 |
ripley |
95 |
#else
|
|
|
96 |
extern InputHandler *R_InputHandlers;
|
|
|
97 |
#endif
|
| 8902 |
duncan |
98 |
|
| 9242 |
pd |
99 |
extern void (* R_PolledEvents)(void);
|
|
|
100 |
extern int R_wait_usec;
|
|
|
101 |
|
| 11211 |
ripley |
102 |
#ifdef __cplusplus
|
|
|
103 |
}
|
| 8902 |
duncan |
104 |
#endif
|
| 11211 |
ripley |
105 |
|
|
|
106 |
#endif /* R_EXT_EVENTLOOP_H */
|