chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / h / alarm
1 /*
2  * alarm.h
3  *
4  * Calling routines at set times
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Steel is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #ifndef __alarm_h
29 #define __alarm_h
30
31 #ifndef BOOL
32   #define BOOL int
33   #define TRUE 1
34   #define FALSE 0
35 #endif
36
37 typedef void (*alarm_handler)(int at,void *handle);
38
39 /*
40  * void alarm_init(void)
41  *
42  * Use
43  *  None at all
44  */
45
46 void alarm_init(void);
47
48 /*
49  * int alarm_timenow(void)
50  *
51  * Use
52  *  Reports the time right now
53  */
54
55 int alarm_timenow(void);
56
57 /*
58  * int alarm_timedifference(int t1,int t2)
59  *
60  * Use
61  *  Tells you the difference between two times.  t2 is considered to be later
62  *  than t1.
63  */
64
65 int alarm_timedifference(int t1,int t2);
66
67 /*
68  * void alarm_set(int at,alarm_handler proc,void *handle)
69  *
70  * Use
71  *  Sets up `proc' to be called at time `at', being passed `handle'.
72  */
73
74 void alarm_set(int at,alarm_handler proc,void *handle);
75
76 /*
77  * void alarm_remove(int at,void *handle)
78  *
79  * Use
80  *  Removes an alarm identified by a time and a handle
81  */
82
83 void alarm_remove(int at,void *handle);
84
85 /*
86  * void alarm_removeall(void *handle)
87  *
88  * Use
89  *  Removes all alarms for the given handle
90  */
91
92 void alarm_removeall(void *handle);
93
94 /*
95  * BOOL alarm_anypending(void *handle)
96  *
97  * Use
98  *  Returns TRUE if there are alarms for the given handle
99  */
100
101 BOOL alarm_anypending(void *handle);
102
103 /*
104  * BOOL alarm_next(int *when)
105  *
106  * Use
107  *  Informs the caller (a) if there are any alarms waiting, and (b) when
108  *  the next one is.
109  *
110  * Parameters
111  *  int *when == where to put the next time for an alarm (unchanged if no
112  *    alarm is set)
113  *
114  * Returns
115  *  TRUE if there are any alarms left
116  */
117
118 BOOL alarm_next(int *when);
119
120 /*
121  * void alarm_callnext(void)
122  *
123  * Use
124  *  Calls the next alarm and removes it from the list
125  */
126
127 void alarm_callnext(void);
128
129 #endif