This commit is contained in:
stskeeps 2001-05-13 19:43:18 +00:00
parent a245aa8369
commit 49ad7cb797
4 changed files with 104 additions and 3 deletions

36
include/events.h Normal file
View file

@ -0,0 +1,36 @@
/************************************************************************
* Unreal Internet Relay Chat Daemon, include/events.h
* (C) Carsten V. Munk 2001 <stskeeps@tspre.org>
*
* 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
#define EVENT(x) void (x) (void *data)
void EventAdd(char *name, long every, long howmany,
vFP event, void *data);
typedef struct _event Event;
struct _event {
char *name;
time_t every;
long howmany;
vFP event;
void *data;
time_t last;
};

View file

@ -1400,6 +1400,6 @@ extern char *gnulicense[];
#endif
#define HASH_TEST HASH_CHECK
#include "modules.h"
#include "events.h"
#endif /* __struct_include__ */

65
src/events.c Normal file
View file

@ -0,0 +1,65 @@
/************************************************************************
* IRC - Internet Relay Chat, events.c
* (C) 2001 Carsten Munk (Techie/Stskeeps) <stskeeps@tspre.org>
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include "userload.h"
#include "version.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
ID_Copyright("(C) Carsten Munk 1999");
Event *events = NULL;
void DoEvents(void)
{
Event *eventptr;
for (eventptr = events; events; events = events->next)
if ((TStime() - eventptr->last) >= eventptr->every)
{
if (eventptr->howmany > 0)
{
eventptr->howmany--;
if (eventptr->howmany == 0)
{
/* Mark event for deletion, or delete it
*/
}
}
eventptr->last = TStime();
(*evenptr->event)(eventptr->data);
}
}

View file

@ -1186,9 +1186,9 @@ void SocketLoop(void *dummy)
loop.do_tkl_sweep = 0;
}
/* we want accuarte time here not the fucked up TStime() :P -Stskeeps */
if ((TStime() - last_tune) > 300)
if ((timeofday - last_tune) > 300)
{
last_tune = time(NULL);
last_tune = timeofday;
save_tunefile();
}