Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / timer.h @ afa8937a

History | View | Annotate | Download (1.31 KB)

1
/*
2
 *        BIRD -- Unix Timers
3
 *
4
 *        (c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#ifndef _BIRD_TIMER_H_
10
#define _BIRD_TIMER_H_
11

    
12
#include <sys/time.h>
13

    
14
#include "lib/resource.h"
15

    
16
typedef time_t bird_clock_t;                /* Use instead of time_t */
17

    
18
typedef struct timer {
19
  resource r;
20
  void (*hook)(struct timer *);
21
  void *data;
22
  unsigned randomize;                        /* Amount of randomization */
23
  unsigned recurrent;                        /* Timer recurrence */
24
  node n;                                /* Internal link */
25
  bird_clock_t expires;                        /* 0=inactive */
26
} timer;
27

    
28
timer *tm_new(pool *);
29
void tm_start(timer *, unsigned after);
30
void tm_stop(timer *);
31
void tm_dump_all(void);
32

    
33
extern bird_clock_t now;                /* Time in seconds since unknown epoch */
34

    
35
bird_clock_t tm_parse_date(char *);        /* Convert date to bird_clock_t */
36
void tm_format_date(char *, bird_clock_t);        /* Convert bird_clock_t to date */
37
#define TM_DATE_BUFFER_SIZE 12                /* Buffer size required by tm_format_date */
38
void tm_format_reltime(char *, bird_clock_t);        /* Convert bird_clock_t to relative datetime string */
39
#define TM_RELTIME_BUFFER_SIZE 12        /* Buffer size required by tm_format_time */
40

    
41
#ifdef TIME_T_IS_64BIT
42
#define TIME_INFINITY 0x7fffffffffffffff
43
#else
44
#ifdef TIME_T_IS_SIGNED
45
#define TIME_INFINITY 0x7fffffff
46
#else
47
#define TIME_INFINITY 0xffffffff
48
#endif
49
#endif
50

    
51
#endif