Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.36 KB)

1 58ef912c Martin Mares
/*
2 a2ccbb0b Martin Mares
 *        BIRD -- Unix Timers
3 58ef912c Martin Mares
 *
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 01b776e1 Martin Mares
#include <time.h>
13 a2ccbb0b Martin Mares
14 1feea03e Martin Mares
#include "lib/resource.h"
15 58ef912c Martin Mares
16 a2ccbb0b Martin Mares
typedef time_t bird_clock_t;                /* Use instead of time_t */
17
18 58ef912c Martin Mares
typedef struct timer {
19 a2ccbb0b Martin Mares
  resource r;
20
  void (*hook)(struct timer *);
21
  void *data;
22
  unsigned randomize;                        /* Amount of randomization */
23 af847acc Martin Mares
  unsigned recurrent;                        /* Timer recurrence */
24 a2ccbb0b Martin Mares
  node n;                                /* Internal link */
25 28a9a189 Martin Mares
  bird_clock_t expires;                        /* 0=inactive */
26 58ef912c Martin Mares
} timer;
27
28 a2ccbb0b Martin Mares
timer *tm_new(pool *);
29 58ef912c Martin Mares
void tm_start(timer *, unsigned after);
30
void tm_stop(timer *);
31 a2ccbb0b Martin Mares
void tm_dump_all(void);
32
33 fd91ae33 Ondrej Zajicek
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 58ef912c Martin Mares
36 c37e7851 Ondrej Zajicek
struct timeformat {
37
  char *fmt1, *fmt2;
38
  bird_clock_t limit;
39
};
40
41 913f7dc9 Martin Mares
bird_clock_t tm_parse_date(char *);        /* Convert date to bird_clock_t */
42 030d3b38 Ondrej Filip
bird_clock_t tm_parse_datetime(char *);        /* Convert date to bird_clock_t */
43 c37e7851 Ondrej Zajicek
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 913f7dc9 Martin Mares
48 487d1afa Martin Mares
#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 58ef912c Martin Mares
#endif