The R Project SVN R

Rev

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

Rev Author Line No. Line
12778 pd 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
59039 ripley 3
 *  Copyright (C) 2000-2007 The R Core Team.
12778 pd 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
42308 ripley 16
 *  along with this program; if not, a copy is available at
17
 *  http://www.r-project.org/Licenses/
12778 pd 18
 */
19
 
60255 ripley 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
 
11211 ripley 27
#ifndef R_EXT_EVENTLOOP_H
28
#define R_EXT_EVENTLOOP_H
8902 duncan 29
 
42409 ripley 30
#ifndef NO_C_HEADERS
42535 ripley 31
#ifdef HAVE_SYS_SELECT_H
32
# include <sys/select.h>	/* for fd_set according to recent POSIX */
33
#endif
42409 ripley 34
/* NOTE: Needed at least on FreeBSD so that fd_set is defined. */
35
# include <sys/types.h>
36
#endif
19423 hornik 37
 
11211 ripley 38
#ifdef  __cplusplus
39
extern "C" {
40
#endif
8902 duncan 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);
21006 pd 74
extern fd_set *R_checkActivity(int usec, int ignore_stdin);
25220 luke 75
extern fd_set *R_checkActivityEx(int usec, int ignore_stdin, void (*intr)(void));
21006 pd 76
extern void R_runHandlers(InputHandler *handlers, fd_set *mask);
8902 duncan 77
 
25220 luke 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
 
8973 ripley 82
#ifdef __SYSTEM__
39864 duncan 83
#ifndef __cplusplus   /* Would get duplicate conflicting symbols*/
8973 ripley 84
InputHandler *R_InputHandlers;
39864 duncan 85
#endif
8973 ripley 86
#else
87
extern InputHandler *R_InputHandlers;
88
#endif
8902 duncan 89
 
9242 pd 90
extern void (* R_PolledEvents)(void);
91
extern int R_wait_usec;
92
 
11211 ripley 93
#ifdef  __cplusplus
94
}
8902 duncan 95
#endif
11211 ripley 96
 
97
#endif /* R_EXT_EVENTLOOP_H */