Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / include / R_ext / eventloop.h @ 2486

History | View | Annotate | Download (2.9 kB)

1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 2000-2007 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 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, a copy is available at
17
 *  http://www.r-project.org/Licenses/
18
 */
19

    
20
/* 
21
   For use by alternative front-ends and packages which need to share
22
   the R event loop (on all platforms).
23

24
   Not part of the API and subject to change without notice.
25
 */
26

    
27
#ifndef R_EXT_EVENTLOOP_H
28
#define R_EXT_EVENTLOOP_H
29

    
30
#ifndef NO_C_HEADERS
31
#ifdef HAVE_SYS_SELECT_H
32
# include <sys/select.h>        /* for fd_set according to recent POSIX */
33
#endif
34
/* NOTE: Needed at least on FreeBSD so that fd_set is defined. */
35
# include <sys/types.h>
36
#endif
37

    
38
#ifdef  __cplusplus
39
extern "C" {
40
#endif
41

    
42
#define XActivity 1
43
#define StdinActivity 2
44

    
45
typedef void (*InputHandlerProc)(void *userData); 
46

    
47
typedef struct _InputHandler {
48

    
49
  int activity;
50
  int fileDescriptor;
51
  InputHandlerProc handler;
52

    
53
  struct _InputHandler *next;
54

    
55
    /* Whether we should be listening to this file descriptor or not. */
56
  int active;
57

    
58
    /* Data that can be passed to the routine as its only argument.
59
       This might be a user-level function or closure when we implement
60
       a callback to R mechanism. 
61
     */
62
  void *userData;
63

    
64
} InputHandler;
65

    
66

    
67
extern InputHandler *initStdinHandler(void);
68
extern void consoleInputHandler(unsigned char *buf, int len);
69

    
70
extern InputHandler *addInputHandler(InputHandler *handlers, int fd, InputHandlerProc handler, int activity);
71
extern InputHandler *getInputHandler(InputHandler *handlers, int fd);
72
extern int           removeInputHandler(InputHandler **handlers, InputHandler *it);
73
extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
74
extern fd_set *R_checkActivity(int usec, int ignore_stdin);
75
extern fd_set *R_checkActivityEx(int usec, int ignore_stdin, void (*intr)(void));
76
extern void R_runHandlers(InputHandler *handlers, fd_set *mask);
77

    
78
extern int R_SelectEx(int  n,  fd_set  *readfds,  fd_set  *writefds,
79
                      fd_set *exceptfds, struct timeval *timeout,
80
                      void (*intr)(void));
81

    
82
#ifdef __SYSTEM__
83
#ifndef __cplusplus   /* Would get duplicate conflicting symbols*/
84
InputHandler *R_InputHandlers;
85
#endif
86
#else
87
extern InputHandler *R_InputHandlers;
88
#endif
89

    
90
extern void (* R_PolledEvents)(void);
91
extern int R_wait_usec;
92

    
93
#ifdef  __cplusplus
94
}
95
#endif
96

    
97
#endif /* R_EXT_EVENTLOOP_H */