~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to event.h

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:28:49 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: siretart@tauware.de-20110427172849-mj5cj5a0igpcc9fn
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: event.h 840 2007-09-09 12:17:42Z michael $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/event.h $
 
3
 *
 
4
 * generic timer handling
 
5
 *
 
6
 * Copyright (C) 2009 Ed Martin <edman007@edman007.com>
 
7
 * Copyright (C) 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 
8
 *
 
9
 * This file is part of LCD4Linux.
 
10
 *
 
11
 * LCD4Linux is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2, or (at your option)
 
14
 * any later version.
 
15
 *
 
16
 * LCD4Linux is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; if not, write to the Free Software
 
23
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
24
 *
 
25
 */
 
26
 
 
27
 
 
28
#ifndef _EVENT_H_
 
29
#define _EVENT_H_
 
30
 
 
31
#include <time.h>
 
32
 
 
33
//events are identified by their file descriptor only
 
34
 
 
35
/*
 
36
 * these functions allow plugins to add event hooks
 
37
 * (and thus break out of the main loop when sleeping)
 
38
 * these callbacks than then trigger named events to propagate
 
39
 * the event to the screen
 
40
 */
 
41
 
 
42
typedef enum {
 
43
    EVENT_READ = 1,
 
44
    EVENT_WRITE = 2,
 
45
    EVENT_HUP = 4,
 
46
    EVENT_ERR = 8
 
47
} event_flags_t;
 
48
 
 
49
 
 
50
int event_add(void (*callback) (event_flags_t flags, void *data), void *data, const int fd, const int read,
 
51
              const int write, const int active);
 
52
int event_del(const int fd);
 
53
int event_modify(const int fd, const int read, const int write, const int active);
 
54
int event_process(const struct timespec *timeout);
 
55
void event_exit(void);
 
56
 
 
57
/*
 
58
 * These fuctions keep a list of the events to trigger on allowing multiple
 
59
 * things to trigger an event and multiple things to receive the event
 
60
 */
 
61
 
 
62
//add an event to be triggered
 
63
int named_event_add(char *event, void (*callback) (void *data), void *data);
 
64
//remove an event from the list of events
 
65
int named_event_del(char *event, void (*callback) (void *data), void *data);
 
66
int named_event_trigger(char *event);   //call all calbacks for this event
 
67
 
 
68
#endif