~ubuntu-branches/debian/wheezy/upstart/wheezy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* upstart
 *
 * Copyright © 2006 Canonical Ltd.
 * Author: Scott James Remnant <scott@ubuntu.com>.
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef INIT_EVENT_H
#define INIT_EVENT_H

#include <nih/macros.h>
#include <nih/list.h>
#include <nih/main.h>


/**
 * Event:
 * @entry: list header,
 * @name: string name of the event; namespace shared with jobs,
 * @value: current or expected value for level events.
 *
 * We talk about two types of events, level events which have a @value
 * associated and edge events which do not (@value is %NULL).  The change
 * of any level event's @value is also considered an edge event.
 *
 * This structure is used within the event code to hold a record of previously
 * seen events and the current value of level events; it is also
 * used within the job code to hold the list of events a job is waiting for.
 **/
typedef struct event {
	NihList  entry;

	char    *name;
	char    *value;
} Event;


NIH_BEGIN_EXTERN

Event *event_new          (void *parent, const char *name)
	__attribute__ ((warn_unused_result, malloc));
Event *event_record       (void *parent, const char *name);

Event *event_find_by_name (const char *name);
int    event_match        (Event *event1, Event *event2);

int    event_change_value (Event *event, const char *value);

Event *event_queue_edge   (const char *name);
Event *event_queue_level  (const char *name, const char *value);
void   event_queue_run    (void *data, NihMainLoopFunc *func);

NIH_END_EXTERN

#endif /* INIT_EVENT_H */