Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / timer.h @ 1bc26957

History | View | Annotate | Download (1.36 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 <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;                 /* Relative, monotonic time in seconds */
34
extern bird_clock_t now_real;                /* Time in seconds since fixed known epoch */
35

    
36
struct timeformat {
37
  char *fmt1, *fmt2;
38
  bird_clock_t limit;
39
};
40

    
41
bird_clock_t tm_parse_date(char *);        /* Convert date to bird_clock_t */
42
bird_clock_t tm_parse_datetime(char *);        /* Convert date to bird_clock_t */
43

    
44
#define TM_DATETIME_BUFFER_SIZE 32        /* Buffer size required by tm_format_datetime */
45
void
46
tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t);
47

    
48
#ifdef TIME_T_IS_64BIT
49
#define TIME_INFINITY 0x7fffffffffffffff
50
#else
51
#ifdef TIME_T_IS_SIGNED
52
#define TIME_INFINITY 0x7fffffff
53
#else
54
#define TIME_INFINITY 0xffffffff
55
#endif
56
#endif
57

    
58
#endif