| 1 |
/* Time-delay routine include stuff. |
| 2 |
* |
| 3 |
* IRC Services is copyright (c) 1996-2009 Andrew Church. |
| 4 |
* E-mail: <achurch@achurch.org> |
| 5 |
* Parts written by Andrew Kempe and others. |
| 6 |
* This program is free but copyrighted software; see the file GPL.txt for |
| 7 |
* details. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef TIMEOUT_H |
| 11 |
#define TIMEOUT_H |
| 12 |
|
| 13 |
#include <time.h> |
| 14 |
|
| 15 |
/*************************************************************************/ |
| 16 |
|
| 17 |
/* Timeout type. */ |
| 18 |
|
| 19 |
typedef struct timeout_ Timeout; |
| 20 |
|
| 21 |
struct timeout_ |
| 22 |
{ |
| 23 |
void *data; /* Caller data; can be anything */ |
| 24 |
time_t settime; /* Time timer was set (from time()) */ |
| 25 |
/* Remainder is PRIVATE DATA! */ |
| 26 |
#ifdef IN_TIMEOUT_C |
| 27 |
Timeout *next, *prev; |
| 28 |
uint32 timeout; /* In milliseconds (time_msec()) */ |
| 29 |
uint32 repeat; /* Does this timeout repeat indefinitely? |
| 30 |
* (if nonzero, new value of `timeout') */ |
| 31 |
void (*code) (Timeout *); /* This structure is passed to the code */ |
| 32 |
#endif |
| 33 |
}; |
| 34 |
|
| 35 |
/*************************************************************************/ |
| 36 |
|
| 37 |
/* Check the timeout list for any pending actions. */ |
| 38 |
extern void check_timeouts(void); |
| 39 |
|
| 40 |
/* Add a timeout to the list to be triggered in `delay' seconds (`delay' |
| 41 |
* may be zero). Any timeout added from within a timeout routine will not |
| 42 |
* be checked during that run through the timeout list. Always succeeds. */ |
| 43 |
extern Timeout *add_timeout(int delay, void (*code) (Timeout *), int repeat); |
| 44 |
|
| 45 |
/* Add a timeout to the list to be triggered in `delay' milliseconds |
| 46 |
* (`delay' may be zero). */ |
| 47 |
extern Timeout *add_timeout_ms(uint32 delay, void (*code) (Timeout *), |
| 48 |
int repeat); |
| 49 |
|
| 50 |
/* Remove a timeout from the list (if it's there). */ |
| 51 |
extern void del_timeout(Timeout * t); |
| 52 |
|
| 53 |
#ifdef DEBUG_COMMANDS |
| 54 |
/* Send the list of timeouts to the given user. */ |
| 55 |
extern void send_timeout_list(User * u); |
| 56 |
#endif |
| 57 |
|
| 58 |
/*************************************************************************/ |
| 59 |
|
| 60 |
#endif /* TIMEOUT_H */ |
| 61 |
|
| 62 |
/* |
| 63 |
* Local variables: |
| 64 |
* c-file-style: "stroustrup" |
| 65 |
* c-file-offsets: ((case-label . *) (statement-case-intro . *)) |
| 66 |
* indent-tabs-mode: nil |
| 67 |
* End: |
| 68 |
* |
| 69 |
* vim: expandtab shiftwidth=4: |
| 70 |
*/ |