-
Notifications
You must be signed in to change notification settings - Fork 1
/
vdb.c
100 lines (83 loc) · 2.17 KB
/
vdb.c
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) Regents of The University of Michigan
* See COPYING.
*/
#include <config.h>
#include <stdlib.h>
#include <syslog.h>
#include <time.h>
#include "simvacation.h"
#include "vdb.h"
struct vdb_backend *
vdb_backend(const char *provider) {
struct vdb_backend *functable;
functable = malloc(sizeof(struct vdb_backend));
/* Default all functions to the null implementation */
functable->init = vdb_init;
functable->close = vdb_close;
functable->recent = vdb_recent;
functable->store_reply = vdb_store_reply;
functable->get_names = vdb_get_names;
functable->clean = vdb_clean;
functable->gc = vdb_gc;
if (strcasecmp(provider, "redis") == 0) {
#ifdef HAVE_URCL
functable->init = redis_vdb_init;
functable->close = redis_vdb_close;
functable->recent = redis_vdb_recent;
functable->store_reply = redis_vdb_store_reply;
return functable;
#else /* HAVE_URCL */
syslog(LOG_ERR, "vdb_backend: redis was disabled during compilation");
return NULL;
#endif /* HAVE_URCL */
}
if (strcasecmp(provider, "lmdb") == 0) {
#ifdef HAVE_LMDB
functable->init = lmdb_vdb_init;
functable->close = lmdb_vdb_close;
functable->recent = lmdb_vdb_recent;
functable->store_reply = lmdb_vdb_store_reply;
functable->gc = lmdb_vdb_gc;
return functable;
#else /* HAVE_LMDB */
syslog(LOG_ERR, "vdb_backend: LMDB was disabled during compilation");
return NULL;
#endif /* HAVE_LMDB */
}
if (strcasecmp(provider, "null") == 0) {
return functable;
}
syslog(LOG_ERR, "vdb_backend: unknown backend %s", provider);
free(functable);
return NULL;
}
VDB *
vdb_init(const yastr rcpt) {
return calloc(1, 1);
}
void
vdb_close(VDB *vdb) {
free(vdb);
return;
}
vdb_status
vdb_recent(VDB *vdb, const yastr from, time_t interval) {
return VDB_STATUS_OK;
}
vac_result
vdb_store_reply(VDB *vdb, const yastr from) {
return VAC_RESULT_OK;
}
ucl_object_t *
vdb_get_names(VDB *vdb) {
return ucl_object_typed_new(UCL_ARRAY);
}
void
vdb_clean(VDB *vdb, const yastr user) {
return;
}
void
vdb_gc(VDB *vdb) {
return;
}