| 1 | /* |
| 2 | * Copyright (C) 1999 Ross Combs ([email protected]) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #ifndef INCLUDED_TIMER_TYPES |
| 19 | #define INCLUDED_TIMER_TYPES |
| 20 | |
| 21 | #include <ctime> |
| 22 | |
| 23 | #ifdef JUST_NEED_TYPES |
| 24 | # include "connection.h" |
| 25 | #else |
| 26 | # define JUST_NEED_TYPES |
| 27 | # include "connection.h" |
| 28 | # undef JUST_NEED_TYPES |
| 29 | #endif |
| 30 | #include "common/elist.h" |
| 31 | |
| 32 | namespace pvpgn |
| 33 | { |
| 34 | |
| 35 | namespace bnetd |
| 36 | { |
| 37 | |
| 38 | typedef union |
| 39 | { |
| 40 | unsigned long n; |
| 41 | void * p; |
| 42 | } t_timer_data; |
| 43 | |
| 44 | typedef void(*t_timer_cb)(t_connection * owner, std::time_t when, t_timer_data data); |
| 45 | |
| 46 | typedef struct timer_struct |
| 47 | #ifdef TIMER_INTERNAL_ACCESS |
| 48 | { |
| 49 | t_connection * owner; /* who to notify */ |
| 50 | std::time_t when; /* when the timer expires */ |
| 51 | t_timer_cb cb; /* what to call */ |
| 52 | t_timer_data data; /* data argument */ |
| 53 | t_elist owners; /* list to the setup timers of same owner */ |
| 54 | t_elist timers; /* timers list, used for final cleaning */ |
| 55 | } |
| 56 | #endif |
| 57 | t_timer; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | #endif |
| 64 | |
| 65 | #ifndef JUST_NEED_TYPES |
| 66 | #ifndef INCLUDED_TIMER_PROTOS |
| 67 | #define INCLUDED_TIMER_PROTOS |
| 68 | |
| 69 | #include <ctime> |
| 70 | |
| 71 | #define JUST_NEED_TYPES |
| 72 | #include "connection.h" |
| 73 | #undef JUST_NEED_TYPES |
| 74 | |
| 75 | namespace pvpgn |
| 76 | { |
| 77 | |
| 78 | namespace bnetd |
| 79 | { |
| 80 | |
| 81 | extern int timerlist_create(void); |
| 82 | extern int timerlist_destroy(void); |
| 83 | extern int timerlist_add_timer(t_connection * owner, std::time_t when, t_timer_cb cb, t_timer_data data); |
| 84 | extern int timerlist_del_all_timers(t_connection * owner); |
| 85 | extern int timerlist_check_timers(std::time_t when); |
| 86 | |
| 87 | } |
| 88 | |
| 89 | } |
| 90 | |
| 91 | #endif |
| 92 | #endif |