2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gbx_watch.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GBX_WATCH_H
|
|
|
|
#define __GBX_WATCH_H
|
|
|
|
|
|
|
|
#include "gambas.h"
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
2007-12-31 23:38:56 +01:00
|
|
|
#ifdef OS_OPENBSD
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
enum {
|
|
|
|
WATCH_NONE = 0,
|
|
|
|
WATCH_READ = 1,
|
|
|
|
WATCH_WRITE = 2,
|
|
|
|
};
|
|
|
|
|
2012-08-31 00:13:25 +02:00
|
|
|
enum {
|
|
|
|
WP_NOTHING = 0,
|
|
|
|
WP_END = 1,
|
2012-08-31 00:49:21 +02:00
|
|
|
WP_OUTPUT = 2,
|
|
|
|
WP_TIMEOUT = 4
|
2012-08-31 00:13:25 +02:00
|
|
|
};
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
typedef
|
|
|
|
struct {
|
2008-01-17 22:39:26 +01:00
|
|
|
int fd;
|
2009-06-07 01:31:48 +02:00
|
|
|
void (*callback_read)();
|
|
|
|
void (*callback_write)();
|
|
|
|
intptr_t param_read;
|
|
|
|
intptr_t param_write;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
WATCH_CALLBACK;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_TIMER *timer;
|
|
|
|
struct timeval timeout;
|
|
|
|
}
|
|
|
|
WATCH_TIMER;
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void WATCH_init(void);
|
|
|
|
void WATCH_exit(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void WATCH_watch(int fd, int flag, void *callback, intptr_t param);
|
|
|
|
bool WATCH_one_loop(int);
|
|
|
|
void WATCH_loop(void);
|
|
|
|
void WATCH_wait(int);
|
|
|
|
int WATCH_loop_signal(const sigset_t *sig);
|
2012-08-31 00:49:21 +02:00
|
|
|
int WATCH_process(int fd_end, int fd_output, int timeout);
|
2008-01-17 22:39:26 +01:00
|
|
|
void WATCH_timer(void *t, int on);
|
2010-08-27 23:09:34 +02:00
|
|
|
double WATCH_get_timeout(GB_TIMER *timer);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif /* */
|