| 12778 |
pd |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
|
|
3 |
* Copyright (C) 2000, 2001 The R Development Core Team.
|
|
|
4 |
*
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
|
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 |
*
|
|
|
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 Lesser General Public License for more details.
|
|
|
14 |
*
|
|
|
15 |
* You should have received a copy of the GNU Lesser General Public License
|
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
18 |
*/
|
|
|
19 |
|
| 11211 |
ripley |
20 |
#ifndef R_EXT_EVENTLOOP_H
|
|
|
21 |
#define R_EXT_EVENTLOOP_H
|
| 8902 |
duncan |
22 |
|
| 19423 |
hornik |
23 |
/* NOTE:
|
|
|
24 |
Needed at least on FreeBSD so that fd_set is defined.
|
|
|
25 |
*/
|
|
|
26 |
#include <sys/types.h>
|
|
|
27 |
|
| 11211 |
ripley |
28 |
#ifdef __cplusplus
|
|
|
29 |
extern "C" {
|
|
|
30 |
#endif
|
| 8902 |
duncan |
31 |
|
|
|
32 |
#define XActivity 1
|
|
|
33 |
#define StdinActivity 2
|
|
|
34 |
|
|
|
35 |
typedef void (*InputHandlerProc)(void *userData);
|
|
|
36 |
|
|
|
37 |
typedef struct _InputHandler {
|
|
|
38 |
|
|
|
39 |
int activity;
|
|
|
40 |
int fileDescriptor;
|
|
|
41 |
InputHandlerProc handler;
|
|
|
42 |
|
|
|
43 |
struct _InputHandler *next;
|
|
|
44 |
|
|
|
45 |
/* Whether we should be listening to this file descriptor or not. */
|
|
|
46 |
int active;
|
|
|
47 |
|
|
|
48 |
/* Data that can be passed to the routine as its only argument.
|
|
|
49 |
This might be a user-level function or closure when we implement
|
|
|
50 |
a callback to R mechanism.
|
|
|
51 |
*/
|
|
|
52 |
void *userData;
|
|
|
53 |
|
|
|
54 |
} InputHandler;
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
extern InputHandler *initStdinHandler(void);
|
|
|
58 |
extern void consoleInputHandler(unsigned char *buf, int len);
|
|
|
59 |
|
|
|
60 |
extern InputHandler *addInputHandler(InputHandler *handlers, int fd, InputHandlerProc handler, int activity);
|
|
|
61 |
extern InputHandler *getInputHandler(InputHandler *handlers, int fd);
|
|
|
62 |
extern int removeInputHandler(InputHandler **handlers, InputHandler *it);
|
|
|
63 |
extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
|
| 21006 |
pd |
64 |
extern fd_set *R_checkActivity(int usec, int ignore_stdin);
|
| 25220 |
luke |
65 |
extern fd_set *R_checkActivityEx(int usec, int ignore_stdin, void (*intr)(void));
|
| 21006 |
pd |
66 |
extern void R_runHandlers(InputHandler *handlers, fd_set *mask);
|
| 8902 |
duncan |
67 |
|
| 25220 |
luke |
68 |
extern int R_SelectEx(int n, fd_set *readfds, fd_set *writefds,
|
|
|
69 |
fd_set *exceptfds, struct timeval *timeout,
|
|
|
70 |
void (*intr)(void));
|
|
|
71 |
|
| 8973 |
ripley |
72 |
#ifdef __SYSTEM__
|
|
|
73 |
InputHandler *R_InputHandlers;
|
|
|
74 |
#else
|
|
|
75 |
extern InputHandler *R_InputHandlers;
|
|
|
76 |
#endif
|
| 8902 |
duncan |
77 |
|
| 9242 |
pd |
78 |
extern void (* R_PolledEvents)(void);
|
|
|
79 |
extern int R_wait_usec;
|
|
|
80 |
|
| 11211 |
ripley |
81 |
#ifdef __cplusplus
|
|
|
82 |
}
|
| 8902 |
duncan |
83 |
#endif
|
| 11211 |
ripley |
84 |
|
|
|
85 |
#endif /* R_EXT_EVENTLOOP_H */
|