blob: a959d9cc7de078bc3dcfdd80ebd61a6ae3ac9a3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright (c) 2013-2014 RIPE NCC <atlas@ripe.net>
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* Standalone version of the event-based ntp.
*/
#include "libbb.h"
#include <syslog.h>
#include <event2/dns.h>
#include <event2/event.h>
#include <event2/event_struct.h>
#include "eperd.h"
static void done(void *state UNUSED_PARAM)
{
fprintf(stderr, "And we are done\n");
exit(0);
}
int evntp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int evntp_main(int argc UNUSED_PARAM, char **argv)
{
int r;
void *state;
/* Create libevent event base */
EventBase= event_base_new();
if (!EventBase)
{
fprintf(stderr, "evntp: event_base_new failed\n");
exit(1);
}
DnsBase= evdns_base_new(EventBase, 1 /*initialize*/);
if (!DnsBase)
{
fprintf(stderr, "evdns_base_new failed\n");
exit(1);
}
state= ntp_ops.init(argc, argv, done);
if (!state)
{
fprintf(stderr, "evntp: ntp_ops.init failed\n");
exit(1);
}
ntp_ops.start(state);
r= event_base_loop(EventBase, 0);
if (r != 0)
{
fprintf(stderr, "evntp: event_base_loop failed\n");
exit(1);
}
return 0; /* not reached */
}
|