FireBirdLib - Topfield TMS PVR TAP Programming Library
cronEventHandler.c
Go to the documentation of this file.
1#include "FBLib_time.h"
2
5bool cronInit = FALSE;
6
8{
10
11 int i;
12 long next;
13 TYPE_CRONTAB *pcronTable;
14
16
18 {
19 pcronTable = cronTable;
20 for(i = 0; i <= MAX_CRON_EVENTS-1; i++)
21 {
22 if((pcronTable->active == TRUE) && (pcronTable->nextExecution <= TAP_GetTick()))
23 {
24 int (*theFunct)(void) = pcronTable->function;
25
26 if(theFunct)
27 {
28 next = theFunct();
29 }
30 else
31 {
32 next = -1;
33 }
34
35 //If the callback function returns a -1 then deactivate that item
36 //If frequency is < 0, this was a single-shot cron and also deactivate it
37 if((next == -1) || (pcronTable->frequency < 0))
38 {
39 pcronTable->active = FALSE;
41 }
42 else
43 {
44 if(next == 0) next = pcronTable->frequency; //If the callback returns zero, use the default frequency.
45 do
46 {
47 pcronTable->nextExecution = pcronTable->nextExecution + next;
48 } while(pcronTable->nextExecution < TAP_GetTick());
49 }
50 }
51 pcronTable++;
52 }
53 }
54
55 TRACEEXIT();
56}
#define MAX_CRON_EVENTS
Definition: FBLib_time.h:25
TYPE_CRONTAB cronTable[MAX_CRON_EVENTS]
void cronEventHandler(void)
bool cronInit
int cronItemCount
#define TRACEEXIT()
Definition: libFireBird.h:1244
void cronUnregisterAllEvents(void)
#define TRACEENTER()
Definition: libFireBird.h:1243
void * function
Definition: FBLib_time.h:21
dword nextExecution
Definition: FBLib_time.h:20