Fix indexing inconsistency in manual.
[polipo.git] / event.h
blob3ecd0c9db520b950d18a38d04eae88e45c83611c
1 /*
2 Copyright (c) 2003-2006 by Juliusz Chroboczek
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
23 extern struct timeval current_time;
24 extern struct timeval null_time;
25 extern int diskIsClean;
27 typedef struct _TimeEventHandler {
28 struct timeval time;
29 struct _TimeEventHandler *previous, *next;
30 int (*handler)(struct _TimeEventHandler*);
31 char data[1];
32 } TimeEventHandlerRec, *TimeEventHandlerPtr;
34 typedef struct _FdEventHandler {
35 short fd;
36 short poll_events;
37 struct _FdEventHandler *previous, *next;
38 int (*handler)(int, struct _FdEventHandler*);
39 char data[1];
40 } FdEventHandlerRec, *FdEventHandlerPtr;
42 typedef struct _ConditionHandler {
43 struct _Condition *condition;
44 struct _ConditionHandler *previous, *next;
45 int (*handler)(int, struct _ConditionHandler*);
46 char data[1];
47 } ConditionHandlerRec, *ConditionHandlerPtr;
49 typedef struct _Condition {
50 ConditionHandlerPtr handlers;
51 } ConditionRec, *ConditionPtr;
53 void initEvents(void);
54 void uninitEvents(void);
55 void interestingSignals(sigset_t *ss);
57 TimeEventHandlerPtr scheduleTimeEvent(int seconds,
58 int (*handler)(TimeEventHandlerPtr),
59 int dsize, void *data);
61 int timeval_minus_usec(struct timeval *s1, struct timeval *s2)
62 ATTRIBUTE((pure));
63 void cancelTimeEvent(TimeEventHandlerPtr);
64 int allocateFdEventNum(int fd);
65 void deallocateFdEventNum(int i);
66 void timeToSleep(struct timeval *);
67 void runTimeEventQueue(void);
68 FdEventHandlerPtr makeFdEvent(int fd, int poll_events,
69 int (*handler)(int, FdEventHandlerPtr),
70 int dsize, void *data);
71 FdEventHandlerPtr registerFdEvent(int fd, int poll_events,
72 int (*handler)(int, FdEventHandlerPtr),
73 int dsize, void *data);
74 FdEventHandlerPtr registerFdEventHelper(FdEventHandlerPtr event);
75 void unregisterFdEvent(FdEventHandlerPtr event);
76 void pokeFdEvent(int fd, int status, int what);
77 int workToDo(void);
78 void eventLoop(void);
79 ConditionPtr makeCondition(void);
80 void initCondition(ConditionPtr);
81 void signalCondition(ConditionPtr condition);
82 ConditionHandlerPtr
83 conditionWait(ConditionPtr condition,
84 int (*handler)(int, ConditionHandlerPtr),
85 int dsize, void *data);
86 void unregisterConditionHandler(ConditionHandlerPtr);
87 void abortConditionHandler(ConditionHandlerPtr);
88 void polipoExit(void);