aboutsummaryrefslogtreecommitdiffstats
path: root/event.h
blob: 6486a54ca82563969bf28b91a523671aaf76be2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #0088
/* $Id: event.h 840 2007-09-09 12:17:42Z michael $
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/event.h $
 *
 * generic timer handling
 *
 * Copyright (C) 2009 Ed Martin <edman007@edman007.com>
 * Copyright (C) 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LCD4Linux 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
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#ifndef _EVENT_H_
#define _EVENT_H_

#include <time.h>

//events are identified by their file descriptor only

/*
 * these functions allow plugins to add event hooks
 * (and thus break out of the main loop when sleeping)
 * these callbacks than then trigger named events to propagate
 * the event to the screen
 */

typedef enum {
    EVENT_READ = 1,
    EVENT_WRITE = 2,
    EVENT_HUP = 4,
    EVENT_ERR = 8
} event_flags_t;


int event_add(void (*callback) (event_flags_t flags, void *data), void *data, const int fd, const int read,
	      const int write, const int active);
int event_del(const int fd);
int event_modify(const int fd, const int read, const int write, const int active);
int event_process(const struct timespec *timeout);
void event_exit(void);

/*
 * These fuctions keep a list of the events to trigger on allowing multiple
 * things to trigger an event and multiple things to receive the event
 */

//add an event to be triggered
int named_event_add(char *event, void (*callback) (void *data), void *data);
//remove an event from the list of events
int named_event_del(char *event, void (*callback) (void *data), void *data);
int named_event_trigger(char *event);	//call all calbacks for this event

#endif